- Fix offset calculation bug in the ProcFormatString.
authorEric Kohl <eric.kohl@reactos.org>
Sat, 23 Jul 2005 11:55:33 +0000 (11:55 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Sat, 23 Jul 2005 11:55:33 +0000 (11:55 +0000)
- Fix offset calculation bug in the marshalling and unmarshalling code.
- Fix typos in the TypeFormatString.
This makes the [string, out, size_is()] parameters work properly.

svn path=/trunk/; revision=16703

reactos/tools/widl/ChangeLog
reactos/tools/widl/client.c
reactos/tools/widl/server.c

index 6c3d395..6039d01 100644 (file)
@@ -1,5 +1,15 @@
 ChangeLog
 
+2005-07-23 ekohl
+
+   tools/widl/client.c
+   tools/widl/server.c
+
+- Fix offset calculation bug in the ProcFormatString.
+- Fix offset calculation bug in the marshalling and unmarshalling code.
+- Fix typos in the TypeFormatString.
+This makes the [string, out, size_is()] parameters work properly.
+
 2005-07-17 ekohl
 
    tools/widl/client.c
index d4b879d..8386002 100644 (file)
@@ -108,7 +108,7 @@ static unsigned int
 get_var_type_offset(var_t *var)\r
 {\r
     unsigned int toffset = 0;\r
-    void *size_is_attr;\r
+    void *sizeis_attr;\r
     int string_attr;\r
 \r
     if (var->ptr_level == 0)\r
@@ -133,10 +133,10 @@ get_var_type_offset(var_t *var)
     }\r
     else if (var->ptr_level == 1)\r
     {\r
-        size_is_attr = get_attrp(var->attrs, ATTR_SIZEIS);\r
+        sizeis_attr = get_attrp(var->attrs, ATTR_SIZEIS);\r
         string_attr = is_attr(var->attrs, ATTR_STRING);\r
 \r
-        if (size_is_attr)\r
+        if (sizeis_attr)\r
         {\r
             if (string_attr)\r
             {\r
@@ -337,9 +337,6 @@ static void write_procformatstring(type_t *iface)
                     }\r
                     else if (var->type->type == RPC_FC_RP)\r
                     {\r
-                        var_t *field = var->type->ref->ref->fields;\r
-                        int size;\r
-\r
                         if (in_attr & !out_attr)\r
                             print_client("0x4d,    /* FC_IN_PARAM */\n");\r
                         else if (!in_attr & out_attr)\r
@@ -352,17 +349,6 @@ static void write_procformatstring(type_t *iface)
                         print_client("0x02,\n");\r
                         fprintf(client, "#endif\n");\r
                         print_client("NdrFcShort(0x%x),\n", type_offset);\r
-\r
-                        size = 9;\r
-                        while (NEXT_LINK(field)) field = NEXT_LINK(field);\r
-                        while (field)\r
-                        {\r
-                            size++;\r
-                            field = PREV_LINK(field);\r
-                        }\r
-                        if (size % 2)\r
-                            size++;\r
-                        type_offset += size;\r
                     }\r
                     else\r
                     {\r
@@ -389,7 +375,6 @@ static void write_procformatstring(type_t *iface)
                         print_client("0x02,\n");\r
                         fprintf(client, "#endif\n");\r
                         print_client("NdrFcShort(0x%x),\n", type_offset);\r
-                        type_offset += 4;\r
 //                    }\r
 //                    else\r
 //                    {\r
@@ -405,6 +390,8 @@ static void write_procformatstring(type_t *iface)
                     return;\r
                 }\r
 \r
+                type_offset += get_var_type_offset(var);\r
+\r
                 var = PREV_LINK(var);\r
             }\r
         }\r
@@ -552,7 +539,7 @@ static void write_typeformatstring(type_t *iface)
                             print_client("0x%02x,\n", 0x20 + type_type);\r
                             print_client("0x00,\n");\r
 \r
-                            fprintf(client, "#ifndef _APLHA_\n");\r
+                            fprintf(client, "#ifndef _ALPHA_\n");\r
                             print_client("NdrFcShort(0x%02X),\n",\r
                                          get_var_stack_offset_32(func, ((expr_t *)sizeis_attr)->u.sval));\r
                             fprintf(client, "#else\n");\r
@@ -568,7 +555,7 @@ static void write_typeformatstring(type_t *iface)
                             print_client("0x%02x,\n", 0x20 + type_type);\r
                             print_client("0x00,\n");\r
 \r
-                            fprintf(client, "#ifndef _APLHA_\n");\r
+                            fprintf(client, "#ifndef _ALPHA_\n");\r
                             print_client("NdrFcShort(0x04),\n");\r
                             fprintf(client, "#else\n");\r
                             print_client("NdrFcShort(0x08),\n");\r
@@ -967,7 +954,8 @@ static void marshall_in_arguments(func_t *func, unsigned int *type_offset)
                         indent++;\r
                         print_client("(PMIDL_STUB_MESSAGE)&_StubMsg,\n");\r
                         print_client("(unsigned char __RPC_FAR *)%s,\n", var->name);\r
-                        print_client("(PFORMAT_STRING)&__MIDL_TypeFormatString.Format[%u]);\n", *type_offset + 2);\r
+                        print_client("(PFORMAT_STRING)&__MIDL_TypeFormatString.Format[%u]);\n",\r
+                                     local_type_offset + 2);\r
                         indent--;\r
                         fprintf(client, "\n");\r
                         print_client("_StubMsg.Buffer = (unsigned char __RPC_FAR *)(((long)_StubMsg.Buffer + 3) & ~0x3);\n");\r
@@ -1045,7 +1033,8 @@ static void marshall_in_arguments(func_t *func, unsigned int *type_offset)
                     indent++;\r
                     print_client("(PMIDL_STUB_MESSAGE)&_StubMsg,\n");\r
                     print_client("(unsigned char __RPC_FAR *)%s,\n", var->name);\r
-                    print_client("(PFORMAT_STRING)&__MIDL_TypeFormatString.Format[%u]);\n", *type_offset);\r
+                    print_client("(PFORMAT_STRING)&__MIDL_TypeFormatString.Format[%u]);\n",\r
+                                 local_type_offset);\r
                     indent--;\r
                     fprintf(client, "\n");\r
                 }\r
@@ -1126,7 +1115,7 @@ static void marshall_in_arguments(func_t *func, unsigned int *type_offset)
                         print_client("(PMIDL_STUB_MESSAGE)&_StubMsg,\n");\r
                         print_client("(unsigned char __RPC_FAR *)%s,\n", var->name);\r
                         print_client("(PFORMAT_STRING)&__MIDL_TypeFormatString.Format[%u]);\n",\r
-                                     *type_offset + 4);\r
+                                     local_type_offset + 4);\r
                         indent--;\r
                         fprintf(client, "\n");\r
                     }\r
@@ -1184,7 +1173,7 @@ static void unmarshall_out_arguments(func_t *func, unsigned int *type_offset)
                         print_client("(PMIDL_STUB_MESSAGE)&_StubMsg,\n");\r
                         print_client("(unsigned char __RPC_FAR * __RPC_FAR *)&%s,\n", var->name);\r
                         print_client("(PFORMAT_STRING)&__MIDL_TypeFormatString.Format[%u],\n",\r
-                                     *type_offset + 4);\r
+                                     local_type_offset + 4);\r
                         print_client("(unsigned char)0);\n");\r
                         indent--;\r
                         fprintf(client, "\n");\r
@@ -1199,7 +1188,7 @@ static void unmarshall_out_arguments(func_t *func, unsigned int *type_offset)
                         print_client("(PMIDL_STUB_MESSAGE)&_StubMsg,\n");\r
                         print_client("(unsigned char __RPC_FAR * __RPC_FAR *)&%s,\n", var->name);\r
                         print_client("(PFORMAT_STRING)&__MIDL_TypeFormatString.Format[%u],\n",\r
-                                     *type_offset + 4);\r
+                                     local_type_offset + 4);\r
                         print_client("(unsigned char)0);\n");\r
                         indent--;\r
                         fprintf(client, "\n");\r
