Hans Leidekker : widl: Avoid lvalue casts in generated code.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Dec 19 14:22:21 CST 2005


Module: wine
Branch: refs/heads/master
Commit: 4f46232368fbfbac621bda169bb19a65622a6f78
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=4f46232368fbfbac621bda169bb19a65622a6f78

Author: Hans Leidekker <hans at it.vu.nl>
Date:   Mon Dec 19 21:20:14 2005 +0100

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 e0c4295..3fd5f5c 100644
--- a/tools/widl/client.c
+++ b/tools/widl/client.c
@@ -255,9 +255,12 @@ static void write_function_stubs(type_t 
             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 936e1e7..c91d388 100644
--- a/tools/widl/proxy.c
+++ b/tools/widl/proxy.c
@@ -323,9 +323,12 @@ static void marshall_copy_arg( var_t *ar
   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 *
   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, fun
      */
     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
      */
     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 cb10993..6022f5a 100644
--- a/tools/widl/server.c
+++ b/tools/widl/server.c
@@ -267,9 +267,12 @@ static void write_function_stubs(type_t 
             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 32ac8e8..cb6e87b 100644
--- a/tools/widl/typegen.c
+++ b/tools/widl/typegen.c
@@ -301,11 +301,14 @@ void marshall_arguments(FILE *file, int 
         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, in
 
         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;




More information about the wine-cvs mailing list