From 4f46232368fbfbac621bda169bb19a65622a6f78 Mon Sep 17 00:00:00 2001 From: Hans Leidekker Date: Mon, 19 Dec 2005 21:20:14 +0100 Subject: [PATCH] widl: Avoid lvalue casts in generated code. --- tools/widl/client.c | 7 +++++-- tools/widl/proxy.c | 28 ++++++++++++++++++++-------- tools/widl/server.c | 7 +++++-- tools/widl/typegen.c | 14 ++++++++++---- 4 files changed, 40 insertions(+), 16 deletions(-) diff --git a/tools/widl/client.c b/tools/widl/client.c index e0c4295993..3fd5f5c364 100644 --- a/tools/widl/client.c +++ b/tools/widl/client.c @@ -255,9 +255,12 @@ static void write_function_stubs(type_t *iface) indent -= 2; fprintf(client, "\n"); - print_client("_RetVal = *(("); + print_client("_RetVal = *("); write_type(client, def->type, def, def->tname); - fprintf(client, " *)_StubMsg.Buffer)++;\n"); + fprintf(client, " *)_StubMsg.Buffer;\n"); + fprintf(client, "_StubMsg.Buffer += sizeof("); + write_type(client, def->type, def, def->tname); + fprintf(client, ");\n"); } /* update proc_offset */ diff --git a/tools/widl/proxy.c b/tools/widl/proxy.c index 936e1e7794..c91d3880ae 100644 --- a/tools/widl/proxy.c +++ b/tools/widl/proxy.c @@ -323,9 +323,12 @@ static void marshall_copy_arg( var_t *arg ) case RPC_FC_LONG: case RPC_FC_ULONG: case RPC_FC_ENUM32: - print_proxy( "*(("); + print_proxy( "*("); write_type(proxy, arg->type, arg, arg->tname); - fprintf(proxy,"*)_StubMsg.Buffer)++ = %s;\n", arg->name ); + fprintf(proxy, " *)_StubMsg.Buffer = %s;\n", arg->name ); + fprintf(proxy, "_StubMsg.Buffer += sizeof("); + write_type(proxy, arg->type, arg, arg->tname); + fprintf(proxy, ");\n"); break; case RPC_FC_STRUCT: @@ -419,9 +422,12 @@ static void unmarshall_copy_arg( var_t *arg ) case RPC_FC_LONG: case RPC_FC_ULONG: case RPC_FC_ENUM32: - print_proxy( "%s = *((", arg->name ); + print_proxy( "%s = *(", arg->name ); + write_type(proxy, arg->type, arg, arg->tname); + fprintf(proxy," *)_StubMsg.Buffer;\n"); + fprintf(proxy, "_StubMsg.Buffer += sizeof("); write_type(proxy, arg->type, arg, arg->tname); - fprintf(proxy,"*)_StubMsg.Buffer)++;\n"); + fprintf(proxy, ");\n"); break; case RPC_FC_STRUCT: @@ -595,9 +601,12 @@ static void gen_proxy(type_t *iface, func_t *cur, int idx) */ print_proxy( "_StubMsg.Buffer = (unsigned char *)(((long)_StubMsg.Buffer + 3) & ~ 0x3);\n"); - print_proxy( "_RetVal = *((" ); + print_proxy( "_RetVal = *(" ); write_type(proxy, def->type, def, def->tname); - fprintf(proxy, "*)_StubMsg.Buffer)++;\n"); + fprintf(proxy, " *)_StubMsg.Buffer;\n"); + fprintf(proxy, "_StubMsg.Buffer += sizeof("); + write_type(proxy, def->type, def, def->tname); + fprintf(proxy, ");\n"); } indent--; @@ -798,9 +807,12 @@ static void gen_stub(type_t *iface, func_t *cur, char *cas) */ print_proxy( "_StubMsg.Buffer = (unsigned char *)(((long)_StubMsg.Buffer + 3) & ~ 0x3);\n"); - print_proxy( "*((" ); + print_proxy( "*(" ); + write_type(proxy, def->type, def, def->tname); + fprintf(proxy, " *)_StubMsg.Buffer = _RetVal;\n"); + fprintf(proxy, "_StubMsg.Buffer += sizeof("); write_type(proxy, def->type, def, def->tname); - fprintf(proxy, "*)_StubMsg.Buffer)++ = _RetVal;\n"); + fprintf(proxy, ");\n"); } indent--; diff --git a/tools/widl/server.c b/tools/widl/server.c index cb1099339d..6022f5a4cc 100644 --- a/tools/widl/server.c +++ b/tools/widl/server.c @@ -267,9 +267,12 @@ static void write_function_stubs(type_t *iface) print_server("_StubMsg.Buffer = (unsigned char *)_pRpcMessage->Buffer;\n"); fprintf(server, "\n"); - print_server("*(("); + print_server("*("); write_type(server, def->type, def, def->tname); - fprintf(server, " *)_StubMsg.Buffer)++ = _RetVal;\n"); + fprintf(server, " *)_StubMsg.Buffer = _RetVal;\n"); + fprintf(server, "_StubMsg.Buffer += sizeof("); + write_type(server, def->type, def, def->tname); + fprintf(server, ");\n"); } indent--; diff --git a/tools/widl/typegen.c b/tools/widl/typegen.c index 32ac8e8393..cb6e87ba68 100644 --- a/tools/widl/typegen.c +++ b/tools/widl/typegen.c @@ -301,11 +301,14 @@ void marshall_arguments(FILE *file, int indent, func_t *func) if (alignment != 0) print_file(file, indent, "_StubMsg.Buffer += %u;\n", alignment); - print_file(file, indent, "*(("); + print_file(file, indent, "*("); write_type(file, var->type, var, var->tname); - fprintf(file, " *)_StubMsg.Buffer)++ = "); + fprintf(file, " *)_StubMsg.Buffer = "); write_name(file, var); fprintf(file, ";\n"); + fprintf(file, "_StubMsg.Buffer += sizeof("); + write_type(file, var->type, var, var->tname); + fprintf(file, ");\n"); fprintf(file, "\n"); last_size = size; @@ -373,9 +376,12 @@ void unmarshall_arguments(FILE *file, int indent, func_t *func) print_file(file, indent, ""); write_name(file, var); - fprintf(file, " = *(("); + fprintf(file, " = *("); + write_type(file, var->type, var, var->tname); + fprintf(file, " *)_StubMsg.Buffer;\n"); + fprintf(file, "_StubMsg.Buffer += sizeof("); write_type(file, var->type, var, var->tname); - fprintf(file, " *)_StubMsg.Buffer)++;\n"); + fprintf(file, ");\n"); fprintf(file, "\n"); last_size = size; -- 2.32.0.93.g670b81a890