@@ -1282,7 +1271,7 @@ static void unmarshall_out_arguments(func_t *func, unsigned int *type_offset)
                         print_client("(PMIDL_STUB_MESSAGE)&_StubMsg,\n");\r
                         print_client("(unsigned char __RPC_FAR * __RPC_FAR *)&%s,\n", var->name);\r
                         print_client("(PFORMAT_STRING)&__MIDL_TypeFormatString.Format[%u],\n",\r
-                                     *type_offset + 4);\r
+                                     local_type_offset + 4);\r
                         print_client("(unsigned char)0);\n");\r
                         indent--;\r
                         fprintf(client, "\n");\r
index 0f1a949..1ce4bc9 100644 (file)
@@ -342,9 +342,6 @@ static void write_procformatstring(type_t *iface)
                     }\r
                     else if (var->type->type == RPC_FC_RP)\r
                     {\r
-                        var_t *field = var->type->ref->ref->fields;\r
-                        int size;\r
-\r
                         if (in_attr & !out_attr)\r
                             print_server("0x4d,    /* FC_IN_PARAM */\n");\r
                         else if (!in_attr & out_attr)\r
@@ -357,17 +354,6 @@ static void write_procformatstring(type_t *iface)
                         print_server("0x02,\n");\r
                         fprintf(server, "#endif\n");\r
                         print_server("NdrFcShort(0x%x),\n", type_offset);\r
-\r
-                        size = 9;\r
-                        while (NEXT_LINK(field)) field = NEXT_LINK(field);\r
-                        while (field)\r
-                        {\r
-                            size++;\r
-                            field = PREV_LINK(field);\r
-                        }\r
-                        if (size % 2)\r
-                            size++;\r
-                        type_offset += size;\r
                     }\r
                     else\r
                     {\r
@@ -392,7 +378,6 @@ static void write_procformatstring(type_t *iface)
                         print_server("0x02,\n");\r
                         fprintf(server, "#endif\n");\r
                         print_server("NdrFcShort(0x%x),\n", type_offset);\r
-                        type_offset += 4;\r
 //                    }\r
 //                    else\r
 //                    {\r
@@ -402,6 +387,8 @@ static void write_procformatstring(type_t *iface)
 //                    }\r
                 }\r
 \r
+                type_offset += get_var_type_offset(var);\r
+\r
                 var = PREV_LINK(var);\r
             }\r
         }\r
@@ -549,7 +536,7 @@ static void write_typeformatstring(type_t *iface)
                             print_server("0x%02x,\n", 0x20 + type_type);\r
                             print_server("0x00,\n");\r
 \r
-                            fprintf(server, "#ifndef _APLHA_\n");\r
+                            fprintf(server, "#ifndef _ALPHA_\n");\r
                             print_server("NdrFcShort(0x%02X),\n",\r
                                          get_var_stack_offset_32(func, ((expr_t *)sizeis_attr)->u.sval));\r
                             fprintf(server, "#else\n");\r
@@ -565,7 +552,7 @@ static void write_typeformatstring(type_t *iface)
                             print_server("0x%02x,\n", 0x20 + type_type);\r
                             print_server("0x00,\n");\r
 \r
-                            fprintf(server, "#ifndef _APLHA_\n");\r
+                            fprintf(server, "#ifndef _ALPHA_\n");\r
                             print_server("NdrFcShort(0x04),\n");\r
                             fprintf(server, "#else\n");\r
                             print_server("NdrFcShort(0x08),\n");\r
@@ -840,10 +827,10 @@ static void print_message_buffer_size(func_t *func, unsigned int *type_offset)
 \r
                     empty_line = 1;\r
                 }\r
-\r
-                /* calculate the next type offset */\r
-                local_type_offset += get_var_type_offset(var);\r
             }\r
+\r
+            /* calculate the next type offset */\r
+            local_type_offset += get_var_type_offset(var);\r
         }\r
 \r
         if (empty_line)\r