2 * This file defines the macros and types necessary to define COM interfaces,
3 * and the three most basic COM interfaces: IUnknown, IMalloc and IClassFactory.
6 #ifndef __WINE_WINE_OBJ_BASE_H
7 #define __WINE_WINE_OBJ_BASE_H
10 /*****************************************************************************
11 * Defines the basic types
16 /*****************************************************************************
17 * Macros to declare the GUIDs
20 #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
22 { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }
24 #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
25 extern const GUID name
28 #define DEFINE_OLEGUID(name, l, w1, w2) \
29 DEFINE_GUID(name, l, w1, w2, 0xC0,0,0,0,0,0,0,0x46)
31 #define DEFINE_SHLGUID(name, l, w1, w2) DEFINE_OLEGUID(name,l,w1,w2)
34 /*****************************************************************************
37 HRESULT WINAPI StringFromCLSID16(REFCLSID id, LPOLESTR16*);
38 HRESULT WINAPI StringFromCLSID(REFCLSID id, LPOLESTR*);
40 HRESULT WINAPI CLSIDFromString16(LPCOLESTR16, CLSID *);
41 HRESULT WINAPI CLSIDFromString(LPCOLESTR, CLSID *);
43 HRESULT WINAPI CLSIDFromProgID16(LPCOLESTR16 progid, LPCLSID riid);
44 HRESULT WINAPI CLSIDFromProgID(LPCOLESTR progid, LPCLSID riid);
46 INT WINAPI StringFromGUID2(REFGUID id, LPOLESTR str, INT cmax);
48 BOOL16 WINAPI IsEqualGUID16(GUID* g1,GUID* g2);
49 BOOL WINAPI IsEqualGUID32(REFGUID rguid1,REFGUID rguid2);
50 /*#define IsEqualGUID WINELIB_NAME(IsEqualGUID)*/
52 #define IsEqualGUID(rguid1, rguid2) (!memcmp(&(rguid1), &(rguid2), sizeof(GUID)))
54 #define IsEqualGUID(rguid1, rguid2) (!memcmp(rguid1, rguid2, sizeof(GUID)))
55 #endif /* cplusplus */
56 #define IsEqualIID(riid1, riid2) IsEqualGUID(riid1, riid2)
57 #define IsEqualCLSID(rclsid1, rclsid2) IsEqualGUID(rclsid1, rclsid2)
60 inline BOOL operator==(const GUID& guidOne, const GUID& guidOther)
62 return !memcmp(&guidOne,&guidOther,sizeof(GUID));
64 inline BOOL operator!=(const GUID& guidOne, const GUID& guidOther)
66 return !(guidOne == guidOther);
71 /*****************************************************************************
72 * Macros to define a COM interface
75 * The goal of the following set of definitions is to provide a way to use the same
76 * header file definitions to provide both a C interface and a C++ object oriented
77 * interface to COM interfaces. The type of interface is selected automatically
78 * depending on the language but it is always possible to get the C interface in C++
79 * by defining CINTERFACE.
81 * It is based on the following assumptions:
82 * - all COM interfaces derive from IUnknown, this should not be a problem.
83 * - the header file only defines the interface, the actual fields are defined
84 * separately in the C file implementing the interface.
86 * The natural approach to this problem would be to make sure we get a C++ class and
87 * virtual methods in C++ and a structure with a table of pointer to functions in C.
88 * Unfortunately the layout of the virtual table is compiler specific, the layout of
89 * g++ virtual tables is not the same as that of an egcs virtual table which is not the
90 * same as that generated by Visual C+. There are workarounds to make the virtual tables
91 * compatible via padding but unfortunately the one which is imposed to the WINE emulator
92 * by the Windows binaries, i.e. the Visual C++ one, is the most compact of all.
94 * So the solution I finally adopted does not use virtual tables. Instead I use inline
95 * non virtual methods that dereference the method pointer themselves and perform the call.
97 * Let's take Direct3D as an example:
99 * #define ICOM_INTERFACE IDirect3D
100 * #define IDirect3D_METHODS \
101 * ICOM_METHOD1(HRESULT,Initialize, REFIID,); \
102 * ICOM_METHOD2(HRESULT,EnumDevices, LPD3DENUMDEVICESCALLBACK,, LPVOID,); \
103 * ICOM_METHOD2(HRESULT,CreateLight, LPDIRECT3DLIGHT*,, IUnknown*,); \
104 * ICOM_METHOD2(HRESULT,CreateMaterial,LPDIRECT3DMATERIAL*,, IUnknown*,); \
105 * ICOM_METHOD2(HRESULT,CreateViewport,LPDIRECT3DVIEWPORT*,, IUnknown*,); \
106 * ICOM_METHOD2(HRESULT,FindDevice, LPD3DFINDDEVICESEARCH,, LPD3DFINDDEVICERESULT,);
107 * #define IDirect3D_IMETHODS \
108 * IUnknown_IMETHODS \
110 * ICOM_DEFINE(IDirect3D,IUnknown)
111 * #undef ICOM_INTERFACE
113 * #ifdef ICOM_CINTERFACE
114 * // *** IUnknown methods *** //
115 * #define IDirect3D_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b)
116 * #define IDirect3D_AddRef(p) ICOM_CALL (AddRef,p)
117 * #define IDirect3D_Release(p) ICOM_CALL (Release,p)
118 * // *** IDirect3D methods *** //
119 * #define IDirect3D_Initialize(p,a) ICOM_CALL1(Initialize,p,a)
120 * #define IDirect3D_EnumDevices(p,a,b) ICOM_CALL2(EnumDevice,p,a,b)
121 * #define IDirect3D_CreateLight(p,a,b) ICOM_CALL2(CreateLight,p,a,b)
122 * #define IDirect3D_CreateMaterial(p,a,b) ICOM_CALL2(CreateMaterial,p,a,b)
123 * #define IDirect3D_CreateViewport(p,a,b) ICOM_CALL2(CreateViewport,p,a,b)
124 * #define IDirect3D_FindDevice(p,a,b) ICOM_CALL2(FindDevice,p,a,b)
128 * - The ICOM_INTERFACE macro is used in the ICOM_METHOD macros to define the type of the 'this'
129 * pointer. Defining this macro here saves us the trouble of having to repeat the interface
130 * name everywhere. Note however that because of the way macros work, a macro like ICOM_METHOD1
131 * cannot use 'ICOM_INTERFACE##_VTABLE' because this would give 'ICOM_INTERFACE_VTABLE' and not
132 * 'IDirect3D_VTABLE'.
133 * - ICOM_METHODS defines the methods specific to this interface. It is then aggregated with the
134 * inherited methods to form ICOM_IMETHODS.
135 * - ICOM_IMETHODS defines the list of methods that are inheritable from this interface. It must
136 * be written manually (rather than using a macro to generate the equivalent code) to avoid
137 * macro recursion (which compilers don't like).
138 * - The ICOM_DEFINE finally declares all the structures necessary for the interface. We have to
139 * explicitly use the interface name for macro expansion reasons again.
140 * Inherited methods are inherited in C by using the IDirect3D_METHODS macro and the parent's
141 * Xxx_IMETHODS macro. In C++ we need only use the IDirect3D_METHODS since method inheritance
142 * is taken care of by the language.
143 * - In C++ the ICOM_METHOD macros generate a function prototype and a call to a function pointer
144 * method. This means using once 't1 p1, t2 p2, ...' and once 'p1, p2' without the types. The
145 * only way I found to handle this is to have one ICOM_METHOD macro per number of parameters and
146 * to have it take only the type information (with const if necessary) as parameters.
147 * The 'undef ICOM_INTERFACE' is here to remind you that using ICOM_INTERFACE in the following
148 * macros will not work. This time it's because the ICOM_CALL macro expansion is done only once
149 * the 'IDirect3D_Xxx' macro is expanded. And by that time ICOM_INTERFACE will be long gone
151 * - You may have noticed the double commas after each parameter type. This allows you to put the
152 * name of that parameter which I think is good for documentation. It is not required and since
153 * I did not know what to put there for this example (I could only find doc about IDirect3D2),
155 * - Finally the set of 'IDirect3D_Xxx' macros is a standard set of macros defined to ease access
156 * to the interface methods in C. Unfortunately I don't see any way to avoid having to duplicate
157 * the inherited method definitions there. This time I could have used a trick to use only one
158 * macro whatever the number of parameters but I prefered to have it work the same way as above.
159 * - You probably have noticed that we don't define the fields we need to actually implement this
160 * interface: reference count, pointer to other resources and miscellaneous fields. That's
161 * because these interfaces are just that: interfaces. They may be implemented more than once, in
162 * different contexts and sometimes not even in Wine. Thus it would not make sense to impose
163 * that the interface contains some specific fields.
167 * typedef struct IDirect3DVtbl IDirect3DVtbl;
169 * IDirect3DVtbl* lpvtbl;
171 * struct IDirect3DVtbl {
172 * HRESULT (*fnQueryInterface)(IDirect3D* me, REFIID riid, LPVOID* ppvObj);
173 * ULONG (*fnQueryInterface)(IDirect3D* me);
174 * ULONG (*fnQueryInterface)(IDirect3D* me);
175 * HRESULT (*fnInitialize)(IDirect3D* me, REFIID a);
176 * HRESULT (*fnEnumDevices)(IDirect3D* me, LPD3DENUMDEVICESCALLBACK a, LPVOID b);
177 * HRESULT (*fnCreateLight)(IDirect3D* me, LPDIRECT3DLIGHT* a, IUnknown* b);
178 * HRESULT (*fnCreateMaterial)(IDirect3D* me, LPDIRECT3DMATERIAL* a, IUnknown* b);
179 * HRESULT (*fnCreateViewport)(IDirect3D* me, LPDIRECT3DVIEWPORT* a, IUnknown* b);
180 * HRESULT (*fnFindDevice)(IDirect3D* me, LPD3DFINDDEVICESEARCH a, LPD3DFINDDEVICERESULT b);
183 * #ifdef ICOM_CINTERFACE
184 * // *** IUnknown methods *** //
185 * #define IDirect3D_QueryInterface(p,a,b) (p)->lpvtbl->fnQueryInterface(p,a,b)
186 * #define IDirect3D_AddRef(p) (p)->lpvtbl->fnAddRef(p)
187 * #define IDirect3D_Release(p) (p)->lpvtbl->fnRelease(p)
188 * // *** IDirect3D methods *** //
189 * #define IDirect3D_Initialize(p,a) (p)->lpvtbl->fnInitialize(p,a)
190 * #define IDirect3D_EnumDevices(p,a,b) (p)->lpvtbl->fnEnumDevice(p,a,b)
191 * #define IDirect3D_CreateLight(p,a,b) (p)->lpvtbl->fnCreateLight(p,a,b)
192 * #define IDirect3D_CreateMaterial(p,a,b) (p)->lpvtbl->fnCreateMaterial(p,a,b)
193 * #define IDirect3D_CreateViewport(p,a,b) (p)->lpvtbl->fnCreateViewport(p,a,b)
194 * #define IDirect3D_FindDevice(p,a,b) (p)->lpvtbl->fnFindDevice(p,a,b)
198 * - IDirect3D only contains a pointer to the IDirect3D virtual/jump table. This is the only thing
199 * the user needs to know to use the interface. Of course the structure we will define to
200 * implement this interface will have more fields but the first one will match this pointer.
201 * - The code generated by ICOM_DEFINE defines both the structure representing the interface and
202 * the structure for the jump table. ICOM_DEFINE uses the parent's Xxx_IMETHODS macro to
203 * automatically repeat the prototypes of all the inherited methods and then uses IDirect3D_METHODS
204 * to define the IDirect3D methods.
205 * - Each method is declared as a pointer to function field in the jump table. The implementation
206 * will fill this jump table with appropriate values, probably using a static variable, and
207 * initialize the lpvtbl field to point to this variable.
208 * - The IDirect3D_Xxx macros then just derefence the lpvtbl pointer and use the function pointer
209 * corresponding to the macro name. This emulates the behavior of a virtual table and should be
211 * - This C code should be quite compatible with the Windows headers both for code that uses COM
212 * interfaces and for code implementing a COM interface.
215 * And in C++ (with gcc's g++):
217 * typedef struct IDirect3D: public IUnknown {
218 * private: HRESULT (*fnInitialize)(IDirect3D* me, REFIID a);
219 * public: inline HRESULT Initialize(REFIID a) { return ((IDirect3D*)t.lpvtbl)->fnInitialize(this,a); };
220 * private: HRESULT (*fnEnumDevices)(IDirect3D* me, LPD3DENUMDEVICESCALLBACK a, LPVOID b);
221 * public: inline HRESULT EnumDevices(LPD3DENUMDEVICESCALLBACK a, LPVOID b)
222 * { return ((IDirect3D*)t.lpvtbl)->fnEnumDevices(this,a,b); };
223 * private: HRESULT (*fnCreateLight)(IDirect3D* me, LPDIRECT3DLIGHT* a, IUnknown* b);
224 * public: inline HRESULT CreateLight(LPDIRECT3DLIGHT* a, IUnknown* b)
225 * { return ((IDirect3D*)t.lpvtbl)->fnCreateLight(this,a,b); };
226 * private: HRESULT (*fnCreateMaterial)(IDirect3D* me, LPDIRECT3DMATERIAL* a, IUnknown* b);
227 * public: inline HRESULT CreateMaterial(LPDIRECT3DMATERIAL* a, IUnknown* b)
228 * { return ((IDirect3D*)t.lpvtbl)->fnCreateMaterial(this,a,b); };
229 * private: HRESULT (*fnCreateViewport)(IDirect3D* me, LPDIRECT3DVIEWPORT* a, IUnknown* b);
230 * public: inline HRESULT CreateViewport(LPDIRECT3DVIEWPORT* a, IUnknown* b)
231 * { return ((IDirect3D*)t.lpvtbl)->fnCreateViewport(this,a,b); };
232 * private: HRESULT (*fnFindDevice)(IDirect3D* me, LPD3DFINDDEVICESEARCH a, LPD3DFINDDEVICERESULT b);
233 * public: inline HRESULT FindDevice(LPD3DFINDDEVICESEARCH a, LPD3DFINDDEVICERESULT b)
234 * { return ((IDirect3D*)t.lpvtbl)->fnFindDevice(this,a,b); };
238 * - In C++ IDirect3D does double duty as both the virtual/jump table and as the interface
239 * definition. The reason for this is to avoid having to duplicate the mehod definitions: once
240 * to have the function pointers in the jump table and once to have the methods in the interface
241 * class. Here one macro can generate both. This means though that the first pointer, t.lpvtbl
242 * defined in IUnknown, must be interpreted as the jump table pointer if we interpret the
243 * structure as the the interface class, and as the function pointer to the QueryInterface
244 * method, t.fnQueryInterface, if we interpret the structure as the jump table. Fortunately this
245 * gymnastic is entirely taken care of in the header of IUnknown.
246 * - Of course in C++ we use inheritance so that we don't have to duplicate the method definitions.
247 * - Since IDirect3D does double duty, each ICOM_METHOD macro defines both a function pointer and
248 * a non-vritual inline method which dereferences it and calls it. This way this method behaves
249 * just like a virtual method but does not create a true C++ virtual table which would break the
250 * structure layout. If you look at the implementation of these methods you'll notice that they
251 * would not work for void functions. We have to return something and fortunately this seems to
252 * be what all the COM methods do (otherwise we would need another set of macros).
253 * - Note how the ICOM_METHOD generates both function prototypes mixing types and formal parameter
254 * names and the method invocation using only the formal parameter name. This is the reason why
255 * we need different macros to handle different numbers of parameters.
256 * - Finally there is no IDirect3D_Xxx macro. These are not needed in C++ unless the CINTERFACE
257 * macro is defined in which case we would not be here.
258 * - This C++ code works well for code that just uses COM interfaces. But it will not work with
259 * C++ code implement a COM interface. That's because such code assumes the interface methods
260 * are declared as virtual C++ methods which is not the case here.
263 * Implementing a COM interface.
265 * This continues the above example. This example assumes that the implementation is in C.
267 * typedef struct _IDirect3D {
273 * static ICOM_VTABLE(IDirect3D) d3dvt;
275 * // implement the IDirect3D methods here
277 * int IDirect3D_fnQueryInterface(IDirect3D* me)
279 * ICOM_THIS(IDirect3D,me);
285 * static ICOM_VTABLE(IDirect3D) d3dvt = {
286 * IDirect3D_fnQueryInterface,
289 * IDirect3D_fnInitialize,
290 * IDirect3D_fnSetWidth
294 * - We first define what the interface really contains. This is th e_IDirect3D structure. The
295 * first field must of course be the virtual table pointer. Everything else is free.
296 * - Then we predeclare our static virtual table variable, we will need its address in some
297 * methods to initialize the virtual table pointer of the returned interface objects.
298 * - Then we implement the interface methods. To match what has been declared in the header file
299 * they must take a pointer to a IDirect3D structure and we must cast it to an _IDirect3D so that
300 * we can manipulate the fields. This is performed by the ICOM_THIS macro.
301 * - Finally we initialize the virtual table.
305 #define ICOM_VTABLE(iface) iface##Vtbl
308 #if !defined(__cplusplus) || defined(CINTERFACE)
309 #define ICOM_CINTERFACE 1
312 #ifndef ICOM_CINTERFACE
315 #define ICOM_METHOD(ret,xfn) \
316 private: ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me); \
317 public: inline ret (CALLBACK xfn)(void) { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this); };
319 #define ICOM_METHOD1(ret,xfn,ta,na) \
320 private: ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a); \
321 public: inline ret (CALLBACK xfn)(ta a) { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a); };
323 #define ICOM_METHOD2(ret,xfn,ta,na,tb,nb) \
324 private: ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b); \
325 public: inline ret (CALLBACK xfn)(ta a,tb b) { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b); };
327 #define ICOM_METHOD3(ret,xfn,ta,na,tb,nb,tc,nc) \
328 private: ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c); \
329 public: inline ret (CALLBACK xfn)(ta a,tb b,tc c) { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c); };
331 #define ICOM_METHOD4(ret,xfn,ta,na,tb,nb,tc,nc,td,nd) \
332 private: ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d); \
333 public: inline ret (CALLBACK xfn)(ta a,tb b,tc c,td d) { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c,d); };
335 #define ICOM_METHOD5(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne) \
336 private: ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e); \
337 public: inline ret (CALLBACK xfn)(ta a,tb b,tc c,td d,te e) { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c,d,e); };
339 #define ICOM_METHOD6(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf) \
340 private: ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f); \
341 public: inline ret (CALLBACK xfn)(ta a,tb b,tc c,td d,te e,tf f) { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c,d,e,f); };
343 #define ICOM_METHOD7(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \
344 private: ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g); \
345 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); };
347 #define ICOM_METHOD8(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh) \
348 private: ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h); \
349 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); };
351 #define ICOM_METHOD9(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni) \
352 private: ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i); \
353 public: inline ret (CALLBACK xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i) { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c,d,e,f,g,h,i); };
355 #define ICOM_METHOD10(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj) \
356 private: ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i,tj j); \
357 public: inline ret (CALLBACK xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i,tj j) { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c,d,e,f,g,h,i,j); };
360 #define ICOM_CMETHOD(ret,xfn) \
361 private: ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me); \
362 public: inline ret (CALLBACK xfn)(void) const { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this); };
364 #define ICOM_CMETHOD1(ret,xfn,ta,na) \
365 private: ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a); \
366 public: inline ret (CALLBACK xfn)(ta a) const { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a); };
368 #define ICOM_CMETHOD2(ret,xfn,ta,na,tb,nb) \
369 private: ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b); \
370 public: inline ret (CALLBACK xfn)(ta a,tb b) const { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b); };
372 #define ICOM_CMETHOD3(ret,xfn,ta,na,tb,nb,tc,nc) \
373 private: ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c); \
374 public: inline ret (CALLBACK xfn)(ta a,tb b,tc c) const { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c); };
376 #define ICOM_CMETHOD4(ret,xfn,ta,na,tb,nb,tc,nc,td,nd) \
377 private: ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d); \
378 public: inline ret (CALLBACK xfn)(ta a,tb b,tc c,td d) const { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c,d); };
380 #define ICOM_CMETHOD5(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne) \
381 private: ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e); \
382 public: inline ret (CALLBACK xfn)(ta a,tb b,tc c,td d,te e) const { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c,d,e); };
384 #define ICOM_CMETHOD6(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf) \
385 private: ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f); \
386 public: inline ret (CALLBACK xfn)(ta a,tb b,tc c,td d,te e,tf f) const { return ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c,d,e,f); };
388 #define ICOM_CMETHOD7(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \
389 private: ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g); \
390 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); };
392 #define ICOM_CMETHOD8(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh) \
393 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); \
394 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); };
397 #define ICOM_VMETHOD(xfn) \
398 private: void (CALLBACK *fn##xfn)(ICOM_INTERFACE* me); \
399 public: inline void (CALLBACK xfn)(void) { ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this); };
401 #define ICOM_VMETHOD1(xfn,ta,na) \
402 private: void (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a); \
403 public: inline void (CALLBACK xfn)(ta a) { ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a); };
405 #define ICOM_VMETHOD2(xfn,ta,na,tb,nb) \
406 private: void (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b); \
407 public: inline void (CALLBACK xfn)(ta a,tb b) { ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b); };
409 #define ICOM_VMETHOD3(xfn,ta,na,tb,nb,tc,nc) \
410 private: void (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c); \
411 public: inline void (CALLBACK xfn)(ta a,tb b,tc c) { ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c); };
413 #define ICOM_VMETHOD4(xfn,ta,na,tb,nb,tc,nc,td,nd) \
414 private: void (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d); \
415 public: inline void (CALLBACK xfn)(ta a,tb b,tc c,td d) { ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c,d); };
417 #define ICOM_VMETHOD5(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne) \
418 private: void (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e); \
419 public: inline void (CALLBACK xfn)(ta a,tb b,tc c,td d,te e) { ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c,d,e); };
421 #define ICOM_VMETHOD6(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf) \
422 private: void (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f); \
423 public: inline void (CALLBACK xfn)(ta a,tb b,tc c,td d,te e,tf f) { ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c,d,e,f); };
425 #define ICOM_VMETHOD7(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \
426 private: void (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g); \
427 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); };
429 #define ICOM_VMETHOD8(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh) \
430 private: void (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h); \
431 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); };
434 #define ICOM_CVMETHOD(xfn) \
435 private: void (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me); \
436 public: inline void (CALLBACK xfn)(void) const { ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this); };
438 #define ICOM_CVMETHOD1(xfn,ta,na) \
439 private: void (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a); \
440 public: inline void (CALLBACK xfn)(ta a) const { ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a); };
442 #define ICOM_CVMETHOD2(xfn,ta,na,tb,nb) \
443 private: void (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b); \
444 public: inline void (CALLBACK xfn)(ta a,tb b) const { ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b); };
446 #define ICOM_CVMETHOD3(xfn,ta,na,tb,nb,tc,nc) \
447 private: void (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c); \
448 public: inline void (CALLBACK xfn)(ta a,tb b,tc c) const { ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c); };
450 #define ICOM_CVMETHOD4(xfn,ta,na,tb,nb,tc,nc,td,nd) \
451 private: void (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d); \
452 public: inline void (CALLBACK xfn)(ta a,tb b,tc c,td d) const { ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c,d); };
454 #define ICOM_CVMETHOD5(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne) \
455 private: void (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e); \
456 public: inline void (CALLBACK xfn)(ta a,tb b,tc c,td d,te e) const { ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c,d,e); };
458 #define ICOM_CVMETHOD6(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf) \
459 private: void (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f); \
460 public: inline void (CALLBACK xfn)(ta a,tb b,tc c,td d,te e,tf f) const { ((ICOM_INTERFACE*)t.lpvtbl)->fn##xfn(this,a,b,c,d,e,f); };
462 #define ICOM_CVMETHOD7(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \
463 private: void (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g); \
464 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); };
466 #define ICOM_CVMETHOD8(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh) \
467 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); \
468 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); };
471 #define ICOM_DEFINE(iface,ibase) \
472 typedef struct iface: public ibase { \
476 #define ICOM_CALL(xfn, p) this_is_a_syntax_error
477 #define ICOM_CALL1(xfn, p,a) this_is_a_syntax_error
478 #define ICOM_CALL2(xfn, p,a,b) this_is_a_syntax_error
479 #define ICOM_CALL3(xfn, p,a,b,c) this_is_a_syntax_error
480 #define ICOM_CALL4(xfn, p,a,b,c,d) this_is_a_syntax_error
481 #define ICOM_CALL5(xfn, p,a,b,c,d,e) this_is_a_syntax_error
482 #define ICOM_CALL6(xfn, p,a,b,c,d,e,f) this_is_a_syntax_error
483 #define ICOM_CALL7(xfn, p,a,b,c,d,e,f,g) this_is_a_syntax_error
484 #define ICOM_CALL8(xfn, p,a,b,c,d,e,f,g,h) this_is_a_syntax_error
491 #define ICOM_METHOD(ret,xfn) \
492 ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me);
494 #define ICOM_METHOD1(ret,xfn,ta,na) \
495 ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a);
497 #define ICOM_METHOD2(ret,xfn,ta,na,tb,nb) \
498 ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b);
500 #define ICOM_METHOD3(ret,xfn,ta,na,tb,nb,tc,nc) \
501 ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c);
503 #define ICOM_METHOD4(ret,xfn,ta,na,tb,nb,tc,nc,td,nd) \
504 ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d);
506 #define ICOM_METHOD5(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne) \
507 ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e);
509 #define ICOM_METHOD6(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf) \
510 ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f);
512 #define ICOM_METHOD7(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \
513 ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g);
515 #define ICOM_METHOD8(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh) \
516 ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h);
518 #define ICOM_METHOD9(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni) \
519 ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i);
521 #define ICOM_METHOD10(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj) \
522 ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i,tj j);
525 #define ICOM_CMETHOD(ret,xfn) \
526 ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me);
528 #define ICOM_CMETHOD1(ret,xfn,ta,na) \
529 ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a);
531 #define ICOM_CMETHOD2(ret,xfn,ta,na,tb,nb) \
532 ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b);
534 #define ICOM_CMETHOD3(ret,xfn,ta,na,tb,nb,tc,nc) \
535 ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c);
537 #define ICOM_CMETHOD4(ret,xfn,ta,na,tb,nb,tc,nc,td,nd) \
538 ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d);
540 #define ICOM_CMETHOD5(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne) \
541 ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e);
543 #define ICOM_CMETHOD6(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf) \
544 ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f);
546 #define ICOM_CMETHOD7(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \
547 ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g);
549 #define ICOM_CMETHOD8(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh) \
550 ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h);
553 #define ICOM_VMETHOD(xfn) \
554 void (CALLBACK *fn##xfn)(ICOM_INTERFACE* me);
556 #define ICOM_VMETHOD1(xfn,ta,na) \
557 void (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a);
559 #define ICOM_VMETHOD2(xfn,ta,na,tb,nb) \
560 void (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b);
562 #define ICOM_VMETHOD3(xfn,ta,na,tb,nb,tc,nc) \
563 void (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c);
565 #define ICOM_VMETHOD4(xfn,ta,na,tb,nb,tc,nc,td,nd) \
566 void (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d);
568 #define ICOM_VMETHOD5(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne) \
569 void (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e);
571 #define ICOM_VMETHOD6(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf) \
572 void (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f);
574 #define ICOM_VMETHOD7(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \
575 void (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g);
577 #define ICOM_VMETHOD8(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,nh) \
578 void (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h);
581 #define ICOM_CVMETHOD(xfn) \
582 void (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me);
584 #define ICOM_CVMETHOD1(xfn,ta,na) \
585 void (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a);
587 #define ICOM_CVMETHOD2(xfn,ta,na,tb,nb) \
588 void (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b);
590 #define ICOM_CVMETHOD3(xfn,ta,na,tb,nb,tc,nc) \
591 void (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c);
593 #define ICOM_CVMETHOD4(xfn,ta,na,tb,nb,tc,nc,td,nd) \
594 void (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d);
596 #define ICOM_CVMETHOD5(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne) \
597 void (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e);
599 #define ICOM_CVMETHOD6(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf) \
600 void (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f);
602 #define ICOM_CVMETHOD7(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \
603 void (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g);
605 #define ICOM_CVMETHOD8(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh) \
606 void (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h);
609 #define ICOM_DEFINE(iface,ibase) \
610 typedef struct ICOM_VTABLE(iface) ICOM_VTABLE(iface); \
612 const ICOM_VTABLE(iface)* lpvtbl; \
614 struct ICOM_VTABLE(iface) { \
620 #define ICOM_CALL(xfn, p) (p)->lpvtbl->fn##xfn(p)
621 #define ICOM_CALL1(xfn, p,a) (p)->lpvtbl->fn##xfn(p,a)
622 #define ICOM_CALL2(xfn, p,a,b) (p)->lpvtbl->fn##xfn(p,a,b)
623 #define ICOM_CALL3(xfn, p,a,b,c) (p)->lpvtbl->fn##xfn(p,a,b,c)
624 #define ICOM_CALL4(xfn, p,a,b,c,d) (p)->lpvtbl->fn##xfn(p,a,b,c,d)
625 #define ICOM_CALL5(xfn, p,a,b,c,d,e) (p)->lpvtbl->fn##xfn(p,a,b,c,d,e)
626 #define ICOM_CALL6(xfn, p,a,b,c,d,e,f) (p)->lpvtbl->fn##xfn(p,a,b,c,d,e,f)
627 #define ICOM_CALL7(xfn, p,a,b,c,d,e,f,g) (p)->lpvtbl->fn##xfn(p,a,b,c,d,e,f,g)
628 #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)
629 #define ICOM_CALL10(xfn, p,a,b,c,d,e,f,g,h,i,j) (p)->lpvtbl->fn##xfn(p,a,b,c,d,e,f,g,h,i,j)
632 #define ICOM_THIS(impl,iface) impl* const This=(impl*)iface
633 #define ICOM_CTHIS(impl,iface) const impl* const This=(const impl*)iface
638 /*****************************************************************************
639 * Predeclare the interfaces
641 DEFINE_OLEGUID(IID_IClassFactory, 0x00000001L, 0, 0);
642 typedef struct IClassFactory IClassFactory, *LPCLASSFACTORY;
644 DEFINE_OLEGUID(IID_IMalloc, 0x00000002L, 0, 0);
645 typedef struct IMalloc16 IMalloc16,*LPMALLOC16;
646 typedef struct IMalloc IMalloc,*LPMALLOC;
648 DEFINE_OLEGUID(IID_IUnknown, 0x00000000L, 0, 0);
649 typedef struct IUnknown IUnknown, *LPUNKNOWN;
652 /*****************************************************************************
655 #define ICOM_INTERFACE IUnknown
656 #define IUnknown_IMETHODS \
657 ICOM_METHOD2(HRESULT,QueryInterface,REFIID,riid, LPVOID*,ppvObj) \
658 ICOM_METHOD (ULONG,AddRef) \
659 ICOM_METHOD (ULONG,Release)
660 #ifdef ICOM_CINTERFACE
661 typedef struct ICOM_VTABLE(IUnknown) ICOM_VTABLE(IUnknown);
663 ICOM_VTABLE(IUnknown)* lpvtbl;
665 struct ICOM_VTABLE(IUnknown) {
666 ICOM_METHOD2(HRESULT,QueryInterface,REFIID,riid, LPVOID*,ppvObj);
671 HRESULT (CALLBACK *fnQueryInterface)(IUnknown* me, REFIID riid, LPVOID* ppvObj);
673 inline int QueryInterface(REFIID a, LPVOID* b) { return ((IUnknown*)t.lpvtbl)->t.fnQueryInterface(this,a,b); }
676 ICOM_METHOD (ULONG,AddRef);
677 ICOM_METHOD (ULONG,Release);
679 #undef ICOM_INTERFACE
681 #ifdef ICOM_CINTERFACE
682 /*** IUnknown methods ***/
683 #define IUnknown_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b)
684 #define IUnknown_AddRef(p) ICOM_CALL (AddRef,p)
685 #define IUnknown_Release(p) ICOM_CALL (Release,p)
689 /*****************************************************************************
690 * IClassFactory interface
692 #define ICOM_INTERFACE IClassFactory
693 #define IClassFactory_METHODS \
694 ICOM_METHOD3(HRESULT,CreateInstance, LPUNKNOWN,pUnkOuter, REFIID,riid, LPVOID*,ppvObject) \
695 ICOM_METHOD1(HRESULT,LockServer, BOOL,fLock)
696 #define IClassFactory_IMETHODS \
698 IClassFactory_METHODS
699 ICOM_DEFINE(IClassFactory,IUnknown)
700 #undef ICOM_INTERFACE
702 #ifdef ICOM_CINTERFACE
703 /*** IUnknown methods ***/
704 #define IClassFactory_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b)
705 #define IClassFactory_AddRef(p) ICOM_CALL (AddRef,p)
706 #define IClassFactory_Release(p) ICOM_CALL (Release,p)
707 /*** IClassFactory methods ***/
708 #define IClassFactory_CreateInstance(p,a,b,c) ICOM_CALL3(CreateInstance,p,a,b,c)
709 #define IClassFactory_LockServer(p,a) ICOM_CALL1(LockServer,p,a)
713 /*****************************************************************************
716 #define ICOM_INTERFACE IMalloc16
717 #define IMalloc16_METHODS \
718 ICOM_METHOD1 (LPVOID,Alloc, DWORD,cb) \
719 ICOM_METHOD2 (LPVOID,Realloc, LPVOID,pv, DWORD,cb) \
720 ICOM_VMETHOD1( Free, LPVOID,pv) \
721 ICOM_CMETHOD1(DWORD, GetSize, LPVOID,pv) \
722 ICOM_CMETHOD1(INT16, DidAlloc, LPVOID,pv) \
723 ICOM_METHOD (LPVOID,HeapMinimize)
724 #define IMalloc16_IMETHODS \
727 ICOM_DEFINE(IMalloc16,IUnknown)
728 #undef ICOM_INTERFACE
730 #ifdef ICOM_CINTERFACE
731 /*** IUnknown methods ***/
732 #define IMalloc16_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b)
733 #define IMalloc16_AddRef(p) ICOM_CALL (AddRef,p)
734 #define IMalloc16_Release(p) ICOM_CALL (Release,p)
735 /*** IMalloc16 methods ***/
736 #define IMalloc16_Alloc(p,a) ICOM_CALL1(Alloc,p,a)
737 #define IMalloc16_Realloc(p,a,b) ICOM_CALL2(Realloc,p,a,b)
738 #define IMalloc16_Free(p,a) ICOM_CALL1(Free,p,a)
739 #define IMalloc16_GetSize(p,a) ICOM_CALL1(GetSize,p,a)
740 #define IMalloc16_DidAlloc(p,a) ICOM_CALL1(DidAlloc,p,a)
741 #define IMalloc16_HeapMinimize(p) ICOM_CALL (HeapMinimize,p)
745 #define ICOM_INTERFACE IMalloc
746 #define IMalloc_METHODS \
747 ICOM_METHOD1 (LPVOID,Alloc, DWORD,cb) \
748 ICOM_METHOD2 (LPVOID,Realloc, LPVOID,pv, DWORD,cb) \
749 ICOM_VMETHOD1( Free, LPVOID,pv) \
750 ICOM_CMETHOD1(DWORD, GetSize, LPVOID,pv) \
751 ICOM_CMETHOD1(INT, DidAlloc, LPVOID,pv) \
752 ICOM_METHOD (LPVOID,HeapMinimize)
753 #define IMalloc_IMETHODS \
756 ICOM_DEFINE(IMalloc,IUnknown)
757 #undef ICOM_INTERFACE
759 #ifdef ICOM_CINTERFACE
760 /*** IUnknown methods ***/
761 #define IMalloc_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b)
762 #define IMalloc_AddRef(p) ICOM_CALL (AddRef,p)
763 #define IMalloc_Release(p) ICOM_CALL (Release,p)
764 /*** IMalloc32 methods ***/
765 #define IMalloc_Alloc(p,a) ICOM_CALL1(Alloc,p,a)
766 #define IMalloc_Realloc(p,a,b) ICOM_CALL2(Realloc,p,a,b)
767 #define IMalloc_Free(p,a) ICOM_CALL1(Free,p,a)
768 #define IMalloc_GetSize(p,a) ICOM_CALL1(GetSize,p,a)
769 #define IMalloc_DidAlloc(p,a) ICOM_CALL1(DidAlloc,p,a)
770 #define IMalloc_HeapMinimize(p) ICOM_CALL (HeapMinimize,p)
773 /* Duplicated for WINELIB */
774 /*** IUnknown methods ***/
775 #define IMalloc_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b)
776 #define IMalloc_AddRef(p) ICOM_CALL (AddRef,p)
777 #define IMalloc_Release(p) ICOM_CALL (Release,p)
778 /*** IMalloc methods ***/
779 #define IMalloc_Alloc(p,a) ICOM_CALL1(Alloc,p,a)
780 #define IMalloc_Realloc(p,a,b) ICOM_CALL2(Realloc,p,a,b)
781 #define IMalloc_Free(p,a) ICOM_CALL1(Free,p,a)
782 #define IMalloc_GetSize(p,a) ICOM_CALL1(GetSize,p,a)
783 #define IMalloc_DidAlloc(p,a) ICOM_CALL1(DidAlloc,p,a)
784 #define IMalloc_HeapMinimize(p) ICOM_CALL (HeapMinimize,p)
789 HRESULT WINAPI CoCreateStandardMalloc16(DWORD dwMemContext, LPMALLOC16* lpMalloc);
791 HRESULT WINAPI CoGetMalloc16(DWORD dwMemContext,LPMALLOC16* lpMalloc);
792 HRESULT WINAPI CoGetMalloc(DWORD dwMemContext,LPMALLOC* lpMalloc);
794 LPVOID WINAPI CoTaskMemAlloc(ULONG size);
796 void WINAPI CoTaskMemFree(LPVOID ptr);
798 /* FIXME: unimplemented */
799 LPVOID WINAPI CoTaskMemRealloc(LPVOID ptr, ULONG size);
802 /*****************************************************************************
806 HRESULT WINAPI CoCreateGuid(GUID* pguid);
808 void WINAPI CoFreeAllLibraries(void);
810 void WINAPI CoFreeLibrary(HINSTANCE hLibrary);
812 void WINAPI CoFreeUnusedLibraries(void);
814 HRESULT WINAPI CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv);
816 HRESULT WINAPI CoGetClassObject(REFCLSID rclsid, DWORD dwClsContext, LPVOID pvReserved, REFIID iid, LPVOID *ppv);
818 HRESULT WINAPI CoInitialize16(LPVOID lpReserved);
819 HRESULT WINAPI CoInitialize(LPVOID lpReserved);
821 typedef enum tagCOINIT
823 COINIT_APARTMENTTHREADED = 0x2, /* Apartment model */
824 COINIT_MULTITHREADED = 0x0, /* OLE calls objects on any thread */
825 COINIT_DISABLE_OLE1DDE = 0x4, /* Don't use DDE for Ole1 support */
826 COINIT_SPEED_OVER_MEMORY = 0x8 /* Trade memory for speed */
829 HRESULT WINAPI CoInitializeEx(LPVOID lpReserved, DWORD dwCoInit);
831 /* FIXME: not implemented */
832 BOOL WINAPI CoIsOle1Class(REFCLSID rclsid);
834 HINSTANCE WINAPI CoLoadLibrary(LPOLESTR16 lpszLibName, BOOL bAutoFree);
836 HRESULT WINAPI CoLockObjectExternal16(LPUNKNOWN pUnk, BOOL16 fLock, BOOL16 fLastUnlockReleases);
837 HRESULT WINAPI CoLockObjectExternal(LPUNKNOWN pUnk, BOOL fLock, BOOL fLastUnlockReleases);
839 /* class registration flags; passed to CoRegisterClassObject */
840 typedef enum tagREGCLS
842 REGCLS_SINGLEUSE = 0,
843 REGCLS_MULTIPLEUSE = 1,
844 REGCLS_MULTI_SEPARATE = 2,
848 HRESULT WINAPI CoRegisterClassObject16(REFCLSID rclsid, LPUNKNOWN pUnk, DWORD dwClsContext, DWORD flags, LPDWORD lpdwRegister);
849 HRESULT WINAPI CoRegisterClassObject(REFCLSID rclsid,LPUNKNOWN pUnk,DWORD dwClsContext,DWORD flags,LPDWORD lpdwRegister);
851 HRESULT WINAPI CoRevokeClassObject(DWORD dwRegister);
853 void WINAPI CoUninitialize16(void);
854 void WINAPI CoUninitialize(void);
857 /*****************************************************************************
861 HRESULT WINE_StringFromCLSID(const CLSID *id, LPSTR);
864 #endif /* __WINE_WINE_OBJ_BASE_H */