Rob Shearman : widl: Use is_string_type for detecting strings in write_typeformatstring_var to make it consistent with write_remoting_arg .

Alexandre Julliard julliard at winehq.org
Thu Mar 27 15:43:22 CDT 2008


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

Author: Rob Shearman <rob at codeweavers.com>
Date:   Thu Mar 27 14:02:58 2008 +0000

widl: Use is_string_type for detecting strings in write_typeformatstring_var to make it consistent with write_remoting_arg.

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  |   13 +++++++++++++
 tools/widl/header.h  |    3 ++-
 tools/widl/typegen.c |    2 +-
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/tools/widl/header.c b/tools/widl/header.c
index 0a28fd9..5ffa549 100644
--- a/tools/widl/header.c
+++ b/tools/widl/header.c
@@ -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;
diff --git a/tools/widl/header.h b/tools/widl/header.h
index 656d4b2..173bd03 100644
--- a/tools/widl/header.h
+++ b/tools/widl/header.h
@@ -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)));
 }
 
diff --git a/tools/widl/typegen.c b/tools/widl/typegen.c
index ae23f94..4e5782b 100644
--- a/tools/widl/typegen.c
+++ b/tools/widl/typegen.c
@@ -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))




More information about the wine-cvs mailing list