winex11: Use SetWindowPos to invalidate DCEs when changing the pixel format.
[wine/hacks.git] / tools / widl / proxy.c
blobe0864f8a28af71502d410f931029823c14215c14
1 /*
2 * IDL Compiler
4 * Copyright 2002 Ove Kaaven
5 * Copyright 2004 Mike McCormack
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "config.h"
23 #include "wine/port.h"
25 #include <stdio.h>
26 #include <stdlib.h>
27 #ifdef HAVE_UNISTD_H
28 # include <unistd.h>
29 #endif
30 #include <string.h>
31 #include <ctype.h>
33 #include "widl.h"
34 #include "utils.h"
35 #include "parser.h"
36 #include "header.h"
37 #include "typegen.h"
39 #define END_OF_LIST(list) \
40 do { \
41 if (list) { \
42 while (NEXT_LINK(list)) \
43 list = NEXT_LINK(list); \
44 } \
45 } while(0)
47 static FILE* proxy;
48 static int indent = 0;
50 /* FIXME: support generation of stubless proxies */
52 static void print_proxy( const char *format, ... )
54 va_list va;
55 va_start( va, format );
56 print( proxy, indent, format, va );
57 va_end( va );
60 static void write_stubdescproto(void)
62 print_proxy( "static const MIDL_STUB_DESC Object_StubDesc;\n");
63 print_proxy( "\n");
66 static void write_stubdesc(int expr_eval_routines)
68 print_proxy( "static const MIDL_STUB_DESC Object_StubDesc =\n{\n");
69 indent++;
70 print_proxy( "0,\n");
71 print_proxy( "NdrOleAllocate,\n");
72 print_proxy( "NdrOleFree,\n");
73 print_proxy( "{0}, 0, 0, %s, 0,\n", expr_eval_routines ? "ExprEvalRoutines" : "0");
74 print_proxy( "__MIDL_TypeFormatString.Format,\n");
75 print_proxy( "1, /* -error bounds_check flag */\n");
76 print_proxy( "0x10001, /* Ndr library version */\n");
77 print_proxy( "0,\n");
78 print_proxy( "0x50100a4, /* MIDL Version 5.1.164 */\n");
79 print_proxy( "0,\n");
80 print_proxy("%s,\n", list_empty(&user_type_list) ? "0" : "UserMarshalRoutines");
81 print_proxy( "0, /* notify & notify_flag routine table */\n");
82 print_proxy( "1, /* Flags */\n");
83 print_proxy( "0, /* Reserved3 */\n");
84 print_proxy( "0, /* Reserved4 */\n");
85 print_proxy( "0 /* Reserved5 */\n");
86 indent--;
87 print_proxy( "};\n");
88 print_proxy( "\n");
91 static void init_proxy(ifref_list_t *ifaces)
93 if (proxy) return;
94 if(!(proxy = fopen(proxy_name, "w")))
95 error("Could not open %s for output\n", proxy_name);
96 print_proxy( "/*** Autogenerated by WIDL %s from %s - Do not edit ***/\n", PACKAGE_VERSION, input_name);
97 print_proxy( "\n");
98 print_proxy( "#ifndef __REDQ_RPCPROXY_H_VERSION__\n");
99 print_proxy( "#define __REQUIRED_RPCPROXY_H_VERSION__ 440\n");
100 print_proxy( "#endif /* __REDQ_RPCPROXY_H_VERSION__ */\n");
101 print_proxy( "\n");
102 print_proxy( "#define __midl_proxy\n");
103 print_proxy( "#include \"objbase.h\"\n");
104 print_proxy( "#include \"rpcproxy.h\"\n");
105 print_proxy( "#ifndef __RPCPROXY_H_VERSION__\n");
106 print_proxy( "#error This code needs a newer version of rpcproxy.h\n");
107 print_proxy( "#endif /* __RPCPROXY_H_VERSION__ */\n");
108 print_proxy( "\n");
109 print_proxy( "#include \"%s\"\n", header_name);
110 print_proxy( "\n");
111 write_formatstringsdecl(proxy, indent, ifaces, need_proxy);
112 write_stubdescproto();
115 static void clear_output_vars( const var_list_t *args )
117 const var_t *arg;
119 if (!args) return;
120 LIST_FOR_EACH_ENTRY( arg, args, const var_t, entry )
122 if (is_attr(arg->attrs, ATTR_OUT) && !is_attr(arg->attrs, ATTR_IN)) {
123 print_proxy( "if(%s)\n", arg->name );
124 indent++;
125 print_proxy( "MIDL_memset( %s, 0, sizeof( *%s ));\n", arg->name, arg->name );
126 indent--;
131 int is_var_ptr(const var_t *v)
133 return is_ptr(v->type);
136 int cant_be_null(const var_t *v)
138 /* Search backwards for the most recent pointer attribute. */
139 const attr_list_t *attrs = v->attrs;
140 const type_t *type = v->type;
142 if (! attrs && type)
144 attrs = type->attrs;
145 type = type->ref;
148 while (attrs)
150 int t = get_attrv(attrs, ATTR_POINTERTYPE);
152 if (t == RPC_FC_FP || t == RPC_FC_OP || t == RPC_FC_UP)
153 return 0;
155 if (t == RPC_FC_RP)
156 return 1;
158 if (type)
160 attrs = type->attrs;
161 type = type->ref;
163 else
164 attrs = NULL;
167 return 1; /* Default is RPC_FC_RP. */
170 static void proxy_check_pointers( const var_list_t *args )
172 const var_t *arg;
174 if (!args) return;
175 LIST_FOR_EACH_ENTRY( arg, args, const var_t, entry )
177 if (is_var_ptr(arg) && cant_be_null(arg)) {
178 print_proxy( "if(!%s)\n", arg->name );
179 indent++;
180 print_proxy( "RpcRaiseException(RPC_X_NULL_REF_POINTER);\n");
181 indent--;
186 static void free_variable( const var_t *arg )
188 unsigned int type_offset = arg->type->typestring_offset;
189 expr_t *iid;
190 type_t *type = arg->type;
191 expr_t *size = get_size_is_expr(type, arg->name);
193 if (size)
195 print_proxy( "_StubMsg.MaxCount = " );
196 write_expr(proxy, size, 0);
197 fprintf(proxy, ";\n\n");
198 print_proxy( "NdrClearOutParameters( &_StubMsg, ");
199 fprintf(proxy, "&__MIDL_TypeFormatString.Format[%u], ", type_offset );
200 fprintf(proxy, "(void*)%s );\n", arg->name );
201 return;
204 switch( type->type )
206 case RPC_FC_BYTE:
207 case RPC_FC_CHAR:
208 case RPC_FC_WCHAR:
209 case RPC_FC_SHORT:
210 case RPC_FC_USHORT:
211 case RPC_FC_ENUM16:
212 case RPC_FC_LONG:
213 case RPC_FC_ULONG:
214 case RPC_FC_ENUM32:
215 case RPC_FC_STRUCT:
216 break;
218 case RPC_FC_FP:
219 case RPC_FC_IP:
220 iid = get_attrp( arg->attrs, ATTR_IIDIS );
221 if( iid )
223 print_proxy( "_StubMsg.MaxCount = (unsigned long) " );
224 write_expr(proxy, iid, 1);
225 print_proxy( ";\n\n" );
227 print_proxy( "NdrClearOutParameters( &_StubMsg, ");
228 fprintf(proxy, "&__MIDL_TypeFormatString.Format[%u], ", type_offset );
229 fprintf(proxy, "(void*)%s );\n", arg->name );
230 break;
232 default:
233 print_proxy("/* FIXME: %s code for %s type %d missing */\n", __FUNCTION__, arg->name, type->type );
237 static void proxy_free_variables( var_list_t *args )
239 const var_t *arg;
241 if (!args) return;
242 LIST_FOR_EACH_ENTRY( arg, args, const var_t, entry )
243 if (is_attr(arg->attrs, ATTR_OUT))
245 free_variable( arg );
246 fprintf(proxy, "\n");
250 static void gen_proxy(type_t *iface, const func_t *cur, int idx,
251 unsigned int proc_offset)
253 var_t *def = cur->def;
254 int has_ret = !is_void(get_func_return_type(cur));
255 int has_full_pointer = is_full_pointer_function(cur);
256 const char *callconv = get_attrp(def->type->attrs, ATTR_CALLCONV);
257 if (!callconv) callconv = "";
259 indent = 0;
260 write_type_decl_left(proxy, get_func_return_type(cur));
261 print_proxy( " %s %s_", callconv, iface->name);
262 write_name(proxy, def);
263 print_proxy( "_Proxy(\n");
264 write_args(proxy, cur->args, iface->name, 1, TRUE);
265 print_proxy( ")\n");
266 print_proxy( "{\n");
267 indent ++;
268 /* local variables */
269 if (has_ret) {
270 print_proxy( "" );
271 write_type_decl_left(proxy, get_func_return_type(cur));
272 print_proxy( " _RetVal;\n");
274 print_proxy( "RPC_MESSAGE _RpcMessage;\n" );
275 print_proxy( "MIDL_STUB_MESSAGE _StubMsg;\n" );
276 if (has_ret) {
277 if (decl_indirect(get_func_return_type(cur)))
278 print_proxy("void *_p_%s = &%s;\n",
279 "_RetVal", "_RetVal");
281 print_proxy( "\n");
283 if (has_full_pointer)
284 write_full_pointer_init(proxy, indent, cur, FALSE);
286 /* FIXME: trace */
287 clear_output_vars( cur->args );
289 print_proxy( "RpcTryExcept\n" );
290 print_proxy( "{\n" );
291 indent++;
292 print_proxy( "NdrProxyInitialize(This, &_RpcMessage, &_StubMsg, &Object_StubDesc, %d);\n", idx);
293 proxy_check_pointers( cur->args );
295 print_proxy( "RpcTryFinally\n" );
296 print_proxy( "{\n" );
297 indent++;
299 write_remoting_arguments(proxy, indent, cur, PASS_IN, PHASE_BUFFERSIZE);
301 print_proxy( "NdrProxyGetBuffer(This, &_StubMsg);\n" );
303 write_remoting_arguments(proxy, indent, cur, PASS_IN, PHASE_MARSHAL);
305 print_proxy( "NdrProxySendReceive(This, &_StubMsg);\n" );
306 fprintf(proxy, "\n");
307 print_proxy( "_StubMsg.BufferStart = _RpcMessage.Buffer;\n" );
308 print_proxy( "_StubMsg.BufferEnd = _StubMsg.BufferStart + _RpcMessage.BufferLength;\n\n" );
310 print_proxy("if ((_RpcMessage.DataRepresentation & 0xffff) != NDR_LOCAL_DATA_REPRESENTATION)\n");
311 indent++;
312 print_proxy("NdrConvert( &_StubMsg, &__MIDL_ProcFormatString.Format[%u]);\n", proc_offset );
313 indent--;
314 fprintf(proxy, "\n");
316 write_remoting_arguments(proxy, indent, cur, PASS_OUT, PHASE_UNMARSHAL);
318 if (has_ret)
320 if (decl_indirect(get_func_return_type(cur)))
321 print_proxy("MIDL_memset(&%s, 0, sizeof(%s));\n", "_RetVal", "_RetVal");
322 else if (is_ptr(get_func_return_type(cur)) || is_array(get_func_return_type(cur)))
323 print_proxy("%s = 0;\n", "_RetVal");
324 write_remoting_arguments(proxy, indent, cur, PASS_RETURN, PHASE_UNMARSHAL);
327 indent--;
328 print_proxy( "}\n");
329 print_proxy( "RpcFinally\n" );
330 print_proxy( "{\n" );
331 indent++;
332 if (has_full_pointer)
333 write_full_pointer_free(proxy, indent, cur);
334 print_proxy( "NdrProxyFreeBuffer(This, &_StubMsg);\n" );
335 indent--;
336 print_proxy( "}\n");
337 print_proxy( "RpcEndFinally\n" );
338 indent--;
339 print_proxy( "}\n" );
340 print_proxy( "RpcExcept(_StubMsg.dwStubPhase != PROXY_SENDRECEIVE)\n" );
341 print_proxy( "{\n" );
342 if (has_ret) {
343 indent++;
344 proxy_free_variables( cur->args );
345 print_proxy( "_RetVal = NdrProxyErrorHandler(RpcExceptionCode());\n" );
346 indent--;
348 print_proxy( "}\n" );
349 print_proxy( "RpcEndExcept\n" );
351 if (has_ret) {
352 print_proxy( "return _RetVal;\n" );
354 indent--;
355 print_proxy( "}\n");
356 print_proxy( "\n");
359 static void gen_stub(type_t *iface, const func_t *cur, const char *cas,
360 unsigned int proc_offset)
362 var_t *def = cur->def;
363 const var_t *arg;
364 int has_ret = !is_void(get_func_return_type(cur));
365 int has_full_pointer = is_full_pointer_function(cur);
367 indent = 0;
368 print_proxy( "void __RPC_STUB %s_", iface->name);
369 write_name(proxy, def);
370 print_proxy( "_Stub(\n");
371 indent++;
372 print_proxy( "IRpcStubBuffer* This,\n");
373 print_proxy( "IRpcChannelBuffer *_pRpcChannelBuffer,\n");
374 print_proxy( "PRPC_MESSAGE _pRpcMessage,\n");
375 print_proxy( "DWORD* _pdwStubPhase)\n");
376 indent--;
377 print_proxy( "{\n");
378 indent++;
379 print_proxy("%s * _This = (%s*)((CStdStubBuffer*)This)->pvServerObject;\n", iface->name, iface->name);
380 print_proxy("MIDL_STUB_MESSAGE _StubMsg;\n");
381 declare_stub_args( proxy, indent, cur );
382 fprintf(proxy, "\n");
384 /* FIXME: trace */
386 print_proxy("NdrStubInitialize(_pRpcMessage, &_StubMsg, &Object_StubDesc, _pRpcChannelBuffer);\n");
387 fprintf(proxy, "\n");
389 write_parameters_init(proxy, indent, cur);
391 print_proxy("RpcTryFinally\n");
392 print_proxy("{\n");
393 indent++;
394 if (has_full_pointer)
395 write_full_pointer_init(proxy, indent, cur, TRUE);
396 print_proxy("if ((_pRpcMessage->DataRepresentation & 0xffff) != NDR_LOCAL_DATA_REPRESENTATION)\n");
397 indent++;
398 print_proxy("NdrConvert( &_StubMsg, &__MIDL_ProcFormatString.Format[%u]);\n", proc_offset );
399 indent--;
400 fprintf(proxy, "\n");
402 write_remoting_arguments(proxy, indent, cur, PASS_IN, PHASE_UNMARSHAL);
403 fprintf(proxy, "\n");
405 assign_stub_out_args( proxy, indent, cur );
407 print_proxy("*_pdwStubPhase = STUB_CALL_SERVER;\n");
408 fprintf(proxy, "\n");
409 print_proxy("");
410 if (has_ret) fprintf(proxy, "_RetVal = ");
411 if (cas) fprintf(proxy, "%s_%s_Stub", iface->name, cas);
412 else
414 fprintf(proxy, "_This->lpVtbl->");
415 write_name(proxy, def);
417 fprintf(proxy, "(_This");
419 if (cur->args)
421 LIST_FOR_EACH_ENTRY( arg, cur->args, const var_t, entry )
423 fprintf(proxy, ", ");
424 if (arg->type->declarray)
425 fprintf(proxy, "*");
426 write_name(proxy, arg);
429 fprintf(proxy, ");\n");
430 fprintf(proxy, "\n");
431 print_proxy("*_pdwStubPhase = STUB_MARSHAL;\n");
432 fprintf(proxy, "\n");
434 write_remoting_arguments(proxy, indent, cur, PASS_OUT, PHASE_BUFFERSIZE);
436 if (!is_void(get_func_return_type(cur)))
437 write_remoting_arguments(proxy, indent, cur, PASS_RETURN, PHASE_BUFFERSIZE);
439 print_proxy("NdrStubGetBuffer(This, _pRpcChannelBuffer, &_StubMsg);\n");
441 write_remoting_arguments(proxy, indent, cur, PASS_OUT, PHASE_MARSHAL);
442 fprintf(proxy, "\n");
444 /* marshall the return value */
445 if (!is_void(get_func_return_type(cur)))
446 write_remoting_arguments(proxy, indent, cur, PASS_RETURN, PHASE_MARSHAL);
448 indent--;
449 print_proxy("}\n");
450 print_proxy("RpcFinally\n");
451 print_proxy("{\n");
453 write_remoting_arguments(proxy, indent+1, cur, PASS_OUT, PHASE_FREE);
455 if (has_full_pointer)
456 write_full_pointer_free(proxy, indent, cur);
458 print_proxy("}\n");
459 print_proxy("RpcEndFinally\n");
461 print_proxy("_pRpcMessage->BufferLength = _StubMsg.Buffer - (unsigned char *)_pRpcMessage->Buffer;\n");
462 indent--;
464 print_proxy("}\n");
465 print_proxy("\n");
468 static int write_proxy_methods(type_t *iface)
470 const func_t *cur;
471 int i = 0;
473 if (iface->ref) i = write_proxy_methods(iface->ref);
474 if (iface->funcs) LIST_FOR_EACH_ENTRY( cur, iface->funcs, const func_t, entry ) {
475 var_t *def = cur->def;
476 if (!is_callas(def->attrs)) {
477 if (i) fprintf(proxy, ",\n");
478 print_proxy( "%s_", iface->name);
479 write_name(proxy, def);
480 fprintf(proxy, "_Proxy");
481 i++;
484 return i;
487 static int write_stub_methods(type_t *iface)
489 const func_t *cur;
490 int i = 0;
492 if (iface->ref) i = write_stub_methods(iface->ref);
493 else return i; /* skip IUnknown */
495 if (iface->funcs) LIST_FOR_EACH_ENTRY( cur, iface->funcs, const func_t, entry ) {
496 var_t *def = cur->def;
497 if (!is_local(def->attrs)) {
498 if (i) fprintf(proxy,",\n");
499 print_proxy( "%s_", iface->name);
500 write_name(proxy, def);
501 fprintf(proxy, "_Stub");
502 i++;
505 return i;
508 static void write_proxy(type_t *iface, unsigned int *proc_offset)
510 int midx = -1, stubs;
511 const func_t *cur;
513 if (!iface->funcs) return;
515 /* FIXME: check for [oleautomation], shouldn't generate proxies/stubs if specified */
517 fprintf(proxy, "/*****************************************************************************\n");
518 fprintf(proxy, " * %s interface\n", iface->name);
519 fprintf(proxy, " */\n");
520 LIST_FOR_EACH_ENTRY( cur, iface->funcs, const func_t, entry )
522 const var_t *def = cur->def;
523 if (!is_local(def->attrs)) {
524 const var_t *cas = is_callas(def->attrs);
525 const char *cname = cas ? cas->name : NULL;
526 int idx = cur->idx;
527 if (cname) {
528 const func_t *m;
529 LIST_FOR_EACH_ENTRY( m, iface->funcs, const func_t, entry )
530 if (!strcmp(m->def->name, cname))
532 idx = m->idx;
533 break;
536 gen_proxy(iface, cur, idx, *proc_offset);
537 gen_stub(iface, cur, cname, *proc_offset);
538 *proc_offset += get_size_procformatstring_func( cur );
539 if (midx == -1) midx = idx;
540 else if (midx != idx) error("method index mismatch in write_proxy\n");
541 midx++;
545 /* proxy vtable */
546 print_proxy( "static const CINTERFACE_PROXY_VTABLE(%d) _%sProxyVtbl =\n", midx, iface->name);
547 print_proxy( "{\n");
548 indent++;
549 print_proxy( "{\n", iface->name);
550 indent++;
551 print_proxy( "&IID_%s,\n", iface->name);
552 indent--;
553 print_proxy( "},\n");
554 print_proxy( "{\n");
555 indent++;
556 write_proxy_methods(iface);
557 fprintf(proxy, "\n");
558 indent--;
559 print_proxy( "}\n");
560 indent--;
561 print_proxy( "};\n");
562 fprintf(proxy, "\n\n");
564 /* stub vtable */
565 print_proxy( "static const PRPC_STUB_FUNCTION %s_table[] =\n", iface->name);
566 print_proxy( "{\n");
567 indent++;
568 stubs = write_stub_methods(iface);
569 fprintf(proxy, "\n");
570 indent--;
571 fprintf(proxy, "};\n");
572 print_proxy( "\n");
573 print_proxy( "static const CInterfaceStubVtbl _%sStubVtbl =\n", iface->name);
574 print_proxy( "{\n");
575 indent++;
576 print_proxy( "{\n");
577 indent++;
578 print_proxy( "&IID_%s,\n", iface->name);
579 print_proxy( "0,\n");
580 print_proxy( "%d,\n", stubs+3);
581 print_proxy( "&%s_table[-3],\n", iface->name);
582 indent--;
583 print_proxy( "},\n", iface->name);
584 print_proxy( "{\n");
585 indent++;
586 print_proxy( "CStdStubBuffer_METHODS\n");
587 indent--;
588 print_proxy( "}\n");
589 indent--;
590 print_proxy( "};\n");
591 print_proxy( "\n");
594 static int does_any_iface(const ifref_list_t *ifaces, type_pred_t pred)
596 ifref_t *ir;
598 if (ifaces)
599 LIST_FOR_EACH_ENTRY(ir, ifaces, ifref_t, entry)
600 if (pred(ir->iface))
601 return TRUE;
603 return FALSE;
606 int need_proxy(const type_t *iface)
608 return is_object(iface->attrs) && !is_local(iface->attrs);
611 int need_stub(const type_t *iface)
613 return !is_object(iface->attrs) && !is_local(iface->attrs);
616 int need_proxy_file(const ifref_list_t *ifaces)
618 return does_any_iface(ifaces, need_proxy);
621 int need_stub_files(const ifref_list_t *ifaces)
623 return does_any_iface(ifaces, need_stub);
626 void write_proxies(ifref_list_t *ifaces)
628 ifref_t *cur;
629 int expr_eval_routines;
630 char *file_id = proxy_token;
631 int c;
632 unsigned int proc_offset = 0;
634 if (!do_proxies) return;
635 if (do_everything && !need_proxy_file(ifaces)) return;
637 init_proxy(ifaces);
638 if(!proxy) return;
640 if (ifaces)
641 LIST_FOR_EACH_ENTRY( cur, ifaces, ifref_t, entry )
642 if (need_proxy(cur->iface))
643 write_proxy(cur->iface, &proc_offset);
645 expr_eval_routines = write_expr_eval_routines(proxy, proxy_token);
646 if (expr_eval_routines)
647 write_expr_eval_routine_list(proxy, proxy_token);
648 write_user_quad_list(proxy);
649 write_stubdesc(expr_eval_routines);
651 print_proxy( "#if !defined(__RPC_WIN32__)\n");
652 print_proxy( "#error Currently only Wine and WIN32 are supported.\n");
653 print_proxy( "#endif\n");
654 print_proxy( "\n");
655 write_procformatstring(proxy, ifaces, need_proxy);
656 write_typeformatstring(proxy, ifaces, need_proxy);
658 fprintf(proxy, "static const CInterfaceProxyVtbl* const _%s_ProxyVtblList[] =\n", file_id);
659 fprintf(proxy, "{\n");
660 if (ifaces)
661 LIST_FOR_EACH_ENTRY( cur, ifaces, ifref_t, entry )
662 if(cur->iface->ref && cur->iface->funcs && need_proxy(cur->iface))
663 fprintf(proxy, " (const CInterfaceProxyVtbl*)&_%sProxyVtbl,\n", cur->iface->name);
665 fprintf(proxy, " 0\n");
666 fprintf(proxy, "};\n");
667 fprintf(proxy, "\n");
669 fprintf(proxy, "static const CInterfaceStubVtbl* const _%s_StubVtblList[] =\n", file_id);
670 fprintf(proxy, "{\n");
671 if (ifaces)
672 LIST_FOR_EACH_ENTRY( cur, ifaces, ifref_t, entry )
673 if(cur->iface->ref && cur->iface->funcs && need_proxy(cur->iface))
674 fprintf(proxy, " (const CInterfaceStubVtbl*)&_%sStubVtbl,\n", cur->iface->name);
675 fprintf(proxy, " 0\n");
676 fprintf(proxy, "};\n");
677 fprintf(proxy, "\n");
679 fprintf(proxy, "static PCInterfaceName const _%s_InterfaceNamesList[] =\n", file_id);
680 fprintf(proxy, "{\n");
681 if (ifaces)
682 LIST_FOR_EACH_ENTRY( cur, ifaces, ifref_t, entry )
683 if(cur->iface->ref && cur->iface->funcs && need_proxy(cur->iface))
684 fprintf(proxy, " \"%s\",\n", cur->iface->name);
685 fprintf(proxy, " 0\n");
686 fprintf(proxy, "};\n");
687 fprintf(proxy, "\n");
689 fprintf(proxy, "#define _%s_CHECK_IID(n) IID_GENERIC_CHECK_IID(_%s, pIID, n)\n", file_id, file_id);
690 fprintf(proxy, "\n");
691 fprintf(proxy, "int __stdcall _%s_IID_Lookup(const IID* pIID, int* pIndex)\n", file_id);
692 fprintf(proxy, "{\n");
693 c = 0;
694 if (ifaces)
695 LIST_FOR_EACH_ENTRY( cur, ifaces, ifref_t, entry )
696 if(cur->iface->ref && cur->iface->funcs && need_proxy(cur->iface))
698 fprintf(proxy, " if (!_%s_CHECK_IID(%d))\n", file_id, c);
699 fprintf(proxy, " {\n");
700 fprintf(proxy, " *pIndex = %d;\n", c);
701 fprintf(proxy, " return 1;\n");
702 fprintf(proxy, " }\n");
703 c++;
705 fprintf(proxy, " return 0;\n");
706 fprintf(proxy, "}\n");
707 fprintf(proxy, "\n");
709 fprintf(proxy, "const ExtendedProxyFileInfo %s_ProxyFileInfo =\n", file_id);
710 fprintf(proxy, "{\n");
711 fprintf(proxy, " (const PCInterfaceProxyVtblList*)&_%s_ProxyVtblList,\n", file_id);
712 fprintf(proxy, " (const PCInterfaceStubVtblList*)&_%s_StubVtblList,\n", file_id);
713 fprintf(proxy, " _%s_InterfaceNamesList,\n", file_id);
714 fprintf(proxy, " 0,\n");
715 fprintf(proxy, " &_%s_IID_Lookup,\n", file_id);
716 fprintf(proxy, " %d,\n", c);
717 fprintf(proxy, " 1,\n");
718 fprintf(proxy, " 0,\n");
719 fprintf(proxy, " 0,\n");
720 fprintf(proxy, " 0,\n");
721 fprintf(proxy, " 0\n");
722 fprintf(proxy, "};\n");
724 fclose(proxy);