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
39 #define END_OF_LIST(list) \
42 while (NEXT_LINK(list)) \
43 list = NEXT_LINK(list); \
48 static int indent
= 0;
50 /* FIXME: support generation of stubless proxies */
52 int print_proxy( char *format
, ... )
57 va_start( va
, format
);
58 for( i
=0; i
<indent
; i
++ )
59 fprintf( proxy
, " " );
60 r
= vfprintf( proxy
, format
, va
);
65 static type_t
*get_base_type( type_t
*type
)
67 while( (type
->type
== 0) && type
->ref
)
72 static void write_stubdescproto(void)
74 print_proxy( "extern const MIDL_STUB_DESC Object_StubDesc;\n");
78 static void write_stubdesc(void)
80 print_proxy( "const MIDL_STUB_DESC Object_StubDesc = {\n");
81 print_proxy( " 0,\n");
82 print_proxy( " NdrOleAllocate,\n");
83 print_proxy( " NdrOleFree,\n");
84 print_proxy( " {0}, 0, 0, 0, 0,\n");
85 print_proxy( " 0 /* __MIDL_TypeFormatString.Format */\n");
90 static void write_formatdesc( char *str
)
92 print_proxy( "typedef struct _MIDL_%s_FORMAT_STRING {\n", str
);
93 print_proxy( " short Pad;\n");
94 print_proxy( " unsigned char Format[%s_FORMAT_STRING_SIZE];\n", str
);
95 print_proxy( "} MIDL_%s_FORMAT_STRING;\n", str
);
99 static void write_formatstringsdecl(void)
101 print_proxy( "#define TYPE_FORMAT_STRING_SIZE %d\n",1); /* FIXME */
102 print_proxy( "#define PROC_FORMAT_STRING_SIZE %d\n",1); /* FIXME */
104 write_formatdesc( "TYPE" );
105 write_formatdesc( "PROC" );
106 print_proxy( "extern const MIDL_TYPE_FORMAT_STRING __MIDL_TypeFormatString;\n");
107 print_proxy( "extern const MIDL_PROC_FORMAT_STRING __MIDL_ProcFormatString;\n");
111 static void write_formatstring( int proc
)
124 print_proxy( "static const MIDL_%s_FORMAT_STRING __MIDL_%sFormatString =\n", t
, n
);
127 print_proxy( "0,\n");
134 print_proxy( "};\n");
138 static void init_proxy(void)
141 proxy
= fopen(proxy_name
, "w");
142 print_proxy( "/*** Autogenerated by WIDL %s - Do not edit ***/\n", WIDL_FULLVERSION
);
144 print_proxy( "#ifndef __REDQ_RPCPROXY_H_VERSION__\n");
145 print_proxy( "#define __REQUIRED_RPCPROXY_H_VERSION__ 440\n");
146 print_proxy( "#endif /* __REDQ_RPCPROXY_H_VERSION__ */\n");
148 print_proxy( "#include \"rpcproxy.h\"\n");
150 print_proxy( "#ifndef __RPCPROXY_H_VERSION__\n");
151 print_proxy( "#error This code needs a newer version of rpcproxy.h\n");
152 print_proxy( "#endif /* __RPCPROXY_H_VERSION__ */\n");
154 print_proxy( "#include \"%s\"\n", header_name
);
156 write_formatstringsdecl();
157 write_stubdescproto();
160 static void clear_output_vars( var_t
*arg
)
164 if (is_attr(arg
->attrs
, ATTR_OUT
) && !is_attr(arg
->attrs
, ATTR_IN
)) {
165 print_proxy( "if(%s)\n", arg
->name
);
167 print_proxy( "MIDL_memset( %s, 0, sizeof( ", arg
->name
);
169 write_type(proxy
, arg
->type
, arg
, arg
->tname
);
170 fprintf( proxy
, " ));\n" );
172 arg
= PREV_LINK(arg
);
176 static int is_pointer(var_t
*arg
)
180 if (arg
->type
->type
== RPC_FC_FP
)
185 static void proxy_check_pointers( var_t
*arg
)
189 if (is_pointer(arg
)) {
190 print_proxy( "if(!%s)\n", arg
->name
);
192 print_proxy( "RpcRaiseException(RPC_X_NULL_REF_POINTER);\n");
195 arg
= PREV_LINK(arg
);
199 static void proxy_gen_marshall_size( var_t
*arg
)
201 print_proxy( "_StubMsg.BufferLength = 0U;\n" );
205 if (is_attr(arg
->attrs
, ATTR_IN
)) {
207 type_t
*type
= get_base_type(arg
->type
);
213 print_proxy( "_StubMsg.BufferLength += %d; /* %s */\n", 1, arg
->name
);
220 print_proxy( "_StubMsg.BufferLength += %d; /* %s */\n", 2, arg
->name
);
226 print_proxy( "_StubMsg.BufferLength += %d; /* %s */\n", 4, arg
->name
);
230 print_proxy( "NdrSimpleStructBufferSize(&_StubMsg, (unsigned char*)%s, ", arg
->name
);
231 fprintf(proxy
, "&__MIDL_TypeFormatString.Format[%d] );\n", index
);
235 print_proxy( "NdrConformantArrayBufferSize( &_StubMsg, (unsigned char*)%s, ", arg
->name
);
236 fprintf(proxy
, "&__MIDL_TypeFormatString.Format[%d]);\n", index
);
240 print_proxy( "NdrPointerBufferSize( &_StubMsg, (unsigned char*)%s, ", arg
->name
);
241 fprintf(proxy
, "&__MIDL_TypeFormatString.Format[%d]);\n", index
);
245 printf("FIXME: arg %s has unknown type %d\n", arg
->name
, type
->type
);
248 arg
= PREV_LINK(arg
);
252 static void gen_marshall_copydata( var_t
*arg
)
256 if (is_attr(arg
->attrs
, ATTR_IN
)) {
258 type_t
*type
= get_base_type(arg
->type
);
272 write_type(proxy
, arg
->type
, arg
, arg
->tname
);
273 fprintf(proxy
,"*)_StubMsg.Buffer)++ = %s;\n", arg
->name
);
277 /* FIXME: add the format string, and set the index below */
278 print_proxy( "NdrSimpleStructMarshall(&_StubMsg, (unsigned char*)%s, ", arg
->name
);
279 fprintf(proxy
, "&__MIDL_TypeFormatString.Format[%d]);\n", index
);
283 print_proxy( "NdrConformantArrayMarshall( &_StubMsg, (unsigned char*)%s, ", arg
->name
);
284 fprintf(proxy
, "&__MIDL_TypeFormatString.Format[%d]);\n", index
);
288 print_proxy( "NdrPointerMarshall( &_StubMsg, (unsigned char*)%s, ", arg
->name
);
289 fprintf(proxy
, "&__MIDL_TypeFormatString.Format[%d]);\n", index
);
293 printf("FIXME: arg %s has unknown type %d\n", arg
->name
, type
->type
);
296 arg
= PREV_LINK(arg
);
300 static void gen_marshall( var_t
*arg
)
302 /* generated code to determine the size of the buffer required */
303 proxy_gen_marshall_size( arg
);
305 /* generated code to allocate the buffer */
306 print_proxy( "NdrProxyGetBuffer(This, &_StubMsg);\n" );
308 /* generated code to copy the args into the buffer */
309 gen_marshall_copydata( arg
);
314 static void gen_unmarshall( var_t
*arg
)
318 if (is_attr(arg
->attrs
, ATTR_OUT
)) {
320 type_t
*type
= get_base_type(arg
->type
);
333 print_proxy( "%s = *((", arg
->name
);
334 write_type(proxy
, arg
->type
, arg
, arg
->tname
);
335 fprintf(proxy
,"*)_StubMsg.Buffer)++;\n");
339 print_proxy( "NdrSimpleStructUnmarshall(&_StubMsg, (unsigned char**)%s, ", arg
->name
);
340 fprintf(proxy
, "&__MIDL_TypeFormatString.Format[%d], 0);\n", index
);
344 print_proxy( "NdrSimpleStructUnmarshall(&_StubMsg, (unsigned char**)%s, ", arg
->name
);
345 fprintf(proxy
, "&__MIDL_TypeFormatString.Format[%d], 0);\n", index
);
349 print_proxy( "NdrPointerUnmarshall(&_StubMsg, (unsigned char**)&%s, ", arg
->name
);
350 fprintf(proxy
, "&__MIDL_TypeFormatString.Format[%d], 0);\n", index
);
354 printf("FIXME: arg %s has unknown type %d\n", arg
->name
, type
->type
);
356 arg
= PREV_LINK(arg
);
360 static void proxy_free_variables( var_t
*arg
)
364 if (is_attr(arg
->attrs
, ATTR_OUT
)) {
366 int index
= 0; /* FIXME */
367 type_t
*type
= get_base_type(arg
->type
);
385 constraint
= get_attrp( arg
->attrs
, ATTR_IIDIS
);
387 print_proxy( "_StubMsg.MaxCount = (unsigned long) ( %s );\n",constraint
->name
);
388 print_proxy( "NdrClearOutParameters( &_StubMsg, ");
389 fprintf(proxy
, "&__MIDL_TypeFormatString.Format[%d], ", index
);
390 fprintf(proxy
, "(void*)%s );\n", arg
->name
);
394 printf("FIXME: arg %s has unknown type %d\n", arg
->name
, type
->type
);
397 arg
= PREV_LINK(arg
);
401 static void gen_proxy(type_t
*iface
, func_t
*cur
, int idx
)
403 var_t
*def
= cur
->def
;
404 int has_ret
= !is_void(def
->type
, def
);
407 write_type(proxy
, def
->type
, def
, def
->tname
);
408 print_proxy( " STDMETHODCALLTYPE %s_", iface
->name
);
409 write_name(proxy
, def
);
410 print_proxy( "_Proxy(\n");
411 write_args(proxy
, cur
->args
, iface
->name
, 1, TRUE
);
415 /* local variables */
418 write_type(proxy
, def
->type
, def
, def
->tname
);
419 print_proxy( " _RetVal;\n");
421 print_proxy( "RPC_MESSAGE _Msg;\n" );
422 print_proxy( "MIDL_STUB_MESSAGE _StubMsg;\n" );
426 clear_output_vars( cur
->args
);
428 print_proxy( "RpcTryExcept\n" );
429 print_proxy( "{\n" );
431 print_proxy( "NdrProxyInitialize(This, &_Msg, &_StubMsg, &Object_StubDesc, %d);\n", idx
);
432 proxy_check_pointers( cur
->args
);
434 print_proxy( "RpcTryFinally\n" );
435 print_proxy( "{\n" );
438 gen_marshall( cur
->args
);
440 print_proxy( "NdrProxySendReceive(This, &_StubMsg);\n" );
441 fprintf(proxy
, "\n");
442 print_proxy("if ((_Msg.DataRepresentation&0xffff) != NDR_LOCAL_DATA_REPRESENTATION)\n");
444 print_proxy("NdrConvert( &_StubMsg, &__MIDL_ProcFormatString.Format[0]);\n" );
446 fprintf(proxy
, "\n");
448 gen_unmarshall( cur
->args
);
451 * FIXME: We only need to round the buffer up if it could be unaligned...
452 * We should calculate how much buffer we used and output the following
453 * line only if necessary.
455 print_proxy( "_StubMsg.Buffer = (unsigned char *)(((long)_StubMsg.Buffer + 3) & ~ 0x3);\n");
457 print_proxy( "_RetVal = *((" );
458 write_type(proxy
, def
->type
, def
, def
->tname
);
459 fprintf(proxy
, "*)_StubMsg.Buffer)++;\n");
464 print_proxy( "RpcFinally\n" );
465 print_proxy( "{\n" );
467 print_proxy( "NdrProxyFreeBuffer(This, &_StubMsg);\n" );
470 print_proxy( "RpcEndFinally\n" );
472 print_proxy( "}\n" );
473 print_proxy( "RpcExcept(_StubMsg.dwStubPhase != PROXY_SENDRECEIVE)\n" );
474 print_proxy( "{\n" );
477 proxy_free_variables( cur
->args
);
478 print_proxy( "_RetVal = NdrProxyErrorHandler(RpcExceptionCode());\n" );
481 print_proxy( "}\n" );
482 print_proxy( "RpcEndExcept\n" );
485 print_proxy( "return _RetVal;\n" );
492 static void stub_write_locals( var_t
*arg
)
496 int outptr
= is_attr(arg
->attrs
, ATTR_OUT
);
498 /* create a temporary variable to store the output */
501 memset( &temp
, 0, sizeof temp
);
502 temp
.ptr_level
= arg
->ptr_level
- 1; /* dereference once */
504 write_type(proxy
, arg
->type
, &temp
, arg
->tname
);
505 fprintf(proxy
, " _M%d;\n",n
++);
508 write_type(proxy
, arg
->type
, arg
, arg
->tname
);
510 write_name(proxy
, arg
);
511 fprintf(proxy
, ";\n");
512 arg
= NEXT_LINK(arg
);
516 static void stub_unmarshall( var_t
*arg
)
521 type_t
*type
= get_base_type(arg
->type
);
522 if (is_attr(arg
->attrs
, ATTR_IN
)) {
536 print_proxy( "%s = *((", arg
->name
);
537 write_type(proxy
, arg
->type
, arg
, arg
->tname
);
538 fprintf(proxy
,"*)_StubMsg.Buffer)++;\n");
543 /* FIXME: add the format string, and set the index below */
544 print_proxy( "NdrSimpleStructUnmarshall(&_StubMsg, (unsigned char**)&%s, ", arg
->name
);
545 fprintf(proxy
, "&__MIDL_TypeFormatString.Format[%d], 0);\n", index
);
549 printf("FIXME: arg %s has unknown type %d\n", arg
->name
, type
->type
);
552 else if (is_attr(arg
->attrs
, ATTR_OUT
)) {
556 print_proxy("MIDL_memset(");
557 write_name(proxy
, arg
);
558 fprintf(proxy
,", 0, sizeof(");
559 write_type(proxy
, arg
->type
, arg
, arg
->tname
);
560 fprintf(proxy
,"));\n");
564 write_name(proxy
, arg
);
565 fprintf(proxy
," = &_M%d;\n", n
);
566 print_proxy("_M%d = 0;\n", n
++);
570 arg
= PREV_LINK(arg
);
574 static void stub_gen_marshall_size( var_t
*arg
)
576 print_proxy( "_StubMsg.BufferLength = 0U;\n" );
580 if (is_attr(arg
->attrs
, ATTR_OUT
)) {
583 type_t
*type
= get_base_type(arg
->type
);
589 print_proxy( "_StubMsg.BufferLength += %d; /* %s */\n", 1, arg
->name
);
596 print_proxy( "_StubMsg.BufferLength += %d; /* %s */\n", 2, arg
->name
);
602 print_proxy( "_StubMsg.BufferLength += %d; /* %s */\n", 4, arg
->name
);
606 print_proxy( "/*FIXME %s*/\n", arg
->name
);
609 print_proxy( "NdrSimpleStructBufferSize(&_StubMsg, (unsigned char*)%s, ", arg
->name
);
610 fprintf(proxy
, "&__MIDL_TypeFormatString.Format[%d] );\n", index
);
614 constraint
= get_attrp( arg
->attrs
, ATTR_IIDIS
);
616 print_proxy( "_StubMsg.MaxCount = (unsigned long) ( %s );\n",constraint
->name
);
617 print_proxy( "NdrPointerBufferSize( &_StubMsg, (unsigned char*)%s, ", arg
->name
);
618 fprintf(proxy
, "&__MIDL_TypeFormatString.Format[%d]);\n", index
);
622 printf("FIXME: arg %s has unknown type %d\n", arg
->name
, type
->type
);
625 arg
= PREV_LINK(arg
);
629 static void stub_gen_marshall_copydata( var_t
*arg
)
633 if (is_attr(arg
->attrs
, ATTR_OUT
)) {
636 type_t
*type
= get_base_type(arg
->type
);
640 fprintf(stderr
,"FIXME: param %s is an array\n", arg
->name
);
642 else switch( type
->type
)
654 write_type(proxy
, arg
->type
, arg
, arg
->tname
);
655 fprintf(proxy
,"*)_StubMsg.Buffer)++ = %s;\n", arg
->name
);
659 /* FIXME: add the format string, and set the index below */
660 print_proxy( "NdrSimpleStructMarshall(&_StubMsg, (unsigned char*)%s, ", arg
->name
);
661 fprintf(proxy
, "&__MIDL_TypeFormatString.Format[%d]);\n", index
);
665 print_proxy( "NdrConformantArrayBufferSize( &_StubMsg, (unsigned char*)%s, ", arg
->name
);
666 fprintf(proxy
, "&__MIDL_TypeFormatString.Format[%d]);\n", index
);
670 constraint
= get_attrp( arg
->attrs
, ATTR_IIDIS
);
672 print_proxy( "_StubMsg.MaxCount = (unsigned long) ( %s );\n",constraint
->name
);
673 print_proxy( "NdrPointerMarshall( &_StubMsg, (unsigned char*)%s, ", arg
->name
);
674 fprintf(proxy
, "&__MIDL_TypeFormatString.Format[%d]);\n", index
);
678 printf("FIXME: arg %s has unknown type %d\n", arg
->name
, type
->type
);
681 arg
= PREV_LINK(arg
);
685 static void stub_genmarshall( var_t
*args
)
687 /* FIXME: size buffer */
688 stub_gen_marshall_size( args
);
690 print_proxy("NdrStubGetBuffer(This, pRpcChannelBuffer, &_StubMsg);\n");
692 stub_gen_marshall_copydata( args
);
695 static void gen_stub(type_t
*iface
, func_t
*cur
, char *cas
)
697 var_t
*def
= cur
->def
;
699 int has_ret
= !is_void(def
->type
, def
);
702 print_proxy( "void __RPC_STUB %s_", iface
->name
);
703 write_name(proxy
, def
);
704 print_proxy( "_Stub(\n");
706 print_proxy( "IRpcStubBuffer* This,\n");
707 print_proxy( "IRpcChannelBuffer* pRpcChannelBuffer,\n");
708 print_proxy( "PRPC_MESSAGE _Msg,\n");
709 print_proxy( "DWORD* _pdwStubPhase)\n");
713 /* local variables */
716 write_type(proxy
, def
->type
, def
, def
->tname
);
717 fprintf(proxy
, " _RetVal;\n");
719 print_proxy("%s * _This = (%s*)((CStdStubBuffer*)This)->pvServerObject;\n", iface
->name
, iface
->name
);
720 print_proxy("MIDL_STUB_MESSAGE _StubMsg;\n");
721 stub_write_locals( cur
->args
);
722 fprintf(proxy
, "\n");
726 print_proxy("NdrStubInitialize(_Msg, &_StubMsg, &Object_StubDesc, pRpcChannelBuffer);\n");
727 fprintf(proxy
, "\n");
729 print_proxy("RpcTryFinally\n");
732 print_proxy("if ((_Msg->DataRepresentation&0xffff) != NDR_LOCAL_DATA_REPRESENTATION)\n");
734 print_proxy("NdrConvert( &_StubMsg, &__MIDL_ProcFormatString.Format[0]);\n" );
736 fprintf(proxy
, "\n");
738 stub_unmarshall( cur
->args
);
739 fprintf(proxy
, "\n");
741 print_proxy("*_pdwStubPhase = STUB_CALL_SERVER;\n");
742 fprintf(proxy
, "\n");
744 if (has_ret
) fprintf(proxy
, "_RetVal = ");
745 fprintf(proxy
, "%s_", iface
->name
);
746 if (cas
) fprintf(proxy
, "%s_Stub", cas
);
747 else write_name(proxy
, def
);
748 fprintf(proxy
, "(_This");
753 fprintf(proxy
, ", ");
754 write_name(proxy
, arg
);
755 arg
= PREV_LINK(arg
);
758 fprintf(proxy
, ");\n");
759 fprintf(proxy
, "\n");
760 print_proxy("*_pdwStubPhase = STUB_MARSHAL;\n");
761 fprintf(proxy
, "\n");
763 stub_genmarshall( cur
->args
);
764 fprintf(proxy
, "\n");
768 * FIXME: We only need to round the buffer up if it could be unaligned...
769 * We should calculate how much buffer we used and output the following
770 * line only if necessary.
772 print_proxy( "_StubMsg.Buffer = (unsigned char *)(((long)_StubMsg.Buffer + 3) & ~ 0x3);\n");
774 print_proxy( "*((" );
775 write_type(proxy
, def
->type
, def
, def
->tname
);
776 fprintf(proxy
, "*)_StubMsg.Buffer)++ = _RetVal;\n");
781 print_proxy("RpcFinally\n");
784 print_proxy("RpcEndFinally\n");
786 print_proxy("_Msg->BufferLength = ((long)_StubMsg.Buffer - (long)_Msg->Buffer);\n");
793 static int write_proxy_methods(type_t
*iface
)
795 func_t
*cur
= iface
->funcs
;
800 if (iface
->ref
) i
= write_proxy_methods(iface
->ref
);
802 var_t
*def
= cur
->def
;
803 if (!is_callas(def
->attrs
)) {
804 if (i
) fprintf(proxy
, ",\n");
805 print_proxy( "%s_", iface
->name
);
806 write_name(proxy
, def
);
807 fprintf(proxy
, "_Proxy");
810 cur
= PREV_LINK(cur
);
815 static int write_stub_methods(type_t
*iface
)
817 func_t
*cur
= iface
->funcs
;
822 if (iface
->ref
) i
= write_stub_methods(iface
->ref
);
823 else return i
; /* skip IUnknown */
825 var_t
*def
= cur
->def
;
826 if (!is_local(def
->attrs
)) {
827 if (i
) fprintf(proxy
,",\n");
828 print_proxy( "%s_", iface
->name
);
829 write_name(proxy
, def
);
830 fprintf(proxy
, "_Stub");
833 cur
= PREV_LINK(cur
);
838 static void write_proxy(type_t
*iface
)
840 int midx
= -1, stubs
;
841 func_t
*cur
= iface
->funcs
;
847 /* FIXME: check for [oleautomation], shouldn't generate proxies/stubs if specified */
849 fprintf(proxy
, "/*****************************************************************************\n");
850 fprintf(proxy
, " * %s interface\n", iface
->name
);
851 fprintf(proxy
, " */\n");
853 var_t
*def
= cur
->def
;
854 if (!is_local(def
->attrs
)) {
855 var_t
*cas
= is_callas(def
->attrs
);
856 char *cname
= cas
? cas
->name
: NULL
;
859 func_t
*m
= iface
->funcs
;
860 while (m
&& strcmp(get_name(m
->def
), cname
))
864 gen_proxy(iface
, cur
, idx
);
865 gen_stub(iface
, cur
, cname
);
866 if (midx
== -1) midx
= idx
;
867 else if (midx
!= idx
) yyerror("method index mismatch in write_proxy");
870 cur
= PREV_LINK(cur
);
874 print_proxy( "const CINTERFACE_PROXY_VTABLE(%d) %sProxyVtbl =\n", midx
, iface
->name
);
877 print_proxy( "{&IID_%s},{\n", iface
->name
);
878 write_proxy_methods(iface
);
879 fprintf(proxy
, "}\n");
881 print_proxy( "};\n");
885 print_proxy( "static const PRPC_STUB_FUNCTION %s_table[] =\n", iface
->name
);
888 stubs
= write_stub_methods(iface
);
889 fprintf(proxy
, "\n");
891 fprintf(proxy
, "};\n");
893 print_proxy( "const CInterfaceStubVtbl %sStubVtbl = {\n", iface
->name
);
895 print_proxy( "{&IID_%s,\n", iface
->name
);
896 print_proxy( " 0,\n");
897 print_proxy( " %d,\n", stubs
+3);
898 print_proxy( " &%s_table[-3]},\n", iface
->name
);
899 print_proxy( "{CStdStubBuffer_METHODS}\n");
901 print_proxy( "};\n");
905 void write_proxies(ifref_t
*ifaces
)
907 ifref_t
*lcur
= ifaces
;
909 char *file_id
= proxy_token
;
912 if (!do_everything
) return;
920 if (is_object(cur
->iface
->attrs
) && !is_local(cur
->iface
->attrs
))
921 write_proxy(cur
->iface
);
922 cur
= PREV_LINK(cur
);
929 print_proxy( "#if !defined(__RPC_WIN32__)\n");
930 print_proxy( "#error Currently only Wine and WIN32 are supported.\n");
931 print_proxy( "#endif\n");
933 write_formatstring( 1 );
934 write_formatstring( 0 );
936 fprintf(proxy
, "const CInterfaceProxyVtbl* _%s_ProxyVtblList[] =\n", file_id
);
937 fprintf(proxy
, "{\n");
940 if(cur
->iface
->ref
&& cur
->iface
->funcs
&&
941 is_object(cur
->iface
->attrs
) && !is_local(cur
->iface
->attrs
))
942 fprintf(proxy
, " (CInterfaceProxyVtbl*)&%sProxyVtbl,\n", cur
->iface
->name
);
943 cur
= PREV_LINK(cur
);
945 fprintf(proxy
, " 0\n");
946 fprintf(proxy
, "};\n");
947 fprintf(proxy
, "\n");
949 fprintf(proxy
, "const CInterfaceStubVtbl* _%s_StubVtblList[] =\n", file_id
);
950 fprintf(proxy
, "{\n");
953 if(cur
->iface
->ref
&& cur
->iface
->funcs
&&
954 is_object(cur
->iface
->attrs
) && !is_local(cur
->iface
->attrs
))
955 fprintf(proxy
, " (CInterfaceStubVtbl*)&%sStubVtbl,\n", cur
->iface
->name
);
956 cur
= PREV_LINK(cur
);
958 fprintf(proxy
, " 0\n");
959 fprintf(proxy
, "};\n");
960 fprintf(proxy
, "\n");
962 fprintf(proxy
, "const PCInterfaceName _%s_InterfaceNamesList[] =\n", file_id
);
963 fprintf(proxy
, "{\n");
966 if(cur
->iface
->ref
&& cur
->iface
->funcs
&&
967 is_object(cur
->iface
->attrs
) && !is_local(cur
->iface
->attrs
))
968 fprintf(proxy
, " \"%s\",\n", cur
->iface
->name
);
969 cur
= PREV_LINK(cur
);
971 fprintf(proxy
, " 0\n");
972 fprintf(proxy
, "};\n");
973 fprintf(proxy
, "\n");
975 fprintf(proxy
, "#define _%s_CHECK_IID(n) IID_GENERIC_CHECK_IID(_%s, pIID, n)\n", file_id
, file_id
);
976 fprintf(proxy
, "\n");
977 fprintf(proxy
, "int __stdcall _%s_IID_Lookup(const IID* pIID, int* pIndex)\n", file_id
);
978 fprintf(proxy
, "{\n");
984 fprintf(proxy
, " if (!_%s_CHECK_IID(%d)) {\n", file_id
, c
);
985 fprintf(proxy
, " *pIndex = %d;\n", c
);
986 fprintf(proxy
, " return 1;\n");
987 fprintf(proxy
, " }\n");
990 cur
= PREV_LINK(cur
);
992 fprintf(proxy
, " return 0;\n");
993 fprintf(proxy
, "}\n");
994 fprintf(proxy
, "\n");
996 fprintf(proxy
, "const ExtendedProxyFileInfo %s_ProxyFileInfo =\n", file_id
);
997 fprintf(proxy
, "{\n");
998 fprintf(proxy
, " (PCInterfaceProxyVtblList*)&_%s_ProxyVtblList,\n", file_id
);
999 fprintf(proxy
, " (PCInterfaceStubVtblList*)&_%s_StubVtblList,\n", file_id
);
1000 fprintf(proxy
, " (const PCInterfaceName*)&_%s_InterfaceNamesList,\n", file_id
);
1001 fprintf(proxy
, " 0,\n");
1002 fprintf(proxy
, " &_%s_IID_Lookup,\n", file_id
);
1003 fprintf(proxy
, " %d,\n", c
);
1004 fprintf(proxy
, " 1,\n");
1005 fprintf(proxy
, " 0,\n");
1006 fprintf(proxy
, " 0,\n");
1007 fprintf(proxy
, " 0,\n");
1008 fprintf(proxy
, " 0\n");
1009 fprintf(proxy
, "};\n");