home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 May / Pcwk5b98.iso / Borland / Cplus45 / BC45 / OSL_INC.PAK / DEFS.H next >
C/C++ Source or Header  |  1995-08-29  |  4KB  |  148 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectSupport
  3. // (C) Copyright 1993, 1994 by Borland International, All Rights Reserved
  4. //
  5. //----------------------------------------------------------------------------
  6. #if !defined(OSL_DEFS_H)
  7. #define OSL_DEFS_H
  8.  
  9. #if !defined(CLASSLIB_DEFS_H)
  10. # include <classlib/defs.h>
  11. #endif
  12.  
  13.  
  14. //----------------------------------------------------------------------------
  15. //
  16. // Include windows.h, if indicated, with necessary macros defined
  17. //
  18.  
  19. #if defined(BI_PLAT_WIN32) && !defined(_OLEAUTO_H_)
  20. //
  21. // NOTE: 'tagCY' seems to undergo several changes [from struct to union,
  22. //       then to union containing a struct] making it hard to properly
  23. //       choose between inheritance and containment.
  24. //       The following approach ensures the it can be used as a base class.
  25. //
  26. #ifndef _tagCY_DEFINED
  27. #define _tagCY_DEFINED
  28. #define _CY_DEFINED
  29.                         /* size is 8 */
  30. typedef struct  tagCY
  31.     {
  32.     unsigned long Lo;
  33.     long Hi;
  34.     }   CY;
  35.  
  36. #endif
  37. #endif
  38.  
  39. #if defined(BI_PLAT_MSW)
  40. # if defined(__WINDOWS_H) && !defined(INC_WINDOWS)
  41. #   if !defined(STRICT)
  42. #     error if windows.h is included before osl/defs.h, STRICT must be defined
  43. #   endif
  44. # else
  45. #   define STRICT
  46. #   if defined(BI_NO_BOOL) && defined(EMULATE_BOOL)
  47. #     define BOOL WBOOL
  48. #     include <windows.h>
  49. #     undef BOOL           // redefine Windows BOOL in terms of the bool type
  50. #     define BOOL bool
  51. #     undef FALSE
  52. #     define FALSE false
  53. #     undef TRUE
  54. #     define TRUE true
  55. #   else
  56. #     include <windows.h>
  57. #   endif
  58. # endif
  59. # if !defined(__SHELLAPI_H) && !defined(_INC_SHELLAPI) && !defined(BI_PLAT_WIN32)
  60. #   include <shellapi.h>
  61. # endif
  62. # if defined(BI_PLAT_WIN16) && defined(INC_OLE2)
  63. #   if !defined(__OLE2_H) && !defined(_OLE2_H_)
  64. #     include <ole2.h>
  65. #   endif
  66. #   if !defined(__DISPATCH_H)
  67. #     include <dispatch.h>
  68. #   endif
  69. #   if !defined(__OLENLS_H) && !defined(_OLENLS_)
  70. #     include <olenls.h>
  71. #   endif
  72. # endif
  73. #endif
  74.  
  75. //
  76. // Some nonfixed-size types defined similar to the fixedsize in systypes.h
  77. //
  78. typedef unsigned long  ulong;
  79. typedef unsigned int   uint;
  80. typedef unsigned short ushort;
  81.  
  82. //
  83. // Shorthand 'far' keyword evaluates to __far when needed & supported, else
  84. // nothing
  85. //
  86. #if !defined(far)
  87. # if defined(BI_PTR_0_32)
  88. #   define far
  89. # else
  90. #   define far __far
  91. # endif
  92. #endif
  93. #if defined(BI_NO_BOOL) && defined(EMULATE_BOOL)
  94.   template<class T> inline bool ToBool(const T& t) {
  95.     return static_cast<bool>(t != 0);
  96.   }
  97. #else
  98.   template<class T> inline bool ToBool(const T& t) {
  99.     return static_cast<bool>(t);
  100.   }
  101. #endif
  102.  
  103. //
  104. // Current module instance in RTL (PLAT_WIN16) or OSL (PLAT_WIN32)
  105. //
  106. extern __cdecl HINSTANCE _hInstance;
  107.  
  108. //
  109. // Class encapsulations for 64 bit signed and unsigned integers compatible
  110. // with Ole2 and Win32 structs
  111. //
  112. #if !defined(__SYSTYPES_H)
  113. # include <systypes.h>    // int8, int16, etc.
  114. #endif
  115.  
  116. #if defined(BI_PLAT_WIN32)
  117.   union _ULARGE_INTEGER;
  118.   union _LARGE_INTEGER;
  119. #else
  120.   class far _ULARGE_INTEGER;
  121.   class far _LARGE_INTEGER;
  122. #endif
  123.  
  124. class uint64 {
  125.   public:
  126.     uint64(uint32 low, uint32 high) {LowPart = low; HighPart = high;}
  127.     uint64() {LowPart = HighPart = 0;}
  128.     uint64(_ULARGE_INTEGER uli) {*(_ULARGE_INTEGER*)this = uli;}
  129.     operator _ULARGE_INTEGER() const {return *(_ULARGE_INTEGER*)this;}
  130.  
  131.     uint32 LowPart;
  132.     uint32 HighPart;
  133. };
  134.  
  135. class int64 {
  136.   public:
  137.     int64(uint32 low, long high) {LowPart = low; HighPart = high;}
  138.     int64(long low) {LowPart = low; HighPart = low<0 ? -1 : 0;}
  139.     int64() {LowPart = HighPart = 0;}
  140.     int64(_LARGE_INTEGER li) {*(_LARGE_INTEGER*)this = li;}
  141.     operator _LARGE_INTEGER() const {return *(_LARGE_INTEGER*)this;}
  142.  
  143.     uint32 LowPart;
  144.     int32  HighPart;
  145. };
  146.  
  147. #endif  // OSL_DEFS_H
  148.