//+--------------------------------------------------------------------------- // // Microsoft Windows // Copyright (C) Microsoft Corporation, 1992-1997. // // File: basetyps.h // //---------------------------------------------------------------------------- #if !defined( _BASETYPS_H_ ) #define _BASETYPS_H_ // Common macros gleamed from COMPOBJ.H #ifdef __cplusplus #define EXTERN_C extern "C" #else #define EXTERN_C extern #endif #ifdef _WIN32 // Win32 doesn't support __export #define STDMETHODCALLTYPE __stdcall #define STDMETHODVCALLTYPE __cdecl #define STDAPICALLTYPE __stdcall #define STDAPIVCALLTYPE __cdecl #else #define STDMETHODCALLTYPE __export __stdcall #define STDMETHODVCALLTYPE __export __cdecl #define STDAPICALLTYPE __export __stdcall #define STDAPIVCALLTYPE __export __cdecl #endif #define STDAPI EXTERN_C HRESULT STDAPICALLTYPE #define STDAPI_(type) EXTERN_C type STDAPICALLTYPE #define STDMETHODIMP HRESULT STDMETHODCALLTYPE #define STDMETHODIMP_(type) type STDMETHODCALLTYPE // The 'V' versions allow Variable Argument lists. #define STDAPIV EXTERN_C HRESULT STDAPIVCALLTYPE #define STDAPIV_(type) EXTERN_C type STDAPIVCALLTYPE #define STDMETHODIMPV HRESULT STDMETHODVCALLTYPE #define STDMETHODIMPV_(type) type STDMETHODVCALLTYPE /****** Interface Declaration ***********************************************/ /* * These are macros for declaring interfaces. They exist so that * a single definition of the interface is simulataneously a proper * declaration of the interface structures (C++ abstract classes) * for both C and C++. * * DECLARE_INTERFACE(iface) is used to declare an interface that does * not derive from a base interface. * DECLARE_INTERFACE_(iface, baseiface) is used to declare an interface * that does derive from a base interface. * * By default if the source file has a .c extension the C version of * the interface declaratations will be expanded; if it has a .cpp * extension the C++ version will be expanded. if you want to force * the C version expansion even though the source file has a .cpp * extension, then define the macro "CINTERFACE". * eg. cl -DCINTERFACE file.cpp * * Example Interface declaration: * * #undef INTERFACE * #define INTERFACE IClassFactory * * DECLARE_INTERFACE_(IClassFactory, IUnknown) * { * // *** IUnknown methods *** * STDMETHOD(QueryInterface) (THIS_ * REFIID riid, * LPVOID FAR* ppvObj) PURE; * STDMETHOD_(ULONG,AddRef) (THIS) PURE; * STDMETHOD_(ULONG,Release) (THIS) PURE; * * // *** IClassFactory methods *** * STDMETHOD(CreateInstance) (THIS_ * LPUNKNOWN pUnkOuter, * REFIID riid, * LPVOID FAR* ppvObject) PURE; * }; * * Example C++ expansion: * * struct FAR IClassFactory : public IUnknown * { * virtual HRESULT STDMETHODCALLTYPE QueryInterface( * IID FAR& riid, * LPVOID FAR* ppvObj) = 0; * virtual HRESULT STDMETHODCALLTYPE AddRef(void) = 0; * virtual HRESULT STDMETHODCALLTYPE Release(void) = 0; * virtual HRESULT STDMETHODCALLTYPE CreateInstance( * LPUNKNOWN pUnkOuter, * IID FAR& riid, * LPVOID FAR* ppvObject) = 0; * }; * * NOTE: Our documentation says '#define interface class' but we use * 'struct' instead of 'class' to keep a lot of 'public:' lines * out of the interfaces. The 'FAR' forces the 'this' pointers to * be far, which is what we need. * * Example C expansion: * * typedef struct IClassFactory * { * const struct IClassFactoryVtbl FAR* lpVtbl; * } IClassFactory; * * typedef struct IClassFactoryVtbl IClassFactoryVtbl; * * struct IClassFactoryVtbl * { * HRESULT (STDMETHODCALLTYPE * QueryInterface) ( * IClassFactory FAR* This, * IID FAR* riid, * LPVOID FAR* ppvObj) ; * HRESULT (STDMETHODCALLTYPE * AddRef) (IClassFactory FAR* This) ; * HRESULT (STDMETHODCALLTYPE * Release) (IClassFactory FAR* This) ; * HRESULT (STDMETHODCALLTYPE * CreateInstance) ( * IClassFactory FAR* This, * LPUNKNOWN pUnkOuter, * IID FAR* riid, * LPVOID FAR* ppvObject); * HRESULT (STDMETHODCALLTYPE * LockServer) ( * IClassFactory FAR* This, * BOOL fLock); * }; */ #if defined(__cplusplus) && !defined(CINTERFACE) //#define interface struct FAR #define interface struct #define STDMETHOD(method) virtual HRESULT STDMETHODCALLTYPE method #define STDMETHOD_(type,method) virtual type STDMETHODCALLTYPE method #define PURE = 0 #define THIS_ #define THIS void #define DECLARE_INTERFACE(iface) interface iface #define DECLARE_INTERFACE_(iface, baseiface) interface iface : public baseiface #else #define interface struct #define STDMETHOD(method) HRESULT (STDMETHODCALLTYPE * method) #define STDMETHOD_(type,method) type (STDMETHODCALLTYPE * method) #define PURE #define THIS_ INTERFACE FAR* This, #define THIS INTERFACE FAR* This #ifdef CONST_VTABLE #define DECLARE_INTERFACE(iface) typedef interface iface { \ const struct iface##Vtbl FAR* lpVtbl; \ } iface; \ typedef const struct iface##Vtbl iface##Vtbl; \ const struct iface##Vtbl #else #define DECLARE_INTERFACE(iface) typedef interface iface { \ struct iface##Vtbl FAR* lpVtbl; \ } iface; \ typedef struct iface##Vtbl iface##Vtbl; \ struct iface##Vtbl #endif #define DECLARE_INTERFACE_(iface, baseiface) DECLARE_INTERFACE(iface) #endif // macros to define byte pattern for a GUID. // Example: DEFINE_GUID(GUID_XXX, a, b, c, ...); // // Each dll/exe must initialize the GUIDs once. This is done in one of // two ways. If you are not using precompiled headers for the file(s) which // initializes the GUIDs, define INITGUID before including compobj.h. This // is how OLE builds the initialized versions of the GUIDs which are included // in ole2.lib. The GUIDs in ole2.lib are all defined in the same text // segment GUID_TEXT. // // The alternative (which some versions of the compiler don't handle properly; // they wind up with the initialized GUIDs in a data, not a text segment), // is to use a precompiled version of compobj.h and then include initguid.h // after compobj.h followed by one or more of the guid defintion files. #ifndef INITGUID #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ EXTERN_C const GUID FAR name #else #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ EXTERN_C const GUID name \ = { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } } #endif // INITGUID #define DEFINE_OLEGUID(name, l, w1, w2) \ DEFINE_GUID(name, l, w1, w2, 0xC0,0,0,0,0,0,0,0x46) #ifndef _ERROR_STATUS_T_DEFINED typedef unsigned long error_status_t; #define _ERROR_STATUS_T_DEFINED #endif #ifndef _WCHAR_T_DEFINED typedef unsigned short wchar_t; #define _WCHAR_T_DEFINED #endif #ifndef GUID_DEFINED #define GUID_DEFINED typedef struct _GUID { unsigned long Data1; unsigned short Data2; unsigned short Data3; unsigned char Data4[8]; } GUID; #endif /* GUID_DEFINED */ #endif