widl: Factor the entry_t structure.
This commit is contained in:
parent
c117a20cdb
commit
aadc90b266
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue