home *** CD-ROM | disk | FTP | other *** search
/ PC Format (South-Africa) 2001 June / PCFJune.iso / Xenon / C++ / FreeCommandLineTools.exe / Include / basetyps.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-01-31  |  7.8 KB  |  214 lines

  1. //+---------------------------------------------------------------------------
  2. //
  3. //  Microsoft Windows
  4. //  Copyright (C) Microsoft Corporation, 1992-1999.
  5. //
  6. //  File:       basetyps.h
  7. //
  8. //----------------------------------------------------------------------------
  9. #if !defined( _BASETYPS_H_ )
  10. #pragma option push -b -a8 -pc -A- /*P_O_Push*/
  11. #define _BASETYPS_H_
  12.  
  13. #if _MSC_VER > 1000
  14. #pragma once
  15. #endif
  16.  
  17. // Common macros gleamed from COMPOBJ.H
  18.  
  19. #ifdef __cplusplus
  20.     #define EXTERN_C    extern "C"
  21. #else
  22.     #define EXTERN_C    extern
  23. #endif
  24.  
  25. #ifdef _WIN32
  26.  
  27. // Win32 doesn't support __export
  28.  
  29. #define STDMETHODCALLTYPE       __stdcall
  30. #define STDMETHODVCALLTYPE      __cdecl
  31.  
  32. #define STDAPICALLTYPE          __stdcall
  33. #define STDAPIVCALLTYPE         __cdecl
  34.  
  35. #else
  36.  
  37. #define STDMETHODCALLTYPE       __export __stdcall
  38. #define STDMETHODVCALLTYPE      __export __cdecl
  39.  
  40. #define STDAPICALLTYPE          __export __stdcall
  41. #define STDAPIVCALLTYPE         __export __cdecl
  42.  
  43. #endif
  44.  
  45. #define STDAPI                  EXTERN_C HRESULT STDAPICALLTYPE
  46. #define STDAPI_(type)           EXTERN_C type STDAPICALLTYPE
  47.  
  48. #define STDMETHODIMP            HRESULT STDMETHODCALLTYPE
  49. #define STDMETHODIMP_(type)     type STDMETHODCALLTYPE
  50.  
  51. // The 'V' versions allow Variable Argument lists.
  52.  
  53. #define STDAPIV                 EXTERN_C HRESULT STDAPIVCALLTYPE
  54. #define STDAPIV_(type)          EXTERN_C type STDAPIVCALLTYPE
  55.  
  56. #define STDMETHODIMPV           HRESULT STDMETHODVCALLTYPE
  57. #define STDMETHODIMPV_(type)    type STDMETHODVCALLTYPE
  58.  
  59.  
  60.  
  61.  
  62. /****** Interface Declaration ***********************************************/
  63.  
  64. /*
  65.  *      These are macros for declaring interfaces.  They exist so that
  66.  *      a single definition of the interface is simulataneously a proper
  67.  *      declaration of the interface structures (C++ abstract classes)
  68.  *      for both C and C++.
  69.  *
  70.  *      DECLARE_INTERFACE(iface) is used to declare an interface that does
  71.  *      not derive from a base interface.
  72.  *      DECLARE_INTERFACE_(iface, baseiface) is used to declare an interface
  73.  *      that does derive from a base interface.
  74.  *
  75.  *      By default if the source file has a .c extension the C version of
  76.  *      the interface declaratations will be expanded; if it has a .cpp
  77.  *      extension the C++ version will be expanded. if you want to force
  78.  *      the C version expansion even though the source file has a .cpp
  79.  *      extension, then define the macro "CINTERFACE".
  80.  *      eg.     cl -DCINTERFACE file.cpp
  81.  *
  82.  *      Example Interface declaration:
  83.  *
  84.  *          #undef  INTERFACE
  85.  *          #define INTERFACE   IClassFactory
  86.  *
  87.  *          DECLARE_INTERFACE_(IClassFactory, IUnknown)
  88.  *          {
  89.  *              // *** IUnknown methods ***
  90.  *              STDMETHOD(QueryInterface) (THIS_
  91.  *                                        REFIID riid,
  92.  *                                        LPVOID FAR* ppvObj) PURE;
  93.  *              STDMETHOD_(ULONG,AddRef) (THIS) PURE;
  94.  *              STDMETHOD_(ULONG,Release) (THIS) PURE;
  95.  *
  96.  *              // *** IClassFactory methods ***
  97.  *              STDMETHOD(CreateInstance) (THIS_
  98.  *                                        LPUNKNOWN pUnkOuter,
  99.  *                                        REFIID riid,
  100.  *                                        LPVOID FAR* ppvObject) PURE;
  101.  *          };
  102.  *
  103.  *      Example C++ expansion:
  104.  *
  105.  *          struct FAR IClassFactory : public IUnknown
  106.  *          {
  107.  *              virtual HRESULT STDMETHODCALLTYPE QueryInterface(
  108.  *                                                  IID FAR& riid,
  109.  *                                                  LPVOID FAR* ppvObj) = 0;
  110.  *              virtual HRESULT STDMETHODCALLTYPE AddRef(void) = 0;
  111.  *              virtual HRESULT STDMETHODCALLTYPE Release(void) = 0;
  112.  *              virtual HRESULT STDMETHODCALLTYPE CreateInstance(
  113.  *                                              LPUNKNOWN pUnkOuter,
  114.  *                                              IID FAR& riid,
  115.  *                                              LPVOID FAR* ppvObject) = 0;
  116.  *          };
  117.  *
  118.  *          NOTE: Our documentation says '#define interface class' but we use
  119.  *          'struct' instead of 'class' to keep a lot of 'public:' lines
  120.  *          out of the interfaces.  The 'FAR' forces the 'this' pointers to
  121.  *          be far, which is what we need.
  122.  *
  123.  *      Example C expansion:
  124.  *
  125.  *          typedef struct IClassFactory
  126.  *          {
  127.  *              const struct IClassFactoryVtbl FAR* lpVtbl;
  128.  *          } IClassFactory;
  129.  *
  130.  *          typedef struct IClassFactoryVtbl IClassFactoryVtbl;
  131.  *
  132.  *          struct IClassFactoryVtbl
  133.  *          {
  134.  *              HRESULT (STDMETHODCALLTYPE * QueryInterface) (
  135.  *                                                  IClassFactory FAR* This,
  136.  *                                                  IID FAR* riid,
  137.  *                                                  LPVOID FAR* ppvObj) ;
  138.  *              HRESULT (STDMETHODCALLTYPE * AddRef) (IClassFactory FAR* This) ;
  139.  *              HRESULT (STDMETHODCALLTYPE * Release) (IClassFactory FAR* This) ;
  140.  *              HRESULT (STDMETHODCALLTYPE * CreateInstance) (
  141.  *                                                  IClassFactory FAR* This,
  142.  *                                                  LPUNKNOWN pUnkOuter,
  143.  *                                                  IID FAR* riid,
  144.  *                                                  LPVOID FAR* ppvObject);
  145.  *              HRESULT (STDMETHODCALLTYPE * LockServer) (
  146.  *                                                  IClassFactory FAR* This,
  147.  *                                                  BOOL fLock);
  148.  *          };
  149.  */
  150.  
  151.  
  152. #if defined(__cplusplus) && !defined(CINTERFACE)
  153. //#define interface               struct FAR
  154. #define interface struct
  155. #define STDMETHOD(method)       virtual HRESULT STDMETHODCALLTYPE method
  156. #define STDMETHOD_(type,method) virtual type STDMETHODCALLTYPE method
  157. #define STDMETHODV(method)       virtual HRESULT STDMETHODVCALLTYPE method
  158. #define STDMETHODV_(type,method) virtual type STDMETHODVCALLTYPE method
  159. #define PURE                    = 0
  160. #define THIS_
  161. #define THIS                    void
  162. #define DECLARE_INTERFACE(iface)    interface DECLSPEC_NOVTABLE iface
  163. #define DECLARE_INTERFACE_(iface, baseiface)    interface DECLSPEC_NOVTABLE iface : public baseiface
  164.  
  165.  
  166.  
  167. #else
  168.  
  169. #define interface               struct
  170.  
  171. #define STDMETHOD(method)       HRESULT (STDMETHODCALLTYPE * method)
  172. #define STDMETHOD_(type,method) type (STDMETHODCALLTYPE * method)
  173. #define STDMETHODV(method)       HRESULT (STDMETHODVCALLTYPE * method)
  174. #define STDMETHODV_(type,method) type (STDMETHODVCALLTYPE * method)
  175.  
  176.  
  177.  
  178.  
  179. #define PURE
  180. #define THIS_                   INTERFACE FAR* This,
  181. #define THIS                    INTERFACE FAR* This
  182. #ifdef CONST_VTABLE
  183. #define DECLARE_INTERFACE(iface)    typedef interface iface { \
  184.                                     const struct iface##Vtbl FAR* lpVtbl; \
  185.                                 } iface; \
  186.                                 typedef const struct iface##Vtbl iface##Vtbl; \
  187.                                 const struct iface##Vtbl
  188. #else
  189. #define DECLARE_INTERFACE(iface)    typedef interface iface { \
  190.                                     struct iface##Vtbl FAR* lpVtbl; \
  191.                                 } iface; \
  192.                                 typedef struct iface##Vtbl iface##Vtbl; \
  193.                                 struct iface##Vtbl
  194. #endif
  195. #define DECLARE_INTERFACE_(iface, baseiface)    DECLARE_INTERFACE(iface)
  196.  
  197. #endif
  198.  
  199. #include <guiddef.h>
  200.  
  201. #ifndef _ERROR_STATUS_T_DEFINED
  202. typedef unsigned long error_status_t;
  203. #define _ERROR_STATUS_T_DEFINED
  204. #endif
  205.  
  206. #ifndef _WCHAR_T_DEFINED
  207. typedef unsigned short wchar_t;
  208. #define _WCHAR_T_DEFINED
  209. #endif
  210.  
  211. #pragma option pop /*P_O_Pop*/
  212. #endif
  213.  
  214.