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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 int print_proxy( const char *format, ... )
58 va_start( va, format );
59 for( i=0; i<indent; i++ )
60 fprintf( proxy, " " );
61 r = vfprintf( proxy, format, va );
67 static type_t *get_base_type( var_t *arg )
69 type_t *t = arg->type;
70 while( (t->type == 0) && t->ref )
75 static void write_stubdescproto(void)
77 print_proxy( "extern const MIDL_STUB_DESC Object_StubDesc;\n");
81 static void write_stubdesc(void)
83 print_proxy( "const MIDL_STUB_DESC Object_StubDesc = {\n");
84 print_proxy( " 0,\n");
85 print_proxy( " NdrOleAllocate,\n");
86 print_proxy( " NdrOleFree,\n");
87 print_proxy( " {0}, 0, 0, 0, 0,\n");
88 print_proxy( " 0 /* __MIDL_TypeFormatString.Format */\n");
93 static void write_formatdesc( const char *str )
95 print_proxy( "typedef struct _MIDL_%s_FORMAT_STRING\n", str );
98 print_proxy( "short Pad;\n");
99 print_proxy( "unsigned char Format[%s_FORMAT_STRING_SIZE];\n", str);
101 print_proxy( "} MIDL_%s_FORMAT_STRING;\n", str);
105 static void write_formatstringsdecl(void)
107 print_proxy( "#define TYPE_FORMAT_STRING_SIZE %d\n",1); /* FIXME */
108 print_proxy( "#define PROC_FORMAT_STRING_SIZE %d\n",1); /* FIXME */
109 fprintf(proxy, "\n");
110 write_formatdesc( "TYPE" );
111 write_formatdesc( "PROC" );
112 fprintf(proxy, "\n");
113 print_proxy( "extern const MIDL_TYPE_FORMAT_STRING __MIDL_TypeFormatString;\n");
114 print_proxy( "extern const MIDL_PROC_FORMAT_STRING __MIDL_ProcFormatString;\n");
118 static void write_formatstring( int proc )
131 print_proxy( "static const MIDL_%s_FORMAT_STRING __MIDL_%sFormatString =\n", t, n);
134 print_proxy( "0,\n");
141 print_proxy( "};\n");
145 static void init_proxy(void)
148 if(!(proxy = fopen(proxy_name, "w")))
149 error("Could not open %s for output\n", proxy_name);
150 print_proxy( "/*** Autogenerated by WIDL %s - Do not edit ***/\n", WIDL_FULLVERSION);
152 print_proxy( "#ifndef __REDQ_RPCPROXY_H_VERSION__\n");
153 print_proxy( "#define __REQUIRED_RPCPROXY_H_VERSION__ 440\n");
154 print_proxy( "#endif /* __REDQ_RPCPROXY_H_VERSION__ */\n");
156 print_proxy( "#include \"rpcproxy.h\"\n");
157 print_proxy( "#ifndef __RPCPROXY_H_VERSION__\n");
158 print_proxy( "#error This code needs a newer version of rpcproxy.h\n");
159 print_proxy( "#endif /* __RPCPROXY_H_VERSION__ */\n");
161 print_proxy( "#include \"%s\"\n", header_name);
163 write_formatstringsdecl();
164 write_stubdescproto();
167 static void clear_output_vars( var_t *arg )
171 if (is_attr(arg->attrs, ATTR_OUT) && !is_attr(arg->attrs, ATTR_IN)) {
172 print_proxy( "if(%s)\n", arg->name );
174 print_proxy( "MIDL_memset( %s, 0, sizeof( ", arg->name );
176 write_type(proxy, arg->type, arg, arg->tname);
177 fprintf( proxy, " ));\n" );
179 arg = PREV_LINK(arg);
183 static int is_pointer(var_t *arg)
187 if (arg->type->type == RPC_FC_FP )
192 static void proxy_check_pointers( var_t *arg )
196 if (is_pointer(arg)) {
197 print_proxy( "if(!%s)\n", arg->name );
199 print_proxy( "RpcRaiseException(RPC_X_NULL_REF_POINTER);\n");
202 arg = PREV_LINK(arg);
206 static void marshall_size_arg( var_t *arg )
209 type_t *type = get_base_type(arg);
212 expr = get_attrp( arg->attrs, ATTR_SIZEIS );
215 print_proxy( "_StubMsg.MaxCount = ", arg->name );
216 write_expr(proxy, expr);
217 fprintf(proxy, ";\n\n");
218 print_proxy( "NdrConformantArrayBufferSize( &_StubMsg, (unsigned char*)%s, ", arg->name );
219 fprintf(proxy, "&__MIDL_TypeFormatString.Format[%d]);\n", index );
227 print_proxy( "_StubMsg.BufferLength += %d; /* %s */\n", 1, arg->name );
234 print_proxy( "_StubMsg.BufferLength += %d; /* %s */\n", 2, arg->name );
240 print_proxy( "_StubMsg.BufferLength += %d; /* %s */\n", 4, arg->name );
244 print_proxy( "NdrSimpleStructBufferSize(&_StubMsg, (unsigned char*)%s, ", arg->name );
245 fprintf(proxy, "&__MIDL_TypeFormatString.Format[%d] );\n", index );
248 case RPC_FC_C_CSTRING:
249 case RPC_FC_C_WSTRING:
251 print_proxy( "NdrConformantArrayBufferSize( &_StubMsg, (unsigned char*)%s, ", arg->name );
252 fprintf(proxy, "&__MIDL_TypeFormatString.Format[%d]);\n", index );
255 case RPC_FC_BOGUS_STRUCT:
256 print_proxy( "NdrComplexStructBufferSize(&_StubMsg, (unsigned char*)%s, ", arg->name );
257 fprintf(proxy, "&__MIDL_TypeFormatString.Format[%d] );\n", index );
263 memset( &temp, 0, sizeof temp );
264 temp.type = type->ref;
265 temp.name = arg->name; /* FIXME */
267 print_proxy( "/* FIXME: %s use the right name for %s */\n", __FUNCTION__, arg->name );
269 marshall_size_arg( &temp );
274 print_proxy( "NdrPointerBufferSize( &_StubMsg, (unsigned char*)%s, ", arg->name );
275 fprintf(proxy, "&__MIDL_TypeFormatString.Format[%d]);\n", index );
279 print_proxy("/* FIXME: %s code for %s type %d missing */\n", __FUNCTION__, arg->name, type->type );
283 static void proxy_gen_marshall_size( var_t *arg )
285 print_proxy( "_StubMsg.BufferLength = 0U;\n" );
289 if (is_attr(arg->attrs, ATTR_IN))
291 marshall_size_arg( arg );
292 fprintf(proxy, "\n");
294 arg = PREV_LINK(arg);
298 static void marshall_copy_arg( var_t *arg )
301 type_t *type = get_base_type(arg);
304 expr = get_attrp( arg->attrs, ATTR_SIZEIS );
307 print_proxy( "_StubMsg.MaxCount = ", arg->name );
308 write_expr(proxy, expr);
309 fprintf(proxy, ";\n\n");
310 print_proxy( "NdrConformantArrayMarshall( &_StubMsg, (unsigned char*)%s, ", arg->name );
311 fprintf(proxy, "&__MIDL_TypeFormatString.Format[%d]);\n", index );
327 write_type(proxy, arg->type, arg, arg->tname);
328 fprintf(proxy,"*)_StubMsg.Buffer)++ = %s;\n", arg->name );
332 /* FIXME: add the format string, and set the index below */
333 print_proxy( "NdrSimpleStructMarshall(&_StubMsg, (unsigned char*)%s, ", arg->name );
334 fprintf(proxy, "&__MIDL_TypeFormatString.Format[%d]);\n", index );
337 case RPC_FC_C_CSTRING:
338 case RPC_FC_C_WSTRING:
342 case RPC_FC_BOGUS_STRUCT:
343 print_proxy( "NdrComplexStructMarshall(&_StubMsg, (unsigned char*)%s, ", arg->name );
344 fprintf(proxy, "&__MIDL_TypeFormatString.Format[%d] );\n", index );
350 memset( &temp, 0, sizeof temp );
351 temp.type = type->ref;
352 temp.name = arg->name; /* FIXME */
354 print_proxy( "/* FIXME: %s use the right name for %s */\n", __FUNCTION__, arg->name );
356 marshall_copy_arg( &temp );
361 print_proxy( "NdrPointerMarshall( &_StubMsg, (unsigned char*)%s, ", arg->name );
362 fprintf(proxy, "&__MIDL_TypeFormatString.Format[%d]);\n", index );
366 print_proxy("/* FIXME: %s code for %s type %d missing */\n", __FUNCTION__, arg->name, type->type );
370 static void gen_marshall_copydata( var_t *arg )
374 if (is_attr(arg->attrs, ATTR_IN))
376 marshall_copy_arg( arg );
377 fprintf(proxy, "\n");
379 arg = PREV_LINK(arg);
383 static void gen_marshall( var_t *arg )
385 /* generated code to determine the size of the buffer required */
386 proxy_gen_marshall_size( arg );
388 /* generated code to allocate the buffer */
389 print_proxy( "NdrProxyGetBuffer(This, &_StubMsg);\n" );
391 /* generated code to copy the args into the buffer */
392 gen_marshall_copydata( arg );
397 static void unmarshall_copy_arg( var_t *arg )
400 type_t *type = get_base_type(arg);
403 expr = get_attrp( arg->attrs, ATTR_SIZEIS );
406 print_proxy( "NdrConformantArrayUnmarshall( &_StubMsg, (unsigned char*)%s, ", arg->name );
407 fprintf(proxy, "&__MIDL_TypeFormatString.Format[%d]);\n", index );
422 print_proxy( "%s = *((", arg->name );
423 write_type(proxy, arg->type, arg, arg->tname);
424 fprintf(proxy,"*)_StubMsg.Buffer)++;\n");
428 print_proxy( "NdrSimpleStructUnmarshall(&_StubMsg, (unsigned char**)%s, ", arg->name );
429 fprintf(proxy, "&__MIDL_TypeFormatString.Format[%d], 0);\n", index );
432 case RPC_FC_C_CSTRING:
433 case RPC_FC_C_WSTRING:
435 print_proxy( "NdrConformantArrayUnmarshall( &_StubMsg, (unsigned char*)%s, ", arg->name );
436 fprintf(proxy, "&__MIDL_TypeFormatString.Format[%d]);\n", index );
439 case RPC_FC_BOGUS_STRUCT:
440 print_proxy( "NdrComplexStructUnmarshall(&_StubMsg, (unsigned char*)%s, ", arg->name );
441 fprintf(proxy, "&__MIDL_TypeFormatString.Format[%d], 0 );\n", index );
447 memset( &temp, 0, sizeof temp );
448 temp.type = type->ref;
449 temp.name = arg->name; /* FIXME */
451 print_proxy( "/* FIXME: %s use the right name for %s */\n", __FUNCTION__, arg->name );
453 unmarshall_copy_arg( &temp );
458 print_proxy( "NdrPointerUnmarshall(&_StubMsg, (unsigned char**)&%s, ", arg->name );
459 fprintf(proxy, "&__MIDL_TypeFormatString.Format[%d], 0);\n", index );
463 print_proxy("/* FIXME: %s code for %s type %d missing */\n", __FUNCTION__, arg->name, type->type );
467 static void gen_unmarshall( var_t *arg )
471 if (is_attr(arg->attrs, ATTR_OUT))
473 unmarshall_copy_arg( arg );
474 fprintf(proxy, "\n");
476 arg = PREV_LINK(arg);
480 static void free_variable( var_t *arg )
483 int index = 0; /* FIXME */
487 expr = get_attrp( arg->attrs, ATTR_SIZEIS );
490 print_proxy( "_StubMsg.MaxCount = ", arg->name );
491 write_expr(proxy, expr);
492 fprintf(proxy, ";\n\n");
493 print_proxy( "NdrClearOutParameters( &_StubMsg, ");
494 fprintf(proxy, "&__MIDL_TypeFormatString.Format[%d], ", index );
495 fprintf(proxy, "(void*)%s );\n", arg->name );
499 type = get_base_type(arg);
516 constraint = get_attrp( arg->attrs, ATTR_IIDIS );
518 print_proxy( "_StubMsg.MaxCount = (unsigned long) ( %s );\n",constraint->name);
519 print_proxy( "NdrClearOutParameters( &_StubMsg, ");
520 fprintf(proxy, "&__MIDL_TypeFormatString.Format[%d], ", index );
521 fprintf(proxy, "(void*)%s );\n", arg->name );
525 print_proxy("/* FIXME: %s code for %s type %d missing */\n", __FUNCTION__, arg->name, type->type );
529 static void proxy_free_variables( var_t *arg )
533 if (is_attr(arg->attrs, ATTR_OUT))
535 free_variable( arg );
536 fprintf(proxy, "\n");
538 arg = PREV_LINK(arg);
542 static void gen_proxy(type_t *iface, func_t *cur, int idx)
544 var_t *def = cur->def;
545 int has_ret = !is_void(def->type, def);
548 write_type(proxy, def->type, def, def->tname);
549 print_proxy( " STDMETHODCALLTYPE %s_", iface->name);
550 write_name(proxy, def);
551 print_proxy( "_Proxy(\n");
552 write_args(proxy, cur->args, iface->name, 1, TRUE);
556 /* local variables */
559 write_type(proxy, def->type, def, def->tname);
560 print_proxy( " _RetVal;\n");
562 print_proxy( "RPC_MESSAGE _Msg;\n" );
563 print_proxy( "MIDL_STUB_MESSAGE _StubMsg;\n" );
567 clear_output_vars( cur->args );
569 print_proxy( "RpcTryExcept\n" );
570 print_proxy( "{\n" );
572 print_proxy( "NdrProxyInitialize(This, &_Msg, &_StubMsg, &Object_StubDesc, %d);\n", idx);
573 proxy_check_pointers( cur->args );
575 print_proxy( "RpcTryFinally\n" );
576 print_proxy( "{\n" );
579 gen_marshall( cur->args );
581 print_proxy( "NdrProxySendReceive(This, &_StubMsg);\n" );
582 fprintf(proxy, "\n");
583 print_proxy("if ((_Msg.DataRepresentation&0xffff) != NDR_LOCAL_DATA_REPRESENTATION)\n");
585 print_proxy("NdrConvert( &_StubMsg, &__MIDL_ProcFormatString.Format[0]);\n" );
587 fprintf(proxy, "\n");
589 gen_unmarshall( cur->args );
592 * FIXME: We only need to round the buffer up if it could be unaligned...
593 * We should calculate how much buffer we used and output the following
594 * line only if necessary.
596 print_proxy( "_StubMsg.Buffer = (unsigned char *)(((long)_StubMsg.Buffer + 3) & ~ 0x3);\n");
598 print_proxy( "_RetVal = *((" );
599 write_type(proxy, def->type, def, def->tname);
600 fprintf(proxy, "*)_StubMsg.Buffer)++;\n");
605 print_proxy( "RpcFinally\n" );
606 print_proxy( "{\n" );
608 print_proxy( "NdrProxyFreeBuffer(This, &_StubMsg);\n" );
611 print_proxy( "RpcEndFinally\n" );
613 print_proxy( "}\n" );
614 print_proxy( "RpcExcept(_StubMsg.dwStubPhase != PROXY_SENDRECEIVE)\n" );
615 print_proxy( "{\n" );
618 proxy_free_variables( cur->args );
619 print_proxy( "_RetVal = NdrProxyErrorHandler(RpcExceptionCode());\n" );
622 print_proxy( "}\n" );
623 print_proxy( "RpcEndExcept\n" );
626 print_proxy( "return _RetVal;\n" );
633 static void stub_write_locals( var_t *arg )
637 int outptr = is_attr(arg->attrs, ATTR_OUT);
639 /* create a temporary variable to store the output */
642 memset( &temp, 0, sizeof temp );
643 temp.ptr_level = arg->ptr_level - 1; /* dereference once */
645 write_type(proxy, arg->type, &temp, arg->tname);
646 fprintf(proxy, " _M%d;\n",n++);
649 write_type(proxy, arg->type, arg, arg->tname);
651 write_name(proxy, arg);
652 fprintf(proxy, ";\n");
653 arg = NEXT_LINK(arg);
657 static void stub_unmarshall( var_t *arg )
662 if (is_attr(arg->attrs, ATTR_IN))
664 unmarshall_copy_arg( arg );
667 else if (is_attr(arg->attrs, ATTR_OUT)) {
668 type_t *type = get_base_type(arg);
672 print_proxy("MIDL_memset(");
673 write_name(proxy, arg);
674 fprintf(proxy,", 0, sizeof(");
675 write_type(proxy, arg->type, arg, arg->tname);
676 fprintf(proxy,"));\n");
680 write_name(proxy, arg);
681 fprintf(proxy," = &_M%d;\n", n);
682 print_proxy("_M%d = 0;\n", n++);
686 arg = PREV_LINK(arg);
690 static void stub_gen_marshall_size( var_t *arg )
692 print_proxy( "_StubMsg.BufferLength = 0U;\n" );
696 if (is_attr(arg->attrs, ATTR_OUT))
697 marshall_size_arg( arg );
698 arg = PREV_LINK(arg);
702 static void stub_gen_marshall_copydata( var_t *arg )
706 if (is_attr(arg->attrs, ATTR_OUT))
707 marshall_copy_arg( arg );
708 arg = PREV_LINK(arg);
712 static void stub_genmarshall( var_t *args )
714 /* FIXME: size buffer */
715 stub_gen_marshall_size( args );
717 print_proxy("NdrStubGetBuffer(This, pRpcChannelBuffer, &_StubMsg);\n");
719 stub_gen_marshall_copydata( args );
722 static void gen_stub(type_t *iface, func_t *cur, char *cas)
724 var_t *def = cur->def;
726 int has_ret = !is_void(def->type, def);
729 print_proxy( "void __RPC_STUB %s_", iface->name);
730 write_name(proxy, def);
731 print_proxy( "_Stub(\n");
733 print_proxy( "IRpcStubBuffer* This,\n");
734 print_proxy( "IRpcChannelBuffer* pRpcChannelBuffer,\n");
735 print_proxy( "PRPC_MESSAGE _Msg,\n");
736 print_proxy( "DWORD* _pdwStubPhase)\n");
740 /* local variables */
743 write_type(proxy, def->type, def, def->tname);
744 fprintf(proxy, " _RetVal;\n");
746 print_proxy("%s * _This = (%s*)((CStdStubBuffer*)This)->pvServerObject;\n", iface->name, iface->name);
747 print_proxy("MIDL_STUB_MESSAGE _StubMsg;\n");
748 stub_write_locals( cur->args );
749 fprintf(proxy, "\n");
753 print_proxy("NdrStubInitialize(_Msg, &_StubMsg, &Object_StubDesc, pRpcChannelBuffer);\n");
754 fprintf(proxy, "\n");
756 print_proxy("RpcTryFinally\n");
759 print_proxy("if ((_Msg->DataRepresentation&0xffff) != NDR_LOCAL_DATA_REPRESENTATION)\n");
761 print_proxy("NdrConvert( &_StubMsg, &__MIDL_ProcFormatString.Format[0]);\n" );
763 fprintf(proxy, "\n");
765 stub_unmarshall( cur->args );
766 fprintf(proxy, "\n");
768 print_proxy("*_pdwStubPhase = STUB_CALL_SERVER;\n");
769 fprintf(proxy, "\n");
771 if (has_ret) fprintf(proxy, "_RetVal = ");
772 fprintf(proxy, "%s_", iface->name);
773 if (cas) fprintf(proxy, "%s_Stub", cas);
774 else write_name(proxy, def);
775 fprintf(proxy, "(_This");
780 fprintf(proxy, ", ");
781 write_name(proxy, arg);
782 arg = PREV_LINK(arg);
785 fprintf(proxy, ");\n");
786 fprintf(proxy, "\n");
787 print_proxy("*_pdwStubPhase = STUB_MARSHAL;\n");
788 fprintf(proxy, "\n");
790 stub_genmarshall( cur->args );
791 fprintf(proxy, "\n");
795 * FIXME: We only need to round the buffer up if it could be unaligned...
796 * We should calculate how much buffer we used and output the following
797 * line only if necessary.
799 print_proxy( "_StubMsg.Buffer = (unsigned char *)(((long)_StubMsg.Buffer + 3) & ~ 0x3);\n");
801 print_proxy( "*((" );
802 write_type(proxy, def->type, def, def->tname);
803 fprintf(proxy, "*)_StubMsg.Buffer)++ = _RetVal;\n");
808 print_proxy("RpcFinally\n");
811 print_proxy("RpcEndFinally\n");
813 print_proxy("_Msg->BufferLength = ((long)_StubMsg.Buffer - (long)_Msg->Buffer);\n");
820 static int write_proxy_methods(type_t *iface)
822 func_t *cur = iface->funcs;
827 if (iface->ref) i = write_proxy_methods(iface->ref);
829 var_t *def = cur->def;
830 if (!is_callas(def->attrs)) {
831 if (i) fprintf(proxy, ",\n");
832 print_proxy( "%s_", iface->name);
833 write_name(proxy, def);
834 fprintf(proxy, "_Proxy");
837 cur = PREV_LINK(cur);
842 static int write_stub_methods(type_t *iface)
844 func_t *cur = iface->funcs;
849 if (iface->ref) i = write_stub_methods(iface->ref);
850 else return i; /* skip IUnknown */
852 var_t *def = cur->def;
853 if (!is_local(def->attrs)) {
854 if (i) fprintf(proxy,",\n");
855 print_proxy( "%s_", iface->name);
856 write_name(proxy, def);
857 fprintf(proxy, "_Stub");
860 cur = PREV_LINK(cur);
865 static void write_proxy(type_t *iface)
867 int midx = -1, stubs;
868 func_t *cur = iface->funcs;
874 /* FIXME: check for [oleautomation], shouldn't generate proxies/stubs if specified */
876 fprintf(proxy, "/*****************************************************************************\n");
877 fprintf(proxy, " * %s interface\n", iface->name);
878 fprintf(proxy, " */\n");
880 var_t *def = cur->def;
881 if (!is_local(def->attrs)) {
882 var_t *cas = is_callas(def->attrs);
883 char *cname = cas ? cas->name : NULL;
886 func_t *m = iface->funcs;
887 while (m && strcmp(get_name(m->def), cname))
891 gen_proxy(iface, cur, idx);
892 gen_stub(iface, cur, cname);
893 if (midx == -1) midx = idx;
894 else if (midx != idx) yyerror("method index mismatch in write_proxy");
897 cur = PREV_LINK(cur);
901 print_proxy( "const CINTERFACE_PROXY_VTABLE(%d) _%sProxyVtbl =\n", midx, iface->name);
904 print_proxy( "{\n", iface->name);
906 print_proxy( "&IID_%s,\n", iface->name);
908 print_proxy( "},\n");
911 write_proxy_methods(iface);
912 fprintf(proxy, "\n");
916 print_proxy( "};\n");
917 fprintf(proxy, "\n\n");
920 print_proxy( "static const PRPC_STUB_FUNCTION %s_table[] =\n", iface->name);
923 stubs = write_stub_methods(iface);
924 fprintf(proxy, "\n");
926 fprintf(proxy, "};\n");
928 print_proxy( "const CInterfaceStubVtbl _%sStubVtbl =\n", iface->name);
933 print_proxy( "&IID_%s,\n", iface->name);
934 print_proxy( "0,\n");
935 print_proxy( "%d,\n", stubs+3);
936 print_proxy( "&%s_table[-3],\n", iface->name);
938 print_proxy( "},\n", iface->name);
941 print_proxy( "CStdStubBuffer_METHODS\n");
945 print_proxy( "};\n");
949 void write_proxies(ifref_t *ifaces)
951 ifref_t *lcur = ifaces;
953 char *file_id = proxy_token;
956 if (!do_proxies) return;
965 if (is_object(cur->iface->attrs) && !is_local(cur->iface->attrs))
966 write_proxy(cur->iface);
967 cur = PREV_LINK(cur);
974 print_proxy( "#if !defined(__RPC_WIN32__)\n");
975 print_proxy( "#error Currently only Wine and WIN32 are supported.\n");
976 print_proxy( "#endif\n");
978 write_formatstring( 1 );
979 write_formatstring( 0 );
981 fprintf(proxy, "const CInterfaceProxyVtbl* _%s_ProxyVtblList[] =\n", file_id);
982 fprintf(proxy, "{\n");
985 if(cur->iface->ref && cur->iface->funcs &&
986 is_object(cur->iface->attrs) && !is_local(cur->iface->attrs))
987 fprintf(proxy, " (CInterfaceProxyVtbl*)&_%sProxyVtbl,\n", cur->iface->name);
988 cur = PREV_LINK(cur);
990 fprintf(proxy, " 0\n");
991 fprintf(proxy, "};\n");
992 fprintf(proxy, "\n");
994 fprintf(proxy, "const CInterfaceStubVtbl* _%s_StubVtblList[] =\n", file_id);
995 fprintf(proxy, "{\n");
998 if(cur->iface->ref && cur->iface->funcs &&
999 is_object(cur->iface->attrs) && !is_local(cur->iface->attrs))
1000 fprintf(proxy, " (CInterfaceStubVtbl*)&_%sStubVtbl,\n", cur->iface->name);
1001 cur = PREV_LINK(cur);
1003 fprintf(proxy, " 0\n");
1004 fprintf(proxy, "};\n");
1005 fprintf(proxy, "\n");
1007 fprintf(proxy, "PCInterfaceName const _%s_InterfaceNamesList[] =\n", file_id);
1008 fprintf(proxy, "{\n");
1011 if(cur->iface->ref && cur->iface->funcs &&
1012 is_object(cur->iface->attrs) && !is_local(cur->iface->attrs))
1013 fprintf(proxy, " \"%s\",\n", cur->iface->name);
1014 cur = PREV_LINK(cur);
1016 fprintf(proxy, " 0\n");
1017 fprintf(proxy, "};\n");
1018 fprintf(proxy, "\n");
1020 fprintf(proxy, "#define _%s_CHECK_IID(n) IID_GENERIC_CHECK_IID(_%s, pIID, n)\n", file_id, file_id);
1021 fprintf(proxy, "\n");
1022 fprintf(proxy, "int __stdcall _%s_IID_Lookup(const IID* pIID, int* pIndex)\n", file_id);
1023 fprintf(proxy, "{\n");
1029 fprintf(proxy, " if (!_%s_CHECK_IID(%d))\n", file_id, c);
1030 fprintf(proxy, " {\n");
1031 fprintf(proxy, " *pIndex = %d;\n", c);
1032 fprintf(proxy, " return 1;\n");
1033 fprintf(proxy, " }\n");
1036 cur = PREV_LINK(cur);
1038 fprintf(proxy, " return 0;\n");
1039 fprintf(proxy, "}\n");
1040 fprintf(proxy, "\n");
1042 fprintf(proxy, "const ExtendedProxyFileInfo %s_ProxyFileInfo =\n", file_id);
1043 fprintf(proxy, "{\n");
1044 fprintf(proxy, " (PCInterfaceProxyVtblList*)&_%s_ProxyVtblList,\n", file_id);
1045 fprintf(proxy, " (PCInterfaceStubVtblList*)&_%s_StubVtblList,\n", file_id);
1046 fprintf(proxy, " (const PCInterfaceName*)&_%s_InterfaceNamesList,\n", file_id);
1047 fprintf(proxy, " 0,\n");
1048 fprintf(proxy, " &_%s_IID_Lookup,\n", file_id);
1049 fprintf(proxy, " %d,\n", c);
1050 fprintf(proxy, " 1,\n");
1051 fprintf(proxy, " 0,\n");
1052 fprintf(proxy, " 0,\n");
1053 fprintf(proxy, " 0,\n");
1054 fprintf(proxy, " 0\n");
1055 fprintf(proxy, "};\n");