home *** CD-ROM | disk | FTP | other *** search
/ C Programming Starter Kit 2.0 / SamsPublishing-CProgrammingStarterKit-v2.0-Win31.iso / bc45 / classinc.pak / DEFS.H < prev    next >
C/C++ Source or Header  |  1997-07-23  |  13KB  |  302 lines

  1. /*------------------------------------------------------------------------*/
  2. /*                                                                        */
  3. /*  CLASSLIB/DEFS.H                                                       */
  4. /*                                                                        */
  5. /*  Copyright (c) 1993, 1994 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_COMPILER_H )
  14. #include <classlib/compiler.h>
  15. #endif
  16.  
  17. #if !defined( CLASSLIB_RESOURCE_H )
  18. #include <classlib/resource.h>
  19. #endif
  20.  
  21. //------------------------------------------------
  22. //
  23. //  To restore the old BIDS naming convention of data and function
  24. //  names beginning with lowercase letters, in addition to the
  25. //  new convention of uppercase letters, remove the // from the
  26. //  #define below. The libraries do not need to be rebuilt.
  27. //
  28.  
  29. //  #define BI_OLDNAMES         // add names with initial lowercase
  30.  
  31. /*------------------------------------------------------------------------*/
  32. /*                                                                        */
  33. /*  OS-specific flags.                                                    */
  34. /*                                                                        */
  35. /*------------------------------------------------------------------------*/
  36.  
  37. //
  38. //  Need to do some special stuff when the OS doesn't support
  39. //  per-instance data in DLLs.
  40. //
  41. #if defined(BI_PLAT_WIN16)
  42. #define BI_NO_PER_INSTANCE_DATA
  43. #endif
  44.  
  45. //
  46. //  Sometimes we need to know if we're building for Windows 3.0.
  47. //
  48. #if defined(BI_PLAT_WIN16) && defined(WINVER) && WINVER < 0x030A
  49. #define BI_IS_WIN30
  50. #endif
  51.  
  52. //
  53. //  Windows 3.1 provides functions to read and write huge buffers.
  54. //
  55. #if defined(BI_PTR_16_16) && !defined(BI_IS_WIN30)
  56. #define BI_HAS_HREADWRITE
  57. #endif
  58.  
  59. //
  60. //  Under Windows 3.0 WEPs are seriously broken.
  61. //
  62. #if defined(BI_IS_WIN30)
  63. #define BI_WINDOWS_WEP_BUG
  64. #endif
  65.  
  66. /*------------------------------------------------------------------------*/
  67. /*                                                                        */
  68. /*  _RTTI provides a convenient macro for switching on Borland's __rtti   */
  69. /*  keyword for finer grained control over generation of runtime type     */
  70. /*  information.                                                          */
  71. /*                                                                        */
  72. /*------------------------------------------------------------------------*/
  73.  
  74. #define _RTTI __rtti
  75.  
  76. /*------------------------------------------------------------------------*/
  77. /*                                                                        */
  78. /*  These CAST macros encapsulate the new cast syntax in the ANSI/ISO     */
  79. /*  working paper. Note that TYPESAFE_DOWNCAST isn't as general as        */
  80. /*  dynamic_cast -- it only works on pointers.                            */
  81. /*                                                                        */
  82. /*  Usage:                                                                */
  83. /*                                                                        */
  84. /*  TYPESAFE_DOWNCAST(object,toClass)                                     */
  85. /*      Converts the pointer referred to by 'object' into a pointer to    */
  86. /*      an object of type 'toClass'. Note that the macro parameters to    */
  87. /*      TYPESAFE_DOWNCAST are in the opposite order from the rest of      */
  88. /*      the macros here. When using a compiler that supports new style    */
  89. /*      casts and runtime type information this is done with              */
  90. /*      dynamic_cast<> and will return 0 if the cast cannot be done.      */
  91. /*      When using a compiler that does not support new style casts and   */
  92. /*      runtime type information this is done with fake runtime type      */
  93. /*      information generated by the IMPLEMENT_CASTABLE macro.            */
  94. /*                                                                        */
  95. /*  STATIC_CAST(targetType,object)                                        */
  96. /*      Converts the data object referred to by 'object' into the type    */
  97. /*      referred to by 'targetType'. When using a compiler that supports  */
  98. /*      new style casts, this is done with static_cast<> and will fail    */
  99. /*      if the cast cannot be done without runtime type information.      */
  100. /*      When using a compiler that does not support new style casts, this */
  101. /*      is done with an old style dangerous cast.                         */
  102. /*                                                                        */
  103. /*  CONST_CAST(targetType,object)                                         */
  104. /*      Converts the data object referred to by 'object' into the type    */
  105. /*      referred to by 'targetType'. When using a compiler that supports  */
  106. /*      new style casts, this is done with const_cast<> and will fail     */
  107. /*      if the cast changes the type of the object in any way other than  */
  108. /*      adding or removing const and volatile qualifiers.                 */
  109. /*      When using a compiler that does not support new style casts, this */
  110. /*      is done with an old style dangerous cast.                         */
  111. /*                                                                        */
  112. /*  REINTERPRET_CAST(targetType,object)                                   */
  113. /*      Converts the data object referred to by 'object' into the type    */
  114. /*      referred to by 'targetType'. When using a compiler that supports  */
  115. /*      new style casts, this is done with reinterpret_cast<>.            */
  116. /*      When using a compiler that does not support new style casts, this */
  117. /*      is done with an old style dangerous cast.                         */
  118. /*                                                                        */
  119. /*------------------------------------------------------------------------*/
  120.  
  121. #if defined( BI_NO_NEW_CASTS )
  122. #   define TYPESAFE_DOWNCAST(object,toClass)\
  123.         (object ?(toClass *)(object)->FindBase(#toClass) : 0)
  124. #   define STATIC_CAST(targetType,object)   \
  125.         ((targetType)(object))
  126. #   define CONST_CAST(targetType,object)    \
  127.         ((targetType)(object))
  128. #   define REINTERPRET_CAST(targetType,object) \
  129.         (*(targetType*)(void *)&(object))
  130. #else
  131. #   define TYPESAFE_DOWNCAST(object,toClass)\
  132.         dynamic_cast<toClass *>(object)
  133. #   define STATIC_CAST(targetType,object)   \
  134.         static_cast<targetType>(object)
  135. #   define CONST_CAST(targetType,object)    \
  136.         const_cast<targetType>(object)
  137. #   define REINTERPRET_CAST(targetType,object) \
  138.         reinterpret_cast<targetType>(object)
  139. #endif
  140.  
  141. /*------------------------------------------------------------------------*/
  142. /*                                                                        */
  143. /*  Provide expansions for mutable and bool when appropriate.             */
  144. /*                                                                        */
  145. /*------------------------------------------------------------------------*/
  146.  
  147. #if defined( BI_NO_MUTABLE )
  148. #define mutable
  149. #endif
  150.  
  151. #if defined( BI_NO_BOOL )
  152. enum TBool
  153. {
  154.     false,
  155.     true
  156. };
  157. #   if defined( EMULATE_BOOL )
  158.         typedef TBool bool;
  159. #       define BI_UNIQUE_BOOL
  160. #   else
  161.         typedef int bool;
  162. #       undef BI_UNIQUE_BOOL
  163. #   endif
  164. #else
  165.     typedef bool TBool;
  166. #   define BI_UNIQUE_BOOL
  167. #endif
  168.  
  169. /*------------------------------------------------------------------------*/
  170. /*                                                                        */
  171. /*  Common definitions for pointer size and calling conventions.          */
  172. /*                                                                        */
  173. /*  Calling conventions:                                                  */
  174. /*                                                                        */
  175. /*  _BIDSENTRY      Specifies the calling convention used by BIDS.        */
  176. /*                                                                        */
  177. /*                                                                        */
  178. /*  Export (and size for DOS) information:                                */
  179. /*                                                                        */
  180. /*  _BIDSCLASS      Exports class if building DLL version of library.     */
  181. /*                  For DOS16 also provides size information.             */
  182. /*                                                                        */
  183. /*  _BIDSDATA       Exports data if building DLL version of library.      */
  184. /*                                                                        */
  185. /*  _BIDSFUNC       Exports function if building DLL version of library.  */
  186. /*                  For DOS16 also provides size information              */
  187. /*                                                                        */
  188. /*  _BIDSFAR        Promotes data pointers to far in DLLs (DOS16 only).   */
  189. /*                                                                        */
  190. /*  _BIDSFARDATA    Forces data pointer to be far.                        */
  191. /*                                                                        */
  192. /*  _BIDSFARFUNC    Forces function to be far.                            */
  193. /*                                                                        */
  194. /*  _BIDSFARCLASS   Forces class to be far.                               */
  195. /*                                                                        */
  196. /*  _BIDSNEARDATA   Forces data to be near.                               */
  197. /*                                                                        */
  198. /*  _BIDSNEARFUNC   Forces function to be near.                           */
  199. /*                                                                        */
  200. /*  _BIDSNEARCLASS  Forces class to be near.                              */
  201. /*                                                                        */
  202. /*------------------------------------------------------------------------*/
  203.  
  204. #if defined(BI_PLAT_OS2)
  205. #    define _BIDSENTRY  __stdcall
  206. #else
  207. #    define _BIDSENTRY  __cdecl
  208. #endif
  209.  
  210. #if defined(BI_PTR_0_32)
  211. #   define _BIDSFAR
  212. #   define _BIDSFARDATA
  213. #   define _BIDSFARFUNC
  214. #   define _BIDSFARCLASS
  215. #   define _BIDSNEARDATA
  216. #   define _BIDSNEARFUNC
  217. #   define _BIDSNEARCLASS
  218. #   if defined(_BUILDBIDSDLL)
  219. #       define _BIDSCLASS  __export
  220. #       define _BIDSDATA   __export
  221. #       define _BIDSFUNC   __export
  222. #   elif defined(_BIDSDLL) && !defined(BI_PLAT_OS2)
  223. #       define _BIDSCLASS  __import
  224. #       define _BIDSDATA   __import
  225. #       define _BIDSFUNC   __import
  226. #   else
  227. #       define _BIDSCLASS
  228. #       define _BIDSDATA
  229. #       define _BIDSFUNC
  230. #   endif
  231. #   define _BIDSCLASS_RTL _BIDSCLASS
  232. #else
  233. #   if defined(BI_APP_DLL)
  234. #       if defined(_BUILDBIDSDLL)
  235. #           define _BIDSCLASS __export
  236. #       elif defined(_BIDSDLL) || defined(_CLASSDLL)
  237. #           define _BIDSCLASS __export
  238. #       elif defined(_BIDSFARVTABLE)
  239. #           define _BIDSCLASS     __huge
  240. #       else
  241. #           define _BIDSCLASS __far
  242. #       endif
  243. #       define _BIDSFAR __far
  244. #       define _BIDSFARDATA __far
  245. #       define _BIDSFARFUNC __far
  246. #       define _BIDSFARCLASS __far
  247. #       define _BIDSNEARDATA __near
  248. #       define _BIDSNEARFUNC __near
  249. #       define _BIDSNEARCLASS __near
  250. #   elif defined(_BIDSDLL) || defined(_CLASSDLL)
  251. #       define _BIDSCLASS __export
  252. #       define _BIDSFAR __far
  253. #       define _BIDSFARDATA __far
  254. #       define _BIDSFARFUNC __far
  255. #       define _BIDSFARCLASS __far
  256. #       define _BIDSNEARDATA __near
  257. #       define _BIDSNEARFUNC __near
  258. #       define _BIDSNEARCLASS __near
  259. #   else
  260. #       if   defined(BI_MODEL_TINY) || defined(BI_MODEL_SMALL) || defined(BI_MODEL_MEDIUM)
  261. #           if defined(_BIDSFARVTABLE)
  262. #               define _BIDSCLASS  __huge
  263. #           else
  264. #               define _BIDSCLASS  __near
  265. #           endif
  266. #       elif defined(BI_MODEL_COMPACT) || defined(BI_MODEL_LARGE)
  267. #           if defined(_BIDSFARVTABLE)
  268. #               define _BIDSCLASS  __huge
  269. #           else
  270. #               define _BIDSCLASS  __far
  271. #           endif
  272. #       else
  273. #           define _BIDSCLASS  __huge
  274. #       endif
  275. #       define _BIDSFAR
  276. #       define _BIDSFARDATA __far
  277. #       define _BIDSFARFUNC __far
  278. #       define _BIDSFARCLASS __far
  279. #       define _BIDSNEARDATA __near
  280. #       define _BIDSNEARFUNC __near
  281. #       define _BIDSNEARCLASS __near
  282. #   endif
  283. #   if defined(_BUILDBIDSDLL)
  284. #       define _BIDSFUNC __export
  285. #   else
  286. #       if defined(_BIDSDLL) || defined(_CLASSDLL)
  287. #           define _BIDSFUNC __far
  288. #       else
  289. #           define _BIDSFUNC
  290. #       endif
  291. #   endif
  292. #   define _BIDSDATA
  293. #   if defined(_BIDSFARVTABLE)
  294. #       define _BIDSCLASS_RTL _EXPCLASS
  295. #   else
  296. #       define _BIDSCLASS_RTL _BIDSCLASS
  297. #   endif
  298. #endif
  299.  
  300. #endif  // CLASSLIB_DEFS_H
  301.  
  302.