Rob Shearman : widl: Add a new function, type_alias_get_aliasee to wrap the retrieval of the type that the alias aliases .

Alexandre Julliard julliard at winehq.org
Mon Jan 19 08:58:49 CST 2009


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

Author: Rob Shearman <robertshearman at gmail.com>
Date:   Mon Jan 19 00:02:28 2009 +0000

widl: Add a new function, type_alias_get_aliasee to wrap  the retrieval of the type that the alias aliases.

---

 tools/widl/header.c     |    8 ++++----
 tools/widl/parser.y     |   10 +++++-----
 tools/widl/typegen.c    |    4 ++--
 tools/widl/typetree.h   |    6 ++++++
 tools/widl/write_msft.c |   11 +++++++----
 5 files changed, 24 insertions(+), 15 deletions(-)

diff --git a/tools/widl/header.c b/tools/widl/header.c
index a3d2250..2afd3b5 100644
--- a/tools/widl/header.c
+++ b/tools/widl/header.c
@@ -63,7 +63,7 @@ int is_ptrchain_attr(const var_t *var, enum attr_type t)
             if (is_attr(type->attrs, t))
                 return 1;
             else if (type_is_alias(type))
-                type = type->orig;
+                type = type_alias_get_aliasee(type);
             else if (is_ptr(type))
                 type = type_pointer_get_ref(type);
             else return 0;
@@ -79,7 +79,7 @@ int is_aliaschain_attr(const type_t *type, enum attr_type attr)
         if (is_attr(t->attrs, attr))
             return 1;
         else if (type_is_alias(t))
-            t = t->orig;
+            t = type_alias_get_aliasee(t);
         else return 0;
     }
 }
@@ -424,7 +424,7 @@ void check_for_additional_prototype_types(const var_list_t *list)
       }
 
       if (type_is_alias(type))
-        type = type->orig;
+        type = type_alias_get_aliasee(type);
       else if (is_ptr(type))
         type = type_pointer_get_ref(type);
       else if (is_array(type))
@@ -472,7 +472,7 @@ static void write_generic_handle_routines(FILE *header)
 static void write_typedef(FILE *header, type_t *type)
 {
   fprintf(header, "typedef ");
-  write_type_def_or_decl(header, type->orig, FALSE, "%s", type->name);
+  write_type_def_or_decl(header, type_alias_get_aliasee(type), FALSE, "%s", type->name);
   fprintf(header, ";\n");
 }
 
