Added missing goto in switch statement.
[wine.git] / include / wine / obj_base.h
blobf7c097d62be0a381d53c769cc09c4f2842fd0324
1 /*
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.
4 */
6 #ifndef __WINE_WINE_OBJ_BASE_H
7 #define __WINE_WINE_OBJ_BASE_H
9 /*****************************************************************************
10 * define ICOM_MSVTABLE_COMPAT
11 * to implement the microsoft com vtable compatibility workaround for g++.
13 * NOTE: Turning this option on will produce a winelib that is incompatible
14 * with the binary emulator.
16 * If the compiler supports the com_interface attribute, leave this off, and
17 * define the ICOM_USE_COM_INTERFACE_ATTRIBUTE macro below. This may also
18 * require the addition of the -vtable-thunks option for g++.
20 * If you aren't interested in WineLib C++ compatability at all, leave both
21 * options off.
23 * The preferable method for using ICOM_USE_COM_INTERFACE_ATTRIBUTE macro
24 * would be to define it only for your WineLib application. This allows you
25 * to have both binary and WineLib compatibility for C and C++ at the same
26 * time :)
28 /* #define ICOM_MSVTABLE_COMPAT 1 */
29 /* #define ICOM_USE_COM_INTERFACE_ATTRIBUTE 1 */
31 /*****************************************************************************
32 * Defines the basic types
34 #include "wtypes.h"
37 #define LISet32(li, v) ((li).HighPart = (v) < 0 ? -1 : 0, (li).LowPart = (v))
38 #define ULISet32(li, v) ((li).HighPart = 0, (li).LowPart = (v))
40 /*****************************************************************************
41 * Macros to declare the GUIDs
43 #ifdef INITGUID
44 #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
45 const GUID name = \
46 { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }
47 #else
48 #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
49 extern const GUID name
50 #endif
52 #define DEFINE_OLEGUID(name, l, w1, w2) \
53 DEFINE_GUID(name, l, w1, w2, 0xC0,0,0,0,0,0,0,0x46)
55 #define DEFINE_SHLGUID(name, l, w1, w2) DEFINE_OLEGUID(name,l,w1,w2)
58 /*****************************************************************************
59 * GUID API
61 HRESULT WINAPI StringFromCLSID16(REFCLSID id, LPOLESTR16*);
62 HRESULT WINAPI StringFromCLSID(REFCLSID id, LPOLESTR*);
64 HRESULT WINAPI CLSIDFromString16(LPCOLESTR16, CLSID *);
65 HRESULT WINAPI CLSIDFromString(LPCOLESTR, CLSID *);
67 HRESULT WINAPI CLSIDFromProgID16(LPCOLESTR16 progid, LPCLSID riid);
68 HRESULT WINAPI CLSIDFromProgID(LPCOLESTR progid, LPCLSID riid);
70 INT WINAPI StringFromGUID2(REFGUID id, LPOLESTR str, INT cmax);
72 BOOL16 WINAPI IsEqualGUID16(GUID* g1,GUID* g2);
73 BOOL WINAPI IsEqualGUID32(REFGUID rguid1,REFGUID rguid2);
74 /*#define IsEqualGUID WINELIB_NAME(IsEqualGUID)*/
75 #if defined(__cplusplus) && !defined(CINTERFACE)
76 #define IsEqualGUID(rguid1, rguid2) (!memcmp(&(rguid1), &(rguid2), sizeof(GUID)))
77 #else /* defined(__cplusplus) && !defined(CINTERFACE) */
78 #define IsEqualGUID(rguid1, rguid2) (!memcmp(rguid1, rguid2, sizeof(GUID)))
79 #endif /* defined(__cplusplus) && !defined(CINTERFACE) */
80 #define IsEqualIID(riid1, riid2) IsEqualGUID(riid1, riid2)
81 #define IsEqualCLSID(rclsid1, rclsid2) IsEqualGUID(rclsid1, rclsid2)
83 #if defined(__cplusplus) && !defined(CINTERFACE)
84 inline BOOL operator==(const GUID& guidOne, const GUID& guidOther)
86 return !memcmp(&guidOne,&guidOther,sizeof(GUID));
88 inline BOOL operator!=(const GUID& guidOne, const GUID& guidOther)
90 return !(guidOne == guidOther);
92 #endif
95 /*****************************************************************************
96 * Macros to define a COM interface
99 * The goal of the following set of definitions is to provide a way to use the same
100 * header file definitions to provide both a C interface and a C++ object oriented
101 * interface to COM interfaces. The type of interface is selected automatically
102 * depending on the language but it is always possible to get the C interface in C++
103 * by defining CINTERFACE.
105 * It is based on the following assumptions:
106 * - all COM interfaces derive from IUnknown, this should not be a problem.
107 * - the header file only defines the interface, the actual fields are defined
108 * separately in the C file implementing the interface.
110 * The natural approach to this problem would be to make sure we get a C++ class and
111 * virtual methods in C++ and a structure with a table of pointer to functions in C.
112 * Unfortunately the layout of the virtual table is compiler specific, the layout of
113 * g++ virtual tables is not the same as that of an egcs virtual table which is not the
114 * same as that generated by Visual C+. There are workarounds to make the virtual tables
115 * compatible via padding but unfortunately the one which is imposed to the WINE emulator
116 * by the Windows binaries, i.e. the Visual C++ one, is the most compact of all.
118 * So the solution I finally adopted does not use virtual tables. Instead I use inline
119 * non virtual methods that dereference the method pointer themselves and perform the call.
121 * Let's take Direct3D as an example:
123 * #define ICOM_INTERFACE IDirect3D
124 * #define IDirect3D_METHODS \
125 * ICOM_METHOD1(HRESULT,Initialize, REFIID,) \
126 * ICOM_METHOD2(HRESULT,EnumDevices, LPD3DENUMDEVICESCALLBACK,, LPVOID,) \
127 * ICOM_METHOD2(HRESULT,CreateLight, LPDIRECT3DLIGHT*,, IUnknown*,) \
128 * ICOM_METHOD2(HRESULT,CreateMaterial,LPDIRECT3DMATERIAL*,, IUnknown*,) \
129 * ICOM_METHOD2(HRESULT,CreateViewport,LPDIRECT3DVIEWPORT*,, IUnknown*,) \
130 * ICOM_METHOD2(HRESULT,FindDevice, LPD3DFINDDEVICESEARCH,, LPD3DFINDDEVICERESULT,)
131 * #define IDirect3D_IMETHODS \
132 * IUnknown_IMETHODS \
133 * IDirect3D_METHODS
134 * ICOM_DEFINE(IDirect3D,IUnknown)
135 * #undef ICOM_INTERFACE
137 * #ifdef ICOM_CINTERFACE
138 * // *** IUnknown methods *** //
139 * #define IDirect3D_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b)
140 * #define IDirect3D_AddRef(p) ICOM_CALL (AddRef,p)
141 * #define IDirect3D_Release(p) ICOM_CALL (Release,p)
142 * // *** IDirect3D methods *** //
143 * #define IDirect3D_Initialize(p,a) ICOM_CALL1(Initialize,p,a)
144 * #define IDirect3D_EnumDevices(p,a,b) ICOM_CALL2(EnumDevice,p,a,b)
145 * #define IDirect3D_CreateLight(p,a,b) ICOM_CALL2(CreateLight,p,a,b)
146 * #define IDirect3D_CreateMaterial(p,a,b) ICOM_CALL2(CreateMaterial,p,a,b)
147 * #define IDirect3D_CreateViewport(p,a,b) ICOM_CALL2(CreateViewport,p,a,b)
148 * #define IDirect3D_FindDevice(p,a,b) ICOM_CALL2(FindDevice,p,a,b)
149 * #endif
151 * Comments:
152 * - The ICOM_INTERFACE macro is used in the ICOM_METHOD macros to define the type of the 'this'
153 * pointer. Defining this macro here saves us the trouble of having to repeat the interface
154 * name everywhere. Note however that because of the way macros work, a macro like ICOM_METHOD1
155 * cannot use 'ICOM_INTERFACE##_VTABLE' because this would give 'ICOM_INTERFACE_VTABLE' and not
156 * 'IDirect3D_VTABLE'.
157 * - ICOM_METHODS defines the methods specific to this interface. It is then aggregated with the
158 * inherited methods to form ICOM_IMETHODS.
159 * - ICOM_IMETHODS defines the list of methods that are inheritable from this interface. It must
160 * be written manually (rather than using a macro to generate the equivalent code) to avoid
161 * macro recursion (which compilers don't like).
162 * - The ICOM_DEFINE finally declares all the structures necessary for the interface. We have to
163 * explicitly use the interface name for macro expansion reasons again.
164 * Inherited methods are inherited in C by using the IDirect3D_METHODS macro and the parent's
165 * Xxx_IMETHODS macro. In C++ we need only use the IDirect3D_METHODS since method inheritance
166 * is taken care of by the language.
167 * - In C++ the ICOM_METHOD macros generate a function prototype and a call to a function pointer
168 * method. This means using once 't1 p1, t2 p2, ...' and once 'p1, p2' without the types. The
169 * only way I found to handle this is to have one ICOM_METHOD macro per number of parameters and
170 * to have it take only the type information (with const if necessary) as parameters.
171 * The 'undef ICOM_INTERFACE' is here to remind you that using ICOM_INTERFACE in the following
172 * macros will not work. This time it's because the ICOM_CALL macro expansion is done only once
173 * the 'IDirect3D_Xxx' macro is expanded. And by that time ICOM_INTERFACE will be long gone
174 * anyway.
175 * - You may have noticed the double commas after each parameter type. This allows you to put the
176 * name of that parameter which I think is good for documentation. It is not required and since
177 * I did not know what to put there for this example (I could only find doc about IDirect3D2),
178 * I left them blank.
179 * - Finally the set of 'IDirect3D_Xxx' macros is a standard set of macros defined to ease access
180 * to the interface methods in C. Unfortunately I don't see any way to avoid having to duplicate
181 * the inherited method definitions there. This time I could have used a trick to use only one
182 * macro whatever the number of parameters but I prefered to have it work the same way as above.
183 * - You probably have noticed that we don't define the fields we need to actually implement this
184 * interface: reference count, pointer to other resources and miscellaneous fields. That's
185 * because these interfaces are just that: interfaces. They may be implemented more than once, in
186 * different contexts and sometimes not even in Wine. Thus it would not make sense to impose
187 * that the interface contains some specific fields.
190 * In C this gives:
191 * typedef struct IDirect3DVtbl IDirect3DVtbl;
192 * struct IDirect3D {
193 * IDirect3DVtbl* lpVtbl;
194 * };
195 * struct IDirect3DVtbl {
196 * HRESULT (*fnQueryInterface)(IDirect3D* me, REFIID riid, LPVOID* ppvObj);
197 * ULONG (*fnQueryInterface)(IDirect3D* me);
198 * ULONG (*fnQueryInterface)(IDirect3D* me);
199 * HRESULT (*fnInitialize)(IDirect3D* me, REFIID a);
200 * HRESULT (*fnEnumDevices)(IDirect3D* me, LPD3DENUMDEVICESCALLBACK a, LPVOID b);
201 * HRESULT (*fnCreateLight)(IDirect3D* me, LPDIRECT3DLIGHT* a, IUnknown* b);
202 * HRESULT (*fnCreateMaterial)(IDirect3D* me, LPDIRECT3DMATERIAL* a, IUnknown* b);
203 * HRESULT (*fnCreateViewport)(IDirect3D* me, LPDIRECT3DVIEWPORT* a, IUnknown* b);
204 * HRESULT (*fnFindDevice)(IDirect3D* me, LPD3DFINDDEVICESEARCH a, LPD3DFINDDEVICERESULT b);
205 * };
207 * #ifdef ICOM_CINTERFACE
208 * // *** IUnknown methods *** //
209 * #define IDirect3D_QueryInterface(p,a,b) (p)->lpVtbl->fnQueryInterface(p,a,b)
210 * #define IDirect3D_AddRef(p) (p)->lpVtbl->fnAddRef(p)
211 * #define IDirect3D_Release(p) (p)->lpVtbl->fnRelease(p)
212 * // *** IDirect3D methods *** //
213 * #define IDirect3D_Initialize(p,a) (p)->lpVtbl->fnInitialize(p,a)
214 * #define IDirect3D_EnumDevices(p,a,b) (p)->lpVtbl->fnEnumDevice(p,a,b)
215 * #define IDirect3D_CreateLight(p,a,b) (p)->lpVtbl->fnCreateLight(p,a,b)
216 * #define IDirect3D_CreateMaterial(p,a,b) (p)->lpVtbl->fnCreateMaterial(p,a,b)
217 * #define IDirect3D_CreateViewport(p,a,b) (p)->lpVtbl->fnCreateViewport(p,a,b)
218 * #define IDirect3D_FindDevice(p,a,b) (p)->lpVtbl->fnFindDevice(p,a,b)
219 * #endif
221 * Comments:
222 * - IDirect3D only contains a pointer to the IDirect3D virtual/jump table. This is the only thing
223 * the user needs to know to use the interface. Of course the structure we will define to
224 * implement this interface will have more fields but the first one will match this pointer.
225 * - The code generated by ICOM_DEFINE defines both the structure representing the interface and
226 * the structure for the jump table. ICOM_DEFINE uses the parent's Xxx_IMETHODS macro to
227 * automatically repeat the prototypes of all the inherited methods and then uses IDirect3D_METHODS
228 * to define the IDirect3D methods.
229 * - Each method is declared as a pointer to function field in the jump table. The implementation
230 * will fill this jump table with appropriate values, probably using a static variable, and
231 * initialize the lpVtbl field to point to this variable.
232 * - The IDirect3D_Xxx macros then just derefence the lpVtbl pointer and use the function pointer
233 * corresponding to the macro name. This emulates the behavior of a virtual table and should be
234 * just as fast.
235 * - This C code should be quite compatible with the Windows headers both for code that uses COM
236 * interfaces and for code implementing a COM interface.
239 * And in C++ (with gcc's g++):
241 * typedef struct IDirect3D: public IUnknown {
242 * private: HRESULT (*fnInitialize)(IDirect3D* me, REFIID a);
243 * public: inline HRESULT Initialize(REFIID a) { return ((IDirect3D*)t.lpVtbl)->fnInitialize(this,a); };
244 * private: HRESULT (*fnEnumDevices)(IDirect3D* me, LPD3DENUMDEVICESCALLBACK a, LPVOID b);
245 * public: inline HRESULT EnumDevices(LPD3DENUMDEVICESCALLBACK a, LPVOID b)
246 * { return ((IDirect3D*)t.lpVtbl)->fnEnumDevices(this,a,b); };
247 * private: HRESULT (*fnCreateLight)(IDirect3D* me, LPDIRECT3DLIGHT* a, IUnknown* b);
248 * public: inline HRESULT CreateLight(LPDIRECT3DLIGHT* a, IUnknown* b)
249 * { return ((IDirect3D*)t.lpVtbl)->fnCreateLight(this,a,b); };
250 * private: HRESULT (*fnCreateMaterial)(IDirect3D* me, LPDIRECT3DMATERIAL* a, IUnknown* b);
251 * public: inline HRESULT CreateMaterial(LPDIRECT3DMATERIAL* a, IUnknown* b)
252 * { return ((IDirect3D*)t.lpVtbl)->fnCreateMaterial(this,a,b); };
253 * private: HRESULT (*fnCreateViewport)(IDirect3D* me, LPDIRECT3DVIEWPORT* a, IUnknown* b);
254 * public: inline HRESULT CreateViewport(LPDIRECT3DVIEWPORT* a, IUnknown* b)
255 * { return ((IDirect3D*)t.lpVtbl)->fnCreateViewport(this,a,b); };
256 * private: HRESULT (*fnFindDevice)(IDirect3D* me, LPD3DFINDDEVICESEARCH a, LPD3DFINDDEVICERESULT b);
257 * public: inline HRESULT FindDevice(LPD3DFINDDEVICESEARCH a, LPD3DFINDDEVICERESULT b)
258 * { return ((IDirect3D*)t.lpVtbl)->fnFindDevice(this,a,b); };
259 * };
261 * Comments:
262 * - In C++ IDirect3D does double duty as both the virtual/jump table and as the interface
263 * definition. The reason for this is to avoid having to duplicate the mehod definitions: once
264 * to have the function pointers in the jump table and once to have the methods in the interface
265 * class. Here one macro can generate both. This means though that the first pointer, t.lpVtbl
266 * defined in IUnknown, must be interpreted as the jump table pointer if we interpret the
267 * structure as the the interface class, and as the function pointer to the QueryInterface
268 * method, t.fnQueryInterface, if we interpret the structure as the jump table. Fortunately this
269 * gymnastic is entirely taken care of in the header of IUnknown.
270 * - Of course in C++ we use inheritance so that we don't have to duplicate the method definitions.
271 * - Since IDirect3D does double duty, each ICOM_METHOD macro defines both a function pointer and
272 * a non-vritual inline method which dereferences it and calls it. This way this method behaves
273 * just like a virtual method but does not create a true C++ virtual table which would break the
274 * structure layout. If you look at the implementation of these methods you'll notice that they
275 * would not work for void functions. We have to return something and fortunately this seems to
276 * be what all the COM methods do (otherwise we would need another set of macros).
277 * - Note how the ICOM_METHOD generates both function prototypes mixing types and formal parameter
278 * names and the method invocation using only the formal parameter name. This is the reason why
279 * we need different macros to handle different numbers of parameters.
280 * - Finally there is no IDirect3D_Xxx macro. These are not needed in C++ unless the CINTERFACE
281 * macro is defined in which case we would not be here.
282 * - This C++ code works well for code that just uses COM interfaces. But it will not work with
283 * C++ code implement a COM interface. That's because such code assumes the interface methods
284 * are declared as virtual C++ methods which is not the case here.
287 * Implementing a COM interface.
289 * This continues the above example. This example assumes that the implementation is in C.
291 * typedef struct _IDirect3D {
292 * void* lpVtbl;
293 * // ...
295 * } _IDirect3D;
297 * static ICOM_VTABLE(IDirect3D) d3dvt;
299 * // implement the IDirect3D methods here
301 * int IDirect3D_fnQueryInterface(IDirect3D* me)
303 * ICOM_THIS(IDirect3D,me);
304 * // ...
307 * // ...
309 * static ICOM_VTABLE(IDirect3D) d3dvt = {
310 * ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
311 * IDirect3D_fnQueryInterface,
312 * IDirect3D_fnAdd,
313 * IDirect3D_fnAdd2,
314 * IDirect3D_fnInitialize,
315 * IDirect3D_fnSetWidth
316 * };
318 * Comments:
319 * - We first define what the interface really contains. This is th e_IDirect3D structure. The
320 * first field must of course be the virtual table pointer. Everything else is free.
321 * - Then we predeclare our static virtual table variable, we will need its address in some
322 * methods to initialize the virtual table pointer of the returned interface objects.
323 * - Then we implement the interface methods. To match what has been declared in the header file
324 * they must take a pointer to a IDirect3D structure and we must cast it to an _IDirect3D so that
325 * we can manipulate the fields. This is performed by the ICOM_THIS macro.
326 * - Finally we initialize the virtual table.
330 #define ICOM_VTABLE(iface) iface##Vtbl
331 #define ICOM_VFIELD(iface) ICOM_VTABLE(iface)* lpVtbl
332 #define ICOM_VTBL(iface) (iface)->lpVtbl
335 #if !defined(__cplusplus) || defined(CINTERFACE)
336 #define ICOM_CINTERFACE 1
337 #endif
339 #ifndef ICOM_CINTERFACE
340 /* C++ interface */
342 #define ICOM_METHOD(ret,xfn) \
343 public: virtual ret (CALLBACK xfn)(void) = 0;
344 #define ICOM_METHOD1(ret,xfn,ta,na) \
345 public: virtual ret (CALLBACK xfn)(ta a) = 0;
346 #define ICOM_METHOD2(ret,xfn,ta,na,tb,nb) \
347 public: virtual ret (CALLBACK xfn)(ta a,tb b) = 0;
348 #define ICOM_METHOD3(ret,xfn,ta,na,tb,nb,tc,nc) \
349 public: virtual ret (CALLBACK xfn)(ta a,tb b,tc c) = 0;
350 #define ICOM_METHOD4(ret,xfn,ta,na,tb,nb,tc,nc,td,nd) \
351 public: virtual ret (CALLBACK xfn)(ta a,tb b,tc c,td d) = 0;
352 #define ICOM_METHOD5(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne) \
353 public: virtual ret (CALLBACK xfn)(ta a,tb b,tc c,td d,te e) = 0;
354 #define ICOM_METHOD6(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf) \
355 public: virtual ret (CALLBACK xfn)(ta a,tb b,tc c,td d,te e,tf f) = 0;
356 #define ICOM_METHOD7(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \
357 public: virtual ret (CALLBACK xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g) = 0;
358 #define ICOM_METHOD8(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh) \
359 public: virtual ret (CALLBACK xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g,th h) = 0;
360 #define ICOM_METHOD9(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni) \
361 public: virtual ret (CALLBACK xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i) = 0;
362 #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) \
363 public: virtual ret (CALLBACK xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i,tj j) = 0;
366 #define ICOM_CMETHOD(ret,xfn) \
367 public: virtual ret (CALLBACK xfn)(void) const = 0;
368 #define ICOM_CMETHOD1(ret,xfn,ta,na) \
369 public: virtual ret (CALLBACK xfn)(ta a) const = 0;
370 #define ICOM_CMETHOD2(ret,xfn,ta,na,tb,nb) \
371 public: virtual ret (CALLBACK xfn)(ta a,tb b) const = 0;
372 #define ICOM_CMETHOD3(ret,xfn,ta,na,tb,nb,tc,nc) \
373 public: virtual ret (CALLBACK xfn)(ta a,tb b,tc c) const = 0;
374 #define ICOM_CMETHOD4(ret,xfn,ta,na,tb,nb,tc,nc,td,nd) \
375 public: virtual ret (CALLBACK xfn)(ta a,tb b,tc c,td d) const = 0;
376 #define ICOM_CMETHOD5(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne) \
377 public: virtual ret (CALLBACK xfn)(ta a,tb b,tc c,td d,te e) const = 0;
378 #define ICOM_CMETHOD6(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf) \
379 public: virtual ret (CALLBACK xfn)(ta a,tb b,tc c,td d,te e,tf f) const = 0;
380 #define ICOM_CMETHOD7(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \
381 public: virtual ret (CALLBACK xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g) const = 0;
382 #define ICOM_CMETHOD8(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh) \
383 public: virtual ret (CALLBACK xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g,th h) const = 0;
386 #define ICOM_VMETHOD(xfn) \
387 public: virtual void (CALLBACK xfn)(void) = 0;
388 #define ICOM_VMETHOD1(xfn,ta,na) \
389 public: virtual void (CALLBACK xfn)(ta a) = 0;
390 #define ICOM_VMETHOD2(xfn,ta,na,tb,nb) \
391 public: virtual void (CALLBACK xfn)(ta a,tb b) = 0;
392 #define ICOM_VMETHOD3(xfn,ta,na,tb,nb,tc,nc) \
393 public: virtual void (CALLBACK xfn)(ta a,tb b,tc c) = 0;
394 #define ICOM_VMETHOD4(xfn,ta,na,tb,nb,tc,nc,td,nd) \
395 public: virtual void (CALLBACK xfn)(ta a,tb b,tc c,td d) = 0;
396 #define ICOM_VMETHOD5(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne) \
397 public: virtual void (CALLBACK xfn)(ta a,tb b,tc c,td d,te e) = 0;
398 #define ICOM_VMETHOD6(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf) \
399 public: virtual void (CALLBACK xfn)(ta a,tb b,tc c,td d,te e,tf f) = 0;
400 #define ICOM_VMETHOD7(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \
401 public: virtual void (CALLBACK xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g) = 0;
402 #define ICOM_VMETHOD8(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh) \
403 public: virtual void (CALLBACK xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g,th h) = 0;
406 #define ICOM_CVMETHOD(xfn) \
407 public: virtual void (CALLBACK xfn)(void) const = 0;
408 #define ICOM_CVMETHOD1(xfn,ta,na) \
409 public: virtual void (CALLBACK xfn)(ta a) const = 0;
410 #define ICOM_CVMETHOD2(xfn,ta,na,tb,nb) \
411 public: virtual void (CALLBACK xfn)(ta a,tb b) const = 0;
412 #define ICOM_CVMETHOD3(xfn,ta,na,tb,nb,tc,nc) \
413 public: virtual void (CALLBACK xfn)(ta a,tb b,tc c) const = 0;
414 #define ICOM_CVMETHOD4(xfn,ta,na,tb,nb,tc,nc,td,nd) \
415 public: virtual void (CALLBACK xfn)(ta a,tb b,tc c,td d) const = 0;
416 #define ICOM_CVMETHOD5(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne) \
417 public: virtual void (CALLBACK xfn)(ta a,tb b,tc c,td d,te e) const = 0;
418 #define ICOM_CVMETHOD6(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf) \
419 public: virtual void (CALLBACK xfn)(ta a,tb b,tc c,td d,te e,tf f) const = 0;
420 #define ICOM_CVMETHOD7(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \
421 public: virtual void (CALLBACK xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g) const = 0;
422 #define ICOM_CVMETHOD8(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh) \
423 public: virtual void (CALLBACK xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g,th h) const = 0;
425 #ifdef ICOM_USE_COM_INTERFACE_ATTRIBUTE
427 #define ICOM_DEFINE(iface,ibase) \
428 typedef struct iface: public ibase { \
429 iface##_METHODS \
430 } __attribute__ ((com_interface));
432 #else
434 #define ICOM_DEFINE(iface,ibase) \
435 typedef struct iface: public ibase { \
436 iface##_METHODS \
439 #endif /* ICOM_USE_COM_INTERFACE_ATTRIBUTE */
441 #define ICOM_CALL(xfn, p) (p)->xfn()
442 #define ICOM_CALL1(xfn, p,a) (p)->xfn(a)
443 #define ICOM_CALL2(xfn, p,a,b) (p)->xfn(a,b)
444 #define ICOM_CALL3(xfn, p,a,b,c) (p)->xfn(a,b,c)
445 #define ICOM_CALL4(xfn, p,a,b,c,d) (p)->xfn(a,b,c,d)
446 #define ICOM_CALL5(xfn, p,a,b,c,d,e) (p)->xfn(a,b,c,d,e)
447 #define ICOM_CALL6(xfn, p,a,b,c,d,e,f) (p)->xfn(a,b,c,d,e,f)
448 #define ICOM_CALL7(xfn, p,a,b,c,d,e,f,g) (p)->xfn(a,b,c,d,e,f,g)
449 #define ICOM_CALL8(xfn, p,a,b,c,d,e,f,g,h) (p)->xfn(a,b,c,d,e,f,g,h)
452 #else
453 /* C interface */
456 #ifdef __WINE__
458 #define ICOM_METHOD(ret,xfn) \
459 ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me);
460 #define ICOM_METHOD1(ret,xfn,ta,na) \
461 ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a);
462 #define ICOM_METHOD2(ret,xfn,ta,na,tb,nb) \
463 ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b);
464 #define ICOM_METHOD3(ret,xfn,ta,na,tb,nb,tc,nc) \
465 ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c);
466 #define ICOM_METHOD4(ret,xfn,ta,na,tb,nb,tc,nc,td,nd) \
467 ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d);
468 #define ICOM_METHOD5(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne) \
469 ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e);
470 #define ICOM_METHOD6(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf) \
471 ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f);
472 #define ICOM_METHOD7(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \
473 ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g);
474 #define ICOM_METHOD8(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh) \
475 ret (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h);
476 #define ICOM_METHOD9(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni) \
477 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);
478 #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) \
479 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);
481 #define ICOM_CMETHOD(ret,xfn) \
482 ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me);
483 #define ICOM_CMETHOD1(ret,xfn,ta,na) \
484 ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a);
485 #define ICOM_CMETHOD2(ret,xfn,ta,na,tb,nb) \
486 ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b);
487 #define ICOM_CMETHOD3(ret,xfn,ta,na,tb,nb,tc,nc) \
488 ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c);
489 #define ICOM_CMETHOD4(ret,xfn,ta,na,tb,nb,tc,nc,td,nd) \
490 ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d);
491 #define ICOM_CMETHOD5(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne) \
492 ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e);
493 #define ICOM_CMETHOD6(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf) \
494 ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f);
495 #define ICOM_CMETHOD7(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \
496 ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g);
497 #define ICOM_CMETHOD8(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh) \
498 ret (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h);
500 #define ICOM_VMETHOD(xfn) \
501 void (CALLBACK *fn##xfn)(ICOM_INTERFACE* me);
502 #define ICOM_VMETHOD1(xfn,ta,na) \
503 void (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a);
504 #define ICOM_VMETHOD2(xfn,ta,na,tb,nb) \
505 void (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b);
506 #define ICOM_VMETHOD3(xfn,ta,na,tb,nb,tc,nc) \
507 void (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c);
508 #define ICOM_VMETHOD4(xfn,ta,na,tb,nb,tc,nc,td,nd) \
509 void (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d);
510 #define ICOM_VMETHOD5(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne) \
511 void (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e);
512 #define ICOM_VMETHOD6(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf) \
513 void (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f);
514 #define ICOM_VMETHOD7(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \
515 void (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g);
516 #define ICOM_VMETHOD8(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,nh) \
517 void (CALLBACK *fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h);
519 #define ICOM_CVMETHOD(xfn) \
520 void (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me);
521 #define ICOM_CVMETHOD1(xfn,ta,na) \
522 void (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a);
523 #define ICOM_CVMETHOD2(xfn,ta,na,tb,nb) \
524 void (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b);
525 #define ICOM_CVMETHOD3(xfn,ta,na,tb,nb,tc,nc) \
526 void (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c);
527 #define ICOM_CVMETHOD4(xfn,ta,na,tb,nb,tc,nc,td,nd) \
528 void (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d);
529 #define ICOM_CVMETHOD5(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne) \
530 void (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e);
531 #define ICOM_CVMETHOD6(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf) \
532 void (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f);
533 #define ICOM_CVMETHOD7(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \
534 void (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g);
535 #define ICOM_CVMETHOD8(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh) \
536 void (CALLBACK *fn##xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h);
538 #define ICOM_CALL(xfn, p) ICOM_VTBL(p)->fn##xfn(p)
539 #define ICOM_CALL1(xfn, p,a) ICOM_VTBL(p)->fn##xfn(p,a)
540 #define ICOM_CALL2(xfn, p,a,b) ICOM_VTBL(p)->fn##xfn(p,a,b)
541 #define ICOM_CALL3(xfn, p,a,b,c) ICOM_VTBL(p)->fn##xfn(p,a,b,c)
542 #define ICOM_CALL4(xfn, p,a,b,c,d) ICOM_VTBL(p)->fn##xfn(p,a,b,c,d)
543 #define ICOM_CALL5(xfn, p,a,b,c,d,e) ICOM_VTBL(p)->fn##xfn(p,a,b,c,d,e)
544 #define ICOM_CALL6(xfn, p,a,b,c,d,e,f) ICOM_VTBL(p)->fn##xfn(p,a,b,c,d,e,f)
545 #define ICOM_CALL7(xfn, p,a,b,c,d,e,f,g) ICOM_VTBL(p)->fn##xfn(p,a,b,c,d,e,f,g)
546 #define ICOM_CALL8(xfn, p,a,b,c,d,e,f,g,h) ICOM_VTBL(p)->fn##xfn(p,a,b,c,d,e,f,g,h)
547 #define ICOM_CALL9(xfn, p,a,b,c,d,e,f,g,h,i) ICOM_VTBL(p)->fn##xfn(p,a,b,c,d,e,f,g,h,i)
548 #define ICOM_CALL10(xfn, p,a,b,c,d,e,f,g,h,i,j) ICOM_VTBL(p)->fn##xfn(p,a,b,c,d,e,f,g,h,i,j)
550 #else
552 /* WINELIB case */
554 #define ICOM_METHOD(ret,xfn) \
555 ret (CALLBACK *xfn)(ICOM_INTERFACE* me);
556 #define ICOM_METHOD1(ret,xfn,ta,na) \
557 ret (CALLBACK *xfn)(ICOM_INTERFACE* me,ta a);
558 #define ICOM_METHOD2(ret,xfn,ta,na,tb,nb) \
559 ret (CALLBACK *xfn)(ICOM_INTERFACE* me,ta a,tb b);
560 #define ICOM_METHOD3(ret,xfn,ta,na,tb,nb,tc,nc) \
561 ret (CALLBACK *xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c);
562 #define ICOM_METHOD4(ret,xfn,ta,na,tb,nb,tc,nc,td,nd) \
563 ret (CALLBACK *xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d);
564 #define ICOM_METHOD5(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne) \
565 ret (CALLBACK *xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e);
566 #define ICOM_METHOD6(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf) \
567 ret (CALLBACK *xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f);
568 #define ICOM_METHOD7(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \
569 ret (CALLBACK *xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g);
570 #define ICOM_METHOD8(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh) \
571 ret (CALLBACK *xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h);
572 #define ICOM_METHOD9(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni) \
573 ret (CALLBACK *xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i);
574 #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) \
575 ret (CALLBACK *xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i,tj j);
577 #define ICOM_CMETHOD(ret,xfn) \
578 ret (CALLBACK *xfn)(const ICOM_INTERFACE* me);
579 #define ICOM_CMETHOD1(ret,xfn,ta,na) \
580 ret (CALLBACK *xfn)(const ICOM_INTERFACE* me,ta a);
581 #define ICOM_CMETHOD2(ret,xfn,ta,na,tb,nb) \
582 ret (CALLBACK *xfn)(const ICOM_INTERFACE* me,ta a,tb b);
583 #define ICOM_CMETHOD3(ret,xfn,ta,na,tb,nb,tc,nc) \
584 ret (CALLBACK *xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c);
585 #define ICOM_CMETHOD4(ret,xfn,ta,na,tb,nb,tc,nc,td,nd) \
586 ret (CALLBACK *xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d);
587 #define ICOM_CMETHOD5(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne) \
588 ret (CALLBACK *xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e);
589 #define ICOM_CMETHOD6(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf) \
590 ret (CALLBACK *xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f);
591 #define ICOM_CMETHOD7(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \
592 ret (CALLBACK *xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g);
593 #define ICOM_CMETHOD8(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh) \
594 ret (CALLBACK *xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h);
596 #define ICOM_VMETHOD(xfn) \
597 void (CALLBACK *xfn)(ICOM_INTERFACE* me);
598 #define ICOM_VMETHOD1(xfn,ta,na) \
599 void (CALLBACK *xfn)(ICOM_INTERFACE* me,ta a);
600 #define ICOM_VMETHOD2(xfn,ta,na,tb,nb) \
601 void (CALLBACK *xfn)(ICOM_INTERFACE* me,ta a,tb b);
602 #define ICOM_VMETHOD3(xfn,ta,na,tb,nb,tc,nc) \
603 void (CALLBACK *xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c);
604 #define ICOM_VMETHOD4(xfn,ta,na,tb,nb,tc,nc,td,nd) \
605 void (CALLBACK *xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d);
606 #define ICOM_VMETHOD5(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne) \
607 void (CALLBACK *xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e);
608 #define ICOM_VMETHOD6(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf) \
609 void (CALLBACK *xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f);
610 #define ICOM_VMETHOD7(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \
611 void (CALLBACK *xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g);
612 #define ICOM_VMETHOD8(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,nh) \
613 void (CALLBACK *xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h);
615 #define ICOM_CVMETHOD(xfn) \
616 void (CALLBACK *xfn)(const ICOM_INTERFACE* me);
617 #define ICOM_CVMETHOD1(xfn,ta,na) \
618 void (CALLBACK *xfn)(const ICOM_INTERFACE* me,ta a);
619 #define ICOM_CVMETHOD2(xfn,ta,na,tb,nb) \
620 void (CALLBACK *xfn)(const ICOM_INTERFACE* me,ta a,tb b);
621 #define ICOM_CVMETHOD3(xfn,ta,na,tb,nb,tc,nc) \
622 void (CALLBACK *xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c);
623 #define ICOM_CVMETHOD4(xfn,ta,na,tb,nb,tc,nc,td,nd) \
624 void (CALLBACK *xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d);
625 #define ICOM_CVMETHOD5(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne) \
626 void (CALLBACK *xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e);
627 #define ICOM_CVMETHOD6(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf) \
628 void (CALLBACK *xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f);
629 #define ICOM_CVMETHOD7(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \
630 void (CALLBACK *xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g);
631 #define ICOM_CVMETHOD8(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh) \
632 void (CALLBACK *xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h);
634 #define ICOM_CALL(xfn, p) ICOM_VTBL(p)->xfn(p)
635 #define ICOM_CALL1(xfn, p,a) ICOM_VTBL(p)->xfn(p,a)
636 #define ICOM_CALL2(xfn, p,a,b) ICOM_VTBL(p)->xfn(p,a,b)
637 #define ICOM_CALL3(xfn, p,a,b,c) ICOM_VTBL(p)->xfn(p,a,b,c)
638 #define ICOM_CALL4(xfn, p,a,b,c,d) ICOM_VTBL(p)->xfn(p,a,b,c,d)
639 #define ICOM_CALL5(xfn, p,a,b,c,d,e) ICOM_VTBL(p)->xfn(p,a,b,c,d,e)
640 #define ICOM_CALL6(xfn, p,a,b,c,d,e,f) ICOM_VTBL(p)->xfn(p,a,b,c,d,e,f)
641 #define ICOM_CALL7(xfn, p,a,b,c,d,e,f,g) ICOM_VTBL(p)->xfn(p,a,b,c,d,e,f,g)
642 #define ICOM_CALL8(xfn, p,a,b,c,d,e,f,g,h) ICOM_VTBL(p)->xfn(p,a,b,c,d,e,f,g,h)
643 #define ICOM_CALL9(xfn, p,a,b,c,d,e,f,g,h,i) ICOM_VTBL(p)->xfn(p,a,b,c,d,e,f,g,h,i)
644 #define ICOM_CALL10(xfn, p,a,b,c,d,e,f,g,h,i,j) ICOM_VTBL(p)->xfn(p,a,b,c,d,e,f,g,h,i,j)
646 #endif /* __WINE__ */
648 #ifdef ICOM_MSVTABLE_COMPAT
649 #define ICOM_DEFINE(iface,ibase) \
650 typedef struct ICOM_VTABLE(iface) ICOM_VTABLE(iface); \
651 struct iface { \
652 const ICOM_VFIELD(iface); \
653 }; \
654 struct ICOM_VTABLE(iface) { \
655 long dummyRTTI1; \
656 long dummyRTTI2; \
657 ibase##_IMETHODS \
658 iface##_METHODS \
660 #define ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE 0,0,
662 #else
663 #define ICOM_DEFINE(iface,ibase) \
664 typedef struct ICOM_VTABLE(iface) ICOM_VTABLE(iface); \
665 struct iface { \
666 const ICOM_VFIELD(iface); \
667 }; \
668 struct ICOM_VTABLE(iface) { \
669 ibase##_IMETHODS \
670 iface##_METHODS \
672 #define ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
673 #endif /* ICOM_MSVTABLE_COMPAT */
676 #define ICOM_THIS(impl,iface) impl* const This=(impl*)iface
677 #define ICOM_CTHIS(impl,iface) const impl* const This=(const impl*)iface
679 #endif
682 /*****************************************************************************
683 * Predeclare the interfaces
685 DEFINE_OLEGUID(IID_IClassFactory, 0x00000001L, 0, 0);
686 typedef struct IClassFactory IClassFactory, *LPCLASSFACTORY;
688 DEFINE_OLEGUID(IID_IMalloc, 0x00000002L, 0, 0);
689 typedef struct IMalloc16 IMalloc16,*LPMALLOC16;
690 typedef struct IMalloc IMalloc,*LPMALLOC;
692 DEFINE_OLEGUID(IID_IUnknown, 0x00000000L, 0, 0);
693 typedef struct IUnknown IUnknown, *LPUNKNOWN;
696 /*****************************************************************************
697 * IUnknown interface
699 #define ICOM_INTERFACE IUnknown
700 #define IUnknown_IMETHODS \
701 ICOM_METHOD2(HRESULT,QueryInterface,REFIID,riid, LPVOID*,ppvObj) \
702 ICOM_METHOD (ULONG,AddRef) \
703 ICOM_METHOD (ULONG,Release)
704 #ifdef ICOM_CINTERFACE
705 typedef struct ICOM_VTABLE(IUnknown) ICOM_VTABLE(IUnknown);
706 struct IUnknown {
707 ICOM_VFIELD(IUnknown);
708 #if defined(ICOM_USE_COM_INTERFACE_ATTRIBUTE)
709 } __attribute__ ((com_interface));
710 #else
712 #endif /* ICOM_US_COM_INTERFACE_ATTRIBUTE */
714 struct ICOM_VTABLE(IUnknown) {
715 #ifdef ICOM_MSVTABLE_COMPAT
716 long dummyRTTI1;
717 long dummyRTTI2;
718 #endif /* ICOM_MSVTABLE_COMPAT */
720 #else /* ICOM_CINTERFACE */
721 struct IUnknown {
723 #endif /* ICOM_CINTERFACE */
725 ICOM_METHOD2(HRESULT,QueryInterface,REFIID,riid, LPVOID*,ppvObj)
726 ICOM_METHOD (ULONG,AddRef)
727 ICOM_METHOD (ULONG,Release)
728 #if defined(ICOM_USE_COM_INTERFACE_ATTRIBUTE)
729 } __attribute__ ((com_interface));
730 #else
732 #endif /* ICOM_US_COM_INTERFACE_ATTRIBUTE */
734 #undef ICOM_INTERFACE
736 /*** IUnknown methods ***/
737 #define IUnknown_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b)
738 #define IUnknown_AddRef(p) ICOM_CALL (AddRef,p)
739 #define IUnknown_Release(p) ICOM_CALL (Release,p)
741 /*****************************************************************************
742 * IClassFactory interface
744 #define ICOM_INTERFACE IClassFactory
745 #define IClassFactory_METHODS \
746 ICOM_METHOD3(HRESULT,CreateInstance, LPUNKNOWN,pUnkOuter, REFIID,riid, LPVOID*,ppvObject) \
747 ICOM_METHOD1(HRESULT,LockServer, BOOL,fLock)
748 #define IClassFactory_IMETHODS \
749 IUnknown_IMETHODS \
750 IClassFactory_METHODS
751 ICOM_DEFINE(IClassFactory,IUnknown)
752 #undef ICOM_INTERFACE
754 /*** IUnknown methods ***/
755 #define IClassFactory_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b)
756 #define IClassFactory_AddRef(p) ICOM_CALL (AddRef,p)
757 #define IClassFactory_Release(p) ICOM_CALL (Release,p)
758 /*** IClassFactory methods ***/
759 #define IClassFactory_CreateInstance(p,a,b,c) ICOM_CALL3(CreateInstance,p,a,b,c)
760 #define IClassFactory_LockServer(p,a) ICOM_CALL1(LockServer,p,a)
763 /*****************************************************************************
764 * IMalloc interface
766 #define ICOM_INTERFACE IMalloc16
767 #define IMalloc16_METHODS \
768 ICOM_METHOD1 (LPVOID,Alloc, DWORD,cb) \
769 ICOM_METHOD2 (LPVOID,Realloc, LPVOID,pv, DWORD,cb) \
770 ICOM_VMETHOD1( Free, LPVOID,pv) \
771 ICOM_CMETHOD1(DWORD, GetSize, LPVOID,pv) \
772 ICOM_CMETHOD1(INT16, DidAlloc, LPVOID,pv) \
773 ICOM_METHOD (LPVOID,HeapMinimize)
774 #define IMalloc16_IMETHODS \
775 IUnknown_IMETHODS \
776 IMalloc16_METHODS
777 ICOM_DEFINE(IMalloc16,IUnknown)
778 #undef ICOM_INTERFACE
780 /*** IUnknown methods ***/
781 #define IMalloc16_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b)
782 #define IMalloc16_AddRef(p) ICOM_CALL (AddRef,p)
783 #define IMalloc16_Release(p) ICOM_CALL (Release,p)
784 /*** IMalloc16 methods ***/
785 #define IMalloc16_Alloc(p,a) ICOM_CALL1(Alloc,p,a)
786 #define IMalloc16_Realloc(p,a,b) ICOM_CALL2(Realloc,p,a,b)
787 #define IMalloc16_Free(p,a) ICOM_CALL1(Free,p,a)
788 #define IMalloc16_GetSize(p,a) ICOM_CALL1(GetSize,p,a)
789 #define IMalloc16_DidAlloc(p,a) ICOM_CALL1(DidAlloc,p,a)
790 #define IMalloc16_HeapMinimize(p) ICOM_CALL (HeapMinimize,p)
793 #define ICOM_INTERFACE IMalloc
794 #define IMalloc_METHODS \
795 ICOM_METHOD1 (LPVOID,Alloc, DWORD,cb) \
796 ICOM_METHOD2 (LPVOID,Realloc, LPVOID,pv, DWORD,cb) \
797 ICOM_VMETHOD1( Free, LPVOID,pv) \
798 ICOM_CMETHOD1(DWORD, GetSize, LPVOID,pv) \
799 ICOM_CMETHOD1(INT, DidAlloc, LPVOID,pv) \
800 ICOM_METHOD (LPVOID,HeapMinimize)
801 #define IMalloc_IMETHODS \
802 IUnknown_IMETHODS \
803 IMalloc_METHODS
804 ICOM_DEFINE(IMalloc,IUnknown)
805 #undef ICOM_INTERFACE
807 /*** IUnknown methods ***/
808 #define IMalloc_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b)
809 #define IMalloc_AddRef(p) ICOM_CALL (AddRef,p)
810 #define IMalloc_Release(p) ICOM_CALL (Release,p)
811 /*** IMalloc32 methods ***/
812 #define IMalloc_Alloc(p,a) ICOM_CALL1(Alloc,p,a)
813 #define IMalloc_Realloc(p,a,b) ICOM_CALL2(Realloc,p,a,b)
814 #define IMalloc_Free(p,a) ICOM_CALL1(Free,p,a)
815 #define IMalloc_GetSize(p,a) ICOM_CALL1(GetSize,p,a)
816 #define IMalloc_DidAlloc(p,a) ICOM_CALL1(DidAlloc,p,a)
817 #define IMalloc_HeapMinimize(p) ICOM_CALL (HeapMinimize,p)
820 HRESULT WINAPI CoCreateStandardMalloc16(DWORD dwMemContext, LPMALLOC16* lpMalloc);
822 HRESULT WINAPI CoGetMalloc16(DWORD dwMemContext,LPMALLOC16* lpMalloc);
823 HRESULT WINAPI CoGetMalloc(DWORD dwMemContext,LPMALLOC* lpMalloc);
825 LPVOID WINAPI CoTaskMemAlloc(ULONG size);
827 void WINAPI CoTaskMemFree(LPVOID ptr);
829 /* FIXME: unimplemented */
830 LPVOID WINAPI CoTaskMemRealloc(LPVOID ptr, ULONG size);
833 /*****************************************************************************
834 * Additional API
837 HRESULT WINAPI CoCreateGuid(GUID* pguid);
839 void WINAPI CoFreeAllLibraries(void);
841 void WINAPI CoFreeLibrary(HINSTANCE hLibrary);
843 void WINAPI CoFreeUnusedLibraries(void);
845 HRESULT WINAPI CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv);
847 HRESULT WINAPI CoGetClassObject(REFCLSID rclsid, DWORD dwClsContext, LPVOID pvReserved, REFIID iid, LPVOID *ppv);
849 HRESULT WINAPI CoInitialize16(LPVOID lpReserved);
850 HRESULT WINAPI CoInitialize(LPVOID lpReserved);
851 HRESULT WINAPI CoInitializeEx(LPVOID lpReserved, DWORD dwCoInit);
853 void WINAPI CoUninitialize16(void);
854 void WINAPI CoUninitialize(void);
856 typedef enum tagCOINIT
858 COINIT_APARTMENTTHREADED = 0x2, /* Apartment model */
859 COINIT_MULTITHREADED = 0x0, /* OLE calls objects on any thread */
860 COINIT_DISABLE_OLE1DDE = 0x4, /* Don't use DDE for Ole1 support */
861 COINIT_SPEED_OVER_MEMORY = 0x8 /* Trade memory for speed */
862 } COINIT;
865 /* FIXME: not implemented */
866 BOOL WINAPI CoIsOle1Class(REFCLSID rclsid);
868 HINSTANCE WINAPI CoLoadLibrary(LPOLESTR16 lpszLibName, BOOL bAutoFree);
870 HRESULT WINAPI CoLockObjectExternal16(LPUNKNOWN pUnk, BOOL16 fLock, BOOL16 fLastUnlockReleases);
871 HRESULT WINAPI CoLockObjectExternal(LPUNKNOWN pUnk, BOOL fLock, BOOL fLastUnlockReleases);
873 /* class registration flags; passed to CoRegisterClassObject */
874 typedef enum tagREGCLS
876 REGCLS_SINGLEUSE = 0,
877 REGCLS_MULTIPLEUSE = 1,
878 REGCLS_MULTI_SEPARATE = 2,
879 REGCLS_SUSPENDED = 4
880 } REGCLS;
882 HRESULT WINAPI CoRegisterClassObject16(REFCLSID rclsid, LPUNKNOWN pUnk, DWORD dwClsContext, DWORD flags, LPDWORD lpdwRegister);
883 HRESULT WINAPI CoRegisterClassObject(REFCLSID rclsid,LPUNKNOWN pUnk,DWORD dwClsContext,DWORD flags,LPDWORD lpdwRegister);
885 HRESULT WINAPI CoRevokeClassObject(DWORD dwRegister);
887 void WINAPI CoUninitialize16(void);
888 void WINAPI CoUninitialize(void);
890 /*****************************************************************************
891 * COM Server dll - exports
893 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID * ppv);
894 HRESULT WINAPI DllCanUnloadNow(void);
896 /*****************************************************************************
897 * Internal WINE API
899 #ifdef __WINE__
900 HRESULT WINE_StringFromCLSID(const CLSID *id, LPSTR);
901 #endif
903 #endif /* __WINE_WINE_OBJ_BASE_H */