Fixed some difficulties with the font on vertical tabs. Also plugged a
[wine.git] / include / wine / obj_base.h
blob9789b6109c2fa4e9f30d9e1ad0270ac6bdbe2cd3
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++ compatibility 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"
35 #include "guiddef.h"
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
42 #ifndef NONAMELESSSTRUCT
43 #define LISet32(li, v) ((li).HighPart = (v) < 0 ? -1 : 0, (li).LowPart = (v))
44 #define ULISet32(li, v) ((li).HighPart = 0, (li).LowPart = (v))
45 #else
46 #define LISet32(li, v) ((li).s.HighPart = (v) < 0 ? -1 : 0, (li).s.LowPart = (v))
47 #define ULISet32(li, v) ((li).s.HighPart = 0, (li).s.LowPart = (v))
48 #endif
50 /*****************************************************************************
51 * GUID API
53 HRESULT WINAPI StringFromCLSID16(REFCLSID id, LPOLESTR16*);
54 HRESULT WINAPI StringFromCLSID(REFCLSID id, LPOLESTR*);
56 HRESULT WINAPI CLSIDFromString16(LPCOLESTR16, CLSID *);
57 HRESULT WINAPI CLSIDFromString(LPCOLESTR, CLSID *);
59 HRESULT WINAPI CLSIDFromProgID16(LPCOLESTR16 progid, LPCLSID riid);
60 HRESULT WINAPI CLSIDFromProgID(LPCOLESTR progid, LPCLSID riid);
62 HRESULT WINAPI ProgIDFromCLSID(REFCLSID clsid, LPOLESTR *lplpszProgID);
65 INT WINAPI StringFromGUID2(REFGUID id, LPOLESTR str, INT cmax);
68 /*****************************************************************************
69 * Macros to define a COM interface
72 * The goal of the following set of definitions is to provide a way to use the same
73 * header file definitions to provide both a C interface and a C++ object oriented
74 * interface to COM interfaces. The type of interface is selected automatically
75 * depending on the language but it is always possible to get the C interface in C++
76 * by defining CINTERFACE.
78 * It is based on the following assumptions:
79 * - all COM interfaces derive from IUnknown, this should not be a problem.
80 * - the header file only defines the interface, the actual fields are defined
81 * separately in the C file implementing the interface.
83 * The natural approach to this problem would be to make sure we get a C++ class and
84 * virtual methods in C++ and a structure with a table of pointer to functions in C.
85 * Unfortunately the layout of the virtual table is compiler specific, the layout of
86 * g++ virtual tables is not the same as that of an egcs virtual table which is not the
87 * same as that generated by Visual C+. There are workarounds to make the virtual tables
88 * compatible via padding but unfortunately the one which is imposed to the WINE emulator
89 * by the Windows binaries, i.e. the Visual C++ one, is the most compact of all.
91 * So the solution I finally adopted does not use virtual tables. Instead I use inline
92 * non virtual methods that dereference the method pointer themselves and perform the call.
94 * Let's take Direct3D as an example:
96 * #define ICOM_INTERFACE IDirect3D
97 * #define IDirect3D_METHODS \
98 * ICOM_METHOD1(HRESULT,Initialize, REFIID,) \
99 * ICOM_METHOD2(HRESULT,EnumDevices, LPD3DENUMDEVICESCALLBACK,, LPVOID,) \
100 * ICOM_METHOD2(HRESULT,CreateLight, LPDIRECT3DLIGHT*,, IUnknown*,) \
101 * ICOM_METHOD2(HRESULT,CreateMaterial,LPDIRECT3DMATERIAL*,, IUnknown*,) \
102 * ICOM_METHOD2(HRESULT,CreateViewport,LPDIRECT3DVIEWPORT*,, IUnknown*,) \
103 * ICOM_METHOD2(HRESULT,FindDevice, LPD3DFINDDEVICESEARCH,, LPD3DFINDDEVICERESULT,)
104 * #define IDirect3D_IMETHODS \
105 * IUnknown_IMETHODS \
106 * IDirect3D_METHODS
107 * ICOM_DEFINE(IDirect3D,IUnknown)
108 * #undef ICOM_INTERFACE
110 * #ifdef ICOM_CINTERFACE
111 * // *** IUnknown methods *** //
112 * #define IDirect3D_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b)
113 * #define IDirect3D_AddRef(p) ICOM_CALL (AddRef,p)
114 * #define IDirect3D_Release(p) ICOM_CALL (Release,p)
115 * // *** IDirect3D methods *** //
116 * #define IDirect3D_Initialize(p,a) ICOM_CALL1(Initialize,p,a)
117 * #define IDirect3D_EnumDevices(p,a,b) ICOM_CALL2(EnumDevice,p,a,b)
118 * #define IDirect3D_CreateLight(p,a,b) ICOM_CALL2(CreateLight,p,a,b)
119 * #define IDirect3D_CreateMaterial(p,a,b) ICOM_CALL2(CreateMaterial,p,a,b)
120 * #define IDirect3D_CreateViewport(p,a,b) ICOM_CALL2(CreateViewport,p,a,b)
121 * #define IDirect3D_FindDevice(p,a,b) ICOM_CALL2(FindDevice,p,a,b)
122 * #endif
124 * Comments:
125 * - The ICOM_INTERFACE macro is used in the ICOM_METHOD macros to define the type of the 'this'
126 * pointer. Defining this macro here saves us the trouble of having to repeat the interface
127 * name everywhere. Note however that because of the way macros work, a macro like ICOM_METHOD1
128 * cannot use 'ICOM_INTERFACE##_VTABLE' because this would give 'ICOM_INTERFACE_VTABLE' and not
129 * 'IDirect3D_VTABLE'.
130 * - ICOM_METHODS defines the methods specific to this interface. It is then aggregated with the
131 * inherited methods to form ICOM_IMETHODS.
132 * - ICOM_IMETHODS defines the list of methods that are inheritable from this interface. It must
133 * be written manually (rather than using a macro to generate the equivalent code) to avoid
134 * macro recursion (which compilers don't like).
135 * - The ICOM_DEFINE finally declares all the structures necessary for the interface. We have to
136 * explicitly use the interface name for macro expansion reasons again.
137 * Inherited methods are inherited in C by using the IDirect3D_METHODS macro and the parent's
138 * Xxx_IMETHODS macro. In C++ we need only use the IDirect3D_METHODS since method inheritance
139 * is taken care of by the language.
140 * - In C++ the ICOM_METHOD macros generate a function prototype and a call to a function pointer
141 * method. This means using once 't1 p1, t2 p2, ...' and once 'p1, p2' without the types. The
142 * only way I found to handle this is to have one ICOM_METHOD macro per number of parameters and
143 * to have it take only the type information (with const if necessary) as parameters.
144 * The 'undef ICOM_INTERFACE' is here to remind you that using ICOM_INTERFACE in the following
145 * macros will not work. This time it's because the ICOM_CALL macro expansion is done only once
146 * the 'IDirect3D_Xxx' macro is expanded. And by that time ICOM_INTERFACE will be long gone
147 * anyway.
148 * - You may have noticed the double commas after each parameter type. This allows you to put the
149 * name of that parameter which I think is good for documentation. It is not required and since
150 * I did not know what to put there for this example (I could only find doc about IDirect3D2),
151 * I left them blank.
152 * - Finally the set of 'IDirect3D_Xxx' macros is a standard set of macros defined to ease access
153 * to the interface methods in C. Unfortunately I don't see any way to avoid having to duplicate
154 * the inherited method definitions there. This time I could have used a trick to use only one
155 * macro whatever the number of parameters but I prefered to have it work the same way as above.
156 * - You probably have noticed that we don't define the fields we need to actually implement this
157 * interface: reference count, pointer to other resources and miscellaneous fields. That's
158 * because these interfaces are just that: interfaces. They may be implemented more than once, in
159 * different contexts and sometimes not even in Wine. Thus it would not make sense to impose
160 * that the interface contains some specific fields.
163 * In C this gives:
164 * typedef struct IDirect3DVtbl IDirect3DVtbl;
165 * struct IDirect3D {
166 * IDirect3DVtbl* lpVtbl;
167 * };
168 * struct IDirect3DVtbl {
169 * HRESULT (*fnQueryInterface)(IDirect3D* me, REFIID riid, LPVOID* ppvObj);
170 * ULONG (*fnQueryInterface)(IDirect3D* me);
171 * ULONG (*fnQueryInterface)(IDirect3D* me);
172 * HRESULT (*fnInitialize)(IDirect3D* me, REFIID a);
173 * HRESULT (*fnEnumDevices)(IDirect3D* me, LPD3DENUMDEVICESCALLBACK a, LPVOID b);
174 * HRESULT (*fnCreateLight)(IDirect3D* me, LPDIRECT3DLIGHT* a, IUnknown* b);
175 * HRESULT (*fnCreateMaterial)(IDirect3D* me, LPDIRECT3DMATERIAL* a, IUnknown* b);
176 * HRESULT (*fnCreateViewport)(IDirect3D* me, LPDIRECT3DVIEWPORT* a, IUnknown* b);
177 * HRESULT (*fnFindDevice)(IDirect3D* me, LPD3DFINDDEVICESEARCH a, LPD3DFINDDEVICERESULT b);
178 * };
180 * #ifdef ICOM_CINTERFACE
181 * // *** IUnknown methods *** //
182 * #define IDirect3D_QueryInterface(p,a,b) (p)->lpVtbl->fnQueryInterface(p,a,b)
183 * #define IDirect3D_AddRef(p) (p)->lpVtbl->fnAddRef(p)
184 * #define IDirect3D_Release(p) (p)->lpVtbl->fnRelease(p)
185 * // *** IDirect3D methods *** //
186 * #define IDirect3D_Initialize(p,a) (p)->lpVtbl->fnInitialize(p,a)
187 * #define IDirect3D_EnumDevices(p,a,b) (p)->lpVtbl->fnEnumDevice(p,a,b)
188 * #define IDirect3D_CreateLight(p,a,b) (p)->lpVtbl->fnCreateLight(p,a,b)
189 * #define IDirect3D_CreateMaterial(p,a,b) (p)->lpVtbl->fnCreateMaterial(p,a,b)
190 * #define IDirect3D_CreateViewport(p,a,b) (p)->lpVtbl->fnCreateViewport(p,a,b)
191 * #define IDirect3D_FindDevice(p,a,b) (p)->lpVtbl->fnFindDevice(p,a,b)
192 * #endif
194 * Comments:
195 * - IDirect3D only contains a pointer to the IDirect3D virtual/jump table. This is the only thing
196 * the user needs to know to use the interface. Of course the structure we will define to
197 * implement this interface will have more fields but the first one will match this pointer.
198 * - The code generated by ICOM_DEFINE defines both the structure representing the interface and
199 * the structure for the jump table. ICOM_DEFINE uses the parent's Xxx_IMETHODS macro to
200 * automatically repeat the prototypes of all the inherited methods and then uses IDirect3D_METHODS
201 * to define the IDirect3D methods.
202 * - Each method is declared as a pointer to function field in the jump table. The implementation
203 * will fill this jump table with appropriate values, probably using a static variable, and
204 * initialize the lpVtbl field to point to this variable.
205 * - The IDirect3D_Xxx macros then just derefence the lpVtbl pointer and use the function pointer
206 * corresponding to the macro name. This emulates the behavior of a virtual table and should be
207 * just as fast.
208 * - This C code should be quite compatible with the Windows headers both for code that uses COM
209 * interfaces and for code implementing a COM interface.
212 * And in C++ (with gcc's g++):
214 * typedef struct IDirect3D: public IUnknown {
215 * private: HRESULT (*fnInitialize)(IDirect3D* me, REFIID a);
216 * public: inline HRESULT Initialize(REFIID a) { return ((IDirect3D*)t.lpVtbl)->fnInitialize(this,a); };
217 * private: HRESULT (*fnEnumDevices)(IDirect3D* me, LPD3DENUMDEVICESCALLBACK a, LPVOID b);
218 * public: inline HRESULT EnumDevices(LPD3DENUMDEVICESCALLBACK a, LPVOID b)
219 * { return ((IDirect3D*)t.lpVtbl)->fnEnumDevices(this,a,b); };
220 * private: HRESULT (*fnCreateLight)(IDirect3D* me, LPDIRECT3DLIGHT* a, IUnknown* b);
221 * public: inline HRESULT CreateLight(LPDIRECT3DLIGHT* a, IUnknown* b)
222 * { return ((IDirect3D*)t.lpVtbl)->fnCreateLight(this,a,b); };
223 * private: HRESULT (*fnCreateMaterial)(IDirect3D* me, LPDIRECT3DMATERIAL* a, IUnknown* b);
224 * public: inline HRESULT CreateMaterial(LPDIRECT3DMATERIAL* a, IUnknown* b)
225 * { return ((IDirect3D*)t.lpVtbl)->fnCreateMaterial(this,a,b); };
226 * private: HRESULT (*fnCreateViewport)(IDirect3D* me, LPDIRECT3DVIEWPORT* a, IUnknown* b);
227 * public: inline HRESULT CreateViewport(LPDIRECT3DVIEWPORT* a, IUnknown* b)
228 * { return ((IDirect3D*)t.lpVtbl)->fnCreateViewport(this,a,b); };
229 * private: HRESULT (*fnFindDevice)(IDirect3D* me, LPD3DFINDDEVICESEARCH a, LPD3DFINDDEVICERESULT b);
230 * public: inline HRESULT FindDevice(LPD3DFINDDEVICESEARCH a, LPD3DFINDDEVICERESULT b)
231 * { return ((IDirect3D*)t.lpVtbl)->fnFindDevice(this,a,b); };
232 * };
234 * Comments:
235 * - In C++ IDirect3D does double duty as both the virtual/jump table and as the interface
236 * definition. The reason for this is to avoid having to duplicate the mehod definitions: once
237 * to have the function pointers in the jump table and once to have the methods in the interface
238 * class. Here one macro can generate both. This means though that the first pointer, t.lpVtbl
239 * defined in IUnknown, must be interpreted as the jump table pointer if we interpret the
240 * structure as the the interface class, and as the function pointer to the QueryInterface
241 * method, t.fnQueryInterface, if we interpret the structure as the jump table. Fortunately this
242 * gymnastic is entirely taken care of in the header of IUnknown.
243 * - Of course in C++ we use inheritance so that we don't have to duplicate the method definitions.
244 * - Since IDirect3D does double duty, each ICOM_METHOD macro defines both a function pointer and
245 * a non-vritual inline method which dereferences it and calls it. This way this method behaves
246 * just like a virtual method but does not create a true C++ virtual table which would break the
247 * structure layout. If you look at the implementation of these methods you'll notice that they
248 * would not work for void functions. We have to return something and fortunately this seems to
249 * be what all the COM methods do (otherwise we would need another set of macros).
250 * - Note how the ICOM_METHOD generates both function prototypes mixing types and formal parameter
251 * names and the method invocation using only the formal parameter name. This is the reason why
252 * we need different macros to handle different numbers of parameters.
253 * - Finally there is no IDirect3D_Xxx macro. These are not needed in C++ unless the CINTERFACE
254 * macro is defined in which case we would not be here.
255 * - This C++ code works well for code that just uses COM interfaces. But it will not work with
256 * C++ code implement a COM interface. That's because such code assumes the interface methods
257 * are declared as virtual C++ methods which is not the case here.
260 * Implementing a COM interface.
262 * This continues the above example. This example assumes that the implementation is in C.
264 * typedef struct _IDirect3D {
265 * void* lpVtbl;
266 * // ...
268 * } _IDirect3D;
270 * static ICOM_VTABLE(IDirect3D) d3dvt;
272 * // implement the IDirect3D methods here
274 * int IDirect3D_fnQueryInterface(IDirect3D* me)
276 * ICOM_THIS(IDirect3D,me);
277 * // ...
280 * // ...
282 * static ICOM_VTABLE(IDirect3D) d3dvt = {
283 * ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
284 * IDirect3D_fnQueryInterface,
285 * IDirect3D_fnAdd,
286 * IDirect3D_fnAdd2,
287 * IDirect3D_fnInitialize,
288 * IDirect3D_fnSetWidth
289 * };
291 * Comments:
292 * - We first define what the interface really contains. This is th e_IDirect3D structure. The
293 * first field must of course be the virtual table pointer. Everything else is free.
294 * - Then we predeclare our static virtual table variable, we will need its address in some
295 * methods to initialize the virtual table pointer of the returned interface objects.
296 * - Then we implement the interface methods. To match what has been declared in the header file
297 * they must take a pointer to a IDirect3D structure and we must cast it to an _IDirect3D so that
298 * we can manipulate the fields. This is performed by the ICOM_THIS macro.
299 * - Finally we initialize the virtual table.
303 #define ICOM_VTABLE(iface) iface##Vtbl
304 #define ICOM_VFIELD(iface) ICOM_VTABLE(iface)* lpVtbl
305 #define ICOM_VTBL(iface) (iface)->lpVtbl
308 #if !defined(__cplusplus) || defined(CINTERFACE)
309 #define ICOM_CINTERFACE 1
310 #endif
312 #ifndef ICOM_CINTERFACE
313 /* C++ interface */
315 #define ICOM_METHOD(ret,xfn) \
316 public: virtual ret CALLBACK (xfn)(void) = 0;
317 #define ICOM_METHOD1(ret,xfn,ta,na) \
318 public: virtual ret CALLBACK (xfn)(ta a) = 0;
319 #define ICOM_METHOD2(ret,xfn,ta,na,tb,nb) \
320 public: virtual ret CALLBACK (xfn)(ta a,tb b) = 0;
321 #define ICOM_METHOD3(ret,xfn,ta,na,tb,nb,tc,nc) \
322 public: virtual ret CALLBACK (xfn)(ta a,tb b,tc c) = 0;
323 #define ICOM_METHOD4(ret,xfn,ta,na,tb,nb,tc,nc,td,nd) \
324 public: virtual ret CALLBACK (xfn)(ta a,tb b,tc c,td d) = 0;
325 #define ICOM_METHOD5(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne) \
326 public: virtual ret CALLBACK (xfn)(ta a,tb b,tc c,td d,te e) = 0;
327 #define ICOM_METHOD6(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf) \
328 public: virtual ret CALLBACK (xfn)(ta a,tb b,tc c,td d,te e,tf f) = 0;
329 #define ICOM_METHOD7(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \
330 public: virtual ret CALLBACK (xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g) = 0;
331 #define ICOM_METHOD8(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh) \
332 public: virtual ret CALLBACK (xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g,th h) = 0;
333 #define ICOM_METHOD9(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni) \
334 public: virtual ret CALLBACK (xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i) = 0;
335 #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) \
336 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;
337 #define ICOM_METHOD11(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk) \
338 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,tk k) = 0;
341 #define ICOM_VMETHOD(xfn) \
342 public: virtual void CALLBACK (xfn)(void) = 0;
343 #define ICOM_VMETHOD1(xfn,ta,na) \
344 public: virtual void CALLBACK (xfn)(ta a) = 0;
345 #define ICOM_VMETHOD2(xfn,ta,na,tb,nb) \
346 public: virtual void CALLBACK (xfn)(ta a,tb b) = 0;
347 #define ICOM_VMETHOD3(xfn,ta,na,tb,nb,tc,nc) \
348 public: virtual void CALLBACK (xfn)(ta a,tb b,tc c) = 0;
349 #define ICOM_VMETHOD4(xfn,ta,na,tb,nb,tc,nc,td,nd) \
350 public: virtual void CALLBACK (xfn)(ta a,tb b,tc c,td d) = 0;
351 #define ICOM_VMETHOD5(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne) \
352 public: virtual void CALLBACK (xfn)(ta a,tb b,tc c,td d,te e) = 0;
353 #define ICOM_VMETHOD6(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf) \
354 public: virtual void CALLBACK (xfn)(ta a,tb b,tc c,td d,te e,tf f) = 0;
355 #define ICOM_VMETHOD7(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \
356 public: virtual void CALLBACK (xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g) = 0;
357 #define ICOM_VMETHOD8(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh) \
358 public: virtual void CALLBACK (xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g,th h) = 0;
359 #define ICOM_VMETHOD9(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni) \
360 public: virtual void CALLBACK (xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i) = 0;
361 #define ICOM_VMETHOD10(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj) \
362 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) = 0;
363 #define ICOM_VMETHOD11(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk) \
364 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) = 0;
367 #ifdef ICOM_USE_COM_INTERFACE_ATTRIBUTE
369 #define ICOM_DEFINE(iface,ibase) \
370 typedef struct iface: public ibase { \
371 iface##_METHODS \
372 } __attribute__ ((com_interface));
374 #else
376 #define ICOM_DEFINE(iface,ibase) \
377 typedef struct iface: public ibase { \
378 iface##_METHODS \
381 #endif /* ICOM_USE_COM_INTERFACE_ATTRIBUTE */
383 #define ICOM_CALL(xfn, p) (p)->xfn()
384 #define ICOM_CALL1(xfn, p,a) (p)->xfn(a)
385 #define ICOM_CALL2(xfn, p,a,b) (p)->xfn(a,b)
386 #define ICOM_CALL3(xfn, p,a,b,c) (p)->xfn(a,b,c)
387 #define ICOM_CALL4(xfn, p,a,b,c,d) (p)->xfn(a,b,c,d)
388 #define ICOM_CALL5(xfn, p,a,b,c,d,e) (p)->xfn(a,b,c,d,e)
389 #define ICOM_CALL6(xfn, p,a,b,c,d,e,f) (p)->xfn(a,b,c,d,e,f)
390 #define ICOM_CALL7(xfn, p,a,b,c,d,e,f,g) (p)->xfn(a,b,c,d,e,f,g)
391 #define ICOM_CALL8(xfn, p,a,b,c,d,e,f,g,h) (p)->xfn(a,b,c,d,e,f,g,h)
392 #define ICOM_CALL9(xfn, p,a,b,c,d,e,f,g,h,i) (p)->xfn(a,b,c,d,e,f,g,h,i)
393 #define ICOM_CALL10(xfn, p,a,b,c,d,e,f,g,h,i,j) (p)->xfn(a,b,c,d,e,f,g,h,i,j)
394 #define ICOM_CALL11(xfn, p,a,b,c,d,e,f,g,h,i,j,k) (p)->xfn(a,b,c,d,e,f,g,h,i,j,k)
397 #else
398 /* C interface */
401 #ifdef __WINE__
403 #define ICOM_METHOD(ret,xfn) \
404 ret CALLBACK (*fn##xfn)(ICOM_INTERFACE* me);
405 #define ICOM_METHOD1(ret,xfn,ta,na) \
406 ret CALLBACK (*fn##xfn)(ICOM_INTERFACE* me,ta a);
407 #define ICOM_METHOD2(ret,xfn,ta,na,tb,nb) \
408 ret CALLBACK (*fn##xfn)(ICOM_INTERFACE* me,ta a,tb b);
409 #define ICOM_METHOD3(ret,xfn,ta,na,tb,nb,tc,nc) \
410 ret CALLBACK (*fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c);
411 #define ICOM_METHOD4(ret,xfn,ta,na,tb,nb,tc,nc,td,nd) \
412 ret CALLBACK (*fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d);
413 #define ICOM_METHOD5(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne) \
414 ret CALLBACK (*fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e);
415 #define ICOM_METHOD6(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf) \
416 ret CALLBACK (*fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f);
417 #define ICOM_METHOD7(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \
418 ret CALLBACK (*fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g);
419 #define ICOM_METHOD8(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh) \
420 ret CALLBACK (*fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h);
421 #define ICOM_METHOD9(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni) \
422 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);
423 #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) \
424 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);
425 #define ICOM_METHOD11(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk) \
426 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,tk k);
428 #define ICOM_VMETHOD(xfn) \
429 void CALLBACK (*fn##xfn)(ICOM_INTERFACE* me);
430 #define ICOM_VMETHOD1(xfn,ta,na) \
431 void CALLBACK (*fn##xfn)(ICOM_INTERFACE* me,ta a);
432 #define ICOM_VMETHOD2(xfn,ta,na,tb,nb) \
433 void CALLBACK (*fn##xfn)(ICOM_INTERFACE* me,ta a,tb b);
434 #define ICOM_VMETHOD3(xfn,ta,na,tb,nb,tc,nc) \
435 void CALLBACK (*fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c);
436 #define ICOM_VMETHOD4(xfn,ta,na,tb,nb,tc,nc,td,nd) \
437 void CALLBACK (*fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d);
438 #define ICOM_VMETHOD5(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne) \
439 void CALLBACK (*fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e);
440 #define ICOM_VMETHOD6(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf) \
441 void CALLBACK (*fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f);
442 #define ICOM_VMETHOD7(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \
443 void CALLBACK (*fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g);
444 #define ICOM_VMETHOD8(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,nh) \
445 void CALLBACK (*fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h);
446 #define ICOM_VMETHOD9(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ni) \
447 void CALLBACK (*fn##xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i);
448 #define ICOM_VMETHOD10(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,nj) \
449 void 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);
450 #define ICOM_VMETHOD11(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,nk) \
451 void 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,tk k);
453 #define ICOM_CALL(xfn, p) ICOM_VTBL(p)->fn##xfn(p)
454 #define ICOM_CALL1(xfn, p,a) ICOM_VTBL(p)->fn##xfn(p,a)
455 #define ICOM_CALL2(xfn, p,a,b) ICOM_VTBL(p)->fn##xfn(p,a,b)
456 #define ICOM_CALL3(xfn, p,a,b,c) ICOM_VTBL(p)->fn##xfn(p,a,b,c)
457 #define ICOM_CALL4(xfn, p,a,b,c,d) ICOM_VTBL(p)->fn##xfn(p,a,b,c,d)
458 #define ICOM_CALL5(xfn, p,a,b,c,d,e) ICOM_VTBL(p)->fn##xfn(p,a,b,c,d,e)
459 #define ICOM_CALL6(xfn, p,a,b,c,d,e,f) ICOM_VTBL(p)->fn##xfn(p,a,b,c,d,e,f)
460 #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)
461 #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)
462 #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)
463 #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)
464 #define ICOM_CALL11(xfn, p,a,b,c,d,e,f,g,h,i,j,k) ICOM_VTBL(p)->fn##xfn(p,a,b,c,d,e,f,g,h,i,j,k)
466 #else
468 /* WINELIB case */
470 #define ICOM_METHOD(ret,xfn) \
471 ret CALLBACK (*xfn)(ICOM_INTERFACE* me);
472 #define ICOM_METHOD1(ret,xfn,ta,na) \
473 ret CALLBACK (*xfn)(ICOM_INTERFACE* me,ta a);
474 #define ICOM_METHOD2(ret,xfn,ta,na,tb,nb) \
475 ret CALLBACK (*xfn)(ICOM_INTERFACE* me,ta a,tb b);
476 #define ICOM_METHOD3(ret,xfn,ta,na,tb,nb,tc,nc) \
477 ret CALLBACK (*xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c);
478 #define ICOM_METHOD4(ret,xfn,ta,na,tb,nb,tc,nc,td,nd) \
479 ret CALLBACK (*xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d);
480 #define ICOM_METHOD5(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne) \
481 ret CALLBACK (*xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e);
482 #define ICOM_METHOD6(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf) \
483 ret CALLBACK (*xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f);
484 #define ICOM_METHOD7(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \
485 ret CALLBACK (*xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g);
486 #define ICOM_METHOD8(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh) \
487 ret CALLBACK (*xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h);
488 #define ICOM_METHOD9(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni) \
489 ret CALLBACK (*xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i);
490 #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) \
491 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);
492 #define ICOM_METHOD11(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk) \
493 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,tk k);
495 #define ICOM_VMETHOD(xfn) \
496 void CALLBACK (*xfn)(ICOM_INTERFACE* me);
497 #define ICOM_VMETHOD1(xfn,ta,na) \
498 void CALLBACK (*xfn)(ICOM_INTERFACE* me,ta a);
499 #define ICOM_VMETHOD2(xfn,ta,na,tb,nb) \
500 void CALLBACK (*xfn)(ICOM_INTERFACE* me,ta a,tb b);
501 #define ICOM_VMETHOD3(xfn,ta,na,tb,nb,tc,nc) \
502 void CALLBACK (*xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c);
503 #define ICOM_VMETHOD4(xfn,ta,na,tb,nb,tc,nc,td,nd) \
504 void CALLBACK (*xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d);
505 #define ICOM_VMETHOD5(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne) \
506 void CALLBACK (*xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e);
507 #define ICOM_VMETHOD6(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf) \
508 void CALLBACK (*xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f);
509 #define ICOM_VMETHOD7(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \
510 void CALLBACK (*xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g);
511 #define ICOM_VMETHOD8(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,nh) \
512 void CALLBACK (*xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h);
513 #define ICOM_VMETHOD9(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ni) \
514 void CALLBACK (*xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i);
515 #define ICOM_VMETHOD10(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,nj) \
516 void 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);
517 #define ICOM_VMETHOD11(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,nk) \
518 void 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,tk k);
520 #define ICOM_CVMETHOD(xfn) \
521 void CALLBACK (*xfn)(const ICOM_INTERFACE* me);
522 #define ICOM_CVMETHOD1(xfn,ta,na) \
523 void CALLBACK (*xfn)(const ICOM_INTERFACE* me,ta a);
524 #define ICOM_CVMETHOD2(xfn,ta,na,tb,nb) \
525 void CALLBACK (*xfn)(const ICOM_INTERFACE* me,ta a,tb b);
526 #define ICOM_CVMETHOD3(xfn,ta,na,tb,nb,tc,nc) \
527 void CALLBACK (*xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c);
528 #define ICOM_CVMETHOD4(xfn,ta,na,tb,nb,tc,nc,td,nd) \
529 void CALLBACK (*xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d);
530 #define ICOM_CVMETHOD5(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne) \
531 void CALLBACK (*xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e);
532 #define ICOM_CVMETHOD6(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf) \
533 void CALLBACK (*xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f);
534 #define ICOM_CVMETHOD7(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \
535 void CALLBACK (*xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g);
536 #define ICOM_CVMETHOD8(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh) \
537 void CALLBACK (*xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h);
539 #define ICOM_CVMETHOD9(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni) \
540 void CALLBACK (*xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i);
541 #define ICOM_CVMETHOD10(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj) \
542 void CALLBACK (*xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i,tj j);
543 #define ICOM_CVMETHOD11(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk) \
544 void CALLBACK (*xfn)(const ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i,tj j,tk k);
546 #define ICOM_CALL(xfn, p) ICOM_VTBL(p)->xfn(p)
547 #define ICOM_CALL1(xfn, p,a) ICOM_VTBL(p)->xfn(p,a)
548 #define ICOM_CALL2(xfn, p,a,b) ICOM_VTBL(p)->xfn(p,a,b)
549 #define ICOM_CALL3(xfn, p,a,b,c) ICOM_VTBL(p)->xfn(p,a,b,c)
550 #define ICOM_CALL4(xfn, p,a,b,c,d) ICOM_VTBL(p)->xfn(p,a,b,c,d)
551 #define ICOM_CALL5(xfn, p,a,b,c,d,e) ICOM_VTBL(p)->xfn(p,a,b,c,d,e)
552 #define ICOM_CALL6(xfn, p,a,b,c,d,e,f) ICOM_VTBL(p)->xfn(p,a,b,c,d,e,f)
553 #define ICOM_CALL7(xfn, p,a,b,c,d,e,f,g) ICOM_VTBL(p)->xfn(p,a,b,c,d,e,f,g)
554 #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)
555 #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)
556 #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)
557 #define ICOM_CALL11(xfn, p,a,b,c,d,e,f,g,h,i,j,k) ICOM_VTBL(p)->xfn(p,a,b,c,d,e,f,g,h,i,j,k)
559 #endif /* __WINE__ */
561 #ifdef ICOM_MSVTABLE_COMPAT
562 #define ICOM_DEFINE(iface,ibase) \
563 typedef struct ICOM_VTABLE(iface) ICOM_VTABLE(iface); \
564 struct iface { \
565 const ICOM_VFIELD(iface); \
566 }; \
567 struct ICOM_VTABLE(iface) { \
568 long dummyRTTI1; \
569 long dummyRTTI2; \
570 ibase##_IMETHODS \
571 iface##_METHODS \
573 #define ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE 0,0,
575 #else
576 #define ICOM_DEFINE(iface,ibase) \
577 typedef struct ICOM_VTABLE(iface) ICOM_VTABLE(iface); \
578 struct iface { \
579 const ICOM_VFIELD(iface); \
580 }; \
581 struct ICOM_VTABLE(iface) { \
582 ibase##_IMETHODS \
583 iface##_METHODS \
585 #define ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
586 #endif /* ICOM_MSVTABLE_COMPAT */
589 #define ICOM_THIS(impl,iface) impl* const This=(impl*)iface
590 #define ICOM_CTHIS(impl,iface) const impl* const This=(const impl*)iface
592 #endif
595 /*****************************************************************************
596 * Predeclare the interfaces
598 DEFINE_OLEGUID(IID_IClassFactory, 0x00000001L, 0, 0);
599 typedef struct IClassFactory IClassFactory, *LPCLASSFACTORY;
601 DEFINE_OLEGUID(IID_IMalloc, 0x00000002L, 0, 0);
602 typedef struct IMalloc IMalloc,*LPMALLOC;
604 DEFINE_OLEGUID(IID_IUnknown, 0x00000000L, 0, 0);
605 typedef struct IUnknown IUnknown, *LPUNKNOWN;
608 /*****************************************************************************
609 * IUnknown interface
611 #define ICOM_INTERFACE IUnknown
612 #define IUnknown_IMETHODS \
613 ICOM_METHOD2(HRESULT,QueryInterface,REFIID,riid, LPVOID*,ppvObj) \
614 ICOM_METHOD (ULONG,AddRef) \
615 ICOM_METHOD (ULONG,Release)
616 #ifdef ICOM_CINTERFACE
617 typedef struct ICOM_VTABLE(IUnknown) ICOM_VTABLE(IUnknown);
618 struct IUnknown {
619 ICOM_VFIELD(IUnknown);
620 #if defined(ICOM_USE_COM_INTERFACE_ATTRIBUTE)
621 } __attribute__ ((com_interface));
622 #else
624 #endif /* ICOM_US_COM_INTERFACE_ATTRIBUTE */
626 struct ICOM_VTABLE(IUnknown) {
627 #ifdef ICOM_MSVTABLE_COMPAT
628 long dummyRTTI1;
629 long dummyRTTI2;
630 #endif /* ICOM_MSVTABLE_COMPAT */
632 #else /* ICOM_CINTERFACE */
633 struct IUnknown {
635 #endif /* ICOM_CINTERFACE */
637 ICOM_METHOD2(HRESULT,QueryInterface,REFIID,riid, LPVOID*,ppvObj)
638 ICOM_METHOD (ULONG,AddRef)
639 ICOM_METHOD (ULONG,Release)
640 #if defined(ICOM_USE_COM_INTERFACE_ATTRIBUTE)
641 } __attribute__ ((com_interface));
642 #else
644 #endif /* ICOM_US_COM_INTERFACE_ATTRIBUTE */
646 #undef ICOM_INTERFACE
648 /*** IUnknown methods ***/
649 #define IUnknown_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b)
650 #define IUnknown_AddRef(p) ICOM_CALL (AddRef,p)
651 #define IUnknown_Release(p) ICOM_CALL (Release,p)
653 /*****************************************************************************
654 * IClassFactory interface
656 #define ICOM_INTERFACE IClassFactory
657 #define IClassFactory_METHODS \
658 ICOM_METHOD3(HRESULT,CreateInstance, LPUNKNOWN,pUnkOuter, REFIID,riid, LPVOID*,ppvObject) \
659 ICOM_METHOD1(HRESULT,LockServer, BOOL,fLock)
660 #define IClassFactory_IMETHODS \
661 IUnknown_IMETHODS \
662 IClassFactory_METHODS
663 ICOM_DEFINE(IClassFactory,IUnknown)
664 #undef ICOM_INTERFACE
666 /*** IUnknown methods ***/
667 #define IClassFactory_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b)
668 #define IClassFactory_AddRef(p) ICOM_CALL (AddRef,p)
669 #define IClassFactory_Release(p) ICOM_CALL (Release,p)
670 /*** IClassFactory methods ***/
671 #define IClassFactory_CreateInstance(p,a,b,c) ICOM_CALL3(CreateInstance,p,a,b,c)
672 #define IClassFactory_LockServer(p,a) ICOM_CALL1(LockServer,p,a)
675 /*****************************************************************************
676 * IMalloc interface
678 #define ICOM_INTERFACE IMalloc
679 #define IMalloc_METHODS \
680 ICOM_METHOD1 (LPVOID,Alloc, DWORD,cb) \
681 ICOM_METHOD2 (LPVOID,Realloc, LPVOID,pv, DWORD,cb) \
682 ICOM_VMETHOD1( Free, LPVOID,pv) \
683 ICOM_METHOD1(DWORD, GetSize, LPVOID,pv) \
684 ICOM_METHOD1(INT, DidAlloc, LPVOID,pv) \
685 ICOM_METHOD (VOID, HeapMinimize)
686 #define IMalloc_IMETHODS \
687 IUnknown_IMETHODS \
688 IMalloc_METHODS
689 ICOM_DEFINE(IMalloc,IUnknown)
690 #undef ICOM_INTERFACE
692 /*** IUnknown methods ***/
693 #define IMalloc_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b)
694 #define IMalloc_AddRef(p) ICOM_CALL (AddRef,p)
695 #define IMalloc_Release(p) ICOM_CALL (Release,p)
696 /*** IMalloc32 methods ***/
697 #define IMalloc_Alloc(p,a) ICOM_CALL1(Alloc,p,a)
698 #define IMalloc_Realloc(p,a,b) ICOM_CALL2(Realloc,p,a,b)
699 #define IMalloc_Free(p,a) ICOM_CALL1(Free,p,a)
700 #define IMalloc_GetSize(p,a) ICOM_CALL1(GetSize,p,a)
701 #define IMalloc_DidAlloc(p,a) ICOM_CALL1(DidAlloc,p,a)
702 #define IMalloc_HeapMinimize(p) ICOM_CALL (HeapMinimize,p)
704 /* values passed to CoGetMalloc */
705 #define MEMCTX_TASK 1 /* private task memory */
706 #define MEMCTX_SHARED 2 /* shared memory */
707 #ifdef _MAC
708 #define MEMCTX_MACSYSTEM 3 /* system heap on mac */
709 #endif
710 /* mainly for internal use... */
711 #define MEMCTX_UNKNOWN -1
712 #define MEMCTX_SAME -2
714 HRESULT WINAPI CoGetMalloc(DWORD dwMemContext,LPMALLOC* lpMalloc);
716 LPVOID WINAPI CoTaskMemAlloc(ULONG size);
718 void WINAPI CoTaskMemFree(LPVOID ptr);
720 /* FIXME: unimplemented */
721 LPVOID WINAPI CoTaskMemRealloc(LPVOID ptr, ULONG size);
724 /*****************************************************************************
725 * Additional API
728 HRESULT WINAPI CoCreateGuid(GUID* pguid);
730 HINSTANCE WINAPI CoLoadLibrary(LPOLESTR lpszLibName, BOOL bAutoFree);
732 void WINAPI CoFreeAllLibraries(void);
734 void WINAPI CoFreeLibrary(HINSTANCE hLibrary);
736 void WINAPI CoFreeUnusedLibraries(void);
738 HRESULT WINAPI CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv);
740 HRESULT WINAPI CoGetClassObject(REFCLSID rclsid, DWORD dwClsContext, LPVOID pvReserved, REFIID iid, LPVOID *ppv);
742 HRESULT WINAPI CoInitialize(LPVOID lpReserved);
743 HRESULT WINAPI CoInitializeEx(LPVOID lpReserved, DWORD dwCoInit);
745 void WINAPI CoUninitialize(void);
747 typedef enum tagCOINIT
749 COINIT_APARTMENTTHREADED = 0x2, /* Apartment model */
750 COINIT_MULTITHREADED = 0x0, /* OLE calls objects on any thread */
751 COINIT_DISABLE_OLE1DDE = 0x4, /* Don't use DDE for Ole1 support */
752 COINIT_SPEED_OVER_MEMORY = 0x8 /* Trade memory for speed */
753 } COINIT;
756 /* FIXME: not implemented */
757 BOOL WINAPI CoIsOle1Class(REFCLSID rclsid);
759 HRESULT WINAPI CoLockObjectExternal(LPUNKNOWN pUnk, BOOL fLock, BOOL fLastUnlockReleases);
761 /* class registration flags; passed to CoRegisterClassObject */
762 typedef enum tagREGCLS
764 REGCLS_SINGLEUSE = 0,
765 REGCLS_MULTIPLEUSE = 1,
766 REGCLS_MULTI_SEPARATE = 2,
767 REGCLS_SUSPENDED = 4
768 } REGCLS;
770 HRESULT WINAPI CoRegisterClassObject(REFCLSID rclsid,LPUNKNOWN pUnk,DWORD dwClsContext,DWORD flags,LPDWORD lpdwRegister);
772 HRESULT WINAPI CoRevokeClassObject(DWORD dwRegister);
774 /*****************************************************************************
775 * COM Server dll - exports
777 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID * ppv);
778 HRESULT WINAPI DllCanUnloadNow(void);
780 #ifdef __cplusplus
781 } /* extern "C" */
782 #endif
784 #endif /* __WINE_WINE_OBJ_BASE_H */