diff --git a/tools/widl/parser.y b/tools/widl/parser.y
index 084b5b3..91036ab 100644
--- a/tools/widl/parser.y
+++ b/tools/widl/parser.y
@@ -1443,7 +1443,7 @@ static void set_type(var_t *v, decl_spec_t *decl_spec, const declarator_t *decl,
     {
       ptr_attr = get_attrv(ptr->attrs, ATTR_POINTERTYPE);
       if (!ptr_attr && type_is_alias(ptr))
-        ptr = ptr->orig;
+        ptr = type_alias_get_aliasee(ptr);
       else
         break;
     }
@@ -1777,7 +1777,7 @@ static void add_incomplete(type_t *t)
 static void fix_type(type_t *t)
 {
   if (type_is_alias(t) && is_incomplete(t)) {
-    type_t *ot = t->orig;
+    type_t *ot = type_alias_get_aliasee(t);
     fix_type(ot);
     if (is_struct(ot->type) || is_union(ot->type))
       t->details.structure = ot->details.structure;
@@ -2380,9 +2380,9 @@ static void check_field_common(const type_t *container_type,
             break;
         }
         if (type_is_alias(type))
-            type = type->orig;
+            type = type_alias_get_aliasee(type);
         else if (is_ptr(type))
-            type = type->ref;
+            type = type_pointer_get_ref(type);
         else if (is_array(type))
             type = type_array_get_element(type);
         else
@@ -2442,7 +2442,7 @@ static void check_remoting_args(const var_t *func)
             if (is_attr(type->attrs, ATTR_CONTEXTHANDLE))
                 break;
             if (type_is_alias(type))
-                type = type->orig;
+                type = type_alias_get_aliasee(type);
             else if (is_ptr(type))
             {
                 ptr_level++;
diff --git a/tools/widl/typegen.c b/tools/widl/typegen.c
index da5c29b..4e0bea0 100644
--- a/tools/widl/typegen.c
+++ b/tools/widl/typegen.c
@@ -515,7 +515,7 @@ static type_t *get_user_type(const type_t *t, const char **pname)
         }
 
         if (type_is_alias(t))
-            t = t->orig;
+            t = type_alias_get_aliasee(t);
         else
             return 0;
     }
@@ -1053,7 +1053,7 @@ size_t type_memsize(const type_t *t, unsigned int *align)
     size_t size = 0;
 
     if (type_is_alias(t))
-        size = type_memsize(t->orig, align);
+        size = type_memsize(type_alias_get_aliasee(t), align);
     else if (t->declarray && is_conformant_array(t))
     {
         type_memsize(type_array_get_element(t), align);
diff --git a/tools/widl/typetree.h b/tools/widl/typetree.h
index 8efc62b..245a9c5 100644
--- a/tools/widl/typetree.h
+++ b/tools/widl/typetree.h
@@ -180,6 +180,12 @@ static inline int type_is_alias(const type_t *type)
     return type->is_alias;
 }
 
+static inline type_t *type_alias_get_aliasee(const type_t *type)
+{
+    assert(type_is_alias(type));
+    return type->orig;
+}
+
 static inline ifref_list_t *type_coclass_get_ifaces(const type_t *type)
 {
     assert(type->type == RPC_FC_COCLASS);
diff --git a/tools/widl/write_msft.c b/tools/widl/write_msft.c
index 04195ff..9816048 100644
--- a/tools/widl/write_msft.c
+++ b/tools/widl/write_msft.c
@@ -981,7 +981,7 @@ static int encode_type(
 
         /* typedef'd types without public attribute aren't included in the typelib */
         while (type->typelib_idx < 0 && type_is_alias(type) && !is_attr(type->attrs, ATTR_PUBLIC))
-          type = type->orig;
+          type = type_alias_get_aliasee(type);
 
         chat("encode_type: VT_USERDEFINED - type %p name = %s type->type %d idx %d\n", type,
              type->name, type->type, type->typelib_idx);
@@ -2095,8 +2095,11 @@ static void add_typedef_typeinfo(msft_typelib_t *typelib, type_t *tdef)
 
     tdef->typelib_idx = typelib->typelib_header.nrtypeinfos;
     msft_typeinfo = create_msft_typeinfo(typelib, TKIND_ALIAS, tdef->name, tdef->attrs);
-    encode_type(typelib, get_type_vt(tdef->orig), tdef->orig, &msft_typeinfo->typeinfo->datatype1, &msft_typeinfo->typeinfo->size,
-               &alignment, &msft_typeinfo->typeinfo->datatype2);
+    encode_type(typelib, get_type_vt(type_alias_get_aliasee(tdef)),
+                type_alias_get_aliasee(tdef),
+                &msft_typeinfo->typeinfo->datatype1,
+                &msft_typeinfo->typeinfo->size,
+                &alignment, &msft_typeinfo->typeinfo->datatype2);
     msft_typeinfo->typeinfo->typekind |= (alignment << 11 | alignment << 6);
 }
 
@@ -2269,7 +2272,7 @@ static void add_entry(msft_typelib_t *typelib, const statement_t *stmt)
             if (is_attr(type_entry->type->attrs, ATTR_PUBLIC))
                 add_typedef_typeinfo(typelib, type_entry->type);
             else
-                add_type_typeinfo(typelib, type_entry->type->orig);
+                add_type_typeinfo(typelib, type_alias_get_aliasee(type_entry->type));
         }
         break;
     }




More information about the wine-cvs mailing list