home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c083 / 12.ddi / CLASSINC.PAK / DEFS.H < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-02  |  10.7 KB  |  221 lines

  1. /*------------------------------------------------------------------------*/
  2. /*                                                                        */
  3. /*  DEFS.H                                                                */
  4. /*                                                                        */
  5. /*  Copyright (c) 1993 Borland International                              */
  6. /*  All Rights Reserved                                                   */
  7. /*                                                                        */
  8. /*------------------------------------------------------------------------*/
  9.  
  10. #if !defined( __CLASSLIB_DEFS_H )
  11. #define __CLASSLIB_DEFS_H
  12.  
  13. #if !defined( __CLASSLIB_RESOURCE_H )
  14. #include "classlib\resource.h"
  15. #endif  // __CLASSLIB_RESOURCE_H
  16.  
  17. /*------------------------------------------------------------------------*/
  18. /*                                                                        */
  19. /*  _RTTI provides a convenient macro for switching on the __rtti         */
  20. /*  keyword for finer grained control over generation of runtime type     */
  21. /*  information.                                                          */
  22. /*                                                                        */
  23. /*------------------------------------------------------------------------*/
  24.  
  25. #if defined(__BORLANDC__) && !defined(BI_NO_RTTI)
  26. #define _RTTI __rtti
  27. #else
  28. #define _RTTI
  29. #endif
  30.  
  31. /*------------------------------------------------------------------------*/
  32. /*                                                                        */
  33. /*  These CAST macros encapsulate the new cast syntax in the ANSI/ISO     */
  34. /*  working paper. Note that TYPESAFE_DOWNCAST isn't as general as        */
  35. /*  dynamic_cast -- it only works on pointers.                            */
  36. /*                                                                        */
  37. /*  Usage:                                                                */
  38. /*                                                                        */
  39. /*  TYPESAFE_DOWNCAST(object,toClass)                                     */
  40. /*      Converts the pointer referred to by 'object' into a pointer to    */
  41. /*      an object of type 'toClass'. Note that the macro parameters to    */
  42. /*      TYPESAFE_DOWNCAST are in the opposite order from the rest of      */
  43. /*      the macros here. When using a compiler that supports new style    */
  44. /*      casts and runtime type information this is done with              */
  45. /*      dynamic_cast<> and will return 0 if the cast cannot be done.      */
  46. /*      When using a compiler that does not support new style casts and   */
  47. /*      runtime type information this is done with fake runtime type      */
  48. /*      information generated by the IMPLEMENT_CASTABLE macro.            */
  49. /*                                                                        */
  50. /*  STATIC_CAST(targetType,object)                                        */
  51. /*      Converts the data object referred to by 'object' into the type    */
  52. /*      referred to by 'targetType'. When using a compiler that supports  */
  53. /*      new style casts, this is done with static_cast<> and will fail    */
  54. /*      if the cast cannot be done without runtime type information.      */
  55. /*      When using a compiler that does not support new style casts, this */
  56. /*      is done with an old style dangerous cast.                         */
  57. /*                                                                        */
  58. /*  CONST_CAST(targetType,object)                                         */
  59. /*      Converts the data object referred to by 'object' into the type    */
  60. /*      referred to by 'targetType'. When using a compiler that supports  */
  61. /*      new style casts, this is done with const_cast<> and will fail     */
  62. /*      if the cast changes the type of the object in any way other than  */
  63. /*      adding or removing const and volatile qualifiers.                 */
  64. /*      When using a compiler that does not support new style casts, this */
  65. /*      is done with an old style dangerous cast.                         */
  66. /*                                                                        */
  67. /*  REINTERPRET_CAST(targetType,object)                                   */
  68. /*      Converts the data object referred to by 'object' into the type    */
  69. /*      referred to by 'targetType'. When using a compiler that supports  */
  70. /*      new style casts, this is done with reinterpret_cast<>.            */
  71. /*      When using a compiler that does not support new style casts, this */
  72. /*      is done with an old style dangerous cast.                         */
  73. /*                                                                        */
  74. /*------------------------------------------------------------------------*/
  75.  
  76. #if defined( BI_NO_NEW_CASTS )
  77. #   define TYPESAFE_DOWNCAST(object,toClass)\
  78.         (object ?(toClass *)(object)->FindBase(#toClass) : 0)
  79. #   define STATIC_CAST(targetType,object)   \
  80.         ((targetType)(object))
  81. #   define CONST_CAST(targetType,object)    \
  82.         ((targetType)(object))
  83. #   define REINTERPRET_CAST(targetType,object) \
  84.         (*(targetType*)(void *)&(object))
  85. #else
  86. #   define TYPESAFE_DOWNCAST(object,toClass)\
  87.         dynamic_cast<toClass *>(object)
  88. #   define STATIC_CAST(targetType,object)   \
  89.         static_cast<targetType>(object)
  90. #   define CONST_CAST(targetType,object)    \
  91.         const_cast<targetType>(object)
  92. #   define REINTERPRET_CAST(targetType,object) \
  93.         reinterpret_cast<targetType>(object)
  94. #endif
  95.  
  96. /*------------------------------------------------------------------------*/
  97. /*                                                                        */
  98. /*  Common definitions for pointer size and calling conventions.          */
  99. /*                                                                        */
  100. /*  Calling conventions:                                                  */
  101. /*                                                                        */
  102. /*  _BIDSENTRY      Specifies the calling convention used by BIDS.        */
  103. /*                                                                        */
  104. /*                                                                        */
  105. /*  Export (and size for DOS) information:                                */
  106. /*                                                                        */
  107. /*  _BIDSCLASS      Exports class if building DLL version of library.     */
  108. /*                  For DOS16 also provides size information.             */
  109. /*                                                                        */
  110. /*  _BIDSDATA       Exports data if building DLL version of library.      */
  111. /*                                                                        */
  112. /*  _BIDSFUNC       Exports function if building DLL version of library.  */
  113. /*                  For DOS16 also provides size information              */
  114. /*                                                                        */
  115. /*  _BIDSFAR        Promotes data pointers to far in DLLs (DOS16 only).   */
  116. /*                                                                        */
  117. /*  _BIDSFARDATA    Forces data pointer to be far.                        */
  118. /*                                                                        */
  119. /*  _BIDSFARFUNC    Forces function to be far.                            */
  120. /*                                                                        */
  121. /*  _BIDSFARCLASS   Forces class to be far.                               */
  122. /*                                                                        */
  123. /*  _BIDSNEARDATA   Forces data to be near.                               */
  124. /*                                                                        */
  125. /*  _BIDSNEARFUNC   Forces function to be near.                           */
  126. /*                                                                        */
  127. /*  _BIDSNEARCLASS  Forces class to be near.                              */
  128. /*                                                                        */
  129. /*------------------------------------------------------------------------*/
  130.  
  131. #if defined(__OS2__)
  132. #    define _BIDSENTRY  __stdcall
  133. #else
  134. #    define _BIDSENTRY  __cdecl
  135. #endif
  136.  
  137. #if defined(__FLAT__)
  138. #   define _BIDSFAR
  139. #   define _BIDSFARDATA
  140. #   define _BIDSFARFUNC
  141. #   define _BIDSFARCLASS
  142. #   define _BIDSNEARDATA
  143. #   define _BIDSNEARFUNC
  144. #   define _BIDSNEARCLASS
  145. #   if defined(_BUILDBIDSDLL)
  146. #       define _BIDSCLASS  __export
  147. #       define _BIDSDATA   __export
  148. #       define _BIDSFUNC   __export
  149. #   elif defined(_BIDSDLL) && !defined(__OS2__)
  150. #       define _BIDSCLASS  __import
  151. #       define _BIDSDATA   __import
  152. #       define _BIDSFUNC   __import
  153. #   else
  154. #       define _BIDSCLASS
  155. #       define _BIDSDATA
  156. #       define _BIDSFUNC
  157. #   endif
  158. #else
  159. #   if defined(__DLL__)
  160. #       if defined(_BUILDBIDSDLL)
  161. #           define _BIDSCLASS __export
  162. #       elif defined(_BIDSDLL) || defined(_CLASSDLL)
  163. #           define _BIDSCLASS __export
  164. #       else
  165. #           define _BIDSCLASS __far
  166. #       endif
  167. #       define _BIDSFAR __far
  168. #       define _BIDSFARDATA __far
  169. #       define _BIDSFARFUNC __far
  170. #       define _BIDSFARCLASS __far
  171. #       define _BIDSNEARDATA __near
  172. #       define _BIDSNEARFUNC __near
  173. #       define _BIDSNEARCLASS __near
  174. #   elif defined(_BIDSDLL) || defined(_CLASSDLL)
  175. #       define _BIDSCLASS __export
  176. #       define _BIDSFAR __far
  177. #       define _BIDSFARDATA __far
  178. #       define _BIDSFARFUNC __far
  179. #       define _BIDSFARCLASS __far
  180. #       define _BIDSNEARDATA __near
  181. #       define _BIDSNEARFUNC __near
  182. #       define _BIDSNEARCLASS __near
  183. #   else
  184. #       if   defined(__TINY__) || defined(__SMALL__) || defined(__MEDIUM__)
  185. #           if defined(_BIDSFARVTABLE)
  186. #               define _BIDSCLASS  __huge
  187. #           else
  188. #               define _BIDSCLASS  __near
  189. #           endif
  190. #       elif defined(__COMPACT__) || defined(__LARGE__)
  191. #           if defined(_BIDSFARVTABLE)
  192. #               define _BIDSCLASS  __huge
  193. #           else
  194. #               define _BIDSCLASS  __far
  195. #           endif
  196. #       else
  197. #           define _BIDSCLASS  __huge
  198. #       endif
  199. #       define _BIDSFAR
  200. #       define _BIDSFARDATA __far
  201. #       define _BIDSFARFUNC __far
  202. #       define _BIDSFARCLASS __far
  203. #       define _BIDSNEARDATA __near
  204. #       define _BIDSNEARFUNC __near
  205. #       define _BIDSNEARCLASS __near
  206. #   endif
  207. #   if defined(_BUILDBIDSDLL)
  208. #       define _BIDSFUNC __export
  209. #   else
  210. #       if defined(_BIDSDLL) || defined(_CLASSDLL)
  211. #           define _BIDSFUNC __far
  212. #       else
  213. #           define _BIDSFUNC
  214. #       endif
  215. #   endif
  216. #   define _BIDSDATA
  217. #endif
  218.  
  219. #endif  // __CLASSLIB_DEFS_H
  220.  
  221.