Added ICOM_METHOD12-26, ICOM_VMETHOD12-26, ICOM_CALL12-26.
[wine] / include / wine / obj_base.h
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  */
5
6 #ifndef __WINE_WINE_OBJ_BASE_H
7 #define __WINE_WINE_OBJ_BASE_H
8
9 /*****************************************************************************
10  * define ICOM_MSVTABLE_COMPAT
11  * to implement the microsoft com vtable compatibility workaround for g++.
12  *
13  * NOTE: Turning this option on will produce a winelib that is incompatible
14  * with the binary emulator.
15  *
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++.
19  *
20  * If you aren't interested in Winelib C++ compatibility at all, leave both
21  * options off.
22  *
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 :)
27  */
28 /* #define ICOM_MSVTABLE_COMPAT 1 */
29 /* #define ICOM_USE_COM_INTERFACE_ATTRIBUTE 1 */
30
31 /*****************************************************************************
32  * Defines the basic types
33  */
34 #include "wtypes.h"
35 #include "guiddef.h"
36
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40
41
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
49
50 /*****************************************************************************
51  * GUID API
52  */
53 HRESULT WINAPI StringFromCLSID16(REFCLSID id, LPOLESTR16*);
54 HRESULT WINAPI StringFromCLSID(REFCLSID id, LPOLESTR*);
55
56 HRESULT WINAPI CLSIDFromString16(LPCOLESTR16, CLSID *);
57 HRESULT WINAPI CLSIDFromString(LPCOLESTR, CLSID *);
58
59 HRESULT WINAPI CLSIDFromProgID16(LPCOLESTR16 progid, LPCLSID riid);
60 HRESULT WINAPI CLSIDFromProgID(LPCOLESTR progid, LPCLSID riid);
61
62 HRESULT WINAPI ProgIDFromCLSID(REFCLSID clsid, LPOLESTR *lplpszProgID);
63
64
65 INT WINAPI StringFromGUID2(REFGUID id, LPOLESTR str, INT cmax);
66
67
68 /*****************************************************************************
69  * Macros to define a COM interface
70  */
71 /*
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.
77  *
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.
82  *
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.
90  *
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.
93  *
94  * Let's take Direct3D as an example:
95  *
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
109  *
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
123  *
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.
161  *
162  *
163  * In C this gives:
164  *    typedef struct IDirect3DVtbl IDirect3DVtbl;
165  *    struct IDirect3D {
166  *        IDirect3DVtbl* lpVtbl;
167  *    };
168  *    struct IDirect3DVtbl {
169  *        HRESULT (*QueryInterface)(IDirect3D* me, REFIID riid, LPVOID* ppvObj);
170  *        ULONG (*QueryInterface)(IDirect3D* me);
171  *        ULONG (*QueryInterface)(IDirect3D* me);
172  *        HRESULT (*Initialize)(IDirect3D* me, REFIID a);
173  *        HRESULT (*EnumDevices)(IDirect3D* me, LPD3DENUMDEVICESCALLBACK a, LPVOID b);
174  *        HRESULT (*CreateLight)(IDirect3D* me, LPDIRECT3DLIGHT* a, IUnknown* b);
175  *        HRESULT (*CreateMaterial)(IDirect3D* me, LPDIRECT3DMATERIAL* a, IUnknown* b);
176  *        HRESULT (*CreateViewport)(IDirect3D* me, LPDIRECT3DVIEWPORT* a, IUnknown* b);
177  *        HRESULT (*FindDevice)(IDirect3D* me, LPD3DFINDDEVICESEARCH a, LPD3DFINDDEVICERESULT b);
178  *    }; 
179  *
180  *    #ifdef ICOM_CINTERFACE
181  *    // *** IUnknown methods *** //
182  *    #define IDirect3D_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
183  *    #define IDirect3D_AddRef(p)             (p)->lpVtbl->AddRef(p)
184  *    #define IDirect3D_Release(p)            (p)->lpVtbl->Release(p)
185  *    // *** IDirect3D methods *** //
186  *    #define IDirect3D_Initialize(p,a)       (p)->lpVtbl->Initialize(p,a)
187  *    #define IDirect3D_EnumDevices(p,a,b)    (p)->lpVtbl->EnumDevice(p,a,b)
188  *    #define IDirect3D_CreateLight(p,a,b)    (p)->lpVtbl->CreateLight(p,a,b)
189  *    #define IDirect3D_CreateMaterial(p,a,b) (p)->lpVtbl->CreateMaterial(p,a,b)
190  *    #define IDirect3D_CreateViewport(p,a,b) (p)->lpVtbl->CreateViewport(p,a,b)
191  *    #define IDirect3D_FindDevice(p,a,b)     (p)->lpVtbl->FindDevice(p,a,b)
192  *    #endif
193  *
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.
210  *
211  *
212  * And in C++ (with gcc's g++):
213  *
214  *    typedef struct IDirect3D: public IUnknown {
215  *        private: HRESULT (*Initialize)(IDirect3D* me, REFIID a);
216  *        public: inline HRESULT Initialize(REFIID a) { return ((IDirect3D*)t.lpVtbl)->Initialize(this,a); };
217  *        private: HRESULT (*EnumDevices)(IDirect3D* me, LPD3DENUMDEVICESCALLBACK a, LPVOID b);
218  *        public: inline HRESULT EnumDevices(LPD3DENUMDEVICESCALLBACK a, LPVOID b)
219  *            { return ((IDirect3D*)t.lpVtbl)->EnumDevices(this,a,b); };
220  *        private: HRESULT (*freateLight)(IDirect3D* me, LPDIRECT3DLIGHT* a, IUnknown* b);
221  *        public: inline HRESULT CreateLight(LPDIRECT3DLIGHT* a, IUnknown* b)
222  *            { return ((IDirect3D*)t.lpVtbl)->CreateLight(this,a,b); };
223  *        private: HRESULT (*CreateMaterial)(IDirect3D* me, LPDIRECT3DMATERIAL* a, IUnknown* b);
224  *        public: inline HRESULT CreateMaterial(LPDIRECT3DMATERIAL* a, IUnknown* b)
225  *            { return ((IDirect3D*)t.lpVtbl)->CreateMaterial(this,a,b); };
226  *        private: HRESULT (*CreateViewport)(IDirect3D* me, LPDIRECT3DVIEWPORT* a, IUnknown* b);
227  *        public: inline HRESULT CreateViewport(LPDIRECT3DVIEWPORT* a, IUnknown* b)
228  *            { return ((IDirect3D*)t.lpVtbl)->CreateViewport(this,a,b); };
229  *        private:  HRESULT (*FindDevice)(IDirect3D* me, LPD3DFINDDEVICESEARCH a, LPD3DFINDDEVICERESULT b);
230  *        public: inline HRESULT FindDevice(LPD3DFINDDEVICESEARCH a, LPD3DFINDDEVICERESULT b)
231  *            { return ((IDirect3D*)t.lpVtbl)->FindDevice(this,a,b); };
232  *    }; 
233  *
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.QueryInterface, 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.
258  *
259  *
260  * Implementing a COM interface.
261  *
262  * This continues the above example. This example assumes that the implementation is in C.
263  *
264  *    typedef struct _IDirect3D {
265  *        void* lpVtbl;
266  *        // ...
267  *
268  *    } _IDirect3D;
269  *
270  *    static ICOM_VTABLE(IDirect3D) d3dvt;
271  *
272  *    // implement the IDirect3D methods here
273  *
274  *    int IDirect3D_QueryInterface(IDirect3D* me)
275  *    {
276  *        ICOM_THIS(IDirect3D,me);
277  *        // ...
278  *    }
279  *
280  *    // ...
281  *
282  *    static ICOM_VTABLE(IDirect3D) d3dvt = {
283  *        ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
284  *        IDirect3D_QueryInterface,
285  *        IDirect3D_Add,
286  *        IDirect3D_Add2,
287  *        IDirect3D_Initialize,
288  *        IDirect3D_SetWidth
289  *    };
290  *
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.
300  */
301
302
303
304 #if !defined(__cplusplus) || defined(CINTERFACE)
305 #define ICOM_CINTERFACE 1
306 #endif
307
308 #ifndef ICOM_CINTERFACE
309 /* C++ interface */
310
311 #define ICOM_METHOD(ret,xfn) \
312      public: virtual ret CALLBACK (xfn)(void) = 0;
313 #define ICOM_METHOD1(ret,xfn,ta,na) \
314      public: virtual ret CALLBACK (xfn)(ta a) = 0;
315 #define ICOM_METHOD2(ret,xfn,ta,na,tb,nb) \
316      public: virtual ret CALLBACK (xfn)(ta a,tb b) = 0;
317 #define ICOM_METHOD3(ret,xfn,ta,na,tb,nb,tc,nc) \
318      public: virtual ret CALLBACK (xfn)(ta a,tb b,tc c) = 0;
319 #define ICOM_METHOD4(ret,xfn,ta,na,tb,nb,tc,nc,td,nd) \
320      public: virtual ret CALLBACK (xfn)(ta a,tb b,tc c,td d) = 0;
321 #define ICOM_METHOD5(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne) \
322      public: virtual ret CALLBACK (xfn)(ta a,tb b,tc c,td d,te e) = 0;
323 #define ICOM_METHOD6(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf) \
324      public: virtual ret CALLBACK (xfn)(ta a,tb b,tc c,td d,te e,tf f) = 0;
325 #define ICOM_METHOD7(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \
326      public: virtual ret CALLBACK (xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g) = 0;
327 #define ICOM_METHOD8(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh) \
328      public: virtual ret CALLBACK (xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g,th h) = 0;
329 #define ICOM_METHOD9(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni) \
330      public: virtual ret CALLBACK (xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i) = 0;
331 #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) \
332      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;
333 #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) \
334      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;
335 #define ICOM_METHOD12(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl) \
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,tk k,tl l) = 0;
337 #define ICOM_METHOD13(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl,tm,nm) \
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,tl l,tm m) = 0;
339 #define ICOM_METHOD14(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl,tm,nm,tn,nn) \
340     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,tl l,tm m,tn n) = 0;
341 #define ICOM_METHOD15(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl,tm,nm,tn,nn,to,no) \
342     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,tl l,tm m,tn n,to o) = 0;
343 #define ICOM_METHOD16(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl,tm,nm,tn,nn,to,no,tp,np) \
344     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,tl l,tm m,tn n,to o,tp p) = 0;
345 #define ICOM_METHOD17(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl,tm,nm,tn,nn,to,no,tp,np,tq,nq) \
346     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,tl l,tm m,tn n,to o,tp p,tq q) = 0;
347 #define ICOM_METHOD18(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl,tm,nm,tn,nn,to,no,tp,np,tq,nq,tr,nr) \
348     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,tl l,tm m,tn n,to o,tp p,tq q,tr r) = 0;
349 #define ICOM_METHOD19(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl,tm,nm,tn,nn,to,no,tp,np,tq,nq,tr,nr,ts,ns) \
350     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,tl l,tm m,tn n,to o,tp p,tq q,tr r,ts s) = 0;
351 #define ICOM_METHOD20(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl,tm,nm,tn,nn,to,no,tp,np,tq,nq,tr,nr,ts,ns,tt,nt) \
352     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,tl l,tm m,tn n,to o,tp p,tq q,tr r,ts s,tt t) = 0;
353 #define ICOM_METHOD21(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl,tm,nm,tn,nn,to,no,tp,np,tq,nq,tr,nr,ts,ns,tt,nt,tu,nu) \
354     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,tl l,tm m,tn n,to o,tp p,tq q,tr r,ts s,tt t,tu u) = 0;
355 #define ICOM_METHOD22(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl,tm,nm,tn,nn,to,no,tp,np,tq,nq,tr,nr,ts,ns,tt,nt,tu,nu,tv,nv) \
356     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,tl l,tm m,tn n,to o,tp p,tq q,tr r,ts s,tt t,tu u,tv v) = 0;
357 #define ICOM_METHOD23(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl,tm,nm,tn,nn,to,no,tp,np,tq,nq,tr,nr,ts,ns,tt,nt,tu,nu,tv,nv,tw,nw) \
358     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,tl l,tm m,tn n,to o,tp p,tq q,tr r,ts s,tt t,tu u,tv v,tw w) = 0;
359 #define ICOM_METHOD24(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl,tm,nm,tn,nn,to,no,tp,np,tq,nq,tr,nr,ts,ns,tt,nt,tu,nu,tv,nv,tw,nw,tx,nx) \
360     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,tl l,tm m,tn n,to o,tp p,tq q,tr r,ts s,tt t,tu u,tv v,tw w,tx x) = 0;
361 #define ICOM_METHOD25(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl,tm,nm,tn,nn,to,no,tp,np,tq,nq,tr,nr,ts,ns,tt,nt,tu,nu,tv,nv,tw,nw,tx,nx,ty,ny) \
362     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,tl l,tm m,tn n,to o,tp p,tq q,tr r,ts s,tt t,tu u,tv v,tw w,tx x,ty y) = 0;
363 #define ICOM_METHOD26(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl,tm,nm,tn,nn,to,no,tp,np,tq,nq,tr,nr,ts,ns,tt,nt,tu,nu,tv,nv,tw,nw,tx,nx,ty,ny,tz,nz) \
364     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,tl l,tm m,tn n,to o,tp p,tq q,tr r,ts s,tt t,tu u,tv v,tw w,tx x,ty y,tz z) = 0;
365
366
367 #define ICOM_VMETHOD(xfn) \
368      public: virtual void CALLBACK (xfn)(void) = 0;
369 #define ICOM_VMETHOD1(xfn,ta,na) \
370      public: virtual void CALLBACK (xfn)(ta a) = 0;
371 #define ICOM_VMETHOD2(xfn,ta,na,tb,nb) \
372      public: virtual void CALLBACK (xfn)(ta a,tb b) = 0;
373 #define ICOM_VMETHOD3(xfn,ta,na,tb,nb,tc,nc) \
374      public: virtual void CALLBACK (xfn)(ta a,tb b,tc c) = 0;
375 #define ICOM_VMETHOD4(xfn,ta,na,tb,nb,tc,nc,td,nd) \
376      public: virtual void CALLBACK (xfn)(ta a,tb b,tc c,td d) = 0;
377 #define ICOM_VMETHOD5(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne) \
378      public: virtual void CALLBACK (xfn)(ta a,tb b,tc c,td d,te e) = 0;
379 #define ICOM_VMETHOD6(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf) \
380      public: virtual void CALLBACK (xfn)(ta a,tb b,tc c,td d,te e,tf f) = 0;
381 #define ICOM_VMETHOD7(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \
382      public: virtual void CALLBACK (xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g) = 0;
383 #define ICOM_VMETHOD8(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh) \
384      public: virtual void CALLBACK (xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g,th h) = 0;
385 #define ICOM_VMETHOD9(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni) \
386      public: virtual void CALLBACK (xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i) = 0;
387 #define ICOM_VMETHOD10(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj) \
388      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;
389 #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) \
390      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;
391 #define ICOM_VMETHOD12(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl) \
392     public: virtual void CALLBACK (xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i,tj j,tk k,tl l) = 0;
393 #define ICOM_VMETHOD13(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl,tm,nm) \
394     public: virtual void CALLBACK (xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i,tj j,tk k,tl l,tm m) = 0;
395 #define ICOM_VMETHOD14(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl,tm,nm,tn,nn) \
396     public: virtual void CALLBACK (xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i,tj j,tk k,tl l,tm m,tn n) = 0;
397 #define ICOM_VMETHOD15(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl,tm,nm,tn,nn,to,no) \
398     public: virtual void CALLBACK (xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i,tj j,tk k,tl l,tm m,tn n,to o) = 0;
399 #define ICOM_VMETHOD16(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl,tm,nm,tn,nn,to,no,tp,np) \
400     public: virtual void CALLBACK (xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i,tj j,tk k,tl l,tm m,tn n,to o,tp p) = 0;
401 #define ICOM_VMETHOD17(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl,tm,nm,tn,nn,to,no,tp,np,tq,nq) \
402     public: virtual void CALLBACK (xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i,tj j,tk k,tl l,tm m,tn n,to o,tp p,tq q) = 0;
403 #define ICOM_VMETHOD18(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl,tm,nm,tn,nn,to,no,tp,np,tq,nq,tr,nr) \
404     public: virtual void CALLBACK (xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i,tj j,tk k,tl l,tm m,tn n,to o,tp p,tq q,tr r) = 0;
405 #define ICOM_VMETHOD19(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl,tm,nm,tn,nn,to,no,tp,np,tq,nq,tr,nr,ts,ns) \
406     public: virtual void CALLBACK (xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i,tj j,tk k,tl l,tm m,tn n,to o,tp p,tq q,tr r,ts s) = 0;
407 #define ICOM_VMETHOD20(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl,tm,nm,tn,nn,to,no,tp,np,tq,nq,tr,nr,ts,ns,tt,nt) \
408     public: virtual void CALLBACK (xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i,tj j,tk k,tl l,tm m,tn n,to o,tp p,tq q,tr r,ts s,tt t) = 0;
409 #define ICOM_VMETHOD21(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl,tm,nm,tn,nn,to,no,tp,np,tq,nq,tr,nr,ts,ns,tt,nt,tu,nu) \
410     public: virtual void CALLBACK (xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i,tj j,tk k,tl l,tm m,tn n,to o,tp p,tq q,tr r,ts s,tt t,tu u) = 0;
411 #define ICOM_VMETHOD22(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl,tm,nm,tn,nn,to,no,tp,np,tq,nq,tr,nr,ts,ns,tt,nt,tu,nu,tv,nv) \
412     public: virtual void CALLBACK (xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i,tj j,tk k,tl l,tm m,tn n,to o,tp p,tq q,tr r,ts s,tt t,tu u,tv v) = 0;
413 #define ICOM_VMETHOD23(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl,tm,nm,tn,nn,to,no,tp,np,tq,nq,tr,nr,ts,ns,tt,nt,tu,nu,tv,nv,tw,nw) \
414     public: virtual void CALLBACK (xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i,tj j,tk k,tl l,tm m,tn n,to o,tp p,tq q,tr r,ts s,tt t,tu u,tv v,tw w) = 0;
415 #define ICOM_VMETHOD24(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl,tm,nm,tn,nn,to,no,tp,np,tq,nq,tr,nr,ts,ns,tt,nt,tu,nu,tv,nv,tw,nw,tx,nx) \
416     public: virtual void CALLBACK (xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i,tj j,tk k,tl l,tm m,tn n,to o,tp p,tq q,tr r,ts s,tt t,tu u,tv v,tw w,tx x) = 0;
417 #define ICOM_VMETHOD25(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl,tm,nm,tn,nn,to,no,tp,np,tq,nq,tr,nr,ts,ns,tt,nt,tu,nu,tv,nv,tw,nw,tx,nx,ty,ny) \
418     public: virtual void CALLBACK (xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i,tj j,tk k,tl l,tm m,tn n,to o,tp p,tq q,tr r,ts s,tt t,tu u,tv v,tw w,tx x,ty y) = 0;
419 #define ICOM_VMETHOD26(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl,tm,nm,tn,nn,to,no,tp,np,tq,nq,tr,nr,ts,ns,tt,nt,tu,nu,tv,nv,tw,nw,tx,nx,ty,ny,tz,nz) \
420     public: virtual void CALLBACK (xfn)(ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i,tj j,tk k,tl l,tm m,tn n,to o,tp p,tq q,tr r,ts s,tt t,tu u,tv v,tw w,tx x,ty y,tz z) = 0;
421
422
423 #ifdef ICOM_USE_COM_INTERFACE_ATTRIBUTE
424
425 #define ICOM_DEFINE(iface,ibase) \
426     typedef struct iface: public ibase { \
427         iface##_METHODS \
428             } __attribute__ ((com_interface));
429
430 #else
431
432 #define ICOM_DEFINE(iface,ibase) \
433     typedef struct iface: public ibase { \
434         iface##_METHODS \
435     };
436
437 #endif /* ICOM_USE_COM_INTERFACE_ATTRIBUTE */
438
439 #define ICOM_VTBL(iface)         (iface)
440
441 #else
442 /* C interface */
443
444 #define ICOM_METHOD(ret,xfn) \
445     ret CALLBACK (*xfn)(ICOM_INTERFACE* me);
446 #define ICOM_METHOD1(ret,xfn,ta,na) \
447     ret CALLBACK (*xfn)(ICOM_INTERFACE* me,ta a);
448 #define ICOM_METHOD2(ret,xfn,ta,na,tb,nb) \
449     ret CALLBACK (*xfn)(ICOM_INTERFACE* me,ta a,tb b);
450 #define ICOM_METHOD3(ret,xfn,ta,na,tb,nb,tc,nc) \
451     ret CALLBACK (*xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c);
452 #define ICOM_METHOD4(ret,xfn,ta,na,tb,nb,tc,nc,td,nd) \
453     ret CALLBACK (*xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d);
454 #define ICOM_METHOD5(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne) \
455     ret CALLBACK (*xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e);
456 #define ICOM_METHOD6(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf) \
457     ret CALLBACK (*xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f);
458 #define ICOM_METHOD7(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \
459     ret CALLBACK (*xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g);
460 #define ICOM_METHOD8(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh) \
461     ret CALLBACK (*xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h);
462 #define ICOM_METHOD9(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni) \
463     ret CALLBACK (*xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h,ti i);
464 #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) \
465     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);
466 #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) \
467     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);
468 #define ICOM_METHOD12(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl) \
469     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,tl l);
470 #define ICOM_METHOD13(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl,tm,nm) \
471     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,tl l,tm m);
472 #define ICOM_METHOD14(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl,tm,nm,tn,nn) \
473     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,tl l,tm m,tn n);
474 #define ICOM_METHOD15(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl,tm,nm,tn,nn,to,no) \
475     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,tl l,tm m,tn n,to o);
476 #define ICOM_METHOD16(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl,tm,nm,tn,nn,to,no,tp,np) \
477     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,tl l,tm m,tn n,to o,tp p);
478 #define ICOM_METHOD17(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl,tm,nm,tn,nn,to,no,tp,np,tq,nq) \
479     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,tl l,tm m,tn n,to o,tp p,tq q);
480 #define ICOM_METHOD18(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl,tm,nm,tn,nn,to,no,tp,np,tq,nq,tr,nr) \
481     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,tl l,tm m,tn n,to o,tp p,tq q,tr r);
482 #define ICOM_METHOD19(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl,tm,nm,tn,nn,to,no,tp,np,tq,nq,tr,nr,ts,ns) \
483     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,tl l,tm m,tn n,to o,tp p,tq q,tr r,ts s);
484 #define ICOM_METHOD20(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl,tm,nm,tn,nn,to,no,tp,np,tq,nq,tr,nr,ts,ns,tt,nt) \
485     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,tl l,tm m,tn n,to o,tp p,tq q,tr r,ts s,tt t);
486 #define ICOM_METHOD21(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl,tm,nm,tn,nn,to,no,tp,np,tq,nq,tr,nr,ts,ns,tt,nt,tu,nu) \
487     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,tl l,tm m,tn n,to o,tp p,tq q,tr r,ts s,tt t,tu u);
488 #define ICOM_METHOD22(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl,tm,nm,tn,nn,to,no,tp,np,tq,nq,tr,nr,ts,ns,tt,nt,tu,nu,tv,nv) \
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,tj j,tk k,tl l,tm m,tn n,to o,tp p,tq q,tr r,ts s,tt t,tu u,tv v);
490 #define ICOM_METHOD23(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl,tm,nm,tn,nn,to,no,tp,np,tq,nq,tr,nr,ts,ns,tt,nt,tu,nu,tv,nv,tw,nw) \
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,tk k,tl l,tm m,tn n,to o,tp p,tq q,tr r,ts s,tt t,tu u,tv v,tw w);
492 #define ICOM_METHOD24(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl,tm,nm,tn,nn,to,no,tp,np,tq,nq,tr,nr,ts,ns,tt,nt,tu,nu,tv,nv,tw,nw,tx,nx) \
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,tl l,tm m,tn n,to o,tp p,tq q,tr r,ts s,tt t,tu u,tv v,tw w,tx x);
494 #define ICOM_METHOD25(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl,tm,nm,tn,nn,to,no,tp,np,tq,nq,tr,nr,ts,ns,tt,nt,tu,nu,tv,nv,tw,nw,tx,nx,ty,ny) \
495     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,tl l,tm m,tn n,to o,tp p,tq q,tr r,ts s,tt t,tu u,tv v,tw w,tx x,ty y);
496 #define ICOM_METHOD26(ret,xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl,tm,nm,tn,nn,to,no,tp,np,tq,nq,tr,nr,ts,ns,tt,nt,tu,nu,tv,nv,tw,nw,tx,nx,ty,ny,tz,nz) \
497     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,tl l,tm m,tn n,to o,tp p,tq q,tr r,ts s,tt t,tu u,tv v,tw w,tx x,ty y,tz z);
498
499 #define ICOM_VMETHOD(xfn) \
500     void CALLBACK (*xfn)(ICOM_INTERFACE* me);
501 #define ICOM_VMETHOD1(xfn,ta,na) \
502     void CALLBACK (*xfn)(ICOM_INTERFACE* me,ta a);
503 #define ICOM_VMETHOD2(xfn,ta,na,tb,nb) \
504     void CALLBACK (*xfn)(ICOM_INTERFACE* me,ta a,tb b);
505 #define ICOM_VMETHOD3(xfn,ta,na,tb,nb,tc,nc) \
506     void CALLBACK (*xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c);
507 #define ICOM_VMETHOD4(xfn,ta,na,tb,nb,tc,nc,td,nd) \
508     void CALLBACK (*xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d);
509 #define ICOM_VMETHOD5(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne) \
510     void CALLBACK (*xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e);
511 #define ICOM_VMETHOD6(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf) \
512     void CALLBACK (*xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f);
513 #define ICOM_VMETHOD7(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng) \
514     void CALLBACK (*xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g);
515 #define ICOM_VMETHOD8(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,nh) \
516     void CALLBACK (*xfn)(ICOM_INTERFACE* me,ta a,tb b,tc c,td d,te e,tf f,tg g,th h);
517 #define ICOM_VMETHOD9(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ni) \
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);
519 #define ICOM_VMETHOD10(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,nj) \
520     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);
521 #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) \
522     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);
523 #define ICOM_VMETHOD12(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl) \
524     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,tl l);
525 #define ICOM_VMETHOD13(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl,tm,nm) \
526     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,tl l,tm m);
527 #define ICOM_VMETHOD14(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl,tm,nm,tn,nn) \
528     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,tl l,tm m,tn n);
529 #define ICOM_VMETHOD15(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl,tm,nm,tn,nn,to,no) \
530     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,tl l,tm m,tn n,to o);
531 #define ICOM_VMETHOD16(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl,tm,nm,tn,nn,to,no,tp,np) \
532     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,tl l,tm m,tn n,to o,tp p);
533 #define ICOM_VMETHOD17(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl,tm,nm,tn,nn,to,no,tp,np,tq,nq) \
534     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,tl l,tm m,tn n,to o,tp p,tq q);
535 #define ICOM_VMETHOD18(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl,tm,nm,tn,nn,to,no,tp,np,tq,nq,tr,nr) \
536     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,tl l,tm m,tn n,to o,tp p,tq q,tr r);
537 #define ICOM_VMETHOD19(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl,tm,nm,tn,nn,to,no,tp,np,tq,nq,tr,nr,ts,ns) \
538     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,tl l,tm m,tn n,to o,tp p,tq q,tr r,ts s);
539 #define ICOM_VMETHOD20(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl,tm,nm,tn,nn,to,no,tp,np,tq,nq,tr,nr,ts,ns,tt,nt) \
540     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,tl l,tm m,tn n,to o,tp p,tq q,tr r,ts s,tt t);
541 #define ICOM_VMETHOD21(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl,tm,nm,tn,nn,to,no,tp,np,tq,nq,tr,nr,ts,ns,tt,nt,tu,nu) \
542     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,tl l,tm m,tn n,to o,tp p,tq q,tr r,ts s,tt t,tu u);
543 #define ICOM_VMETHOD22(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl,tm,nm,tn,nn,to,no,tp,np,tq,nq,tr,nr,ts,ns,tt,nt,tu,nu,tv,nv) \
544     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,tl l,tm m,tn n,to o,tp p,tq q,tr r,ts s,tt t,tu u,tv v);
545 #define ICOM_VMETHOD23(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl,tm,nm,tn,nn,to,no,tp,np,tq,nq,tr,nr,ts,ns,tt,nt,tu,nu,tv,nv,tw,nw) \
546     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,tl l,tm m,tn n,to o,tp p,tq q,tr r,ts s,tt t,tu u,tv v,tw w);
547 #define ICOM_VMETHOD24(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl,tm,nm,tn,nn,to,no,tp,np,tq,nq,tr,nr,ts,ns,tt,nt,tu,nu,tv,nv,tw,nw,tx,nx) \
548     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,tl l,tm m,tn n,to o,tp p,tq q,tr r,ts s,tt t,tu u,tv v,tw w,tx x);
549 #define ICOM_VMETHOD25(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl,tm,nm,tn,nn,to,no,tp,np,tq,nq,tr,nr,ts,ns,tt,nt,tu,nu,tv,nv,tw,nw,tx,nx,ty,ny) \
550     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,tl l,tm m,tn n,to o,tp p,tq q,tr r,ts s,tt t,tu u,tv v,tw w,tx x,ty y);
551 #define ICOM_VMETHOD26(xfn,ta,na,tb,nb,tc,nc,td,nd,te,ne,tf,nf,tg,ng,th,nh,ti,ni,tj,nj,tk,nk,tl,nl,tm,nm,tn,nn,to,no,tp,np,tq,nq,tr,nr,ts,ns,tt,nt,tu,nu,tv,nv,tw,nw,tx,nx,ty,ny,tz,nz) \
552     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,tl l,tm m,tn n,to o,tp p,tq q,tr r,ts s,tt t,tu u,tv v,tw w,tx x,ty y,tz z);
553
554
555 #define ICOM_VTABLE(iface)       iface##Vtbl
556 #define ICOM_VFIELD(iface)       ICOM_VTABLE(iface)* lpVtbl
557 #define ICOM_VTBL(iface)         (iface)->lpVtbl
558
559 #ifdef ICOM_MSVTABLE_COMPAT
560 #define ICOM_DEFINE(iface,ibase) \
561     typedef struct ICOM_VTABLE(iface) ICOM_VTABLE(iface); \
562     struct iface { \
563         const ICOM_VFIELD(iface); \
564     }; \
565     struct ICOM_VTABLE(iface) { \
566         long dummyRTTI1; \
567         long dummyRTTI2; \
568         ibase##_IMETHODS \
569         iface##_METHODS \
570     };
571 #define ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE 0,0,
572
573 #else
574 #define ICOM_DEFINE(iface,ibase) \
575     typedef struct ICOM_VTABLE(iface) ICOM_VTABLE(iface); \
576     struct iface { \
577         const ICOM_VFIELD(iface); \
578     }; \
579     struct ICOM_VTABLE(iface) { \
580         ibase##_IMETHODS \
581         iface##_METHODS \
582     };
583 #define ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
584 #endif /* ICOM_MSVTABLE_COMPAT */
585
586
587 #define ICOM_THIS(impl,iface)          impl* const This=(impl*)iface
588 #define ICOM_CTHIS(impl,iface)         const impl* const This=(const impl*)iface
589
590 #endif /*ICOM_CINTERFACE  */
591
592 #define ICOM_CALL(xfn, ptr)                         ICOM_VTBL(ptr)->xfn(ptr)
593 #define ICOM_CALL1(xfn, ptr,a)                      ICOM_VTBL(ptr)->xfn(ptr,a)
594 #define ICOM_CALL2(xfn, ptr,a,b)                    ICOM_VTBL(ptr)->xfn(ptr,a,b)
595 #define ICOM_CALL3(xfn, ptr,a,b,c)                  ICOM_VTBL(ptr)->xfn(ptr,a,b,c)
596 #define ICOM_CALL4(xfn, ptr,a,b,c,d)                ICOM_VTBL(ptr)->xfn(ptr,a,b,c,d)
597 #define ICOM_CALL5(xfn, ptr,a,b,c,d,e)              ICOM_VTBL(ptr)->xfn(ptr,a,b,c,d,e)
598 #define ICOM_CALL6(xfn, ptr,a,b,c,d,e,f)            ICOM_VTBL(ptr)->xfn(ptr,a,b,c,d,e,f)
599 #define ICOM_CALL7(xfn, ptr,a,b,c,d,e,f,g)          ICOM_VTBL(ptr)->xfn(ptr,a,b,c,d,e,f,g)
600 #define ICOM_CALL8(xfn, ptr,a,b,c,d,e,f,g,h)        ICOM_VTBL(ptr)->xfn(ptr,a,b,c,d,e,f,g,h)
601 #define ICOM_CALL9(xfn, ptr,a,b,c,d,e,f,g,h,i)      ICOM_VTBL(ptr)->xfn(ptr,a,b,c,d,e,f,g,h,i)
602 #define ICOM_CALL10(xfn, ptr,a,b,c,d,e,f,g,h,i,j)   ICOM_VTBL(ptr)->xfn(ptr,a,b,c,d,e,f,g,h,i,j)
603 #define ICOM_CALL11(xfn, ptr,a,b,c,d,e,f,g,h,i,j,k) ICOM_VTBL(ptr)->xfn(ptr,a,b,c,d,e,f,g,h,i,j,k)
604 #define ICOM_CALL12(xfn, ptr,a,b,c,d,e,f,g,h,i,j,k,l) ICOM_VTBL(ptr)->xfn(ptr,a,b,c,d,e,f,g,h,i,j,k,l)
605 #define ICOM_CALL13(xfn, ptr,a,b,c,d,e,f,g,h,i,j,k,l,m) ICOM_VTBL(ptr)->xfn(ptr,a,b,c,d,e,f,g,h,i,j,k,l,m)
606 #define ICOM_CALL14(xfn, ptr,a,b,c,d,e,f,g,h,i,j,k,l,m,n) ICOM_VTBL(ptr)->xfn(ptr,a,b,c,d,e,f,g,h,i,j,k,l,m,n)
607 #define ICOM_CALL15(xfn, ptr,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o) ICOM_VTBL(ptr)->xfn(ptr,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o)
608 #define ICOM_CALL16(xfn, ptr,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) ICOM_VTBL(ptr)->xfn(ptr,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p)
609 #define ICOM_CALL17(xfn, ptr,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q) ICOM_VTBL(ptr)->xfn(ptr,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q)
610 #define ICOM_CALL18(xfn, ptr,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r) ICOM_VTBL(ptr)->xfn(ptr,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r)
611 #define ICOM_CALL19(xfn, ptr,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s) ICOM_VTBL(ptr)->xfn(ptr,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s)
612 #define ICOM_CALL20(xfn, ptr,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t) ICOM_VTBL(ptr)->xfn(ptr,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t)
613 #define ICOM_CALL21(xfn, ptr,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u) ICOM_VTBL(ptr)->xfn(ptr,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u)
614 #define ICOM_CALL22(xfn, ptr,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v) ICOM_VTBL(ptr)->xfn(ptr,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v)
615 #define ICOM_CALL23(xfn, ptr,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w) ICOM_VTBL(ptr)->xfn(ptr,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w)
616 #define ICOM_CALL24(xfn, ptr,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x) ICOM_VTBL(ptr)->xfn(ptr,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x)
617 #define ICOM_CALL25(xfn, ptr,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y) ICOM_VTBL(ptr)->xfn(ptr,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y)
618 #define ICOM_CALL26(xfn, ptr,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z) ICOM_VTBL(ptr)->xfn(ptr,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z)
619
620
621 /*****************************************************************************
622  * Predeclare the interfaces
623  */
624 DEFINE_OLEGUID(IID_IClassFactory,       0x00000001L, 0, 0);
625 typedef struct IClassFactory IClassFactory, *LPCLASSFACTORY;
626
627 DEFINE_OLEGUID(IID_IMalloc,             0x00000002L, 0, 0);
628 typedef struct IMalloc IMalloc,*LPMALLOC;
629
630 DEFINE_OLEGUID(IID_IUnknown,            0x00000000L, 0, 0);
631 typedef struct IUnknown IUnknown, *LPUNKNOWN;
632
633
634 /*****************************************************************************
635  * IUnknown interface
636  */
637 #define ICOM_INTERFACE IUnknown
638 #define IUnknown_IMETHODS \
639     ICOM_METHOD2(HRESULT,QueryInterface,REFIID,riid, LPVOID*,ppvObj) \
640     ICOM_METHOD (ULONG,AddRef) \
641     ICOM_METHOD (ULONG,Release)
642 #ifdef ICOM_CINTERFACE
643 typedef struct ICOM_VTABLE(IUnknown) ICOM_VTABLE(IUnknown);
644 struct IUnknown {
645     ICOM_VFIELD(IUnknown);
646 #if defined(ICOM_USE_COM_INTERFACE_ATTRIBUTE)
647 } __attribute__ ((com_interface)); 
648 #else
649 };
650 #endif /* ICOM_US_COM_INTERFACE_ATTRIBUTE */
651
652 struct ICOM_VTABLE(IUnknown) {
653 #ifdef ICOM_MSVTABLE_COMPAT
654     long dummyRTTI1;
655     long dummyRTTI2;
656 #endif /* ICOM_MSVTABLE_COMPAT */
657
658 #else /* ICOM_CINTERFACE */
659 struct IUnknown {
660
661 #endif /* ICOM_CINTERFACE */
662
663     ICOM_METHOD2(HRESULT,QueryInterface,REFIID,riid, LPVOID*,ppvObj)
664     ICOM_METHOD (ULONG,AddRef)
665     ICOM_METHOD (ULONG,Release)
666 #if defined(ICOM_USE_COM_INTERFACE_ATTRIBUTE)
667 } __attribute__ ((com_interface)); 
668 #else
669 };
670 #endif /* ICOM_US_COM_INTERFACE_ATTRIBUTE */
671
672 #undef ICOM_INTERFACE
673
674 /*** IUnknown methods ***/
675 #define IUnknown_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b)
676 #define IUnknown_AddRef(p)             ICOM_CALL (AddRef,p)
677 #define IUnknown_Release(p)            ICOM_CALL (Release,p)
678
679 /*****************************************************************************
680  * IClassFactory interface
681  */
682 #define ICOM_INTERFACE IClassFactory
683 #define IClassFactory_METHODS \
684     ICOM_METHOD3(HRESULT,CreateInstance, LPUNKNOWN,pUnkOuter, REFIID,riid, LPVOID*,ppvObject) \
685     ICOM_METHOD1(HRESULT,LockServer,     BOOL,fLock)
686 #define IClassFactory_IMETHODS \
687     IUnknown_IMETHODS \
688     IClassFactory_METHODS
689 ICOM_DEFINE(IClassFactory,IUnknown)
690 #undef ICOM_INTERFACE
691
692 /*** IUnknown methods ***/
693 #define IClassFactory_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b)
694 #define IClassFactory_AddRef(p)             ICOM_CALL (AddRef,p)
695 #define IClassFactory_Release(p)            ICOM_CALL (Release,p)
696 /*** IClassFactory methods ***/
697 #define IClassFactory_CreateInstance(p,a,b,c) ICOM_CALL3(CreateInstance,p,a,b,c)
698 #define IClassFactory_LockServer(p,a)         ICOM_CALL1(LockServer,p,a)
699
700
701 /*****************************************************************************
702  * IMalloc interface
703  */
704 #define ICOM_INTERFACE IMalloc
705 #define IMalloc_METHODS \
706     ICOM_METHOD1 (LPVOID,Alloc,       DWORD,cb) \
707     ICOM_METHOD2 (LPVOID,Realloc,     LPVOID,pv, DWORD,cb) \
708     ICOM_VMETHOD1(       Free,        LPVOID,pv) \
709     ICOM_METHOD1(DWORD, GetSize,     LPVOID,pv) \
710     ICOM_METHOD1(INT, DidAlloc,    LPVOID,pv) \
711     ICOM_METHOD  (VOID,  HeapMinimize)
712 #define IMalloc_IMETHODS \
713     IUnknown_IMETHODS \
714     IMalloc_METHODS
715 ICOM_DEFINE(IMalloc,IUnknown)
716 #undef ICOM_INTERFACE
717
718 /*** IUnknown methods ***/
719 #define IMalloc_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b)
720 #define IMalloc_AddRef(p)             ICOM_CALL (AddRef,p)
721 #define IMalloc_Release(p)            ICOM_CALL (Release,p)
722 /*** IMalloc methods ***/
723 #define IMalloc_Alloc(p,a)      ICOM_CALL1(Alloc,p,a)
724 #define IMalloc_Realloc(p,a,b)  ICOM_CALL2(Realloc,p,a,b)
725 #define IMalloc_Free(p,a)       ICOM_CALL1(Free,p,a)
726 #define IMalloc_GetSize(p,a)    ICOM_CALL1(GetSize,p,a)
727 #define IMalloc_DidAlloc(p,a)   ICOM_CALL1(DidAlloc,p,a)
728 #define IMalloc_HeapMinimize(p) ICOM_CALL (HeapMinimize,p)
729
730 /* values passed to CoGetMalloc */
731 #define MEMCTX_TASK             1 /* private task memory */
732 #define MEMCTX_SHARED           2 /* shared memory */
733 #ifdef _MAC
734 #define MEMCTX_MACSYSTEM        3 /* system heap on mac */
735 #endif
736 /* mainly for internal use... */
737 #define MEMCTX_UNKNOWN          -1
738 #define MEMCTX_SAME             -2
739
740 HRESULT WINAPI CoGetMalloc(DWORD dwMemContext,LPMALLOC* lpMalloc);
741
742 LPVOID WINAPI CoTaskMemAlloc(ULONG size);
743
744 void WINAPI CoTaskMemFree(LPVOID ptr);
745
746 /* FIXME: unimplemented */
747 LPVOID WINAPI CoTaskMemRealloc(LPVOID ptr, ULONG size);
748
749
750 /*****************************************************************************
751  * Additional API
752  */
753
754 HRESULT WINAPI CoCreateGuid(GUID* pguid);
755
756 HINSTANCE WINAPI CoLoadLibrary(LPOLESTR lpszLibName, BOOL bAutoFree);
757
758 void WINAPI CoFreeAllLibraries(void);
759
760 void WINAPI CoFreeLibrary(HINSTANCE hLibrary);
761
762 void WINAPI CoFreeUnusedLibraries(void);
763
764 HRESULT WINAPI CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv);
765
766 HRESULT WINAPI CoGetClassObject(REFCLSID rclsid, DWORD dwClsContext, COSERVERINFO *pServerInfo, REFIID iid, LPVOID *ppv);
767
768 HRESULT WINAPI CoInitialize(LPVOID lpReserved);
769 HRESULT WINAPI CoInitializeEx(LPVOID lpReserved, DWORD dwCoInit);
770
771 void WINAPI CoUninitialize(void);
772
773 typedef enum tagCOINIT
774 {
775     COINIT_APARTMENTTHREADED  = 0x2, /* Apartment model */
776     COINIT_MULTITHREADED      = 0x0, /* OLE calls objects on any thread */
777     COINIT_DISABLE_OLE1DDE    = 0x4, /* Don't use DDE for Ole1 support */
778     COINIT_SPEED_OVER_MEMORY  = 0x8  /* Trade memory for speed */
779 } COINIT;
780
781
782 /* FIXME: not implemented */
783 BOOL WINAPI CoIsOle1Class(REFCLSID rclsid);
784
785 HRESULT WINAPI CoLockObjectExternal(LPUNKNOWN pUnk, BOOL fLock, BOOL fLastUnlockReleases);
786
787 /* class registration flags; passed to CoRegisterClassObject */
788 typedef enum tagREGCLS
789 {
790     REGCLS_SINGLEUSE = 0,
791     REGCLS_MULTIPLEUSE = 1,
792     REGCLS_MULTI_SEPARATE = 2,
793     REGCLS_SUSPENDED = 4
794 } REGCLS;
795
796 HRESULT WINAPI CoRegisterClassObject(REFCLSID rclsid,LPUNKNOWN pUnk,DWORD dwClsContext,DWORD flags,LPDWORD lpdwRegister);
797
798 HRESULT WINAPI CoRevokeClassObject(DWORD dwRegister);
799
800 /*****************************************************************************
801  *      COM Server dll - exports
802  */
803 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID * ppv);
804 HRESULT WINAPI DllCanUnloadNow(void);
805
806 #ifdef __cplusplus
807 } /* extern "C" */
808 #endif
809
810 #endif /* __WINE_WINE_OBJ_BASE_H */