Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

217 lines
7.7 KiB

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