WIDL: use __RPC_FAR attribute for pointers in proxies
Mike McCormack
mike at codeweavers.com
Tue Sep 21 00:51:59 CDT 2004
ChangeLog:
* use __RPC_FAR attribute for pointers in proxies
-------------- next part --------------
? tools/widl/proxy-chunk.diff
? tools/widl/proxy-guid-comment.diff
? tools/widl/proxy-stuff.diff
? tools/widl/widl-20040921.diff
? tools/widl/widl-20040921a.diff
? tools/widl/x
Index: tools/widl/header.c
===================================================================
RCS file: /home/wine/wine/tools/widl/header.c,v
retrieving revision 1.27
diff -u -r1.27 header.c
--- tools/widl/header.c 14 Sep 2004 19:28:12 -0000 1.27
+++ tools/widl/header.c 21 Sep 2004 03:52:54 -0000
@@ -36,6 +36,7 @@
#include "header.h"
static int indentation = 0;
+char *rpcptr = "*";
static void indent(int delta)
{
@@ -83,7 +84,7 @@
{
int c;
for (c=0; c<v->ptr_level; c++) {
- fprintf(h, "*");
+ fprintf(h, "%s", rpcptr);
}
if (v->name) fprintf(h, "%s", v->name);
}
@@ -288,7 +289,7 @@
}
if (v) {
for (c=0; c<v->ptr_level; c++) {
- fprintf(h, "*");
+ fprintf(h, "%s", rpcptr);
}
}
}
@@ -551,7 +552,7 @@
} else fprintf(h, " ");
}
if (method == 1) {
- fprintf(h, "%s* This", name);
+ fprintf(h, "%s%s This", name, rpcptr );
count++;
}
while (arg) {
Index: tools/widl/header.h
===================================================================
RCS file: /home/wine/wine/tools/widl/header.h,v
retrieving revision 1.6
diff -u -r1.6 header.h
--- tools/widl/header.h 22 Apr 2004 03:40:01 -0000 1.6
+++ tools/widl/header.h 21 Sep 2004 03:52:54 -0000
@@ -39,4 +39,6 @@
extern void write_constdef(var_t *v);
extern void write_externdef(var_t *v);
+extern char *rpcptr;
+
#endif
Index: tools/widl/proxy.c
===================================================================
RCS file: /home/wine/wine/tools/widl/proxy.c,v
retrieving revision 1.16
diff -u -r1.16 proxy.c
--- tools/widl/proxy.c 20 Sep 2004 19:11:16 -0000 1.16
+++ tools/widl/proxy.c 21 Sep 2004 03:52:54 -0000
@@ -143,6 +143,7 @@
static void init_proxy()
{
+ rpcptr = " __RPC_FAR *";
if (proxy) return;
proxy = fopen(proxy_name, "w");
print_proxy( "/*** Autogenerated by WIDL %s - Do not edit ***/\n", WIDL_FULLVERSION);
@@ -239,37 +240,40 @@
break;
case RPC_FC_STRUCT:
- print_proxy( "NdrSimpleStructBufferSize(&_StubMsg, (unsigned char*)%s, ", arg->name );
+ print_proxy( "NdrSimpleStructBufferSize(&_StubMsg, (unsigned char%s)%s, ", rpcptr, arg->name );
fprintf(proxy, "&__MIDL_TypeFormatString.Format[%d] );\n", index );
break;
case RPC_FC_C_CSTRING:
case RPC_FC_C_WSTRING:
case RPC_FC_CARRAY:
- print_proxy( "NdrConformantArrayBufferSize( &_StubMsg, (unsigned char*)%s, ", arg->name );
+ print_proxy( "NdrConformantArrayBufferSize( &_StubMsg, (unsigned char%s)%s, ", rpcptr, arg->name );
fprintf(proxy, "&__MIDL_TypeFormatString.Format[%d]);\n", index );
break;
case RPC_FC_BOGUS_STRUCT:
- print_proxy( "NdrComplexStructBufferSize(&_StubMsg, (unsigned char*)%s, ", arg->name );
+ print_proxy( "NdrComplexStructBufferSize(&_StubMsg, (unsigned char%s)%s, ", rpcptr, arg->name );
fprintf(proxy, "&__MIDL_TypeFormatString.Format[%d] );\n", index );
break;
case RPC_FC_FP:
{
var_t temp;
+
memset( &temp, 0, sizeof temp );
temp.type = type->ref;
- temp.name = arg->name; /* FIXME */
+ temp.name = malloc( strlen(arg->name)+2 );
+ sprintf(temp.name, "&%s", arg->name);
#if 0
- print_proxy( "/* FIXME: %s use the right name for %s\n", __FUNCTION__, arg->name );
+ print_proxy( "/* FIXME: %s use the right name for %s */\n", __FUNCTION__, arg->name );
#endif
marshall_size_arg( &temp );
+ free( temp.name );
}
break;
case RPC_FC_IP:
- print_proxy( "NdrPointerBufferSize( &_StubMsg, (unsigned char*)%s, ", arg->name );
+ print_proxy( "NdrPointerBufferSize( &_StubMsg, (unsigned char%s)%s, ", rpcptr, arg->name );
fprintf(proxy, "&__MIDL_TypeFormatString.Format[%d]);\n", index );
break;
@@ -305,7 +309,7 @@
print_proxy( "_StubMsg.MaxCount = ", arg->name );
write_expr(proxy, expr);
fprintf(proxy, ";\n\n");
- print_proxy( "NdrConformantArrayMarshall( &_StubMsg, (unsigned char*)%s, ", arg->name );
+ print_proxy( "NdrConformantArrayMarshall( &_StubMsg, (unsigned char%s)%s, ", rpcptr, arg->name );
fprintf(proxy, "&__MIDL_TypeFormatString.Format[%d]);\n", index );
return;
}
@@ -323,12 +327,12 @@
case RPC_FC_ENUM32:
print_proxy( "*((");
write_type(proxy, arg->type, arg, arg->tname);
- fprintf(proxy,"*)_StubMsg.Buffer)++ = %s;\n", arg->name );
+ fprintf(proxy,"%s)_StubMsg.Buffer)++ = %s;\n", rpcptr, arg->name );
break;
case RPC_FC_STRUCT:
/* FIXME: add the format string, and set the index below */
- print_proxy( "NdrSimpleStructMarshall(&_StubMsg, (unsigned char*)%s, ", arg->name );
+ print_proxy( "NdrSimpleStructMarshall(&_StubMsg, (unsigned char%s)%s, ", rpcptr, arg->name );
fprintf(proxy, "&__MIDL_TypeFormatString.Format[%d]);\n", index );
break;
@@ -338,7 +342,7 @@
break;
case RPC_FC_BOGUS_STRUCT:
- print_proxy( "NdrComplexStructMarshall(&_StubMsg, (unsigned char*)%s, ", arg->name );
+ print_proxy( "NdrComplexStructMarshall(&_StubMsg, (unsigned char%s)%s, ", rpcptr, arg->name );
fprintf(proxy, "&__MIDL_TypeFormatString.Format[%d] );\n", index );
break;
@@ -347,16 +351,18 @@
var_t temp;
memset( &temp, 0, sizeof temp );
temp.type = type->ref;
- temp.name = arg->name; /* FIXME */
+ temp.name = malloc( strlen(arg->name)+2 );
+ sprintf(temp.name, "&%s", arg->name);
#if 0
- print_proxy( "/* FIXME: %s use the right name for %s\n", __FUNCTION__, arg->name );
+ print_proxy( "/* FIXME: %s use the right name for %s */\n", __FUNCTION__, arg->name );
#endif
marshall_copy_arg( &temp );
+ free( temp.name );
}
break;
case RPC_FC_IP:
- print_proxy( "NdrPointerMarshall( &_StubMsg, (unsigned char*)%s, ", arg->name );
+ print_proxy( "NdrPointerMarshall( &_StubMsg, (unsigned char%s)%s, ", rpcptr, arg->name );
fprintf(proxy, "&__MIDL_TypeFormatString.Format[%d]);\n", index );
break;
@@ -402,7 +408,7 @@
if (expr)
{
print_proxy( "NdrConformantArrayUnmarshall( &_StubMsg, (unsigned char*)%s, ", arg->name );
- fprintf(proxy, "&__MIDL_TypeFormatString.Format[%d]);\n", index );
+ fprintf(proxy, "&__MIDL_TypeFormatString.Format[%d], 0);\n", index );
return;
}
@@ -419,23 +425,24 @@
case RPC_FC_ENUM32:
print_proxy( "%s = *((", arg->name );
write_type(proxy, arg->type, arg, arg->tname);
- fprintf(proxy,"*)_StubMsg.Buffer)++;\n");
+ fprintf(proxy,"%s)_StubMsg.Buffer)++;\n", rpcptr);
break;
case RPC_FC_STRUCT:
- print_proxy( "NdrSimpleStructUnmarshall(&_StubMsg, (unsigned char**)%s, ", arg->name );
+ print_proxy( "NdrSimpleStructUnmarshall(&_StubMsg, (unsigned char%s%s)%s, ",
+ rpcptr, rpcptr, arg->name );
fprintf(proxy, "&__MIDL_TypeFormatString.Format[%d], 0);\n", index );
break;
case RPC_FC_C_CSTRING:
case RPC_FC_C_WSTRING:
case RPC_FC_CARRAY:
- print_proxy( "NdrConformantArrayUnmarshall( &_StubMsg, (unsigned char*)%s, ", arg->name );
- fprintf(proxy, "&__MIDL_TypeFormatString.Format[%d]);\n", index );
+ print_proxy( "NdrConformantArrayUnmarshall( &_StubMsg, (unsigned char%s)%s, ", rpcptr, arg->name );
+ fprintf(proxy, "&__MIDL_TypeFormatString.Format[%d], 0);\n", index );
break;
case RPC_FC_BOGUS_STRUCT:
- print_proxy( "NdrComplexStructUnmarshall(&_StubMsg, (unsigned char*)%s, ", arg->name );
+ print_proxy( "NdrComplexStructUnmarshall(&_StubMsg, (unsigned char%s)%s, ", rpcptr, arg->name );
fprintf(proxy, "&__MIDL_TypeFormatString.Format[%d], 0 );\n", index );
break;
@@ -444,16 +451,19 @@
var_t temp;
memset( &temp, 0, sizeof temp );
temp.type = type->ref;
- temp.name = arg->name; /* FIXME */
+ temp.name = malloc( strlen(arg->name)+2 );
+ sprintf(temp.name, "&%s", arg->name);
#if 1
- print_proxy( "/* FIXME: %s use the right name for %s\n", __FUNCTION__, arg->name );
+ print_proxy( "/* FIXME: %s use the right name for %s */\n", __FUNCTION__, arg->name );
#endif
unmarshall_copy_arg( &temp );
+ free( temp.name );
}
break;
case RPC_FC_IP:
- print_proxy( "NdrPointerUnmarshall(&_StubMsg, (unsigned char**)&%s, ", arg->name );
+ print_proxy( "NdrPointerUnmarshall(&_StubMsg, (unsigned char%s%s)&%s, ",
+ rpcptr, rpcptr, arg->name );
fprintf(proxy, "&__MIDL_TypeFormatString.Format[%d], 0);\n", index );
break;
@@ -490,7 +500,7 @@
fprintf(proxy, ";\n\n");
print_proxy( "NdrClearOutParameters( &_StubMsg, ");
fprintf(proxy, "&__MIDL_TypeFormatString.Format[%d], ", index );
- fprintf(proxy, "(void*)%s );\n", arg->name );
+ fprintf(proxy, "(void%s)%s );\n", rpcptr, arg->name );
return;
}
@@ -516,7 +526,7 @@
print_proxy( "_StubMsg.MaxCount = (unsigned long) ( %s );\n",constraint->name);
print_proxy( "NdrClearOutParameters( &_StubMsg, ");
fprintf(proxy, "&__MIDL_TypeFormatString.Format[%d], ", index );
- fprintf(proxy, "(void*)%s );\n", arg->name );
+ fprintf(proxy, "(void%s)%s );\n", rpcptr, arg->name );
break;
default:
@@ -591,11 +601,11 @@
* We should calculate how much buffer we used and output the following
* line only if necessary.
*/
- print_proxy( "_StubMsg.Buffer = (unsigned char *)(((long)_StubMsg.Buffer + 3) & ~ 0x3);\n");
+ print_proxy( "_StubMsg.Buffer = (unsigned char%s)(((long)_StubMsg.Buffer + 3) & ~ 0x3);\n",rpcptr);
print_proxy( "_RetVal = *((" );
write_type(proxy, def->type, def, def->tname);
- fprintf(proxy, "*)_StubMsg.Buffer)++;\n");
+ fprintf(proxy, "%s)_StubMsg.Buffer)++;\n",rpcptr);
}
indent--;
@@ -794,11 +804,11 @@
* We should calculate how much buffer we used and output the following
* line only if necessary.
*/
- print_proxy( "_StubMsg.Buffer = (unsigned char *)(((long)_StubMsg.Buffer + 3) & ~ 0x3);\n");
+ print_proxy( "_StubMsg.Buffer = (unsigned char%s)(((long)_StubMsg.Buffer + 3) & ~ 0x3);\n", rpcptr);
print_proxy( "*((" );
write_type(proxy, def->type, def, def->tname);
- fprintf(proxy, "*)_StubMsg.Buffer)++ = _RetVal;\n");
+ fprintf(proxy, "%s)_StubMsg.Buffer)++ = _RetVal;\n", rpcptr);
}
indent--;
@@ -896,15 +906,23 @@
}
/* proxy vtable */
- print_proxy( "const CINTERFACE_PROXY_VTABLE(%d) %sProxyVtbl =\n", midx, iface->name);
+ print_proxy( "const CINTERFACE_PROXY_VTABLE(%d) _%sProxyVtbl =\n", midx, iface->name);
+ print_proxy( "{\n");
+ indent++;
+ print_proxy( "{\n", iface->name);
+ indent++;
+ print_proxy( "&IID_%s,\n", iface->name);
+ indent--;
+ print_proxy( "},\n");
print_proxy( "{\n");
indent++;
- print_proxy( "{&IID_%s},{\n", iface->name);
write_proxy_methods(iface);
- fprintf(proxy, "}\n");
+ fprintf(proxy, "\n");
+ indent--;
+ print_proxy( "}\n");
indent--;
print_proxy( "};\n");
- print_proxy( "\n");
+ fprintf(proxy, "\n\n");
/* stub vtable */
print_proxy( "static const PRPC_STUB_FUNCTION %s_table[] =\n", iface->name);
@@ -915,13 +933,22 @@
indent--;
fprintf(proxy, "};\n");
print_proxy( "\n");
- print_proxy( "const CInterfaceStubVtbl %sStubVtbl = {\n", iface->name);
+ print_proxy( "const CInterfaceStubVtbl _%sStubVtbl =\n", iface->name);
+ print_proxy( "{\n");
+ indent++;
+ print_proxy( "{\n");
indent++;
- print_proxy( "{&IID_%s,\n", iface->name);
- print_proxy( " 0,\n");
- print_proxy( " %d,\n", stubs+3);
- print_proxy( " &%s_table[-3]},\n", iface->name);
- print_proxy( "{CStdStubBuffer_METHODS}\n");
+ print_proxy( "&IID_%s,\n", iface->name);
+ print_proxy( "0,\n");
+ print_proxy( "%d,\n", stubs+3);
+ print_proxy( "&%s_table[-3],\n", iface->name);
+ indent--;
+ print_proxy( "},\n", iface->name);
+ print_proxy( "{\n");
+ indent++;
+ print_proxy( "CStdStubBuffer_METHODS\n");
+ indent--;
+ print_proxy( "}\n");
indent--;
print_proxy( "};\n");
print_proxy( "\n");
@@ -964,7 +991,7 @@
while (cur) {
if(cur->iface->ref && cur->iface->funcs &&
is_object(cur->iface->attrs) && !is_local(cur->iface->attrs))
- fprintf(proxy, " (CInterfaceProxyVtbl*)&%sProxyVtbl,\n", cur->iface->name);
+ fprintf(proxy, " (CInterfaceProxyVtbl*)&_%sProxyVtbl,\n", cur->iface->name);
cur = PREV_LINK(cur);
}
fprintf(proxy, " 0\n");
@@ -977,14 +1004,14 @@
while (cur) {
if(cur->iface->ref && cur->iface->funcs &&
is_object(cur->iface->attrs) && !is_local(cur->iface->attrs))
- fprintf(proxy, " (CInterfaceStubVtbl*)&%sStubVtbl,\n", cur->iface->name);
+ fprintf(proxy, " (CInterfaceStubVtbl*)&_%sStubVtbl,\n", cur->iface->name);
cur = PREV_LINK(cur);
}
fprintf(proxy, " 0\n");
fprintf(proxy, "};\n");
fprintf(proxy, "\n");
- fprintf(proxy, "const PCInterfaceName _%s_InterfaceNamesList[] =\n", file_id);
+ fprintf(proxy, "PCInterfaceName const _%s_InterfaceNamesList[] =\n", file_id);
fprintf(proxy, "{\n");
cur = lcur;
while (cur) {
@@ -1006,7 +1033,8 @@
while (cur) {
if(cur->iface->ref)
{
- fprintf(proxy, " if (!_%s_CHECK_IID(%d)) {\n", file_id, c);
+ fprintf(proxy, " if (!_%s_CHECK_IID(%d))\n", file_id, c);
+ fprintf(proxy, " {\n");
fprintf(proxy, " *pIndex = %d;\n", c);
fprintf(proxy, " return 1;\n");
fprintf(proxy, " }\n");
More information about the wine-patches
mailing list