Robert Shearman : widl: Clean up conformant struct handling.

Alexandre Julliard julliard at wine.codeweavers.com
Tue Jan 31 11:23:30 CST 2006


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

Author: Robert Shearman <rob at codeweavers.com>
Date:   Tue Jan 31 18:08:03 2006 +0100

widl: Clean up conformant struct handling.
Make the writing of conformant structures take advantage of the new
type format string offset handling.

---

 tools/widl/typegen.c |   49 ++++++++++++++++++++++++++-----------------------
 1 files changed, 26 insertions(+), 23 deletions(-)

diff --git a/tools/widl/typegen.c b/tools/widl/typegen.c
index d4dc13e..438a211 100644
--- a/tools/widl/typegen.c
+++ b/tools/widl/typegen.c
@@ -796,6 +796,7 @@ static size_t write_struct_tfs(FILE *fil
     size_t total_size;
     const var_t *array;
     size_t start_offset;
+    size_t array_offset;
 
     switch (type->type)
     {
@@ -827,6 +828,13 @@ static size_t write_struct_tfs(FILE *fil
             error("structure size for parameter %s exceeds %d bytes by %d bytes\n",
                   name, USHRT_MAX, total_size - USHRT_MAX);
 
+        array = find_array_or_string_in_struct(type);
+        current_structure = type;
+        array_offset = write_array_tfs(file, array->attrs, array->type, 
+                                       array->array, array->name,
+                                       typestring_offset);
+        current_structure = NULL;
+
         start_offset = *typestring_offset;
         WRITE_FCTYPE(file, FC_CSTRUCT, *typestring_offset);
         /* alignment */
@@ -834,19 +842,13 @@ static size_t write_struct_tfs(FILE *fil
         /* total size */
         print_file(file, 2, "NdrShort(0x%x), /* %u */\n", total_size, total_size);
         *typestring_offset += 4;
-        /* FIXME: a fixed offset won't work when pointer layout is present */
-        print_file(file, 2, "NdrShort(0x3), /* 3 */\n");
+        print_file(file, 2, "NdrShort(0x%x), /* %d */\n",
+                   array_offset - *typestring_offset,
+                   array_offset - *typestring_offset);
         *typestring_offset += 2;
         print_file(file, 2, "FC_END,\n");
         *typestring_offset += 1;
 
-        array = find_array_or_string_in_struct(type);
-        current_structure = type;
-        write_array_tfs(file, array->attrs, array->type,
-                        array->array, array->name,
-                        typestring_offset);
-        current_structure = NULL;
-
         return start_offset;
     case RPC_FC_CVSTRUCT:
         total_size = type_memsize(type, 0, NULL);
@@ -855,6 +857,18 @@ static size_t write_struct_tfs(FILE *fil
             error("structure size for parameter %s exceeds %d bytes by %d bytes\n",
                   name, USHRT_MAX, total_size - USHRT_MAX);
 
+        array = find_array_or_string_in_struct(type);
+        current_structure = type;
+        if (is_attr(array->attrs, ATTR_STRING))
+            array_offset = write_string_tfs(file, array->attrs, array->type,
+                                            array->array, array->name,
+                                            typestring_offset);
+        else
+            array_offset = write_array_tfs(file, array->attrs, array->type,
+                                           array->array, array->name,
+                                           typestring_offset);
+        current_structure = NULL;
+
         start_offset = *typestring_offset;
         WRITE_FCTYPE(file, FC_CVSTRUCT, *typestring_offset);
         /* alignment */
@@ -862,24 +876,13 @@ static size_t write_struct_tfs(FILE *fil
         /* total size */
         print_file(file, 2, "NdrShort(0x%x), /* %u */\n", total_size, total_size);
         *typestring_offset += 4;
-        /* FIXME: a fixed offset won't work when pointer layout is present */
-        print_file(file, 2, "NdrShort(0x3), /* 3 */\n");
+        print_file(file, 2, "NdrShort(0x%x), /* %d */\n",
+                   array_offset - *typestring_offset,
+                   array_offset - *typestring_offset);
         *typestring_offset += 2;
         print_file(file, 2, "FC_END,\n");
         *typestring_offset += 1;
 
-        array = find_array_or_string_in_struct(type);
-        current_structure = type;
-        if (is_attr(array->attrs, ATTR_STRING))
-            write_string_tfs(file, array->attrs, array->type,
-                             array->array, array->name,
-                             typestring_offset);
-        else
-            write_array_tfs(file, array->attrs, array->type,
-                            array->array, array->name,
-                            typestring_offset);
-        current_structure = NULL;
-
         return start_offset;
     default:
         error("write_struct_tfs: Unimplemented for type 0x%x\n", type->type);




More information about the wine-cvs mailing list