widl: Factor the entry_t structure.

This commit is contained in:
Dan Hipschman 2006-08-29 14:26:43 -07:00 committed by Alexandre Julliard
parent c117a20cdb
commit aadc90b266
5 changed files with 23 additions and 103 deletions

View File

@ -253,24 +253,24 @@ gbl_statements: { $$ = NULL; }
if (!parse_only && do_header) write_coclass_forward($2); if (!parse_only && do_header) write_coclass_forward($2);
} }
| gbl_statements coclassdef { $$ = $1; | gbl_statements coclassdef { $$ = $1;
add_coclass($2); add_typelib_entry($2);
reg_type($2, $2->name, 0); reg_type($2, $2->name, 0);
if (!parse_only && do_header) write_coclass_forward($2); 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 librarydef { $$ = $1; }
| gbl_statements statement { $$ = $1; } | gbl_statements statement { $$ = $1; }
; ;
imp_statements: {} imp_statements: {}
| imp_statements interfacedec { if (!parse_only) add_interface($2); } | imp_statements interfacedec { if (!parse_only) add_typelib_entry($2); }
| imp_statements interfacedef { if (!parse_only) add_interface($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 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); reg_type($2, $2->name, 0);
if (!parse_only && do_header) write_coclass_forward($2); 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 statement {}
| imp_statements importlib {} | imp_statements importlib {}
; ;
@ -501,7 +501,7 @@ enumdef: tENUM t_ident '{' enums '}' { $$ = get_typev(RPC_FC_ENUM16, $2, tsENUM
$$->fields = $4; $$->fields = $4;
$$->defined = TRUE; $$->defined = TRUE;
if(in_typelib) 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; $$->fields = $4;
$$->defined = TRUE; $$->defined = TRUE;
if(in_typelib) if(in_typelib)
add_struct($$); add_typelib_entry($$);
} }
; ;
@ -1672,7 +1672,7 @@ static void process_typedefs(var_t *names)
if (! parse_only && do_header) if (! parse_only && do_header)
write_typedef(type); write_typedef(type);
if (in_typelib && type->attrs) if (in_typelib && type->attrs)
add_typedef(type); add_typelib_entry(type);
free(names); free(names);
names = next; names = next;

View File

@ -234,82 +234,14 @@ void end_typelib(void)
return; return;
} }
void add_interface(type_t *iface) void add_typelib_entry(type_t *t)
{ {
typelib_entry_t *entry; typelib_entry_t *entry;
if (!typelib) return; 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 = xmalloc(sizeof(*entry));
entry->kind = TKIND_INTERFACE; entry->type = t;
entry->u.interface = iface;
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); LINK(entry, typelib->entry);
typelib->entry = entry; typelib->entry = entry;
} }

View File

@ -24,12 +24,7 @@
extern int in_typelib; extern int in_typelib;
extern void start_typelib(char *name, attr_t *attrs); extern void start_typelib(char *name, attr_t *attrs);
extern void end_typelib(void); extern void end_typelib(void);
extern void add_interface(type_t *iface); extern void add_typelib_entry(type_t *t);
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_importlib(const char *name); extern void add_importlib(const char *name);
/* Copied from wtypes.h. Not included directly because that would create a /* Copied from wtypes.h. Not included directly because that would create a

View File

@ -253,15 +253,7 @@ struct _ifref_t {
}; };
struct _typelib_entry_t { struct _typelib_entry_t {
enum type_kind kind; type_t *type;
union {
type_t *class;
type_t *interface;
type_t *module;
type_t *structure;
type_t *enumeration;
type_t *tdef;
} u;
DECL_LINK(typelib_entry_t); DECL_LINK(typelib_entry_t);
}; };

View File

@ -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) static void add_entry(msft_typelib_t *typelib, typelib_entry_t *entry)
{ {
switch(entry->kind) { switch(entry->type->kind) {
case TKIND_INTERFACE: case TKIND_INTERFACE:
add_interface_typeinfo(typelib, entry->u.interface); case TKIND_DISPATCH:
add_interface_typeinfo(typelib, entry->type);
break; break;
case TKIND_RECORD: case TKIND_RECORD:
add_structure_typeinfo(typelib, entry->u.structure); add_structure_typeinfo(typelib, entry->type);
break; break;
case TKIND_ENUM: case TKIND_ENUM:
add_enum_typeinfo(typelib, entry->u.enumeration); add_enum_typeinfo(typelib, entry->type);
break; break;
case TKIND_ALIAS: case TKIND_ALIAS:
add_typedef_typeinfo(typelib, entry->u.tdef); add_typedef_typeinfo(typelib, entry->type);
break; break;
case TKIND_COCLASS: case TKIND_COCLASS:
add_coclass_typeinfo(typelib, entry->u.class); add_coclass_typeinfo(typelib, entry->type);
break; break;
case TKIND_MODULE: case TKIND_MODULE:
add_module_typeinfo(typelib, entry->u.module); add_module_typeinfo(typelib, entry->type);
break; break;
default: default:
error("add_entry: unhandled type %d\n", entry->kind); error("add_entry: unhandled type %d\n", entry->type->kind);
break; break;
} }
} }