diff --git a/tools/widl/client.c b/tools/widl/client.c index 185ab8dffc2..6ecae4187d3 100644 --- a/tools/widl/client.c +++ b/tools/widl/client.c @@ -373,9 +373,9 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset) } case STMT_TYPEDEF: { - const type_list_t *type_entry; - for (type_entry = stmt->u.type_list; type_entry; type_entry = type_entry->next) - write_serialize_functions(client, type_entry->type, iface); + typeref_t *ref; + if (stmt->u.type_list) LIST_FOR_EACH_ENTRY(ref, stmt->u.type_list, typeref_t, entry) + write_serialize_functions(client, ref->type, iface); break; } default: @@ -539,11 +539,11 @@ static void write_client_ifaces(const statement_list_t *stmts, int expr_eval_rou } if (stmt2->type == STMT_TYPEDEF) { - const type_list_t *type_entry; - for (type_entry = stmt2->u.type_list; type_entry; type_entry = type_entry->next) + typeref_t *ref; + if (stmt2->u.type_list) LIST_FOR_EACH_ENTRY(ref, stmt2->u.type_list, typeref_t, entry) { - if (is_attr(type_entry->type->attrs, ATTR_ENCODE) - || is_attr(type_entry->type->attrs, ATTR_DECODE)) + if (is_attr(ref->type->attrs, ATTR_ENCODE) + || is_attr(ref->type->attrs, ATTR_DECODE)) { needs_stub = 1; break; diff --git a/tools/widl/header.c b/tools/widl/header.c index 8423756e060..f4010220206 100644 --- a/tools/widl/header.c +++ b/tools/widl/header.c @@ -776,7 +776,7 @@ static int for_each_serializable(const statement_list_t *stmts, FILE *header, { statement_t *stmt, *iface_stmt; statement_list_t *iface_stmts; - const type_list_t *type_entry; + typeref_t *ref; if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, statement_t, entry ) { @@ -787,12 +787,12 @@ static int for_each_serializable(const statement_list_t *stmts, FILE *header, if (iface_stmts) LIST_FOR_EACH_ENTRY( iface_stmt, iface_stmts, statement_t, entry ) { if (iface_stmt->type != STMT_TYPEDEF) continue; - for (type_entry = iface_stmt->u.type_list; type_entry; type_entry = type_entry->next) + if (iface_stmt->u.type_list) LIST_FOR_EACH_ENTRY(ref, iface_stmt->u.type_list, typeref_t, entry) { - if (!is_attr(type_entry->type->attrs, ATTR_ENCODE) - && !is_attr(type_entry->type->attrs, ATTR_DECODE)) + if (!is_attr(ref->type->attrs, ATTR_ENCODE) + && !is_attr(ref->type->attrs, ATTR_DECODE)) continue; - if (!proc(header, type_entry->type)) + if (!proc(header, ref->type)) return 0; } } @@ -1887,9 +1887,9 @@ static void write_header_stmts(FILE *header, const statement_list_t *stmts, cons break; case STMT_TYPEDEF: { - const type_list_t *type_entry = stmt->u.type_list; - for (; type_entry; type_entry = type_entry->next) - write_typedef(header, type_entry->type, stmt->declonly); + typeref_t *ref; + if (stmt->u.type_list) LIST_FOR_EACH_ENTRY(ref, stmt->u.type_list, typeref_t, entry) + write_typedef(header, ref->type, stmt->declonly); break; } case STMT_LIBRARY: diff --git a/tools/widl/parser.y b/tools/widl/parser.y index 7fec5da2726..31ee9405455 100644 --- a/tools/widl/parser.y +++ b/tools/widl/parser.y @@ -45,7 +45,6 @@ struct _import_t }; static str_list_t *append_str(str_list_t *list, char *str); -static type_list_t *append_type(type_list_t *list, type_t *type); static attr_list_t *append_attr(attr_list_t *list, attr_t *attr); static attr_list_t *append_attr_list(attr_list_t *new_list, attr_list_t *old_list); static decl_spec_t *make_decl_spec(type_t *type, decl_spec_t *left, decl_spec_t *right, @@ -128,7 +127,6 @@ static typelib_t *current_typelib; expr_t *expr; expr_list_t *expr_list; type_t *type; - type_list_t *type_list; var_t *var; var_list_t *var_list; declarator_t *declarator; @@ -292,7 +290,7 @@ static typelib_t *current_typelib; %type enumdef structdef uniondef typedecl %type type unqualified_type qualified_type %type type_parameter -%type type_parameters +%type type_parameters %type class_interface %type class_interfaces %type requires required_types @@ -976,8 +974,8 @@ type_parameter: typename { $$ = get_type(TYPE_PARAMETER, $1, parameters_namesp ; type_parameters: - type_parameter { $$ = append_type(NULL, $1); } - | type_parameters ',' type_parameter { $$ = append_type($1, $3); } + type_parameter { $$ = append_typeref(NULL, make_typeref($1)); } + | type_parameters ',' type_parameter { $$ = append_typeref($1, make_typeref($3)); } ; interface: @@ -1834,16 +1832,6 @@ static typeref_t *make_typeref(type_t *type) return ref; } -static type_list_t *append_type(type_list_t *list, type_t *type) -{ - type_list_t *entry; - if (!type) return list; - entry = xmalloc( sizeof(*entry) ); - entry->type = type; - entry->next = list; - return entry; -} - var_list_t *append_var(var_list_t *list, var_t *var) { if (!var) return list; @@ -3214,24 +3202,18 @@ static statement_t *make_statement_typedef(declarator_list_t *decls, int declonl { declarator_t *decl, *next; statement_t *stmt; - type_list_t **type_list; if (!decls) return NULL; stmt = make_statement(STMT_TYPEDEF); stmt->u.type_list = NULL; - type_list = &stmt->u.type_list; stmt->declonly = declonly; LIST_FOR_EACH_ENTRY_SAFE( decl, next, decls, declarator_t, entry ) { var_t *var = decl->var; type_t *type = find_type_or_error(current_namespace, var->name); - *type_list = xmalloc(sizeof(type_list_t)); - (*type_list)->type = type; - (*type_list)->next = NULL; - - type_list = &(*type_list)->next; + stmt->u.type_list = append_typeref(stmt->u.type_list, make_typeref(type)); free(decl); free(var); } diff --git a/tools/widl/typegen.c b/tools/widl/typegen.c index 1b5fe16b6ec..6ae55ac1934 100644 --- a/tools/widl/typegen.c +++ b/tools/widl/typegen.c @@ -3747,13 +3747,13 @@ static void process_tfs_iface(type_t *iface, FILE *file, int indent, unsigned in } case STMT_TYPEDEF: { - const type_list_t *type_entry; - for (type_entry = stmt->u.type_list; type_entry; type_entry = type_entry->next) + typeref_t *ref; + if (stmt->u.type_list) LIST_FOR_EACH_ENTRY(ref, stmt->u.type_list, typeref_t, entry) { - if (is_attr(type_entry->type->attrs, ATTR_ENCODE) - || is_attr(type_entry->type->attrs, ATTR_DECODE)) - type_entry->type->typestring_offset = write_type_tfs( file, - type_entry->type->attrs, type_entry->type, type_entry->type->name, + if (is_attr(ref->type->attrs, ATTR_ENCODE) + || is_attr(ref->type->attrs, ATTR_DECODE)) + ref->type->typestring_offset = write_type_tfs( file, + ref->type->attrs, ref->type, ref->type->name, TYPE_CONTEXT_CONTAINER, offset); } break; diff --git a/tools/widl/typetree.c b/tools/widl/typetree.c index bafd8d9879f..3071307b353 100644 --- a/tools/widl/typetree.c +++ b/tools/widl/typetree.c @@ -603,7 +603,7 @@ type_t *type_apicontract_define(type_t *apicontract, attr_list_t *attrs) return apicontract; } -type_t *type_parameterized_interface_declare(char *name, struct namespace *namespace, type_list_t *params) +type_t *type_parameterized_interface_declare(char *name, struct namespace *namespace, typeref_list_t *params) { type_t *type = get_type(TYPE_PARAMETERIZED_TYPE, name, namespace, 0); if (type_get_type_detect_alias(type) != TYPE_PARAMETERIZED_TYPE) diff --git a/tools/widl/typetree.h b/tools/widl/typetree.h index aa08c299c20..a2185ae35ea 100644 --- a/tools/widl/typetree.h +++ b/tools/widl/typetree.h @@ -62,7 +62,7 @@ type_t *type_coclass_define(type_t *coclass, attr_list_t *attrs, typeref_list_t type_t *type_runtimeclass_define(type_t *runtimeclass, attr_list_t *attrs, typeref_list_t *ifaces); type_t *type_apicontract_declare(char *name, struct namespace *namespace); type_t *type_apicontract_define(type_t *apicontract, attr_list_t *attrs); -type_t *type_parameterized_interface_declare(char *name, struct namespace *namespace, type_list_t *params); +type_t *type_parameterized_interface_declare(char *name, struct namespace *namespace, typeref_list_t *params); type_t *type_parameterized_interface_define(type_t *type, attr_list_t *attrs, type_t *inherit, statement_list_t *stmts, typeref_list_t *requires); int type_is_equal(const type_t *type1, const type_t *type2); const char *type_get_name(const type_t *type, enum name_type name_type); diff --git a/tools/widl/widltypes.h b/tools/widl/widltypes.h index e2b8608fabb..e2f77fbadec 100644 --- a/tools/widl/widltypes.h +++ b/tools/widl/widltypes.h @@ -51,7 +51,6 @@ typedef struct _typelib_t typelib_t; typedef struct _user_type_t user_type_t; typedef struct _user_type_t context_handle_t; typedef struct _user_type_t generic_handle_t; -typedef struct _type_list_t type_list_t; typedef struct _statement_t statement_t; typedef struct _warning_t warning_t; @@ -439,7 +438,7 @@ struct runtimeclass_details struct parameterized_details { type_t *type; - type_list_t *params; + typeref_list_t *params; }; #define HASHMAX 64 @@ -591,11 +590,6 @@ struct _user_type_t { const char *name; }; -struct _type_list_t { - type_t *type; - struct _type_list_t *next; -}; - struct _statement_t { struct list entry; enum statement_type type; @@ -605,7 +599,7 @@ struct _statement_t { const char *str; var_t *var; typelib_t *lib; - type_list_t *type_list; + typeref_list_t *type_list; } u; unsigned int declonly : 1; /* for STMT_TYPE and STMT_TYPEDEF */ }; diff --git a/tools/widl/write_msft.c b/tools/widl/write_msft.c index 49659123ddd..c39f38249c8 100644 --- a/tools/widl/write_msft.c +++ b/tools/widl/write_msft.c @@ -2479,14 +2479,14 @@ static void add_entry(msft_typelib_t *typelib, const statement_t *stmt) break; case STMT_TYPEDEF: { - const type_list_t *type_entry = stmt->u.type_list; - for (; type_entry; type_entry = type_entry->next) { + typeref_t *ref; + if (stmt->u.type_list) LIST_FOR_EACH_ENTRY(ref, stmt->u.type_list, typeref_t, entry) { /* if the type is public then add the typedef, otherwise attempt * to add the aliased type */ - if (is_attr(type_entry->type->attrs, ATTR_PUBLIC)) - add_typedef_typeinfo(typelib, type_entry->type); + if (is_attr(ref->type->attrs, ATTR_PUBLIC)) + add_typedef_typeinfo(typelib, ref->type); else - add_type_typeinfo(typelib, type_alias_get_aliasee_type(type_entry->type)); + add_type_typeinfo(typelib, type_alias_get_aliasee_type(ref->type)); } break; }