Alexandre Julliard : widl: Output a pointer description for arrays declared as pointers.

Alexandre Julliard julliard at winehq.org
Fri Oct 16 11:26:10 CDT 2009


Module: wine
Branch: master
Commit: 916461d92632019c041d661f63729a4595320aab
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=916461d92632019c041d661f63729a4595320aab

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Fri Oct 16 14:59:01 2009 +0200

widl: Output a pointer description for arrays declared as pointers.

---

 tools/widl/typegen.c |   36 +++++++++++++++++++++++++-----------
 1 files changed, 25 insertions(+), 11 deletions(-)

diff --git a/tools/widl/typegen.c b/tools/widl/typegen.c
index e7e8980..b868651 100644
--- a/tools/widl/typegen.c
+++ b/tools/widl/typegen.c
@@ -529,8 +529,7 @@ static int type_has_pointers(const type_t *type)
     case TGT_POINTER:
         return TRUE;
     case TGT_ARRAY:
-        /* FIXME: array can be pointer */
-        return type_has_pointers(type_array_get_element(type));
+        return type_array_is_decl_as_ptr(type) || type_has_pointers(type_array_get_element(type));
     case TGT_STRUCT:
     {
         var_list_t *fields = type_struct_get_fields(type);
@@ -1704,10 +1703,9 @@ static int write_pointer_description_offsets(
     int written = 0;
     unsigned int align;
 
-    if (is_ptr(type) && type_get_type(type_pointer_get_ref(type)) != TYPE_INTERFACE)
+    if ((is_ptr(type) && type_get_type(type_pointer_get_ref(type)) != TYPE_INTERFACE) ||
+        (is_array(type) && type_array_is_decl_as_ptr(type)))
     {
-        type_t *ref = type_pointer_get_ref(type);
-
         if (offset_in_memory && offset_in_buffer)
         {
             unsigned int memsize;
@@ -1726,12 +1724,28 @@ static int write_pointer_description_offsets(
         }
         *typestring_offset += 4;
 
-        if (is_string_type(attrs, type))
-            write_string_tfs(file, attrs, type, FALSE, NULL, typestring_offset);
-        else if (processed(ref) || type_get_type(ref) == TYPE_BASIC || type_get_type(ref) == TYPE_ENUM)
-            write_pointer_tfs(file, attrs, type, FALSE, typestring_offset);
+        if (is_ptr(type))
+        {
+            type_t *ref = type_pointer_get_ref(type);
+
+            if (is_string_type(attrs, type))
+                write_string_tfs(file, attrs, type, FALSE, NULL, typestring_offset);
+            else if (processed(ref))
+                write_nonsimple_pointer(file, attrs, type, FALSE, ref->typestring_offset, typestring_offset);
+            else if (type_get_type(ref) == TYPE_BASIC || type_get_type(ref) == TYPE_ENUM)
+                *typestring_offset += write_simple_pointer(file, attrs, type, FALSE);
+            else
+                error("write_pointer_description_offsets: type format string unknown\n");
+        }
         else
-            error("write_pointer_description_offsets: type format string unknown\n");
+        {
+            unsigned int offset = type->typestring_offset;
+            /* skip over the pointer that is written for strings, since a
+             * pointer has to be written in-place here */
+            if (is_string_type(attrs, type))
+                offset += 4;
+            write_nonsimple_pointer(file, attrs, type, FALSE, offset, typestring_offset);
+        }
 
         return 1;
     }
@@ -1935,7 +1949,7 @@ static int write_varying_array_pointer_descriptions(
             *typestring_offset += 8;
 
             pointer_count = write_pointer_description_offsets(
-                file, attrs, type, offset_in_memory,
+                file, attrs, type_array_get_element(type), offset_in_memory,
                 offset_in_buffer, typestring_offset);
         }
     }




More information about the wine-cvs mailing list