widl: Use is_string_type for detecting strings in write_typeformatstring_var to make...
authorRob Shearman <rob@codeweavers.com>
Thu, 27 Mar 2008 14:02:58 +0000 (14:02 +0000)
committerAlexandre Julliard <julliard@winehq.org>
Thu, 27 Mar 2008 16:32:58 +0000 (17:32 +0100)
Fix the is_string_type function used for detecting strings by only
examining aliases instead of both aliases and pointers. This is due to
the requirement that pointers to strings be handled as pointers and so
not detected as strings.

tools/widl/header.c
tools/widl/header.h
tools/widl/typegen.c

index 0a28fd93558ec4c7f8e54609eb75aa1c33559cd5..5ffa549425bdca623a2041c6b033c7600248539f 100644 (file)
@@ -66,6 +66,19 @@ int is_ptrchain_attr(const var_t *var, enum attr_type t)
     }
 }
 
+int is_aliaschain_attr(const type_t *type, enum attr_type attr)
+{
+    const type_t *t = type;
+    for (;;)
+    {
+        if (is_attr(t->attrs, attr))
+            return 1;
+        else if (t->kind == TKIND_ALIAS)
+            t = t->orig;
+        else return 0;
+    }
+}
+
 int is_attr(const attr_list_t *list, enum attr_type t)
 {
     const attr_t *attr;
index 656d4b2597bee769838a83f6a09633a0bcdbea5c..173bd03551ae3cc73ecf6372c7ea58ba02c9349a 100644 (file)
@@ -24,6 +24,7 @@
 #include "widltypes.h"
 
 extern int is_ptrchain_attr(const var_t *var, enum attr_type t);
+extern int is_aliaschain_attr(const type_t *var, enum attr_type t);
 extern int is_attr(const attr_list_t *list, enum attr_type t);
 extern void *get_attrp(const attr_list_t *list, enum attr_type t);
 extern unsigned long get_attrv(const attr_list_t *list, enum attr_type t);
@@ -78,7 +79,7 @@ static inline int last_array(const type_t *type)
 
 static inline int is_string_type(const attr_list_t *attrs, const type_t *type)
 {
-    return ((is_attr(attrs, ATTR_STRING) || is_attr(type->attrs, ATTR_STRING))
+    return ((is_attr(attrs, ATTR_STRING) || is_aliaschain_attr(type, ATTR_STRING))
             && (last_ptr(type) || last_array(type)));
 }
 
index ae23f94df1db5b2c86a0f8852db0caef1651bbb1..4e5782b79221b5a306affb010102b1e25fab486e 100644 (file)
@@ -2181,7 +2181,7 @@ static size_t write_typeformatstring_var(FILE *file, int indent, const func_t *f
         return type->typestring_offset;
     }
 
-    if ((last_ptr(type) || last_array(type)) && is_ptrchain_attr(var, ATTR_STRING))
+    if (is_string_type(var->attrs, type))
         return write_string_tfs(file, var->attrs, type, var->name, typeformat_offset, TRUE);
 
     if (is_array(type))