Better set of macros for defining the COM interfaces.

This commit is contained in:
Francois Gouget 1999-02-10 06:42:03 +00:00 committed by Alexandre Julliard
parent 123501fbc6
commit 93217c6056
6 changed files with 210 additions and 152 deletions

View file

@ -180,7 +180,7 @@ LPCLASSFACTORY IShellLink_CF_Constructor(void)
* IShellLink_CF_QueryInterface * IShellLink_CF_QueryInterface
*/ */
static HRESULT WINAPI IShellLink_CF_QueryInterface( static HRESULT WINAPI IShellLink_CF_QueryInterface(
LPUNKNOWN iface, REFIID riid, LPVOID *ppvObj) LPCLASSFACTORY iface, REFIID riid, LPVOID *ppvObj)
{ {
ICOM_THIS(IClassFactory,iface); ICOM_THIS(IClassFactory,iface);
char xriid[50]; char xriid[50];
@ -207,7 +207,7 @@ static HRESULT WINAPI IShellLink_CF_QueryInterface(
/****************************************************************************** /******************************************************************************
* IShellLink_CF_AddRef * IShellLink_CF_AddRef
*/ */
static ULONG WINAPI IShellLink_CF_AddRef(LPUNKNOWN iface) static ULONG WINAPI IShellLink_CF_AddRef(LPCLASSFACTORY iface)
{ {
ICOM_THIS(IClassFactory,iface); ICOM_THIS(IClassFactory,iface);
TRACE(shell,"(%p)->(count=%lu)\n",this,this->ref); TRACE(shell,"(%p)->(count=%lu)\n",this,this->ref);
@ -218,7 +218,7 @@ static ULONG WINAPI IShellLink_CF_AddRef(LPUNKNOWN iface)
/****************************************************************************** /******************************************************************************
* IShellLink_CF_Release * IShellLink_CF_Release
*/ */
static ULONG WINAPI IShellLink_CF_Release(LPUNKNOWN iface) static ULONG WINAPI IShellLink_CF_Release(LPCLASSFACTORY iface)
{ {
ICOM_THIS(IClassFactory,iface); ICOM_THIS(IClassFactory,iface);
TRACE(shell,"(%p)->(count=%lu)\n",this,this->ref); TRACE(shell,"(%p)->(count=%lu)\n",this,this->ref);
@ -280,11 +280,9 @@ static HRESULT WINAPI IShellLink_CF_LockServer(LPCLASSFACTORY iface, BOOL32 fLoc
} }
static ICOM_VTABLE(IClassFactory) slcfvt = static ICOM_VTABLE(IClassFactory) slcfvt =
{ {
{
IShellLink_CF_QueryInterface, IShellLink_CF_QueryInterface,
IShellLink_CF_AddRef, IShellLink_CF_AddRef,
IShellLink_CF_Release IShellLink_CF_Release,
},
IShellLink_CF_CreateInstance, IShellLink_CF_CreateInstance,
IShellLink_CF_LockServer IShellLink_CF_LockServer
}; };
@ -519,7 +517,7 @@ LPCLASSFACTORY IShellLinkW_CF_Constructor(void)
* IShellLinkW_CF_QueryInterface * IShellLinkW_CF_QueryInterface
*/ */
static HRESULT WINAPI IShellLinkW_CF_QueryInterface( static HRESULT WINAPI IShellLinkW_CF_QueryInterface(
LPUNKNOWN iface, REFIID riid, LPVOID *ppvObj) LPCLASSFACTORY iface, REFIID riid, LPVOID *ppvObj)
{ {
ICOM_THIS(IClassFactory,iface); ICOM_THIS(IClassFactory,iface);
char xriid[50]; char xriid[50];
@ -546,7 +544,7 @@ static HRESULT WINAPI IShellLinkW_CF_QueryInterface(
/****************************************************************************** /******************************************************************************
* IShellLinkW_CF_AddRef * IShellLinkW_CF_AddRef
*/ */
static ULONG WINAPI IShellLinkW_CF_AddRef(LPUNKNOWN iface) static ULONG WINAPI IShellLinkW_CF_AddRef(LPCLASSFACTORY iface)
{ {
ICOM_THIS(IClassFactory,iface); ICOM_THIS(IClassFactory,iface);
TRACE(shell,"(%p)->(count=%lu)\n",this,this->ref); TRACE(shell,"(%p)->(count=%lu)\n",this,this->ref);
@ -557,7 +555,7 @@ static ULONG WINAPI IShellLinkW_CF_AddRef(LPUNKNOWN iface)
/****************************************************************************** /******************************************************************************
* IShellLinkW_CF_Release * IShellLinkW_CF_Release
*/ */
static ULONG WINAPI IShellLinkW_CF_Release(LPUNKNOWN iface) static ULONG WINAPI IShellLinkW_CF_Release(LPCLASSFACTORY iface)
{ {
ICOM_THIS(IClassFactory,iface); ICOM_THIS(IClassFactory,iface);
TRACE(shell,"(%p)->(count=%lu)\n",this,this->ref); TRACE(shell,"(%p)->(count=%lu)\n",this,this->ref);
@ -621,11 +619,9 @@ static HRESULT WINAPI IShellLinkW_CF_LockServer(LPCLASSFACTORY iface, BOOL32 fLo
static ICOM_VTABLE(IClassFactory) slwcfvt = static ICOM_VTABLE(IClassFactory) slwcfvt =
{ {
{
IShellLinkW_CF_QueryInterface, IShellLinkW_CF_QueryInterface,
IShellLinkW_CF_AddRef, IShellLinkW_CF_AddRef,
IShellLinkW_CF_Release IShellLinkW_CF_Release,
},
IShellLinkW_CF_CreateInstance, IShellLinkW_CF_CreateInstance,
IShellLinkW_CF_LockServer IShellLinkW_CF_LockServer
}; };

View file

@ -232,7 +232,7 @@ LPCLASSFACTORY IClassFactory_Constructor(void)
* IClassFactory_QueryInterface * IClassFactory_QueryInterface
*/ */
static HRESULT WINAPI IClassFactory_fnQueryInterface( static HRESULT WINAPI IClassFactory_fnQueryInterface(
LPUNKNOWN iface, REFIID riid, LPVOID *ppvObj) LPCLASSFACTORY iface, REFIID riid, LPVOID *ppvObj)
{ {
ICOM_THIS(IClassFactory,iface); ICOM_THIS(IClassFactory,iface);
char xriid[50]; char xriid[50];
@ -259,7 +259,7 @@ static HRESULT WINAPI IClassFactory_fnQueryInterface(
/****************************************************************************** /******************************************************************************
* IClassFactory_AddRef * IClassFactory_AddRef
*/ */
static ULONG WINAPI IClassFactory_fnAddRef(LPUNKNOWN iface) static ULONG WINAPI IClassFactory_fnAddRef(LPCLASSFACTORY iface)
{ {
ICOM_THIS(IClassFactory,iface); ICOM_THIS(IClassFactory,iface);
TRACE(shell,"(%p)->(count=%lu)\n",this,this->ref); TRACE(shell,"(%p)->(count=%lu)\n",this,this->ref);
@ -270,7 +270,7 @@ static ULONG WINAPI IClassFactory_fnAddRef(LPUNKNOWN iface)
/****************************************************************************** /******************************************************************************
* IClassFactory_Release * IClassFactory_Release
*/ */
static ULONG WINAPI IClassFactory_fnRelease(LPUNKNOWN iface) static ULONG WINAPI IClassFactory_fnRelease(LPCLASSFACTORY iface)
{ {
ICOM_THIS(IClassFactory,iface); ICOM_THIS(IClassFactory,iface);
TRACE(shell,"(%p)->(count=%lu)\n",this,this->ref); TRACE(shell,"(%p)->(count=%lu)\n",this,this->ref);
@ -345,11 +345,9 @@ static HRESULT WINAPI IClassFactory_fnLockServer(LPCLASSFACTORY iface, BOOL32 fL
static ICOM_VTABLE(IClassFactory) clfvt = static ICOM_VTABLE(IClassFactory) clfvt =
{ {
{
IClassFactory_fnQueryInterface, IClassFactory_fnQueryInterface,
IClassFactory_fnAddRef, IClassFactory_fnAddRef,
IClassFactory_fnRelease IClassFactory_fnRelease,
},
IClassFactory_fnCreateInstance, IClassFactory_fnCreateInstance,
IClassFactory_fnLockServer IClassFactory_fnLockServer
}; };

View file

@ -34,12 +34,14 @@
/***************************************************************************** /*****************************************************************************
* GUID API * GUID API
*/ */
HRESULT WINAPI StringFromCLSID16(const CLSID *id, LPOLESTR16*); HRESULT WINAPI StringFromCLSID16(REFCLSID id, LPOLESTR16*);
HRESULT WINAPI StringFromCLSID32(const CLSID *id, LPOLESTR32*); HRESULT WINAPI StringFromCLSID32(REFCLSID id, LPOLESTR32*);
#define StringFromCLSID WINELIB_NAME(StringFromCLSID) #define StringFromCLSID WINELIB_NAME(StringFromCLSID)
HRESULT WINAPI CLSIDFromString16(LPCOLESTR16, CLSID *); HRESULT WINAPI CLSIDFromString16(LPCOLESTR16, CLSID *);
HRESULT WINAPI CLSIDFromString32(LPCOLESTR32, CLSID *); HRESULT WINAPI CLSIDFromString32(LPCOLESTR32, CLSID *);
#define CLSIDFromString WINELIB_NAME(CLSIDFromString) #define CLSIDFromString WINELIB_NAME(CLSIDFromString)
HRESULT WINAPI CLSIDFromProgID16(LPCOLESTR16 progid, LPCLSID riid); HRESULT WINAPI CLSIDFromProgID16(LPCOLESTR16 progid, LPCLSID riid);
HRESULT WINAPI CLSIDFromProgID32(LPCOLESTR32 progid, LPCLSID riid); HRESULT WINAPI CLSIDFromProgID32(LPCOLESTR32 progid, LPCLSID riid);
#define CLSIDFromProgID WINELIB_NAME(CLSIDFromProgID) #define CLSIDFromProgID WINELIB_NAME(CLSIDFromProgID)
@ -83,21 +85,23 @@ BOOL32 WINAPI IsEqualGUID32(REFGUID rguid1,REFGUID rguid2);
* Let's take Direct3D as an example: * Let's take Direct3D as an example:
* *
* #define ICOM_INTERFACE IDirect3D * #define ICOM_INTERFACE IDirect3D
* ICOM_BEGIN(IDirect3D,IUnknown) * #define IDirect3D_METHODS \
* ICOM_METHOD1(HRESULT,Initialize, REFIID,); * ICOM_METHOD1(HRESULT,Initialize, REFIID,); \
* ICOM_METHOD2(HRESULT,EnumDevices, LPD3DENUMDEVICESCALLBACK,, LPVOID,); * ICOM_METHOD2(HRESULT,EnumDevices, LPD3DENUMDEVICESCALLBACK,, LPVOID,); \
* ICOM_METHOD2(HRESULT,CreateLight, LPDIRECT3DLIGHT*,, IUnknown*,); * ICOM_METHOD2(HRESULT,CreateLight, LPDIRECT3DLIGHT*,, IUnknown*,); \
* ICOM_METHOD2(HRESULT,CreateMaterial,LPDIRECT3DMATERIAL*,, IUnknown*,); * ICOM_METHOD2(HRESULT,CreateMaterial,LPDIRECT3DMATERIAL*,, IUnknown*,); \
* ICOM_METHOD2(HRESULT,CreateViewport,LPDIRECT3DVIEWPORT*,, IUnknown*,); * ICOM_METHOD2(HRESULT,CreateViewport,LPDIRECT3DVIEWPORT*,, IUnknown*,); \
* ICOM_METHOD2(HRESULT,FindDevice, LPD3DFINDDEVICESEARCH,, LPD3DFINDDEVICERESULT,); * ICOM_METHOD2(HRESULT,FindDevice, LPD3DFINDDEVICESEARCH,, LPD3DFINDDEVICERESULT,);
* ICOM_END(IDirect3D) * #define IDirect3D_IMETHODS \
* ICOM_INHERITS(IDirect3D,IUnknown)
* ICOM_DEFINE(IDirect3D,IUnknown)
* #undef ICOM_INTERFACE * #undef ICOM_INTERFACE
* *
* #if !defined(__cplusplus) || defined(CINTERFACE) * #ifdef ICOM_CINTERFACE
* // *** IUnknown methods *** // * // *** IUnknown methods *** //
* #define IDirect3D_QueryInterface(p,a,b) ICOM_ICALL2(IUnknown,QueryInterface,p,a,b) * #define IDirect3D_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b)
* #define IDirect3D_AddRef(p) ICOM_ICALL (IUnknown,AddRef,p) * #define IDirect3D_AddRef(p) ICOM_CALL (AddRef,p)
* #define IDirect3D_Release(p) ICOM_ICALL (IUnknown,Release,p) * #define IDirect3D_Release(p) ICOM_CALL (Release,p)
* // *** IDirect3D methods *** // * // *** IDirect3D methods *** //
* #define IDirect3D_Initialize(p,a) ICOM_CALL1(Initialize,p,a) * #define IDirect3D_Initialize(p,a) ICOM_CALL1(Initialize,p,a)
* #define IDirect3D_EnumDevices(p,a,b) ICOM_CALL2(EnumDevice,p,a,b) * #define IDirect3D_EnumDevices(p,a,b) ICOM_CALL2(EnumDevice,p,a,b)
@ -108,19 +112,22 @@ BOOL32 WINAPI IsEqualGUID32(REFGUID rguid1,REFGUID rguid2);
* #endif * #endif
* *
* Comments: * Comments:
* - The ICOM_INTERFACE is used in the ICOM_METHOD macros for the 'this' pointer and to cast * - The ICOM_INTERFACE macro is used in the ICOM_METHOD macros to define the type of the 'this'
* pointers. Defining this macro here saves us the trouble of having to repeat the interface * pointer. Defining this macro here saves us the trouble of having to repeat the interface
* name everywhere. Note haowever that because of the way macros work a macro like ICOM_METHOD1 * name everywhere. Note however that because of the way macros work, a macro like ICOM_METHOD1
* cannot use 'ICOM_INTERFACE##_VTABLE' because this would give 'ICOM_INTERFACE_VTABLE' and not * cannot use 'ICOM_INTERFACE##_VTABLE' because this would give 'ICOM_INTERFACE_VTABLE' and not
* 'IDirect3D_VTABLE'. * 'IDirect3D_VTABLE'.
* - ICOM_BEGIN and ICOM_END are responsible for generating whatever structure is appropriate for * - ICOM_METHODS defines the methods specific to this interface. It is then aggregated with the
* representing the interface in the current language. In C this is a couple of structs in C++ * inherited methods to form ICOM_IMETHODS.
* it's a class. The first parameter is the interface name and the second one is the interface * - ICOM_INHERITS takes as its first parameter the name of the current interface and as its
* we inherit from. The reason why you have to repeat the interface name is because that's the * second parameter the name of the parent interface. The reason why you have to repeat the
* only way these macro can successfully output "IDirect3D_VTABLE'. Trying to use ICOM_INTERFACE * interface name is because that's the only way these macro can successfully output
* would, as in ICOM_METHOD, only yield 'ICOM_INTERFACE_VTABLE'. * "IDirect3D_VTABLE'. Trying to use ICOM_INTERFACE would only yield 'ICOM_INTERFACE_VTABLE'.
* - With the way ICOM_BEGIN works you don't have to repeat the definitions of the methods of the * - The ICOM_DEFINE declares all the structures necessary for the interface. As with
* parent interface. They are automatically inherited both in C and in C++. * ICOM_INHERITS you have to explicitly state the name of the current interface and that of
* its parent.
* Inherited methods are inherited in both C and C++ by using the IDirect3D_METHODS macro and
* the parent's Xxx_IMETHODS macro.
* - In C++ the ICOM_METHOD macros generate a function prototype and a call to a function pointer * - In C++ the ICOM_METHOD macros generate a function prototype and a call to a function pointer
* method. This means using once 't1 p1, t2 p2, ...' and once 'p1, p2' without the types. The * method. This means using once 't1 p1, t2 p2, ...' and once 'p1, p2' without the types. The
* only way I found to handle this is to have one ICOM_METHOD macro per number of parameters and * only way I found to handle this is to have one ICOM_METHOD macro per number of parameters and
@ -135,25 +142,24 @@ BOOL32 WINAPI IsEqualGUID32(REFGUID rguid1,REFGUID rguid2);
* I left them blank. * I left them blank.
* - Finally the set of 'IDirect3D_Xxx' macros is a standard set of macros defined to ease access * - Finally the set of 'IDirect3D_Xxx' macros is a standard set of macros defined to ease access
* to the interface methods in C. Unfortunately I don't see any way to avoid having to duplicate * to the interface methods in C. Unfortunately I don't see any way to avoid having to duplicate
* the inherited method definitions there. We must use ICOM_ICALL to invoke inherited methods, * the inherited method definitions there. This time I could have used a trick to use only one
* because in C we have to cast the virtual table pointer, and we should use the ICOM_CALL * macro whatever the number of parameters but I prefered to have it work the same way as above.
* method in the other cases. This time I could have used a trick to use only one macro whatever
* the number of parameters but I prefered to have it work the same way as above.
* - You probably have noticed that we don't define the fields we need to actually implement this * - You probably have noticed that we don't define the fields we need to actually implement this
* interface: reference count, pointer to other resources and miscellaneous fields. That's * interface: reference count, pointer to other resources and miscellaneous fields. That's
* because it's not needed, and the user will anyway only manipulate pointers to this structure * because these interfaces are just that: interfaces. They may be implemented more than once, in
* so he does not need to know its real size. Of course on the implementation side we have the * different contexts and sometimes not even in Wine. Thus it would not make sense to impose
* real definition of the interface structure and they should match what the macros yield in * that the interface contains some specific fields.
* each language (or conversely).
* *
* *
* In C this gives: * In C this gives:
* typedef struct IDirect3D_VTABLE IDirect3D_VTABLE; * typedef struct IDirect3DVtbl IDirect3DVtbl;
* struct IDirect3D { * struct IDirect3D {
* IDirect3D_VTABLE* lpvtbl; * IDirect3DVtbl* lpvtbl;
* }; * };
* struct IDirect3D_VTABLE { * struct IDirect3DVtbl {
* IUnknown_VTABLE bvt; * HRESULT (*fnQueryInterface)(IDirect3D* me, REFIID riid, LPVOID* ppvObj);
* ULONG (*fnQueryInterface)(IDirect3D* me);
* ULONG (*fnQueryInterface)(IDirect3D* me);
* HRESULT (*fnInitialize)(IDirect3D* me, REFIID a); * HRESULT (*fnInitialize)(IDirect3D* me, REFIID a);
* HRESULT (*fnEnumDevices)(IDirect3D* me, LPD3DENUMDEVICESCALLBACK a, LPVOID b); * HRESULT (*fnEnumDevices)(IDirect3D* me, LPD3DENUMDEVICESCALLBACK a, LPVOID b);
* HRESULT (*fnCreateLight)(IDirect3D* me, LPDIRECT3DLIGHT* a, IUnknown* b); * HRESULT (*fnCreateLight)(IDirect3D* me, LPDIRECT3DLIGHT* a, IUnknown* b);
@ -162,11 +168,11 @@ BOOL32 WINAPI IsEqualGUID32(REFGUID rguid1,REFGUID rguid2);
* HRESULT (*fnFindDevice)(IDirect3D* me, LPD3DFINDDEVICESEARCH a, LPD3DFINDDEVICERESULT b); * HRESULT (*fnFindDevice)(IDirect3D* me, LPD3DFINDDEVICESEARCH a, LPD3DFINDDEVICERESULT b);
* }; * };
* *
* #if !defined(__cplusplus) || defined(CINTERFACE) * #ifdef ICOM_CINTERFACE
* // *** IUnknown methods *** // * // *** IUnknown methods *** //
* #define IDirect3D_QueryInterface(p,a,b) ((IUnknown_VTABLE*)(p)->lpvtbl)->fnQueryInterface((IUnknown*)p,a,b) * #define IDirect3D_QueryInterface(p,a,b) (p)->lpvtbl->fnQueryInterface(p,a,b)
* #define IDirect3D_AddRef(p) ((IUnknown_VTABLE*)(p)->lpvtbl)->fnAddRef((IUnknown*)p) * #define IDirect3D_AddRef(p) (p)->lpvtbl->fnAddRef(p)
* #define IDirect3D_Release(p) ((IUnknown_VTABLE*)(p)->lpvtbl)->fnRelease((IUnknown*)p) * #define IDirect3D_Release(p) (p)->lpvtbl->fnRelease(p)
* // *** IDirect3D methods *** // * // *** IDirect3D methods *** //
* #define IDirect3D_Initialize(p,a) (p)->lpvtbl->fnInitialize(p,a) * #define IDirect3D_Initialize(p,a) (p)->lpvtbl->fnInitialize(p,a)
* #define IDirect3D_EnumDevices(p,a,b) (p)->lpvtbl->fnEnumDevice(p,a,b) * #define IDirect3D_EnumDevices(p,a,b) (p)->lpvtbl->fnEnumDevice(p,a,b)
@ -180,22 +186,18 @@ BOOL32 WINAPI IsEqualGUID32(REFGUID rguid1,REFGUID rguid2);
* - IDirect3D only contains a pointer to the IDirect3D virtual/jump table. This is the only thing * - IDirect3D only contains a pointer to the IDirect3D virtual/jump table. This is the only thing
* the user needs to know to use the interface. Of course the structure we will define to * the user needs to know to use the interface. Of course the structure we will define to
* implement this interface will have more fields but the first one will match this pointer. * implement this interface will have more fields but the first one will match this pointer.
* - The code generated by ICOM_BEGIN goes up to the bvt field in the IDirect3D virtual table. * - The code generated by ICOM_DEFINE defines both the structure representing the interface and
* This bvt field is what saves us from having to duplicate the inherited method definitions. * the structure for the jump table. ICOM_DEFINE uses the parent's Xxx_IMETHODS macro to
* It's a shame that C (gcc) will not allow unnamed structs. If this was possible we could * automatically repeat the prototypes of all the inherited methods and then uses IDirect3D_METHODS
* seamlessly inherit and use the parent's interface function pointers. * to define the IDirect3D methods.
* - What follows is just a bunch of function pointer definitions generated by the ICOM_METHOD * - Each method is declared as a pointer to function field in the jump table. The implementation
* macros. The implementation will fill this jump table with appropriate values in a static * will fill this jump table with appropriate values, probably using a static variable, and
* variable and initialize the lpvtbl field to point to this variable. * initialize the lpvtbl field to point to this variable.
* - The IDirect3D_Xxx macros then just derefence the lpvtbl pointer and use the function pointer * - The IDirect3D_Xxx macros then just derefence the lpvtbl pointer and use the function pointer
* corresponding to the macro name. This emulates the behavior of a virtual table and should be * corresponding to the macro name. This emulates the behavior of a virtual table and should be
* about as fast. In the case of inherited methods we have some additional casting to do to * just as fast.
* because the inherited methods are defined in the bvt field or maybe further imbricated. Since * - This C code should be quite compatible with the Windows headers both for code that uses COM
* the effect of the bvt field is that we inherit the parent virtual table fields this cast is * interfaces and for code implementing a COM interface.
* relatively inocuous. A similar cast must be performed on the interface pointer before the
* invoked method will accept it. Despite all these casts there is little chance that you call a
* method on the wrong type of interface because the function names still have to match. But this
* is the only thing that will make the compilation fail.
* *
* *
* And in C++ (with gcc's g++): * And in C++ (with gcc's g++):
@ -241,12 +243,14 @@ BOOL32 WINAPI IsEqualGUID32(REFGUID rguid1,REFGUID rguid2);
* we need different macros to handle different numbers of parameters. * we need different macros to handle different numbers of parameters.
* - Finally there is no IDirect3D_Xxx macro. These are not needed in C++ unless the CINTERFACE * - Finally there is no IDirect3D_Xxx macro. These are not needed in C++ unless the CINTERFACE
* macro is defined in which case we would not be here. * macro is defined in which case we would not be here.
* - This C++ code works well for code that just uses COM interfaces. But it will not work with
* C++ code implement a COM interface. That's because such code assumes the interface methods
* are declared as virtual C++ methods which is not the case here.
* *
* *
* Implementing a COM interface. * Implementing a COM interface.
* *
* This continues the above example.I assume the implementation is in C but it would probably * This continues the above example. This example assumes that the implementation is in C.
* be similar in C++.
* *
* typedef struct _IDirect3D { * typedef struct _IDirect3D {
* void* lpvtbl; * void* lpvtbl;
@ -258,7 +262,7 @@ BOOL32 WINAPI IsEqualGUID32(REFGUID rguid1,REFGUID rguid2);
* *
* // implement the IDirect3D methods here * // implement the IDirect3D methods here
* *
* int IDirect3D_fnQueryInterface(LPUNKNOWN me) * int IDirect3D_fnQueryInterface(IDirect3D* me)
* { * {
* ICOM_THIS(IDirect3D,me); * ICOM_THIS(IDirect3D,me);
* // ... * // ...
@ -267,11 +271,9 @@ BOOL32 WINAPI IsEqualGUID32(REFGUID rguid1,REFGUID rguid2);
* // ... * // ...
* *
* static ICOM_VTABLE(IDirect3D) d3dvt = { * static ICOM_VTABLE(IDirect3D) d3dvt = {
* {
* IDirect3D_fnQueryInterface, * IDirect3D_fnQueryInterface,
* IUnknown_fnAdd, * IDirect3D_fnAdd,
* IUnknown_fnAdd2 * IDirect3D_fnAdd2,
* },
* IDirect3D_fnInitialize, * IDirect3D_fnInitialize,
* IDirect3D_fnSetWidth * IDirect3D_fnSetWidth
* }; * };
@ -282,19 +284,23 @@ BOOL32 WINAPI IsEqualGUID32(REFGUID rguid1,REFGUID rguid2);
* - Then we predeclare our static virtual table variable, we will need its address in some * - Then we predeclare our static virtual table variable, we will need its address in some
* methods to initialize the virtual table pointer of the returned interface objects. * methods to initialize the virtual table pointer of the returned interface objects.
* - Then we implement the interface methods. To match what has been declared in the header file * - Then we implement the interface methods. To match what has been declared in the header file
* they must take a pointer to a IDirect3D structure so we must cast it to an _IDirect3D so that * they must take a pointer to a IDirect3D structure and we must cast it to an _IDirect3D so that
* we can manipulate the fields. This is performed by the ICOM_THIS macro. * we can manipulate the fields. This is performed by the ICOM_THIS macro.
* - Finally we initialize the virtual table. The inherited methods must be in curly brackets to * - Finally we initialize the virtual table.
* match the parent interface's virtual table definition.
*/ */
#define ICOM_VTABLE(iface) iface##_VTABLE #define ICOM_VTABLE(iface) iface##Vtbl
#if defined(__cplusplus) && !defined(CINTERFACE) #if !defined(__cplusplus) || defined(CINTERFACE)
#define ICOM_CINTERFACE 1
#endif
#ifndef ICOM_CINTERFACE
/* C++ interface */ /* C++ interface */
/* FIXME: to be removed as soon as it's no longer used */
#define ICOM_BEGIN(iface,ibase) \ #define ICOM_BEGIN(iface,ibase) \
typedef struct iface: public ibase { typedef struct iface: public ibase {
@ -331,6 +337,10 @@ BOOL32 WINAPI IsEqualGUID32(REFGUID rguid1,REFGUID rguid2);
private: ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g); \ private: ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g); \
public: inline ret (CALLBACK xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g) { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c,d,e,f,g); }; public: inline ret (CALLBACK xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g) { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c,d,e,f,g); };
#define ICOM_METHOD8(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh) \
private: ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h); \
public: inline ret (CALLBACK xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g,th h) { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c,d,e,f,g,h); };
#define ICOM_CMETHOD(ret,xfn) \ #define ICOM_CMETHOD(ret,xfn) \
private: ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me); \ private: ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me); \
@ -364,6 +374,10 @@ BOOL32 WINAPI IsEqualGUID32(REFGUID rguid1,REFGUID rguid2);
private: ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g); \ private: ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g); \
public: inline ret (CALLBACK xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g) const { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c,d,e,f,g); }; public: inline ret (CALLBACK xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g) const { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c,d,e,f,g); };
#define ICOM_CMETHOD8(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh) \
private: ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h); \
public: inline ret (CALLBACK xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g,th h) const { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c,d,e,f,g,h); };
#define ICOM_VMETHOD(xfn) \ #define ICOM_VMETHOD(xfn) \
private: void (CALLBACK *fn##xfn)(ICOM_INTERFACE* me); \ private: void (CALLBACK *fn##xfn)(ICOM_INTERFACE* me); \
@ -397,6 +411,10 @@ BOOL32 WINAPI IsEqualGUID32(REFGUID rguid1,REFGUID rguid2);
private: void (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g); \ private: void (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g); \
public: inline void (CALLBACK xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g) { ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c,d,e,f,g); }; public: inline void (CALLBACK xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g) { ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c,d,e,f,g); };
#define ICOM_VMETHOD8(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh) \
private: void (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h); \
public: inline void (CALLBACK xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g,th h) { ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c,d,e,f,g,h); };
#define ICOM_CVMETHOD(xfn) \ #define ICOM_CVMETHOD(xfn) \
private: void (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me); \ private: void (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me); \
@ -430,10 +448,23 @@ BOOL32 WINAPI IsEqualGUID32(REFGUID rguid1,REFGUID rguid2);
private: void (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g); \ private: void (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g); \
public: inline void (CALLBACK xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g) const { ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c,d,e,f,g); }; public: inline void (CALLBACK xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g) const { ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c,d,e,f,g); };
#define ICOM_CVMETHOD8(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh) \
private: void (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h); \
public: inline void (CALLBACK xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g,th h) const { ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c,d,e,f,g,h); };
/* FIXME: to be removed as soon as it's no longer used */
#define ICOM_END(iface) \ #define ICOM_END(iface) \
}; };
#define ICOM_INHERITS(iface, ibase) this_is_a_syntax_error
#define ICOM_DEFINE(iface,ibase) \
typedef struct iface: public ibase { \
iface##_METHODS \
};
/* FIXME: to be removed as soon as they (ICOM_ICALL) are no longer used */
#define ICOM_ICALL(ibase, xfn, p) this_is_a_syntax_error #define ICOM_ICALL(ibase, xfn, p) this_is_a_syntax_error
#define ICOM_ICALL1(ibase, xfn, p,a) this_is_a_syntax_error #define ICOM_ICALL1(ibase, xfn, p,a) this_is_a_syntax_error
#define ICOM_ICALL2(ibase, xfn, p,a,b) this_is_a_syntax_error #define ICOM_ICALL2(ibase, xfn, p,a,b) this_is_a_syntax_error
@ -442,6 +473,7 @@ BOOL32 WINAPI IsEqualGUID32(REFGUID rguid1,REFGUID rguid2);
#define ICOM_ICALL5(ibase, xfn, p,a,b,c,d,e) this_is_a_syntax_error #define ICOM_ICALL5(ibase, xfn, p,a,b,c,d,e) this_is_a_syntax_error
#define ICOM_ICALL6(ibase, xfn, p,a,b,c,d,e,f) this_is_a_syntax_error #define ICOM_ICALL6(ibase, xfn, p,a,b,c,d,e,f) this_is_a_syntax_error
#define ICOM_ICALL7(ibase, xfn, p,a,b,c,d,e,f,g) this_is_a_syntax_error #define ICOM_ICALL7(ibase, xfn, p,a,b,c,d,e,f,g) this_is_a_syntax_error
#define ICOM_ICALL8(ibase, xfn, p,a,b,c,d,e,f,g,h) this_is_a_syntax_error
#define ICOM_CALL(xfn, p) this_is_a_syntax_error #define ICOM_CALL(xfn, p) this_is_a_syntax_error
#define ICOM_CALL1(xfn, p,a) this_is_a_syntax_error #define ICOM_CALL1(xfn, p,a) this_is_a_syntax_error
@ -451,12 +483,14 @@ BOOL32 WINAPI IsEqualGUID32(REFGUID rguid1,REFGUID rguid2);
#define ICOM_CALL5(xfn, p,a,b,c,d,e) this_is_a_syntax_error #define ICOM_CALL5(xfn, p,a,b,c,d,e) this_is_a_syntax_error
#define ICOM_CALL6(xfn, p,a,b,c,d,e,f) this_is_a_syntax_error #define ICOM_CALL6(xfn, p,a,b,c,d,e,f) this_is_a_syntax_error
#define ICOM_CALL7(xfn, p,a,b,c,d,e,f,g) this_is_a_syntax_error #define ICOM_CALL7(xfn, p,a,b,c,d,e,f,g) this_is_a_syntax_error
#define ICOM_CALL8(xfn, p,a,b,c,d,e,f,g,h) this_is_a_syntax_error
#else #else
/* C interface */ /* C interface */
/* FIXME: to be removed as soon as it's no longer used */
#define ICOM_BEGIN(iface,ibase) \ #define ICOM_BEGIN(iface,ibase) \
typedef struct ICOM_VTABLE(iface) ICOM_VTABLE(iface); \ typedef struct ICOM_VTABLE(iface) ICOM_VTABLE(iface); \
struct iface { \ struct iface { \
@ -490,6 +524,9 @@ BOOL32 WINAPI IsEqualGUID32(REFGUID rguid1,REFGUID rguid2);
#define ICOM_METHOD7(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \ #define ICOM_METHOD7(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \
ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g); ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g);
#define ICOM_METHOD8(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh) \
ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h);
#define ICOM_CMETHOD(ret,xfn) \ #define ICOM_CMETHOD(ret,xfn) \
ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me); ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me);
@ -515,6 +552,9 @@ BOOL32 WINAPI IsEqualGUID32(REFGUID rguid1,REFGUID rguid2);
#define ICOM_CMETHOD7(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \ #define ICOM_CMETHOD7(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \
ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g); ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g);
#define ICOM_CMETHOD8(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh) \
ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h);
#define ICOM_VMETHOD(xfn) \ #define ICOM_VMETHOD(xfn) \
void (CALLBACK *fn##xfn)(ICOM_INTERFACE* me); void (CALLBACK *fn##xfn)(ICOM_INTERFACE* me);
@ -540,6 +580,9 @@ BOOL32 WINAPI IsEqualGUID32(REFGUID rguid1,REFGUID rguid2);
#define ICOM_VMETHOD7(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \ #define ICOM_VMETHOD7(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \
void (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g); void (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g);
#define ICOM_VMETHOD8(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,nh) \
void (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h);
#define ICOM_CVMETHOD(xfn) \ #define ICOM_CVMETHOD(xfn) \
void (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me); void (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me);
@ -565,10 +608,29 @@ BOOL32 WINAPI IsEqualGUID32(REFGUID rguid1,REFGUID rguid2);
#define ICOM_CVMETHOD7(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \ #define ICOM_CVMETHOD7(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \
void (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g); void (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g);
#define ICOM_CVMETHOD8(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh) \
void (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h);
/* FIXME: to be removed as soon as it's no longer used */
#define ICOM_END(iface) \ #define ICOM_END(iface) \
}; };
#define ICOM_INHERITS(iface, ibase) \
ibase##_IMETHODS \
iface##_METHODS
#define ICOM_DEFINE(iface,ibase) \
typedef struct ICOM_VTABLE(iface) ICOM_VTABLE(iface); \
struct iface { \
const ICOM_VTABLE(iface)* lpvtbl; \
}; \
struct ICOM_VTABLE(iface) { \
ibase##_IMETHODS \
iface##_METHODS \
};
/* FIXME: to be removed as soon as they (ICOM_ICALL) are no longer used */
#define ICOM_ICALL(ibase, xfn, p) ((ICOM_VTABLE(ibase)*)(p)->lpvtbl)->fn##xfn((ibase*)p) #define ICOM_ICALL(ibase, xfn, p) ((ICOM_VTABLE(ibase)*)(p)->lpvtbl)->fn##xfn((ibase*)p)
#define ICOM_ICALL1(ibase, xfn, p,a) ((ICOM_VTABLE(ibase)*)(p)->lpvtbl)->fn##xfn((ibase*)p,a) #define ICOM_ICALL1(ibase, xfn, p,a) ((ICOM_VTABLE(ibase)*)(p)->lpvtbl)->fn##xfn((ibase*)p,a)
#define ICOM_ICALL2(ibase, xfn, p,a,b) ((ICOM_VTABLE(ibase)*)(p)->lpvtbl)->fn##xfn((ibase*)p,a,b) #define ICOM_ICALL2(ibase, xfn, p,a,b) ((ICOM_VTABLE(ibase)*)(p)->lpvtbl)->fn##xfn((ibase*)p,a,b)
@ -577,6 +639,7 @@ BOOL32 WINAPI IsEqualGUID32(REFGUID rguid1,REFGUID rguid2);
#define ICOM_ICALL5(ibase, xfn, p,a,b,c,d,e) ((ICOM_VTABLE(ibase)*)(p)->lpvtbl)->fn##xfn((ibase*)p,a,b,c,d,e) #define ICOM_ICALL5(ibase, xfn, p,a,b,c,d,e) ((ICOM_VTABLE(ibase)*)(p)->lpvtbl)->fn##xfn((ibase*)p,a,b,c,d,e)
#define ICOM_ICALL6(ibase, xfn, p,a,b,c,d,e,f) ((ICOM_VTABLE(ibase)*)(p)->lpvtbl)->fn##xfn((ibase*)p,a,b,c,d,e,f) #define ICOM_ICALL6(ibase, xfn, p,a,b,c,d,e,f) ((ICOM_VTABLE(ibase)*)(p)->lpvtbl)->fn##xfn((ibase*)p,a,b,c,d,e,f)
#define ICOM_ICALL7(ibase, xfn, p,a,b,c,d,e,f,g) ((ICOM_VTABLE(ibase)*)(p)->lpvtbl)->fn##xfn((ibase*)p,a,b,c,d,e,f,g) #define ICOM_ICALL7(ibase, xfn, p,a,b,c,d,e,f,g) ((ICOM_VTABLE(ibase)*)(p)->lpvtbl)->fn##xfn((ibase*)p,a,b,c,d,e,f,g)
#define ICOM_ICALL8(ibase, xfn, p,a,b,c,d,e,f,g,h) ((ICOM_VTABLE(ibase)*)(p)->lpvtbl)->fn##xfn((ibase*)p,a,b,c,d,e,f,g,h)
#define ICOM_CALL(xfn, p) (p)->lpvtbl->fn##xfn(p) #define ICOM_CALL(xfn, p) (p)->lpvtbl->fn##xfn(p)
#define ICOM_CALL1(xfn, p,a) (p)->lpvtbl->fn##xfn(p,a) #define ICOM_CALL1(xfn, p,a) (p)->lpvtbl->fn##xfn(p,a)
@ -586,6 +649,7 @@ BOOL32 WINAPI IsEqualGUID32(REFGUID rguid1,REFGUID rguid2);
#define ICOM_CALL5(xfn, p,a,b,c,d,e) (p)->lpvtbl->fn##xfn(p,a,b,c,d,e) #define ICOM_CALL5(xfn, p,a,b,c,d,e) (p)->lpvtbl->fn##xfn(p,a,b,c,d,e)
#define ICOM_CALL6(xfn, p,a,b,c,d,e,f) (p)->lpvtbl->fn##xfn(p,a,b,c,d,e,f) #define ICOM_CALL6(xfn, p,a,b,c,d,e,f) (p)->lpvtbl->fn##xfn(p,a,b,c,d,e,f)
#define ICOM_CALL7(xfn, p,a,b,c,d,e,f,g) (p)->lpvtbl->fn##xfn(p,a,b,c,d,e,f,g) #define ICOM_CALL7(xfn, p,a,b,c,d,e,f,g) (p)->lpvtbl->fn##xfn(p,a,b,c,d,e,f,g)
#define ICOM_CALL8(xfn, p,a,b,c,d,e,f,g,h) (p)->lpvtbl->fn##xfn(p,a,b,c,d,e,f,g,h)
#define ICOM_THIS(iface,me) struct _##iface* this=(struct _##iface*)me #define ICOM_THIS(iface,me) struct _##iface* this=(struct _##iface*)me
@ -614,32 +678,32 @@ typedef struct IUnknown IUnknown, *LPUNKNOWN;
* IUnknown interface * IUnknown interface
*/ */
#define ICOM_INTERFACE IUnknown #define ICOM_INTERFACE IUnknown
#if defined(__cplusplus) && !defined(CINTERFACE) #define IUnknown_IMETHODS \
ICOM_METHOD2(HRESULT,QueryInterface,REFIID,riid, LPVOID*,ppvObj); \
ICOM_METHOD (ULONG,AddRef); \
ICOM_METHOD (ULONG,Release);
#ifdef ICOM_CINTERFACE
typedef struct ICOM_VTABLE(IUnknown) ICOM_VTABLE(IUnknown);
struct IUnknown {
ICOM_VTABLE(IUnknown)* lpvtbl;
};
struct ICOM_VTABLE(IUnknown) {
ICOM_METHOD2(HRESULT,QueryInterface,REFIID,riid, LPVOID*,ppvObj);
#else
struct IUnknown { struct IUnknown {
union { union {
const void* lpvtbl; const void* lpvtbl;
HRESULT (CALLBACK *fnQueryInterface)(IUnknown* me, REFIID riid, LPVOID* ppvObj); HRESULT (CALLBACK *fnQueryInterface)(IUnknown* me, REFIID riid, LPVOID* ppvObj);
} t; } t;
inline int QueryInterface(REFIID a, LPVOID* b) { return ((IUnknown*)t.lpvtbl)->t.fnQueryInterface(this,a,b); } inline int QueryInterface(REFIID a, LPVOID* b) { return ((IUnknown*)t.lpvtbl)->t.fnQueryInterface(this,a,b); }
#else
typedef struct ICOM_VTABLE(IUnknown) ICOM_VTABLE(IUnknown);
struct IUnknown {
ICOM_VTABLE(IUnknown)* lpvtbl;
};
struct ICOM_VTABLE(IUnknown) {
ICOM_METHOD2(HRESULT,QueryInterface,REFIID,riid, LPVOID*,ppvObj)
#endif #endif
ICOM_METHOD (ULONG,AddRef) ICOM_METHOD (ULONG,AddRef);
ICOM_METHOD (ULONG,Release) ICOM_METHOD (ULONG,Release);
#ifdef __WRC__ };
}; /* FIXME: WRC does not support function macros and it is ICOM_END that is supposed to close the class */
#else
ICOM_END(IUnknown)
#endif
#undef ICOM_INTERFACE #undef ICOM_INTERFACE
#if !defined(__cplusplus) || defined(CINTERFACE) #ifdef ICOM_CINTERFACE
/*** IUnknown methods ***/ /*** IUnknown methods ***/
#define IUnknown_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b) #define IUnknown_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b)
#define IUnknown_AddRef(p) ICOM_CALL (AddRef,p) #define IUnknown_AddRef(p) ICOM_CALL (AddRef,p)
@ -651,17 +715,19 @@ ICOM_END(IUnknown)
* IClassFactory interface * IClassFactory interface
*/ */
#define ICOM_INTERFACE IClassFactory #define ICOM_INTERFACE IClassFactory
ICOM_BEGIN(IClassFactory,IUnknown) #define IClassFactory_METHODS \
ICOM_METHOD3(HRESULT,CreateInstance, LPUNKNOWN,pUnkOuter, REFIID,riid, LPVOID*,ppvObject); ICOM_METHOD3(HRESULT,CreateInstance, LPUNKNOWN,pUnkOuter, REFIID,riid, LPVOID*,ppvObject); \
ICOM_METHOD1(HRESULT,LockServer, BOOL32,fLock); ICOM_METHOD1(HRESULT,LockServer, BOOL32,fLock);
ICOM_END(IClassFactory) #define IClassFactory_IMETHODS \
ICOM_INHERITS(IClassFactory,IUnknown)
ICOM_DEFINE(IClassFactory,IUnknown)
#undef ICOM_INTERFACE #undef ICOM_INTERFACE
#if !defined(__cplusplus) || defined(CINTERFACE) #ifdef ICOM_CINTERFACE
/*** IUnknown methods ***/ /*** IUnknown methods ***/
#define IClassFactory_QueryInterface(p,a,b) ICOM_ICALL2(IUnknown,QueryInterface,p,a,b) #define IClassFactory_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b)
#define IClassFactory_AddRef(p) ICOM_ICALL (IUnknown,AddRef,p) #define IClassFactory_AddRef(p) ICOM_CALL (AddRef,p)
#define IClassFactory_Release(p) ICOM_ICALL (IUnknown,Release,p) #define IClassFactory_Release(p) ICOM_CALL (Release,p)
/*** IClassFactory methods ***/ /*** IClassFactory methods ***/
#define IClassFactory_CreateInstance(p,a,b,c) ICOM_CALL3(CreateInstance,p,a,b,c) #define IClassFactory_CreateInstance(p,a,b,c) ICOM_CALL3(CreateInstance,p,a,b,c)
#define IClassFactory_LockServer(p,a) ICOM_CALL1(LockServer,p,a) #define IClassFactory_LockServer(p,a) ICOM_CALL1(LockServer,p,a)
@ -672,21 +738,23 @@ ICOM_END(IClassFactory)
* IMalloc interface * IMalloc interface
*/ */
#define ICOM_INTERFACE IMalloc16 #define ICOM_INTERFACE IMalloc16
ICOM_BEGIN(IMalloc16,IUnknown) #define IMalloc16_METHODS \
ICOM_METHOD1 (LPVOID,Alloc, DWORD,cb); ICOM_METHOD1 (LPVOID,Alloc, DWORD,cb); \
ICOM_METHOD2 (LPVOID,Realloc, LPVOID,pv, DWORD,cb); ICOM_METHOD2 (LPVOID,Realloc, LPVOID,pv, DWORD,cb); \
ICOM_VMETHOD1( Free, LPVOID,pv); ICOM_VMETHOD1( Free, LPVOID,pv); \
ICOM_CMETHOD1(DWORD, GetSize, LPVOID,pv); ICOM_CMETHOD1(DWORD, GetSize, LPVOID,pv); \
ICOM_CMETHOD1(INT16, DidAlloc, LPVOID,pv); ICOM_CMETHOD1(INT16, DidAlloc, LPVOID,pv); \
ICOM_METHOD (LPVOID,HeapMinimize); ICOM_METHOD (LPVOID,HeapMinimize);
ICOM_END(IMalloc16) #define IMalloc16_IMETHODS \
ICOM_INHERITS(IMalloc16,IUnknown)
ICOM_DEFINE(IMalloc16,IUnknown)
#undef ICOM_INTERFACE #undef ICOM_INTERFACE
#if !defined(__cplusplus) || defined(CINTERFACE) #ifdef ICOM_CINTERFACE
/*** IUnknown methods ***/ /*** IUnknown methods ***/
#define IMalloc16_QueryInterface(p,a,b) ICOM_ICALL2(IUnknown,QueryInterface,p,a,b) #define IMalloc16_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b)
#define IMalloc16_AddRef(p) ICOM_ICALL (IUnknown,AddRef,p) #define IMalloc16_AddRef(p) ICOM_CALL (AddRef,p)
#define IMalloc16_Release(p) ICOM_ICALL (IUnknown,Release,p) #define IMalloc16_Release(p) ICOM_CALL (Release,p)
/*** IMalloc16 methods ***/ /*** IMalloc16 methods ***/
#define IMalloc16_Alloc(p,a) ICOM_CALL1(Alloc,p,a) #define IMalloc16_Alloc(p,a) ICOM_CALL1(Alloc,p,a)
#define IMalloc16_Realloc(p,a,b) ICOM_CALL2(Realloc,p,a,b) #define IMalloc16_Realloc(p,a,b) ICOM_CALL2(Realloc,p,a,b)
@ -698,21 +766,23 @@ ICOM_END(IMalloc16)
#define ICOM_INTERFACE IMalloc32 #define ICOM_INTERFACE IMalloc32
ICOM_BEGIN(IMalloc32,IUnknown) #define IMalloc32_METHODS \
ICOM_METHOD1 (LPVOID,Alloc, DWORD,cb); ICOM_METHOD1 (LPVOID,Alloc, DWORD,cb); \
ICOM_METHOD2 (LPVOID,Realloc, LPVOID,pv, DWORD,cb); ICOM_METHOD2 (LPVOID,Realloc, LPVOID,pv, DWORD,cb); \
ICOM_VMETHOD1( Free, LPVOID,pv); ICOM_VMETHOD1( Free, LPVOID,pv); \
ICOM_CMETHOD1(DWORD, GetSize, LPVOID,pv); ICOM_CMETHOD1(DWORD, GetSize, LPVOID,pv); \
ICOM_CMETHOD1(INT32, DidAlloc, LPVOID,pv); ICOM_CMETHOD1(INT32, DidAlloc, LPVOID,pv); \
ICOM_METHOD (LPVOID,HeapMinimize); ICOM_METHOD (LPVOID,HeapMinimize);
ICOM_END(IMalloc32) #define IMalloc32_IMETHODS \
ICOM_INHERITS(IMalloc32,IUnknown)
ICOM_DEFINE(IMalloc32,IUnknown)
#undef ICOM_INTERFACE #undef ICOM_INTERFACE
#if !defined(__cplusplus) || defined(CINTERFACE) #ifdef ICOM_CINTERFACE
/*** IUnknown methods ***/ /*** IUnknown methods ***/
#define IMalloc32_QueryInterface(p,a,b) ICOM_ICALL2(IUnknown,QueryInterface,p,a,b) #define IMalloc32_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b)
#define IMalloc32_AddRef(p) ICOM_ICALL (IUnknown,AddRef,p) #define IMalloc32_AddRef(p) ICOM_CALL (AddRef,p)
#define IMalloc32_Release(p) ICOM_ICALL (IUnknown,Release,p) #define IMalloc32_Release(p) ICOM_CALL (Release,p)
/*** IMalloc32 methods ***/ /*** IMalloc32 methods ***/
#define IMalloc32_Alloc(p,a) ICOM_CALL1(Alloc,p,a) #define IMalloc32_Alloc(p,a) ICOM_CALL1(Alloc,p,a)
#define IMalloc32_Realloc(p,a,b) ICOM_CALL2(Realloc,p,a,b) #define IMalloc32_Realloc(p,a,b) ICOM_CALL2(Realloc,p,a,b)
@ -724,9 +794,9 @@ ICOM_END(IMalloc32)
#ifndef __WINE__ #ifndef __WINE__
/* Duplicated for WINELIB */ /* Duplicated for WINELIB */
/*** IUnknown methods ***/ /*** IUnknown methods ***/
#define IMalloc_QueryInterface(p,a,b) ICOM_ICALL2(IUnknown,QueryInterface,p,a,b) #define IMalloc_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b)
#define IMalloc_AddRef(p) ICOM_ICALL (IUnknown,AddRef,p) #define IMalloc_AddRef(p) ICOM_CALL (AddRef,p)
#define IMalloc_Release(p) ICOM_ICALL (IUnknown,Release,p) #define IMalloc_Release(p) ICOM_CALL (Release,p)
/*** IMalloc methods ***/ /*** IMalloc methods ***/
#define IMalloc_Alloc(p,a) ICOM_CALL1(Alloc,p,a) #define IMalloc_Alloc(p,a) ICOM_CALL1(Alloc,p,a)
#define IMalloc_Realloc(p,a,b) ICOM_CALL2(Realloc,p,a,b) #define IMalloc_Realloc(p,a,b) ICOM_CALL2(Realloc,p,a,b)

View file

@ -2160,7 +2160,7 @@ HRESULT WINAPI DirectSoundCreate(LPGUID lpGUID,LPDIRECTSOUND *ppDS,IUnknown *pUn
* DirectSound ClassFactory * DirectSound ClassFactory
*/ */
static HRESULT WINAPI static HRESULT WINAPI
DSCF_QueryInterface(LPUNKNOWN iface,REFIID riid,LPVOID *ppobj) { DSCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
ICOM_THIS(IClassFactory,iface); ICOM_THIS(IClassFactory,iface);
char buf[80]; char buf[80];
@ -2173,12 +2173,12 @@ DSCF_QueryInterface(LPUNKNOWN iface,REFIID riid,LPVOID *ppobj) {
} }
static ULONG WINAPI static ULONG WINAPI
DSCF_AddRef(LPUNKNOWN iface) { DSCF_AddRef(LPCLASSFACTORY iface) {
ICOM_THIS(IClassFactory,iface); ICOM_THIS(IClassFactory,iface);
return ++(this->ref); return ++(this->ref);
} }
static ULONG WINAPI DSCF_Release(LPUNKNOWN iface) { static ULONG WINAPI DSCF_Release(LPCLASSFACTORY iface) {
ICOM_THIS(IClassFactory,iface); ICOM_THIS(IClassFactory,iface);
/* static class, won't be freed */ /* static class, won't be freed */
return --(this->ref); return --(this->ref);
@ -2206,11 +2206,9 @@ static HRESULT WINAPI DSCF_LockServer(LPCLASSFACTORY iface,BOOL32 dolock) {
} }
static ICOM_VTABLE(IClassFactory) DSCF_VTable = { static ICOM_VTABLE(IClassFactory) DSCF_VTable = {
{
DSCF_QueryInterface, DSCF_QueryInterface,
DSCF_AddRef, DSCF_AddRef,
DSCF_Release DSCF_Release,
},
DSCF_CreateInstance, DSCF_CreateInstance,
DSCF_LockServer DSCF_LockServer
}; };

View file

@ -689,7 +689,7 @@ HRESULT WINE_StringFromCLSID(
* the string representation and OLESTATUS * the string representation and OLESTATUS
*/ */
HRESULT WINAPI StringFromCLSID16( HRESULT WINAPI StringFromCLSID16(
const CLSID *id, /* [in] the GUID to be converted */ REFCLSID id, /* [in] the GUID to be converted */
LPOLESTR16 *idstr /* [out] a pointer to a to-be-allocated segmented pointer pointing to the resulting string */ LPOLESTR16 *idstr /* [out] a pointer to a to-be-allocated segmented pointer pointing to the resulting string */
) { ) {
@ -729,7 +729,7 @@ HRESULT WINAPI StringFromCLSID16(
* the string representation and OLESTATUS * the string representation and OLESTATUS
*/ */
HRESULT WINAPI StringFromCLSID32( HRESULT WINAPI StringFromCLSID32(
const CLSID *id, /* [in] the GUID to be converted */ REFCLSID id, /* [in] the GUID to be converted */
LPOLESTR32 *idstr /* [out] a pointer to a to-be-allocated pointer pointing to the resulting string */ LPOLESTR32 *idstr /* [out] a pointer to a to-be-allocated pointer pointing to the resulting string */
) { ) {
char buf[80]; char buf[80];

View file

@ -97,7 +97,7 @@ typedef struct _IMalloc16 {
/****************************************************************************** /******************************************************************************
* IMalloc16_QueryInterface [COMPOBJ.500] * IMalloc16_QueryInterface [COMPOBJ.500]
*/ */
HRESULT WINAPI IMalloc16_fnQueryInterface(LPUNKNOWN iface,REFIID refiid,LPVOID *obj) { HRESULT WINAPI IMalloc16_fnQueryInterface(IMalloc16* iface,REFIID refiid,LPVOID *obj) {
ICOM_THIS(IMalloc16,iface); ICOM_THIS(IMalloc16,iface);
char xrefiid[50]; char xrefiid[50];
@ -115,7 +115,7 @@ HRESULT WINAPI IMalloc16_fnQueryInterface(LPUNKNOWN iface,REFIID refiid,LPVOID *
/****************************************************************************** /******************************************************************************
* IMalloc16_AddRef [COMPOBJ.501] * IMalloc16_AddRef [COMPOBJ.501]
*/ */
ULONG WINAPI IMalloc16_fnAddRef(LPUNKNOWN iface) { ULONG WINAPI IMalloc16_fnAddRef(IMalloc16* iface) {
ICOM_THIS(IMalloc16,iface); ICOM_THIS(IMalloc16,iface);
TRACE(relay,"(%p)->AddRef()\n",this); TRACE(relay,"(%p)->AddRef()\n",this);
return 1; /* cannot be freed */ return 1; /* cannot be freed */
@ -124,7 +124,7 @@ ULONG WINAPI IMalloc16_fnAddRef(LPUNKNOWN iface) {
/****************************************************************************** /******************************************************************************
* IMalloc16_Release [COMPOBJ.502] * IMalloc16_Release [COMPOBJ.502]
*/ */
ULONG WINAPI IMalloc16_fnRelease(LPUNKNOWN iface) { ULONG WINAPI IMalloc16_fnRelease(IMalloc16* iface) {
ICOM_THIS(IMalloc16,iface); ICOM_THIS(IMalloc16,iface);
TRACE(relay,"(%p)->Release()\n",this); TRACE(relay,"(%p)->Release()\n",this);
return 1; /* cannot be freed */ return 1; /* cannot be freed */
@ -198,12 +198,10 @@ IMalloc16_Constructor() {
if (!msegvt16) { if (!msegvt16) {
this->lpvtbl = msegvt16 = SEGPTR_NEW(ICOM_VTABLE(IMalloc16)); this->lpvtbl = msegvt16 = SEGPTR_NEW(ICOM_VTABLE(IMalloc16));
#define VTENT(x) msegvt16->bvt.fn##x = (void*)WIN32_GetProcAddress16(hcomp,"IMalloc16_"#x);assert(msegvt16->bvt.fn##x) #define VTENT(x) msegvt16->fn##x = (void*)WIN32_GetProcAddress16(hcomp,"IMalloc16_"#x);assert(msegvt16->fn##x)
VTENT(QueryInterface); VTENT(QueryInterface);
VTENT(AddRef); VTENT(AddRef);
VTENT(Release); VTENT(Release);
#undef VTENT
#define VTENT(x) msegvt16->fn##x = (void*)WIN32_GetProcAddress16(hcomp,"IMalloc16_"#x);assert(msegvt16->fn##x)
VTENT(Alloc); VTENT(Alloc);
VTENT(Realloc); VTENT(Realloc);
VTENT(Free); VTENT(Free);
@ -232,7 +230,7 @@ typedef struct _IMalloc32 {
/****************************************************************************** /******************************************************************************
* IMalloc32_QueryInterface [VTABLE] * IMalloc32_QueryInterface [VTABLE]
*/ */
static HRESULT WINAPI IMalloc32_fnQueryInterface(LPUNKNOWN iface,REFIID refiid,LPVOID *obj) { static HRESULT WINAPI IMalloc32_fnQueryInterface(LPMALLOC32 iface,REFIID refiid,LPVOID *obj) {
ICOM_THIS(IMalloc32,iface); ICOM_THIS(IMalloc32,iface);
char xrefiid[50]; char xrefiid[50];
@ -250,7 +248,7 @@ static HRESULT WINAPI IMalloc32_fnQueryInterface(LPUNKNOWN iface,REFIID refiid,L
/****************************************************************************** /******************************************************************************
* IMalloc32_AddRef [VTABLE] * IMalloc32_AddRef [VTABLE]
*/ */
static ULONG WINAPI IMalloc32_fnAddRef(LPUNKNOWN iface) { static ULONG WINAPI IMalloc32_fnAddRef(LPMALLOC32 iface) {
ICOM_THIS(IMalloc32,iface); ICOM_THIS(IMalloc32,iface);
TRACE(relay,"(%p)->AddRef()\n",this); TRACE(relay,"(%p)->AddRef()\n",this);
return 1; /* cannot be freed */ return 1; /* cannot be freed */
@ -259,7 +257,7 @@ static ULONG WINAPI IMalloc32_fnAddRef(LPUNKNOWN iface) {
/****************************************************************************** /******************************************************************************
* IMalloc32_Release [VTABLE] * IMalloc32_Release [VTABLE]
*/ */
static ULONG WINAPI IMalloc32_fnRelease(LPUNKNOWN iface) { static ULONG WINAPI IMalloc32_fnRelease(LPMALLOC32 iface) {
ICOM_THIS(IMalloc32,iface); ICOM_THIS(IMalloc32,iface);
TRACE(relay,"(%p)->Release()\n",this); TRACE(relay,"(%p)->Release()\n",this);
return 1; /* cannot be freed */ return 1; /* cannot be freed */
@ -320,11 +318,9 @@ static LPVOID WINAPI IMalloc32_fnHeapMinimize(LPMALLOC32 iface) {
} }
static ICOM_VTABLE(IMalloc32) VT_IMalloc32 = { static ICOM_VTABLE(IMalloc32) VT_IMalloc32 = {
{
IMalloc32_fnQueryInterface, IMalloc32_fnQueryInterface,
IMalloc32_fnAddRef, IMalloc32_fnAddRef,
IMalloc32_fnRelease IMalloc32_fnRelease,
},
IMalloc32_fnAlloc, IMalloc32_fnAlloc,
IMalloc32_fnRealloc, IMalloc32_fnRealloc,
IMalloc32_fnFree, IMalloc32_fnFree,