diff --git a/tools/widl/parser.y b/tools/widl/parser.y index 352837e028b..08937d244df 100644 --- a/tools/widl/parser.y +++ b/tools/widl/parser.y @@ -253,24 +253,24 @@ gbl_statements: { $$ = NULL; } if (!parse_only && do_header) write_coclass_forward($2); } | gbl_statements coclassdef { $$ = $1; - add_coclass($2); + add_typelib_entry($2); reg_type($2, $2->name, 0); if (!parse_only && do_header) write_coclass_forward($2); } - | gbl_statements moduledef { $$ = $1; add_module($2); } + | gbl_statements moduledef { $$ = $1; add_typelib_entry($2); } | gbl_statements librarydef { $$ = $1; } | gbl_statements statement { $$ = $1; } ; imp_statements: {} - | imp_statements interfacedec { if (!parse_only) add_interface($2); } - | imp_statements interfacedef { if (!parse_only) add_interface($2); } + | imp_statements interfacedec { if (!parse_only) add_typelib_entry($2); } + | imp_statements interfacedef { if (!parse_only) add_typelib_entry($2); } | imp_statements coclass ';' { reg_type($2, $2->name, 0); if (!parse_only && do_header) write_coclass_forward($2); } - | imp_statements coclassdef { if (!parse_only) add_coclass($2); + | imp_statements coclassdef { if (!parse_only) add_typelib_entry($2); reg_type($2, $2->name, 0); if (!parse_only && do_header) write_coclass_forward($2); } - | imp_statements moduledef { if (!parse_only) add_module($2); } + | imp_statements moduledef { if (!parse_only) add_typelib_entry($2); } | imp_statements statement {} | imp_statements importlib {} ; @@ -501,7 +501,7 @@ enumdef: tENUM t_ident '{' enums '}' { $$ = get_typev(RPC_FC_ENUM16, $2, tsENUM $$->fields = $4; $$->defined = TRUE; if(in_typelib) - add_enum($$); + add_typelib_entry($$); } ; @@ -808,7 +808,7 @@ structdef: tSTRUCT t_ident '{' fields '}' { $$ = get_typev(RPC_FC_STRUCT, $2, ts $$->fields = $4; $$->defined = TRUE; if(in_typelib) - add_struct($$); + add_typelib_entry($$); } ; @@ -1672,7 +1672,7 @@ static void process_typedefs(var_t *names) if (! parse_only && do_header) write_typedef(type); if (in_typelib && type->attrs) - add_typedef(type); + add_typelib_entry(type); free(names); names = next; diff --git a/tools/widl/typelib.c b/tools/widl/typelib.c index 3717f8ad404..b91ca28eb4a 100644 --- a/tools/widl/typelib.c +++ b/tools/widl/typelib.c @@ -234,86 +234,18 @@ void end_typelib(void) return; } -void add_interface(type_t *iface) +void add_typelib_entry(type_t *t) { typelib_entry_t *entry; if (!typelib) return; - chat("add interface: %s\n", iface->name); + chat("add kind %i: %s\n", t->kind, t->name); entry = xmalloc(sizeof(*entry)); - entry->kind = TKIND_INTERFACE; - entry->u.interface = iface; + entry->type = t; LINK(entry, typelib->entry); typelib->entry = entry; } -void add_coclass(type_t *cls) -{ - typelib_entry_t *entry; - - if (!typelib) return; - - chat("add coclass: %s\n", cls->name); - - entry = xmalloc(sizeof(*entry)); - entry->kind = TKIND_COCLASS; - entry->u.class = cls; - LINK(entry, typelib->entry); - typelib->entry = entry; -} - -void add_module(type_t *module) -{ - typelib_entry_t *entry; - if (!typelib) return; - - chat("add module: %s\n", module->name); - entry = xmalloc(sizeof(*entry)); - entry->kind = TKIND_MODULE; - entry->u.module = module; - LINK(entry, typelib->entry); - typelib->entry = entry; -} - -void add_struct(type_t *structure) -{ - typelib_entry_t *entry; - if (!typelib) return; - - chat("add struct: %s\n", structure->name); - entry = xmalloc(sizeof(*entry)); - entry->kind = TKIND_RECORD; - entry->u.structure = structure; - LINK(entry, typelib->entry); - typelib->entry = entry; -} - -void add_enum(type_t *enumeration) -{ - typelib_entry_t *entry; - if (!typelib) return; - - chat("add enum: %s\n", enumeration->name); - entry = xmalloc(sizeof(*entry)); - entry->kind = TKIND_ENUM; - entry->u.enumeration = enumeration; - LINK(entry, typelib->entry); - typelib->entry = entry; -} - -void add_typedef(type_t *tdef) -{ - typelib_entry_t *entry; - if (!typelib) return; - - chat("add typedef: %s\n", tdef->name); - entry = xmalloc(sizeof(*entry)); - entry->kind = TKIND_ALIAS; - entry->u.tdef = tdef; - LINK(entry, typelib->entry); - typelib->entry = entry; -} - static void tlb_read(int fd, void *buf, size_t count) { if(read(fd, buf, count) < count) diff --git a/tools/widl/typelib.h b/tools/widl/typelib.h index 688f61155a0..78825ad48d8 100644 --- a/tools/widl/typelib.h +++ b/tools/widl/typelib.h @@ -24,12 +24,7 @@ extern int in_typelib; extern void start_typelib(char *name, attr_t *attrs); extern void end_typelib(void); -extern void add_interface(type_t *iface); -extern void add_coclass(type_t *cls); -extern void add_module(type_t *module); -extern void add_struct(type_t *structure); -extern void add_enum(type_t *enumeration); -extern void add_typedef(type_t *tdef); +extern void add_typelib_entry(type_t *t); extern void add_importlib(const char *name); /* Copied from wtypes.h. Not included directly because that would create a diff --git a/tools/widl/widltypes.h b/tools/widl/widltypes.h index e75db75a826..1c919ce126f 100644 --- a/tools/widl/widltypes.h +++ b/tools/widl/widltypes.h @@ -253,15 +253,7 @@ struct _ifref_t { }; struct _typelib_entry_t { - enum type_kind kind; - union { - type_t *class; - type_t *interface; - type_t *module; - type_t *structure; - type_t *enumeration; - type_t *tdef; - } u; + type_t *type; DECL_LINK(typelib_entry_t); }; diff --git a/tools/widl/write_msft.c b/tools/widl/write_msft.c index 6530483f06b..05302148b38 100644 --- a/tools/widl/write_msft.c +++ b/tools/widl/write_msft.c @@ -2180,33 +2180,34 @@ static void add_module_typeinfo(msft_typelib_t *typelib, type_t *module) static void add_entry(msft_typelib_t *typelib, typelib_entry_t *entry) { - switch(entry->kind) { + switch(entry->type->kind) { case TKIND_INTERFACE: - add_interface_typeinfo(typelib, entry->u.interface); + case TKIND_DISPATCH: + add_interface_typeinfo(typelib, entry->type); break; case TKIND_RECORD: - add_structure_typeinfo(typelib, entry->u.structure); + add_structure_typeinfo(typelib, entry->type); break; case TKIND_ENUM: - add_enum_typeinfo(typelib, entry->u.enumeration); + add_enum_typeinfo(typelib, entry->type); break; case TKIND_ALIAS: - add_typedef_typeinfo(typelib, entry->u.tdef); + add_typedef_typeinfo(typelib, entry->type); break; case TKIND_COCLASS: - add_coclass_typeinfo(typelib, entry->u.class); + add_coclass_typeinfo(typelib, entry->type); break; case TKIND_MODULE: - add_module_typeinfo(typelib, entry->u.module); + add_module_typeinfo(typelib, entry->type); break; default: - error("add_entry: unhandled type %d\n", entry->kind); + error("add_entry: unhandled type %d\n", entry->type->kind); break; } }