advapi32: Create MachineGuid value if it doesn't exist.
[wine/wine64.git] / tools / widl / proxy.c
blob039f54eaa1efb42bbb82e8d3d40e468598d00b58
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(def->type);
255 int has_full_pointer = is_full_pointer_function(cur);
257 indent = 0;
258 write_type_decl_left(proxy, def->type);
259 print_proxy( " STDMETHODCALLTYPE %s_", iface->name);
260 write_name(proxy, def);
261 print_proxy( "_Proxy(\n");
262 write_args(proxy, cur->args, iface->name, 1, TRUE);
263 print_proxy( ")\n");
264 print_proxy( "{\n");
265 indent ++;
266 /* local variables */
267 if (has_ret) {
268 print_proxy( "" );
269 write_type_decl_left(proxy, def->type);
270 print_proxy( " _RetVal;\n");
272 print_proxy( "RPC_MESSAGE _RpcMessage;\n" );
273 print_proxy( "MIDL_STUB_MESSAGE _StubMsg;\n" );
274 if (has_ret) {
275 if (decl_indirect(def->type))
276 print_proxy("void *_p_%s = &%s;\n",
277 "_RetVal", "_RetVal");
279 print_proxy( "\n");
281 if (has_full_pointer)
282 write_full_pointer_init(proxy, indent, cur, FALSE);
284 /* FIXME: trace */
285 clear_output_vars( cur->args );
287 print_proxy( "RpcTryExcept\n" );
288 print_proxy( "{\n" );
289 indent++;
290 print_proxy( "NdrProxyInitialize(This, &_RpcMessage, &_StubMsg, &Object_StubDesc, %d);\n", idx);
291 proxy_check_pointers( cur->args );
293 print_proxy( "RpcTryFinally\n" );
294 print_proxy( "{\n" );
295 indent++;
297 write_remoting_arguments(proxy, indent, cur, PASS_IN, PHASE_BUFFERSIZE);
299 print_proxy( "NdrProxyGetBuffer(This, &_StubMsg);\n" );
301 write_remoting_arguments(proxy, indent, cur, PASS_IN, PHASE_MARSHAL);
303 print_proxy( "NdrProxySendReceive(This, &_StubMsg);\n" );
304 fprintf(proxy, "\n");
305 print_proxy( "_StubMsg.BufferStart = _RpcMessage.Buffer;\n" );
306 print_proxy( "_StubMsg.BufferEnd = _StubMsg.BufferStart + _RpcMessage.BufferLength;\n\n" );
308 print_proxy("if ((_RpcMessage.DataRepresentation & 0xffff) != NDR_LOCAL_DATA_REPRESENTATION)\n");
309 indent++;
310 print_proxy("NdrConvert( &_StubMsg, &__MIDL_ProcFormatString.Format[%u]);\n", proc_offset );
311 indent--;
312 fprintf(proxy, "\n");
314 write_remoting_arguments(proxy, indent, cur, PASS_OUT, PHASE_UNMARSHAL);
316 if (has_ret)
318 if (decl_indirect(def->type))
319 print_proxy("MIDL_memset(&%s, 0, sizeof(%s));\n", "_RetVal", "_RetVal");
320 else if (is_ptr(def->type) || is_array(def->type))
321 print_proxy("%s = 0;\n", "_RetVal");
322 write_remoting_arguments(proxy, indent, cur, PASS_RETURN, PHASE_UNMARSHAL);
325 indent--;
326 print_proxy( "}\n");
327 print_proxy( "RpcFinally\n" );
328 print_proxy( "{\n" );
329 indent++;
330 if (has_full_pointer)
331 write_full_pointer_free(proxy, indent, cur);
332 print_proxy( "NdrProxyFreeBuffer(This, &_StubMsg);\n" );
333 indent--;
334 print_proxy( "}\n");
335 print_proxy( "RpcEndFinally\n" );
336 indent--;
337 print_proxy( "}\n" );
338 print_proxy( "RpcExcept(_StubMsg.dwStubPhase != PROXY_SENDRECEIVE)\n" );
339 print_proxy( "{\n" );
340 if (has_ret) {
341 indent++;
342 proxy_free_variables( cur->args );
343 print_proxy( "_RetVal = NdrProxyErrorHandler(RpcExceptionCode());\n" );
344 indent--;
346 print_proxy( "}\n" );
347 print_proxy( "RpcEndExcept\n" );
349 if (has_ret) {
350 print_proxy( "return _RetVal;\n" );
352 indent--;
353 print_proxy( "}\n");
354 print_proxy( "\n");
357 static void gen_stub(type_t *iface, const func_t *cur, const char *cas,
358 unsigned int proc_offset)
360 var_t *def = cur->def;
361 const var_t *arg;
362 int has_ret = !is_void(def->type);
363 int has_full_pointer = is_full_pointer_function(cur);
365 indent = 0;
366 print_proxy( "void __RPC_STUB %s_", iface->name);
367 write_name(proxy, def);
368 print_proxy( "_Stub(\n");
369 indent++;
370 print_proxy( "IRpcStubBuffer* This,\n");
371 print_proxy( "IRpcChannelBuffer *_pRpcChannelBuffer,\n");
372 print_proxy( "PRPC_MESSAGE _pRpcMessage,\n");
373 print_proxy( "DWORD* _pdwStubPhase)\n");
374 indent--;
375 print_proxy( "{\n");
376 indent++;
377 print_proxy("%s * _This = (%s*)((CStdStubBuffer*)This)->pvServerObject;\n", iface->name, iface->name);
378 print_proxy("MIDL_STUB_MESSAGE _StubMsg;\n");
379 declare_stub_args( proxy, indent, cur );
380 fprintf(proxy, "\n");
382 /* FIXME: trace */
384 print_proxy("NdrStubInitialize(_pRpcMessage, &_StubMsg, &Object_StubDesc, _pRpcChannelBuffer);\n");
385 fprintf(proxy, "\n");
387 write_parameters_init(proxy, indent, cur);
389 print_proxy("RpcTryFinally\n");
390 print_proxy("{\n");
391 indent++;
392 if (has_full_pointer)
393 write_full_pointer_init(proxy, indent, cur, TRUE);
394 print_proxy("if ((_pRpcMessage->DataRepresentation & 0xffff) != NDR_LOCAL_DATA_REPRESENTATION)\n");
395 indent++;
396 print_proxy("NdrConvert( &_StubMsg, &__MIDL_ProcFormatString.Format[%u]);\n", proc_offset );
397 indent--;
398 fprintf(proxy, "\n");
400 write_remoting_arguments(proxy, indent, cur, PASS_IN, PHASE_UNMARSHAL);
401 fprintf(proxy, "\n");
403 assign_stub_out_args( proxy, indent, cur );
405 print_proxy("*_pdwStubPhase = STUB_CALL_SERVER;\n");
406 fprintf(proxy, "\n");
407 print_proxy("");
408 if (has_ret) fprintf(proxy, "_RetVal = ");
409 if (cas) fprintf(proxy, "%s_%s_Stub", iface->name, cas);
410 else
412 fprintf(proxy, "_This->lpVtbl->");
413 write_name(proxy, def);
415 fprintf(proxy, "(_This");
417 if (cur->args)
419 LIST_FOR_EACH_ENTRY( arg, cur->args, const var_t, entry )
421 fprintf(proxy, ", ");
422 if (arg->type->declarray)
423 fprintf(proxy, "*");
424 write_name(proxy, arg);
427 fprintf(proxy, ");\n");
428 fprintf(proxy, "\n");
429 print_proxy("*_pdwStubPhase = STUB_MARSHAL;\n");
430 fprintf(proxy, "\n");
432 write_remoting_arguments(proxy, indent, cur, PASS_OUT, PHASE_BUFFERSIZE);
434 print_proxy("NdrStubGetBuffer(This, _pRpcChannelBuffer, &_StubMsg);\n");
436 write_remoting_arguments(proxy, indent, cur, PASS_OUT, PHASE_MARSHAL);
437 fprintf(proxy, "\n");
439 if (has_ret)
440 print_phase_basetype(proxy, indent, PHASE_MARSHAL, PASS_RETURN, def, "_RetVal");
442 indent--;
443 print_proxy("}\n");
444 print_proxy("RpcFinally\n");
445 print_proxy("{\n");
447 write_remoting_arguments(proxy, indent+1, cur, PASS_OUT, PHASE_FREE);
449 if (has_full_pointer)
450 write_full_pointer_free(proxy, indent, cur);
452 print_proxy("}\n");
453 print_proxy("RpcEndFinally\n");
455 print_proxy("_pRpcMessage->BufferLength = _StubMsg.Buffer - (unsigned char *)_pRpcMessage->Buffer;\n");
456 indent--;
458 print_proxy("}\n");
459 print_proxy("\n");
462 static int write_proxy_methods(type_t *iface)
464 const func_t *cur;
465 int i = 0;
467 if (iface->ref) i = write_proxy_methods(iface->ref);
468 if (iface->funcs) LIST_FOR_EACH_ENTRY( cur, iface->funcs, const func_t, entry ) {
469 var_t *def = cur->def;
470 if (!is_callas(def->attrs)) {
471 if (i) fprintf(proxy, ",\n");
472 print_proxy( "%s_", iface->name);
473 write_name(proxy, def);
474 fprintf(proxy, "_Proxy");
475 i++;
478 return i;
481 static int write_stub_methods(type_t *iface)
483 const func_t *cur;
484 int i = 0;
486 if (iface->ref) i = write_stub_methods(iface->ref);
487 else return i; /* skip IUnknown */
489 if (iface->funcs) LIST_FOR_EACH_ENTRY( cur, iface->funcs, const func_t, entry ) {
490 var_t *def = cur->def;
491 if (!is_local(def->attrs)) {
492 if (i) fprintf(proxy,",\n");
493 print_proxy( "%s_", iface->name);
494 write_name(proxy, def);
495 fprintf(proxy, "_Stub");
496 i++;
499 return i;
502 static void write_proxy(type_t *iface, unsigned int *proc_offset)
504 int midx = -1, stubs;
505 const func_t *cur;
507 if (!iface->funcs) return;
509 /* FIXME: check for [oleautomation], shouldn't generate proxies/stubs if specified */
511 fprintf(proxy, "/*****************************************************************************\n");
512 fprintf(proxy, " * %s interface\n", iface->name);
513 fprintf(proxy, " */\n");
514 LIST_FOR_EACH_ENTRY( cur, iface->funcs, const func_t, entry )
516 const var_t *def = cur->def;
517 if (!is_local(def->attrs)) {
518 const var_t *cas = is_callas(def->attrs);
519 const char *cname = cas ? cas->name : NULL;
520 int idx = cur->idx;
521 if (cname) {
522 const func_t *m;
523 LIST_FOR_EACH_ENTRY( m, iface->funcs, const func_t, entry )
524 if (!strcmp(m->def->name, cname))
526 idx = m->idx;
527 break;
530 gen_proxy(iface, cur, idx, *proc_offset);
531 gen_stub(iface, cur, cname, *proc_offset);
532 *proc_offset += get_size_procformatstring_func( cur );
533 if (midx == -1) midx = idx;
534 else if (midx != idx) error("method index mismatch in write_proxy\n");
535 midx++;
539 /* proxy vtable */
540 print_proxy( "static const CINTERFACE_PROXY_VTABLE(%d) _%sProxyVtbl =\n", midx, iface->name);
541 print_proxy( "{\n");
542 indent++;
543 print_proxy( "{\n", iface->name);
544 indent++;
545 print_proxy( "&IID_%s,\n", iface->name);
546 indent--;
547 print_proxy( "},\n");
548 print_proxy( "{\n");
549 indent++;
550 write_proxy_methods(iface);
551 fprintf(proxy, "\n");
552 indent--;
553 print_proxy( "}\n");
554 indent--;
555 print_proxy( "};\n");
556 fprintf(proxy, "\n\n");
558 /* stub vtable */
559 print_proxy( "static const PRPC_STUB_FUNCTION %s_table[] =\n", iface->name);
560 print_proxy( "{\n");
561 indent++;
562 stubs = write_stub_methods(iface);
563 fprintf(proxy, "\n");
564 indent--;
565 fprintf(proxy, "};\n");
566 print_proxy( "\n");
567 print_proxy( "static const CInterfaceStubVtbl _%sStubVtbl =\n", iface->name);
568 print_proxy( "{\n");
569 indent++;
570 print_proxy( "{\n");
571 indent++;
572 print_proxy( "&IID_%s,\n", iface->name);
573 print_proxy( "0,\n");
574 print_proxy( "%d,\n", stubs+3);
575 print_proxy( "&%s_table[-3],\n", iface->name);
576 indent--;
577 print_proxy( "},\n", iface->name);
578 print_proxy( "{\n");
579 indent++;
580 print_proxy( "CStdStubBuffer_METHODS\n");
581 indent--;
582 print_proxy( "}\n");
583 indent--;
584 print_proxy( "};\n");
585 print_proxy( "\n");
588 static int does_any_iface(const ifref_list_t *ifaces, type_pred_t pred)
590 ifref_t *ir;
592 if (ifaces)
593 LIST_FOR_EACH_ENTRY(ir, ifaces, ifref_t, entry)
594 if (pred(ir->iface))
595 return TRUE;
597 return FALSE;
600 int need_proxy(const type_t *iface)
602 return is_object(iface->attrs) && !is_local(iface->attrs);
605 int need_stub(const type_t *iface)
607 return !is_object(iface->attrs) && !is_local(iface->attrs);
610 int need_proxy_file(const ifref_list_t *ifaces)
612 return does_any_iface(ifaces, need_proxy);
615 int need_stub_files(const ifref_list_t *ifaces)
617 return does_any_iface(ifaces, need_stub);
620 void write_proxies(ifref_list_t *ifaces)
622 ifref_t *cur;
623 int expr_eval_routines;
624 char *file_id = proxy_token;
625 int c;
626 unsigned int proc_offset = 0;
628 if (!do_proxies) return;
629 if (do_everything && !need_proxy_file(ifaces)) return;
631 init_proxy(ifaces);
632 if(!proxy) return;
634 if (ifaces)
635 LIST_FOR_EACH_ENTRY( cur, ifaces, ifref_t, entry )
636 if (need_proxy(cur->iface))
637 write_proxy(cur->iface, &proc_offset);
639 expr_eval_routines = write_expr_eval_routines(proxy, proxy_token);
640 if (expr_eval_routines)
641 write_expr_eval_routine_list(proxy, proxy_token);
642 write_user_quad_list(proxy);
643 write_stubdesc(expr_eval_routines);
645 print_proxy( "#if !defined(__RPC_WIN32__)\n");
646 print_proxy( "#error Currently only Wine and WIN32 are supported.\n");
647 print_proxy( "#endif\n");
648 print_proxy( "\n");
649 write_procformatstring(proxy, ifaces, need_proxy);
650 write_typeformatstring(proxy, ifaces, need_proxy);
652 fprintf(proxy, "static const CInterfaceProxyVtbl* const _%s_ProxyVtblList[] =\n", file_id);
653 fprintf(proxy, "{\n");
654 if (ifaces)
655 LIST_FOR_EACH_ENTRY( cur, ifaces, ifref_t, entry )
656 if(cur->iface->ref && cur->iface->funcs && need_proxy(cur->iface))
657 fprintf(proxy, " (const CInterfaceProxyVtbl*)&_%sProxyVtbl,\n", cur->iface->name);
659 fprintf(proxy, " 0\n");
660 fprintf(proxy, "};\n");
661 fprintf(proxy, "\n");
663 fprintf(proxy, "static const CInterfaceStubVtbl* const _%s_StubVtblList[] =\n", file_id);
664 fprintf(proxy, "{\n");
665 if (ifaces)
666 LIST_FOR_EACH_ENTRY( cur, ifaces, ifref_t, entry )
667 if(cur->iface->ref && cur->iface->funcs && need_proxy(cur->iface))
668 fprintf(proxy, " (const CInterfaceStubVtbl*)&_%sStubVtbl,\n", cur->iface->name);
669 fprintf(proxy, " 0\n");
670 fprintf(proxy, "};\n");
671 fprintf(proxy, "\n");
673 fprintf(proxy, "static PCInterfaceName const _%s_InterfaceNamesList[] =\n", file_id);
674 fprintf(proxy, "{\n");
675 if (ifaces)
676 LIST_FOR_EACH_ENTRY( cur, ifaces, ifref_t, entry )
677 if(cur->iface->ref && cur->iface->funcs && need_proxy(cur->iface))
678 fprintf(proxy, " \"%s\",\n", cur->iface->name);
679 fprintf(proxy, " 0\n");
680 fprintf(proxy, "};\n");
681 fprintf(proxy, "\n");
683 fprintf(proxy, "#define _%s_CHECK_IID(n) IID_GENERIC_CHECK_IID(_%s, pIID, n)\n", file_id, file_id);
684 fprintf(proxy, "\n");
685 fprintf(proxy, "int __stdcall _%s_IID_Lookup(const IID* pIID, int* pIndex)\n", file_id);
686 fprintf(proxy, "{\n");
687 c = 0;
688 if (ifaces)
689 LIST_FOR_EACH_ENTRY( cur, ifaces, ifref_t, entry )
690 if(cur->iface->ref && cur->iface->funcs && need_proxy(cur->iface))
692 fprintf(proxy, " if (!_%s_CHECK_IID(%d))\n", file_id, c);
693 fprintf(proxy, " {\n");
694 fprintf(proxy, " *pIndex = %d;\n", c);
695 fprintf(proxy, " return 1;\n");
696 fprintf(proxy, " }\n");
697 c++;
699 fprintf(proxy, " return 0;\n");
700 fprintf(proxy, "}\n");
701 fprintf(proxy, "\n");
703 fprintf(proxy, "const ExtendedProxyFileInfo %s_ProxyFileInfo =\n", file_id);
704 fprintf(proxy, "{\n");
705 fprintf(proxy, " (const PCInterfaceProxyVtblList*)&_%s_ProxyVtblList,\n", file_id);
706 fprintf(proxy, " (const PCInterfaceStubVtblList*)&_%s_StubVtblList,\n", file_id);
707 fprintf(proxy, " _%s_InterfaceNamesList,\n", file_id);
708 fprintf(proxy, " 0,\n");
709 fprintf(proxy, " &_%s_IID_Lookup,\n", file_id);
710 fprintf(proxy, " %d,\n", c);
711 fprintf(proxy, " 1,\n");
712 fprintf(proxy, " 0,\n");
713 fprintf(proxy, " 0,\n");
714 fprintf(proxy, " 0,\n");
715 fprintf(proxy, " 0\n");
716 fprintf(proxy, "};\n");
718 fclose(proxy);