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
23 #include "wine/port.h"
40 #define END_OF_LIST(list) \
43 while (NEXT_LINK(list)) \
44 list = NEXT_LINK(list); \
49 static int indent
= 0;
51 /* FIXME: support generation of stubless proxies */
53 static void print_proxy( const char *format
, ... )
56 va_start( va
, format
);
57 print( proxy
, indent
, format
, va
);
61 static void write_stubdescproto(void)
63 print_proxy( "static const MIDL_STUB_DESC Object_StubDesc;\n");
67 static void write_stubdesc(int expr_eval_routines
)
69 print_proxy( "static const MIDL_STUB_DESC Object_StubDesc =\n{\n");
72 print_proxy( "NdrOleAllocate,\n");
73 print_proxy( "NdrOleFree,\n");
74 print_proxy( "{0}, 0, 0, %s, 0,\n", expr_eval_routines
? "ExprEvalRoutines" : "0");
75 print_proxy( "__MIDL_TypeFormatString.Format,\n");
76 print_proxy( "1, /* -error bounds_check flag */\n");
77 print_proxy( "0x10001, /* Ndr library version */\n");
79 print_proxy( "0x50100a4, /* MIDL Version 5.1.164 */\n");
81 print_proxy("%s,\n", list_empty(&user_type_list
) ? "0" : "UserMarshalRoutines");
82 print_proxy( "0, /* notify & notify_flag routine table */\n");
83 print_proxy( "1, /* Flags */\n");
84 print_proxy( "0, /* Reserved3 */\n");
85 print_proxy( "0, /* Reserved4 */\n");
86 print_proxy( "0 /* Reserved5 */\n");
92 static void init_proxy(const statement_list_t
*stmts
)
95 if(!(proxy
= fopen(proxy_name
, "w")))
96 error("Could not open %s for output\n", proxy_name
);
97 print_proxy( "/*** Autogenerated by WIDL %s from %s - Do not edit ***/\n", PACKAGE_VERSION
, input_name
);
99 print_proxy( "#ifndef __REDQ_RPCPROXY_H_VERSION__\n");
100 print_proxy( "#define __REQUIRED_RPCPROXY_H_VERSION__ 440\n");
101 print_proxy( "#endif /* __REDQ_RPCPROXY_H_VERSION__ */\n");
103 print_proxy( "#define __midl_proxy\n");
104 print_proxy( "#include \"objbase.h\"\n");
105 print_proxy( "#include \"rpcproxy.h\"\n");
106 print_proxy( "#ifndef __RPCPROXY_H_VERSION__\n");
107 print_proxy( "#error This code needs a newer version of rpcproxy.h\n");
108 print_proxy( "#endif /* __RPCPROXY_H_VERSION__ */\n");
110 print_proxy( "#include \"%s\"\n", header_name
);
112 write_exceptions( proxy
);
114 print_proxy( "struct __proxy_frame\n");
116 print_proxy( " __DECL_EXCEPTION_FRAME;\n");
117 print_proxy( " MIDL_STUB_MESSAGE _StubMsg;\n");
118 print_proxy( " void *This;\n");
119 print_proxy( "};\n");
121 print_proxy( "struct __stub_frame\n");
123 print_proxy( " __DECL_EXCEPTION_FRAME;\n");
124 print_proxy( " MIDL_STUB_MESSAGE _StubMsg;\n");
125 print_proxy( "};\n");
127 print_proxy("static int __proxy_filter( struct __proxy_frame *__frame )\n");
129 print_proxy( " return (__frame->_StubMsg.dwStubPhase != PROXY_SENDRECEIVE);\n");
132 print_proxy("static void __stub_finally( struct __stub_frame *__frame )\n");
136 write_formatstringsdecl(proxy
, indent
, stmts
, need_proxy
);
137 write_stubdescproto();
140 static void clear_output_vars( const var_list_t
*args
)
145 LIST_FOR_EACH_ENTRY( arg
, args
, const var_t
, entry
)
147 if (is_attr(arg
->attrs
, ATTR_OUT
) && !is_attr(arg
->attrs
, ATTR_IN
)) {
148 print_proxy( "if(%s)\n", arg
->name
);
150 print_proxy( "MIDL_memset( %s, 0, sizeof( *%s ));\n", arg
->name
, arg
->name
);
156 int is_var_ptr(const var_t
*v
)
158 return is_ptr(v
->type
);
161 int cant_be_null(const var_t
*v
)
163 /* Search backwards for the most recent pointer attribute. */
164 const attr_list_t
*attrs
= v
->attrs
;
165 const type_t
*type
= v
->type
;
167 /* context handles have their own checking so they can be null for the
168 * purposes of null ref pointer checking */
169 if (is_aliaschain_attr(type
, ATTR_CONTEXTHANDLE
))
180 int t
= get_attrv(attrs
, ATTR_POINTERTYPE
);
182 if (t
== RPC_FC_FP
|| t
== RPC_FC_OP
|| t
== RPC_FC_UP
)
197 return 1; /* Default is RPC_FC_RP. */
200 static void proxy_check_pointers( const var_list_t
*args
)
205 LIST_FOR_EACH_ENTRY( arg
, args
, const var_t
, entry
)
207 if (is_var_ptr(arg
) && cant_be_null(arg
)) {
208 print_proxy( "if(!%s)\n", arg
->name
);
210 print_proxy( "RpcRaiseException(RPC_X_NULL_REF_POINTER);\n");
216 static void free_variable( const var_t
*arg
, const char *local_var_prefix
)
218 unsigned int type_offset
= arg
->type
->typestring_offset
;
220 type_t
*type
= arg
->type
;
221 expr_t
*size
= get_size_is_expr(type
, arg
->name
);
225 print_proxy( "__frame->_StubMsg.MaxCount = " );
226 write_expr(proxy
, size
, 0, 1, NULL
, NULL
, local_var_prefix
);
227 fprintf(proxy
, ";\n\n");
228 print_proxy( "NdrClearOutParameters( &__frame->_StubMsg, ");
229 fprintf(proxy
, "&__MIDL_TypeFormatString.Format[%u], ", type_offset
);
230 fprintf(proxy
, "(void*)%s );\n", arg
->name
);
250 iid
= get_attrp( arg
->attrs
, ATTR_IIDIS
);
253 print_proxy( "__frame->_StubMsg.MaxCount = (unsigned long) " );
254 write_expr(proxy
, iid
, 1, 1, NULL
, NULL
, local_var_prefix
);
255 print_proxy( ";\n\n" );
257 print_proxy( "NdrClearOutParameters( &__frame->_StubMsg, ");
258 fprintf(proxy
, "&__MIDL_TypeFormatString.Format[%u], ", type_offset
);
259 fprintf(proxy
, "(void*)%s );\n", arg
->name
);
263 print_proxy("/* FIXME: %s code for %s type %d missing */\n", __FUNCTION__
, arg
->name
, type
->type
);
267 static void proxy_free_variables( var_list_t
*args
, const char *local_var_prefix
)
272 LIST_FOR_EACH_ENTRY( arg
, args
, const var_t
, entry
)
273 if (is_attr(arg
->attrs
, ATTR_OUT
))
275 free_variable( arg
, local_var_prefix
);
276 fprintf(proxy
, "\n");
280 static void gen_proxy(type_t
*iface
, const func_t
*cur
, int idx
,
281 unsigned int proc_offset
)
283 var_t
*def
= cur
->def
;
284 int has_ret
= !is_void(get_func_return_type(cur
));
285 int has_full_pointer
= is_full_pointer_function(cur
);
286 const char *callconv
= get_attrp(def
->type
->attrs
, ATTR_CALLCONV
);
287 if (!callconv
) callconv
= "";
290 print_proxy( "static void __finally_%s_%s_Proxy( struct __proxy_frame *__frame )\n",
291 iface
->name
, get_name(def
) );
294 if (has_full_pointer
) write_full_pointer_free(proxy
, indent
, cur
);
295 print_proxy( "NdrProxyFreeBuffer( __frame->This, &__frame->_StubMsg );\n" );
300 write_type_decl_left(proxy
, get_func_return_type(cur
));
301 print_proxy( " %s %s_%s_Proxy(\n", callconv
, iface
->name
, get_name(def
));
302 write_args(proxy
, cur
->args
, iface
->name
, 1, TRUE
);
306 print_proxy( "struct __proxy_frame __f, * const __frame = &__f;\n" );
307 /* local variables */
310 write_type_decl_left(proxy
, get_func_return_type(cur
));
311 print_proxy( " _RetVal;\n");
313 print_proxy( "RPC_MESSAGE _RpcMessage;\n" );
315 if (decl_indirect(get_func_return_type(cur
)))
316 print_proxy("void *_p_%s = &%s;\n",
317 "_RetVal", "_RetVal");
321 print_proxy( "RpcExceptionInit( __proxy_filter, __finally_%s_%s_Proxy );\n", iface
->name
, get_name(def
) );
322 print_proxy( "__frame->This = This;\n" );
324 if (has_full_pointer
)
325 write_full_pointer_init(proxy
, indent
, cur
, FALSE
);
328 clear_output_vars( cur
->args
);
330 print_proxy( "RpcTryExcept\n" );
331 print_proxy( "{\n" );
333 print_proxy( "NdrProxyInitialize(This, &_RpcMessage, &__frame->_StubMsg, &Object_StubDesc, %d);\n", idx
);
334 proxy_check_pointers( cur
->args
);
336 print_proxy( "RpcTryFinally\n" );
337 print_proxy( "{\n" );
340 write_remoting_arguments(proxy
, indent
, cur
, "", PASS_IN
, PHASE_BUFFERSIZE
);
342 print_proxy( "NdrProxyGetBuffer(This, &__frame->_StubMsg);\n" );
344 write_remoting_arguments(proxy
, indent
, cur
, "", PASS_IN
, PHASE_MARSHAL
);
346 print_proxy( "NdrProxySendReceive(This, &__frame->_StubMsg);\n" );
347 fprintf(proxy
, "\n");
348 print_proxy( "__frame->_StubMsg.BufferStart = _RpcMessage.Buffer;\n" );
349 print_proxy( "__frame->_StubMsg.BufferEnd = __frame->_StubMsg.BufferStart + _RpcMessage.BufferLength;\n\n" );
351 print_proxy("if ((_RpcMessage.DataRepresentation & 0xffff) != NDR_LOCAL_DATA_REPRESENTATION)\n");
353 print_proxy("NdrConvert( &__frame->_StubMsg, &__MIDL_ProcFormatString.Format[%u]);\n", proc_offset
);
355 fprintf(proxy
, "\n");
357 write_remoting_arguments(proxy
, indent
, cur
, "", PASS_OUT
, PHASE_UNMARSHAL
);
361 if (decl_indirect(get_func_return_type(cur
)))
362 print_proxy("MIDL_memset(&%s, 0, sizeof(%s));\n", "_RetVal", "_RetVal");
363 else if (is_ptr(get_func_return_type(cur
)) || is_array(get_func_return_type(cur
)))
364 print_proxy("%s = 0;\n", "_RetVal");
365 write_remoting_arguments(proxy
, indent
, cur
, "", PASS_RETURN
, PHASE_UNMARSHAL
);
370 print_proxy( "RpcFinally\n" );
371 print_proxy( "{\n" );
373 print_proxy( "__finally_%s_%s_Proxy( __frame );\n", iface
->name
, get_name(def
) );
376 print_proxy( "RpcEndFinally\n" );
378 print_proxy( "}\n" );
379 print_proxy( "RpcExcept(__frame->_StubMsg.dwStubPhase != PROXY_SENDRECEIVE)\n" );
380 print_proxy( "{\n" );
383 proxy_free_variables( cur
->args
, "" );
384 print_proxy( "_RetVal = NdrProxyErrorHandler(RpcExceptionCode());\n" );
387 print_proxy( "}\n" );
388 print_proxy( "RpcEndExcept\n" );
391 print_proxy( "return _RetVal;\n" );
398 static void gen_stub(type_t
*iface
, const func_t
*cur
, const char *cas
,
399 unsigned int proc_offset
)
401 var_t
*def
= cur
->def
;
403 int has_ret
= !is_void(get_func_return_type(cur
));
404 int has_full_pointer
= is_full_pointer_function(cur
);
407 print_proxy( "void __RPC_STUB %s_%s_Stub(\n", iface
->name
, get_name(def
));
409 print_proxy( "IRpcStubBuffer* This,\n");
410 print_proxy( "IRpcChannelBuffer *_pRpcChannelBuffer,\n");
411 print_proxy( "PRPC_MESSAGE _pRpcMessage,\n");
412 print_proxy( "DWORD* _pdwStubPhase)\n");
416 print_proxy( "struct __stub_frame __f, * const __frame = &__f;\n" );
417 print_proxy("%s * _This = (%s*)((CStdStubBuffer*)This)->pvServerObject;\n", iface
->name
, iface
->name
);
418 declare_stub_args( proxy
, indent
, cur
);
419 fprintf(proxy
, "\n");
423 print_proxy("NdrStubInitialize(_pRpcMessage, &__frame->_StubMsg, &Object_StubDesc, _pRpcChannelBuffer);\n");
424 fprintf(proxy
, "\n");
425 print_proxy( "RpcExceptionInit( 0, __stub_finally );\n" );
427 write_parameters_init(proxy
, indent
, cur
, "");
429 print_proxy("RpcTryFinally\n");
432 if (has_full_pointer
)
433 write_full_pointer_init(proxy
, indent
, cur
, TRUE
);
434 print_proxy("if ((_pRpcMessage->DataRepresentation & 0xffff) != NDR_LOCAL_DATA_REPRESENTATION)\n");
436 print_proxy("NdrConvert( &__frame->_StubMsg, &__MIDL_ProcFormatString.Format[%u]);\n", proc_offset
);
438 fprintf(proxy
, "\n");
440 write_remoting_arguments(proxy
, indent
, cur
, "", PASS_IN
, PHASE_UNMARSHAL
);
441 fprintf(proxy
, "\n");
443 assign_stub_out_args( proxy
, indent
, cur
, "" );
445 print_proxy("*_pdwStubPhase = STUB_CALL_SERVER;\n");
446 fprintf(proxy
, "\n");
448 if (has_ret
) fprintf(proxy
, "_RetVal = ");
449 if (cas
) fprintf(proxy
, "%s_%s_Stub", iface
->name
, cas
);
450 else fprintf(proxy
, "_This->lpVtbl->%s", get_name(def
));
451 fprintf(proxy
, "(_This");
455 LIST_FOR_EACH_ENTRY( arg
, cur
->args
, const var_t
, entry
)
456 fprintf(proxy
, ", %s%s", arg
->type
->declarray
? "*" : "", get_name(arg
));
458 fprintf(proxy
, ");\n");
459 fprintf(proxy
, "\n");
460 print_proxy("*_pdwStubPhase = STUB_MARSHAL;\n");
461 fprintf(proxy
, "\n");
463 write_remoting_arguments(proxy
, indent
, cur
, "", PASS_OUT
, PHASE_BUFFERSIZE
);
465 if (!is_void(get_func_return_type(cur
)))
466 write_remoting_arguments(proxy
, indent
, cur
, "", PASS_RETURN
, PHASE_BUFFERSIZE
);
468 print_proxy("NdrStubGetBuffer(This, _pRpcChannelBuffer, &__frame->_StubMsg);\n");
470 write_remoting_arguments(proxy
, indent
, cur
, "", PASS_OUT
, PHASE_MARSHAL
);
471 fprintf(proxy
, "\n");
473 /* marshall the return value */
474 if (!is_void(get_func_return_type(cur
)))
475 write_remoting_arguments(proxy
, indent
, cur
, "", PASS_RETURN
, PHASE_MARSHAL
);
479 print_proxy("RpcFinally\n");
482 write_remoting_arguments(proxy
, indent
+1, cur
, "", PASS_OUT
, PHASE_FREE
);
484 if (has_full_pointer
)
485 write_full_pointer_free(proxy
, indent
, cur
);
488 print_proxy("RpcEndFinally\n");
490 print_proxy("_pRpcMessage->BufferLength = __frame->_StubMsg.Buffer - (unsigned char *)_pRpcMessage->Buffer;\n");
497 static int write_proxy_methods(type_t
*iface
, int skip
)
502 if (iface
->ref
) i
= write_proxy_methods(iface
->ref
, iface
->ref
->ref
!= NULL
);
503 if (iface
->funcs
) LIST_FOR_EACH_ENTRY( cur
, iface
->funcs
, const func_t
, entry
) {
504 var_t
*def
= cur
->def
;
505 if (!is_callas(def
->attrs
)) {
506 if (i
) fprintf(proxy
, ",\n");
507 if (skip
) print_proxy( "0 /* %s_%s_Proxy */", iface
->name
, get_name(def
));
508 else print_proxy( "%s_%s_Proxy", iface
->name
, get_name(def
));
515 static int write_stub_methods(type_t
*iface
, int skip
)
520 if (iface
->ref
) i
= write_stub_methods(iface
->ref
, TRUE
);
521 else return i
; /* skip IUnknown */
523 if (iface
->funcs
) LIST_FOR_EACH_ENTRY( cur
, iface
->funcs
, const func_t
, entry
) {
524 var_t
*def
= cur
->def
;
525 if (!is_local(def
->attrs
)) {
526 if (i
) fprintf(proxy
,",\n");
527 if (skip
) print_proxy("STUB_FORWARDING_FUNCTION");
528 else print_proxy( "%s_%s_Stub", iface
->name
, get_name(def
));
535 static void write_proxy(type_t
*iface
, unsigned int *proc_offset
)
537 int midx
= -1, stubs
;
540 if (!iface
->funcs
) return;
542 /* FIXME: check for [oleautomation], shouldn't generate proxies/stubs if specified */
544 fprintf(proxy
, "/*****************************************************************************\n");
545 fprintf(proxy
, " * %s interface\n", iface
->name
);
546 fprintf(proxy
, " */\n");
547 LIST_FOR_EACH_ENTRY( cur
, iface
->funcs
, const func_t
, entry
)
549 const var_t
*def
= cur
->def
;
550 if (!is_local(def
->attrs
)) {
551 const var_t
*cas
= is_callas(def
->attrs
);
552 const char *cname
= cas
? cas
->name
: NULL
;
556 LIST_FOR_EACH_ENTRY( m
, iface
->funcs
, const func_t
, entry
)
557 if (!strcmp(m
->def
->name
, cname
))
563 gen_proxy(iface
, cur
, idx
, *proc_offset
);
564 gen_stub(iface
, cur
, cname
, *proc_offset
);
565 *proc_offset
+= get_size_procformatstring_func( cur
);
566 if (midx
== -1) midx
= idx
;
567 else if (midx
!= idx
) error("method index mismatch in write_proxy\n");
573 print_proxy( "static const CINTERFACE_PROXY_VTABLE(%d) _%sProxyVtbl =\n", midx
, iface
->name
);
576 print_proxy( "{\n", iface
->name
);
578 print_proxy( "&IID_%s,\n", iface
->name
);
580 print_proxy( "},\n");
583 write_proxy_methods(iface
, FALSE
);
584 fprintf(proxy
, "\n");
588 print_proxy( "};\n");
589 fprintf(proxy
, "\n\n");
592 print_proxy( "static const PRPC_STUB_FUNCTION %s_table[] =\n", iface
->name
);
595 stubs
= write_stub_methods(iface
, FALSE
);
596 fprintf(proxy
, "\n");
598 fprintf(proxy
, "};\n");
600 print_proxy( "static const CInterfaceStubVtbl _%sStubVtbl =\n", iface
->name
);
605 print_proxy( "&IID_%s,\n", iface
->name
);
606 print_proxy( "0,\n");
607 print_proxy( "%d,\n", stubs
+3);
608 print_proxy( "&%s_table[-3],\n", iface
->name
);
610 print_proxy( "},\n", iface
->name
);
613 print_proxy( "CStdStubBuffer_METHODS\n");
617 print_proxy( "};\n");
621 static int does_any_iface(const statement_list_t
*stmts
, type_pred_t pred
)
623 const statement_t
*stmt
;
626 LIST_FOR_EACH_ENTRY(stmt
, stmts
, const statement_t
, entry
)
628 if (stmt
->type
== STMT_LIBRARY
)
630 if (does_any_iface(stmt
->u
.lib
->stmts
, pred
))
633 else if (stmt
->type
== STMT_TYPE
&& stmt
->u
.type
->type
== RPC_FC_IP
)
635 if (pred(stmt
->u
.type
))
643 int need_proxy(const type_t
*iface
)
645 return is_object(iface
->attrs
) && !is_local(iface
->attrs
);
648 int need_stub(const type_t
*iface
)
650 return !is_object(iface
->attrs
) && !is_local(iface
->attrs
);
653 int need_proxy_file(const statement_list_t
*stmts
)
655 return does_any_iface(stmts
, need_proxy
);
658 int need_stub_files(const statement_list_t
*stmts
)
660 return does_any_iface(stmts
, need_stub
);
663 static void write_proxy_stmts(const statement_list_t
*stmts
, unsigned int *proc_offset
)
665 const statement_t
*stmt
;
666 if (stmts
) LIST_FOR_EACH_ENTRY( stmt
, stmts
, const statement_t
, entry
)
668 if (stmt
->type
== STMT_LIBRARY
)
669 write_proxy_stmts(stmt
->u
.lib
->stmts
, proc_offset
);
670 else if (stmt
->type
== STMT_TYPE
&& stmt
->u
.type
->type
== RPC_FC_IP
)
672 if (need_proxy(stmt
->u
.type
))
673 write_proxy(stmt
->u
.type
, proc_offset
);
678 static void write_proxy_iface_name_format(const statement_list_t
*stmts
, const char *format
)
680 const statement_t
*stmt
;
681 if (stmts
) LIST_FOR_EACH_ENTRY( stmt
, stmts
, const statement_t
, entry
)
683 if (stmt
->type
== STMT_LIBRARY
)
684 write_proxy_iface_name_format(stmt
->u
.lib
->stmts
, format
);
685 else if (stmt
->type
== STMT_TYPE
&& stmt
->u
.type
->type
== RPC_FC_IP
)
687 type_t
*iface
= stmt
->u
.type
;
688 if (iface
->ref
&& iface
->funcs
&& need_proxy(iface
))
689 fprintf(proxy
, format
, iface
->name
);
694 static void write_iid_lookup(const statement_list_t
*stmts
, const char *file_id
, int *c
)
696 const statement_t
*stmt
;
697 if (stmts
) LIST_FOR_EACH_ENTRY( stmt
, stmts
, const statement_t
, entry
)
699 if (stmt
->type
== STMT_LIBRARY
)
700 write_iid_lookup(stmt
->u
.lib
->stmts
, file_id
, c
);
701 else if (stmt
->type
== STMT_TYPE
&& stmt
->u
.type
->type
== RPC_FC_IP
)
703 type_t
*iface
= stmt
->u
.type
;
704 if(iface
->ref
&& iface
->funcs
&& need_proxy(iface
))
706 fprintf(proxy
, " if (!_%s_CHECK_IID(%d))\n", file_id
, *c
);
707 fprintf(proxy
, " {\n");
708 fprintf(proxy
, " *pIndex = %d;\n", *c
);
709 fprintf(proxy
, " return 1;\n");
710 fprintf(proxy
, " }\n");
717 void write_proxies(const statement_list_t
*stmts
)
719 int expr_eval_routines
;
720 char *file_id
= proxy_token
;
722 unsigned int proc_offset
= 0;
724 if (!do_proxies
) return;
725 if (do_everything
&& !need_proxy_file(stmts
)) return;
730 write_proxy_stmts(stmts
, &proc_offset
);
732 expr_eval_routines
= write_expr_eval_routines(proxy
, proxy_token
);
733 if (expr_eval_routines
)
734 write_expr_eval_routine_list(proxy
, proxy_token
);
735 write_user_quad_list(proxy
);
736 write_stubdesc(expr_eval_routines
);
738 print_proxy( "#if !defined(__RPC_WIN32__)\n");
739 print_proxy( "#error Currently only Wine and WIN32 are supported.\n");
740 print_proxy( "#endif\n");
742 write_procformatstring(proxy
, stmts
, need_proxy
);
743 write_typeformatstring(proxy
, stmts
, need_proxy
);
745 fprintf(proxy
, "static const CInterfaceProxyVtbl* const _%s_ProxyVtblList[] =\n", file_id
);
746 fprintf(proxy
, "{\n");
747 write_proxy_iface_name_format(stmts
, " (const CInterfaceProxyVtbl*)&_%sProxyVtbl,\n");
748 fprintf(proxy
, " 0\n");
749 fprintf(proxy
, "};\n");
750 fprintf(proxy
, "\n");
752 fprintf(proxy
, "static const CInterfaceStubVtbl* const _%s_StubVtblList[] =\n", file_id
);
753 fprintf(proxy
, "{\n");
754 write_proxy_iface_name_format(stmts
, " (const CInterfaceStubVtbl*)&_%sStubVtbl,\n");
755 fprintf(proxy
, " 0\n");
756 fprintf(proxy
, "};\n");
757 fprintf(proxy
, "\n");
759 fprintf(proxy
, "static PCInterfaceName const _%s_InterfaceNamesList[] =\n", file_id
);
760 fprintf(proxy
, "{\n");
761 write_proxy_iface_name_format(stmts
, " \"%s\",\n");
762 fprintf(proxy
, " 0\n");
763 fprintf(proxy
, "};\n");
764 fprintf(proxy
, "\n");
766 fprintf(proxy
, "#define _%s_CHECK_IID(n) IID_GENERIC_CHECK_IID(_%s, pIID, n)\n", file_id
, file_id
);
767 fprintf(proxy
, "\n");
768 fprintf(proxy
, "int __stdcall _%s_IID_Lookup(const IID* pIID, int* pIndex)\n", file_id
);
769 fprintf(proxy
, "{\n");
771 write_iid_lookup(stmts
, file_id
, &c
);
772 fprintf(proxy
, " return 0;\n");
773 fprintf(proxy
, "}\n");
774 fprintf(proxy
, "\n");
776 fprintf(proxy
, "const ExtendedProxyFileInfo %s_ProxyFileInfo =\n", file_id
);
777 fprintf(proxy
, "{\n");
778 fprintf(proxy
, " (const PCInterfaceProxyVtblList*)&_%s_ProxyVtblList,\n", file_id
);
779 fprintf(proxy
, " (const PCInterfaceStubVtblList*)&_%s_StubVtblList,\n", file_id
);
780 fprintf(proxy
, " _%s_InterfaceNamesList,\n", file_id
);
781 fprintf(proxy
, " 0,\n");
782 fprintf(proxy
, " &_%s_IID_Lookup,\n", file_id
);
783 fprintf(proxy
, " %d,\n", c
);
784 fprintf(proxy
, " 1,\n");
785 fprintf(proxy
, " 0,\n");
786 fprintf(proxy
, " 0,\n");
787 fprintf(proxy
, " 0,\n");
788 fprintf(proxy
, " 0\n");
789 fprintf(proxy
, "};\n");