Add ICOM_DEFINE1 macro to define a COM interface without a base

class.
Use it to define IUnknown.
This commit is contained in:
Ove Kaaven 2002-11-06 19:56:59 +00:00 committed by Alexandre Julliard
parent ca6bcdcc99
commit a2156ead18
1 changed files with 36 additions and 64 deletions

View File

@ -321,6 +321,12 @@ INT WINAPI StringFromGUID2(REFGUID id, LPOLESTR str, INT cmax);
#define ICOM_CINTERFACE 1 #define ICOM_CINTERFACE 1
#endif #endif
#ifdef ICOM_USE_COM_INTERFACE_ATTRIBUTE
#define ICOM_COM_INTERFACE_ATTRIBUTE __attribute__((com_interface))
#else
#define ICOM_COM_INTERFACE_ATTRIBUTE
#endif
#ifndef ICOM_CINTERFACE #ifndef ICOM_CINTERFACE
/* C++ interface */ /* C++ interface */
@ -436,21 +442,14 @@ INT WINAPI StringFromGUID2(REFGUID id, LPOLESTR str, INT cmax);
public: virtual void CALLBACK (xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i,tj j,tk k,tl l,tm m,tn n,to o,tp p,tq q,tr r,ts s,tt t,tu u,tv v,tw w,tx x,ty y,tz z) = 0; public: virtual void CALLBACK (xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i,tj j,tk k,tl l,tm m,tn n,to o,tp p,tq q,tr r,ts s,tt t,tu u,tv v,tw w,tx x,ty y,tz z) = 0;
#ifdef ICOM_USE_COM_INTERFACE_ATTRIBUTE
#define ICOM_DEFINE(iface,ibase) \ #define ICOM_DEFINE(iface,ibase) \
struct iface: public ibase { \ struct iface: public ibase { \
iface##_METHODS \ iface##_METHODS \
} __attribute__ ((com_interface)); } ICOM_COM_INTERFACE_ATTRIBUTE;
#define ICOM_DEFINE1(iface) \
#else struct iface { \
#define ICOM_DEFINE(iface,ibase) \
struct iface: public ibase { \
iface##_METHODS \ iface##_METHODS \
}; } ICOM_COM_INTERFACE_ATTRIBUTE;
#endif /* ICOM_USE_COM_INTERFACE_ATTRIBUTE */
#define ICOM_VTBL(iface) (iface) #define ICOM_VTBL(iface) (iface)
@ -573,32 +572,34 @@ INT WINAPI StringFromGUID2(REFGUID id, LPOLESTR str, INT cmax);
#define ICOM_VTBL(iface) (iface)->lpVtbl #define ICOM_VTBL(iface) (iface)->lpVtbl
#ifdef ICOM_MSVTABLE_COMPAT #ifdef ICOM_MSVTABLE_COMPAT
#define ICOM_DEFINE(iface,ibase) \ #define ICOM_MSVTABLE_COMPAT_FIELDS \
typedef struct ICOM_VTABLE(iface) ICOM_VTABLE(iface); \
struct iface { \
const ICOM_VFIELD(iface); \
}; \
struct ICOM_VTABLE(iface) { \
long dummyRTTI1; \ long dummyRTTI1; \
long dummyRTTI2; \ long dummyRTTI2;
ibase##_IMETHODS \
iface##_METHODS \
};
#define ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE 0,0, #define ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE 0,0,
#else #else
#define ICOM_DEFINE(iface,ibase) \ #define ICOM_MSVTABLE_COMPAT_FIELDS
typedef struct ICOM_VTABLE(iface) ICOM_VTABLE(iface); \
struct iface { \
const ICOM_VFIELD(iface); \
}; \
struct ICOM_VTABLE(iface) { \
ibase##_IMETHODS \
iface##_METHODS \
};
#define ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE #define ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
#endif /* ICOM_MSVTABLE_COMPAT */ #endif /* ICOM_MSVTABLE_COMPAT */
#define ICOM_DEFINE(iface,ibase) \
typedef struct ICOM_VTABLE(iface) ICOM_VTABLE(iface); \
struct iface { \
const ICOM_VFIELD(iface); \
}; \
struct ICOM_VTABLE(iface) { \
ICOM_MSVTABLE_COMPAT_FIELDS \
ibase##_IMETHODS \
iface##_METHODS \
};
#define ICOM_DEFINE1(iface) \
typedef struct ICOM_VTABLE(iface) ICOM_VTABLE(iface); \
struct iface { \
const ICOM_VFIELD(iface); \
}; \
struct ICOM_VTABLE(iface) { \
ICOM_MSVTABLE_COMPAT_FIELDS \
iface##_METHODS \
};
#define ICOM_THIS(impl,iface) impl* const This=(impl*)(iface) #define ICOM_THIS(impl,iface) impl* const This=(impl*)(iface)
#define ICOM_CTHIS(impl,iface) const impl* const This=(const impl*)(iface) #define ICOM_CTHIS(impl,iface) const impl* const This=(const impl*)(iface)
@ -654,42 +655,13 @@ typedef struct IUnknown IUnknown, *LPUNKNOWN;
* IUnknown interface * IUnknown interface
*/ */
#define ICOM_INTERFACE IUnknown #define ICOM_INTERFACE IUnknown
#define IUnknown_IMETHODS \ #define IUnknown_METHODS \
ICOM_METHOD2(HRESULT,QueryInterface,REFIID,riid, LPVOID*,ppvObj) \ ICOM_METHOD2(HRESULT,QueryInterface,REFIID,riid, LPVOID*,ppvObj) \
ICOM_METHOD (ULONG,AddRef) \ ICOM_METHOD (ULONG,AddRef) \
ICOM_METHOD (ULONG,Release) ICOM_METHOD (ULONG,Release)
#ifdef ICOM_CINTERFACE #define IUnknown_IMETHODS \
typedef struct ICOM_VTABLE(IUnknown) ICOM_VTABLE(IUnknown); IUnknown_METHODS
struct IUnknown { ICOM_DEFINE1(IUnknown)
ICOM_VFIELD(IUnknown);
}
#if defined(ICOM_USE_COM_INTERFACE_ATTRIBUTE)
__attribute__ ((com_interface));
#else
;
#endif /* ICOM_US_COM_INTERFACE_ATTRIBUTE */
struct ICOM_VTABLE(IUnknown) {
#ifdef ICOM_MSVTABLE_COMPAT
long dummyRTTI1;
long dummyRTTI2;
#endif /* ICOM_MSVTABLE_COMPAT */
#else /* ICOM_CINTERFACE */
struct IUnknown {
#endif /* ICOM_CINTERFACE */
ICOM_METHOD2(HRESULT,QueryInterface,REFIID,riid, LPVOID*,ppvObj)
ICOM_METHOD (ULONG,AddRef)
ICOM_METHOD (ULONG,Release)
}
#if defined(ICOM_USE_COM_INTERFACE_ATTRIBUTE)
__attribute__ ((com_interface));
#else
;
#endif /* ICOM_US_COM_INTERFACE_ATTRIBUTE */
#undef ICOM_INTERFACE #undef ICOM_INTERFACE
/*** IUnknown methods ***/ /*** IUnknown methods ***/