From: Richard Pospesel richard@torproject.org
Signed-off-by: Richard Pospesel richard@torproject.org Signed-off-by: Zebediah Figura z.figura12@gmail.com --- tools/widl/header.c | 14 +++++++------- tools/widl/header.h | 2 +- tools/widl/parser.y | 2 +- tools/widl/typegen.c | 8 ++++---- tools/widl/typetree.c | 5 +---- tools/widl/typetree.h | 6 +++--- tools/widl/widltypes.h | 7 ++++++- tools/widl/write_msft.c | 12 ++++++------ 8 files changed, 29 insertions(+), 27 deletions(-)
diff --git a/tools/widl/header.c b/tools/widl/header.c index f4bf13aca8..51c2be7eef 100644 --- a/tools/widl/header.c +++ b/tools/widl/header.c @@ -75,7 +75,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_alias_get_aliasee(type); + type = type_alias_get_aliasee_type(type); else if (is_ptr(type)) type = type_pointer_get_ref_type(type); else return 0; @@ -91,7 +91,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 = type_alias_get_aliasee(t); + t = type_alias_get_aliasee_type(t); else return 0; } } @@ -602,7 +602,7 @@ unsigned int get_context_handle_offset( const type_t *type )
while (!is_attr( type->attrs, ATTR_CONTEXTHANDLE )) { - if (type_is_alias( type )) type = type_alias_get_aliasee( type ); + if (type_is_alias( type )) type = type_alias_get_aliasee_type( type ); else if (is_ptr( type )) type = type_pointer_get_ref_type( type ); else error( "internal error: %s is not a context handle\n", type->name ); } @@ -622,7 +622,7 @@ unsigned int get_generic_handle_offset( const type_t *type )
while (!is_attr( type->attrs, ATTR_HANDLE )) { - if (type_is_alias( type )) type = type_alias_get_aliasee( type ); + if (type_is_alias( type )) type = type_alias_get_aliasee_type( type ); else if (is_ptr( type )) type = type_pointer_get_ref_type( type ); else error( "internal error: %s is not a generic handle\n", type->name ); } @@ -701,7 +701,7 @@ void check_for_additional_prototype_types(type_t *type) }
if (type_is_alias(type)) - type = type_alias_get_aliasee(type); + type = type_alias_get_aliasee_type(type); else if (is_ptr(type)) type = type_pointer_get_ref_type(type); else if (is_array(type)) @@ -789,7 +789,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_alias_get_aliasee(type), FALSE, type->name); + write_type_def_or_decl(header, type_alias_get_aliasee_type(type), FALSE, type->name); fprintf(header, ";\n"); }
@@ -852,7 +852,7 @@ const type_t* get_explicit_generic_handle_type(const var_t* var) const type_t *t; for (t = var->declspec.type; is_ptr(t) || type_is_alias(t); - t = type_is_alias(t) ? type_alias_get_aliasee(t) : type_pointer_get_ref_type(t)) + t = type_is_alias(t) ? type_alias_get_aliasee_type(t) : type_pointer_get_ref_type(t)) if ((type_get_type_detect_alias(t) != TYPE_BASIC || type_basic_get_type(t) != TYPE_BASIC_HANDLE) && is_attr(t->attrs, ATTR_HANDLE)) return t; diff --git a/tools/widl/header.h b/tools/widl/header.h index eb98125b25..94b90a391f 100644 --- a/tools/widl/header.h +++ b/tools/widl/header.h @@ -102,7 +102,7 @@ static inline int is_context_handle(const type_t *type) const type_t *t; for (t = type; is_ptr(t) || type_is_alias(t); - t = type_is_alias(t) ? type_alias_get_aliasee(t) : type_pointer_get_ref_type(t)) + t = type_is_alias(t) ? type_alias_get_aliasee_type(t) : type_pointer_get_ref_type(t)) if (is_attr(t->attrs, ATTR_CONTEXTHANDLE)) return 1; return 0; diff --git a/tools/widl/parser.y b/tools/widl/parser.y index 1504fb9638..df3d78f567 100644 --- a/tools/widl/parser.y +++ b/tools/widl/parser.y @@ -1548,7 +1548,7 @@ static var_t *declare_var(attr_list_t *attrs, decl_spec_t *decl_spec, const decl { ptr_attr = get_attrv(ptr->attrs, ATTR_POINTERTYPE); if (!ptr_attr && type_is_alias(ptr)) - ptr = type_alias_get_aliasee(ptr); + ptr = type_alias_get_aliasee_type(ptr); else break; } diff --git a/tools/widl/typegen.c b/tools/widl/typegen.c index e21aa5703c..e266764144 100644 --- a/tools/widl/typegen.c +++ b/tools/widl/typegen.c @@ -197,7 +197,7 @@ static void *get_aliaschain_attrp(const type_t *type, enum attr_type attr) if (is_attr(t->attrs, attr)) return get_attrp(t->attrs, attr); else if (type_is_alias(t)) - t = type_alias_get_aliasee(t); + t = type_alias_get_aliasee_type(t); else return NULL; } } @@ -267,7 +267,7 @@ unsigned char get_pointer_fc(const type_t *type, const attr_list_t *attrs, int t if (pointer_type) return pointer_type;
- for (t = type; type_is_alias(t); t = type_alias_get_aliasee(t)) + for (t = type; type_is_alias(t); t = type_alias_get_aliasee_type(t)) { pointer_type = get_attrv(t->attrs, ATTR_POINTERTYPE); if (pointer_type) @@ -316,7 +316,7 @@ static type_t *get_user_type(const type_t *t, const char **pname) }
if (type_is_alias(t)) - t = type_alias_get_aliasee(t); + t = type_alias_get_aliasee_type(t); else return NULL; } @@ -857,7 +857,7 @@ static const char *get_context_handle_type_name(const type_t *type) const type_t *t; for (t = type; is_ptr(t) || type_is_alias(t); - t = type_is_alias(t) ? type_alias_get_aliasee(t) : type_pointer_get_ref_type(t)) + t = type_is_alias(t) ? type_alias_get_aliasee_type(t) : type_pointer_get_ref_type(t)) if (is_attr(t->attrs, ATTR_CONTEXTHANDLE)) return t->name; assert(0); diff --git a/tools/widl/typetree.c b/tools/widl/typetree.c index d823a46edc..ae3f375450 100644 --- a/tools/widl/typetree.c +++ b/tools/widl/typetree.c @@ -49,7 +49,6 @@ type_t *make_type(enum type_type type) t->type_type = type; t->attrs = NULL; t->c_name = NULL; - t->orig = NULL; memset(&t->details, 0, sizeof(t->details)); t->typestring_offset = 0; t->ptrdesc = 0; @@ -191,9 +190,7 @@ type_t *type_new_alias(type_t *t, const char *name)
a->name = xstrdup(name); a->attrs = NULL; - a->orig = t; - /* for pointer types */ - a->details = t->details; + a->details.alias.aliasee.type = t; init_loc_info(&a->loc_info);
return a; diff --git a/tools/widl/typetree.h b/tools/widl/typetree.h index db8c1fcade..58b388c825 100644 --- a/tools/widl/typetree.h +++ b/tools/widl/typetree.h @@ -60,7 +60,7 @@ type_t *duptype(type_t *t, int dupname); static inline type_t *type_get_real_type(const type_t *type) { if (type->type_type == TYPE_ALIAS) - return type_get_real_type(type->orig); + return type_get_real_type(type->details.alias.aliasee.type); else return (type_t *)type; } @@ -302,10 +302,10 @@ static inline int type_is_alias(const type_t *type) return type->type_type == TYPE_ALIAS; }
-static inline type_t *type_alias_get_aliasee(const type_t *type) +static inline type_t *type_alias_get_aliasee_type(const type_t *type) { assert(type_is_alias(type)); - return type->orig; + return type->details.alias.aliasee.type; }
static inline ifref_list_t *type_coclass_get_ifaces(const type_t *type) diff --git a/tools/widl/widltypes.h b/tools/widl/widltypes.h index 29ff266388..43931c9813 100644 --- a/tools/widl/widltypes.h +++ b/tools/widl/widltypes.h @@ -393,6 +393,11 @@ struct bitfield_details const expr_t *bits; };
+struct alias_details +{ + struct _decl_spec_t aliasee; +}; + #define HASHMAX 64
struct namespace { @@ -438,9 +443,9 @@ struct _type_t { struct basic_details basic; struct pointer_details pointer; struct bitfield_details bitfield; + struct alias_details alias; } details; const char *c_name; - type_t *orig; /* dup'd types */ unsigned int typestring_offset; unsigned int ptrdesc; /* used for complex structs */ int typelib_idx; diff --git a/tools/widl/write_msft.c b/tools/widl/write_msft.c index 98fa7ddadf..420404af6d 100644 --- a/tools/widl/write_msft.c +++ b/tools/widl/write_msft.c @@ -912,10 +912,10 @@ static int encode_type(
case VT_SAFEARRAY: { - type_t *element_type = type_alias_get_aliasee(type_array_get_element_type(type)); + type_t *element_type = type_alias_get_aliasee_type(type_array_get_element_type(type)); int next_vt = get_type_vt(element_type);
- encode_type(typelib, next_vt, type_alias_get_aliasee(type_array_get_element_type(type)), + encode_type(typelib, next_vt, type_alias_get_aliasee_type(type_array_get_element_type(type)), &target_type, &child_size);
for (typeoffset = 0; typeoffset < typelib->typelib_segdir[MSFT_SEG_TYPEDESC].length; typeoffset += 8) { @@ -968,7 +968,7 @@ static int encode_type( { /* typedef'd types without public attribute aren't included in the typelib */ while (type_is_alias(type) && !is_attr(type->attrs, ATTR_PUBLIC)) - type = type_alias_get_aliasee(type); + type = type_alias_get_aliasee_type(type);
chat("encode_type: VT_USERDEFINED - adding new type %s, real type %d\n", type->name, type_get_type(type)); @@ -1114,7 +1114,7 @@ static int encode_var( if (target_type & 0x80000000) { mix_field = ((target_type >> 16) & 0x3fff) | VT_BYREF; } else if (get_type_vt(ref) == VT_SAFEARRAY) { - type_t *element_type = type_alias_get_aliasee(type_array_get_element_type(ref)); + type_t *element_type = type_alias_get_aliasee_type(type_array_get_element_type(ref)); mix_field = get_type_vt(element_type) | VT_ARRAY | VT_BYREF; } else { typedata = (void *)&typelib->typelib_segment_data[MSFT_SEG_TYPEDESC][target_type]; @@ -2181,7 +2181,7 @@ static void add_typedef_typeinfo(msft_typelib_t *typelib, type_t *tdef) if (-1 < tdef->typelib_idx) return;
- type = type_alias_get_aliasee(tdef); + type = type_alias_get_aliasee_type(tdef);
if (!type->name || strcmp(tdef->name, type->name) != 0) { @@ -2364,7 +2364,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_alias_get_aliasee(type_entry->type)); + add_type_typeinfo(typelib, type_alias_get_aliasee_type(type_entry->type)); } break; }