Rob Shearman : widl: Don' t store typelib kind information in the type structure.
Alexandre Julliard
julliard at winehq.org
Tue Jan 6 08:23:16 CST 2009
Module: wine
Branch: master
Commit: 1f519e17ccfde8773decbd2f8237bbd240800809
URL: http://source.winehq.org/git/wine.git/?a=commit;h=1f519e17ccfde8773decbd2f8237bbd240800809
Author: Rob Shearman <robertshearman at gmail.com>
Date: Mon Jan 5 23:34:23 2009 +0000
widl: Don't store typelib kind information in the type structure.
It can trivially be derived from the type field now.
---
tools/widl/parser.y | 23 +++++++++--------------
tools/widl/typetree.c | 17 ++++++++---------
tools/widl/typetree.h | 4 ++--
tools/widl/widltypes.h | 2 +-
tools/widl/write_msft.c | 34 ++++++++++++++++++++++++++--------
5 files changed, 46 insertions(+), 34 deletions(-)
diff --git a/tools/widl/parser.y b/tools/widl/parser.y
index bc252e8..2820f45 100644
--- a/tools/widl/parser.y
+++ b/tools/widl/parser.y
@@ -816,7 +816,7 @@ int_std: tINT { $$ = make_builtin($<str>1); }
coclass: tCOCLASS aIDENTIFIER { $$ = make_class($2); }
| tCOCLASS aKNOWNTYPE { $$ = find_type($2, 0);
- if ($$->kind != TKIND_COCLASS)
+ if ($$->type != RPC_FC_COCLASS)
error_loc("%s was not declared a coclass at %s:%d\n",
$2, $$->loc_info.input_name,
$$->loc_info.line_number);
@@ -844,8 +844,8 @@ coclass_int:
m_attributes interfacedec { $$ = make_ifref($2); $$->attrs = $1; }
;
-dispinterface: tDISPINTERFACE aIDENTIFIER { $$ = get_type(RPC_FC_IP, $2, 0); $$->kind = TKIND_DISPATCH; }
- | tDISPINTERFACE aKNOWNTYPE { $$ = get_type(RPC_FC_IP, $2, 0); $$->kind = TKIND_DISPATCH; }
+dispinterface: tDISPINTERFACE aIDENTIFIER { $$ = get_type(RPC_FC_IP, $2, 0); }
+ | tDISPINTERFACE aKNOWNTYPE { $$ = get_type(RPC_FC_IP, $2, 0); }
;
dispinterfacehdr: attributes dispinterface { attr_t *attrs;
@@ -882,8 +882,8 @@ inherit: { $$ = NULL; }
| ':' aKNOWNTYPE { $$ = find_type_or_error2($2, 0); }
;
-interface: tINTERFACE aIDENTIFIER { $$ = get_type(RPC_FC_IP, $2, 0); $$->kind = TKIND_INTERFACE; }
- | tINTERFACE aKNOWNTYPE { $$ = get_type(RPC_FC_IP, $2, 0); $$->kind = TKIND_INTERFACE; }
+interface: tINTERFACE aIDENTIFIER { $$ = get_type(RPC_FC_IP, $2, 0); }
+ | tINTERFACE aKNOWNTYPE { $$ = get_type(RPC_FC_IP, $2, 0); }
;
interfacehdr: attributes interface { $$.interface = $2;
@@ -1293,7 +1293,6 @@ type_t *make_type(unsigned char type, type_t *ref)
{
type_t *t = alloc_type();
t->name = NULL;
- t->kind = TKIND_PRIMITIVE;
t->type = type;
t->ref = ref;
t->attrs = NULL;
@@ -1310,6 +1309,7 @@ type_t *make_type(unsigned char type, type_t *ref)
t->user_types_registered = FALSE;
t->tfswrite = FALSE;
t->checked = FALSE;
+ t->is_alias = FALSE;
t->typelib_idx = -1;
init_loc_info(&t->loc_info);
return t;
@@ -1318,7 +1318,6 @@ type_t *make_type(unsigned char type, type_t *ref)
static type_t *type_new_enum(char *name, var_list_t *enums)
{
type_t *t = get_type(RPC_FC_ENUM16, name, tsENUM);
- t->kind = TKIND_ENUM;
if (enums)
{
t->details.enumeration = xmalloc(sizeof(*t->details.enumeration));
@@ -1335,7 +1334,6 @@ static type_t *type_new_struct(char *name, int defined, var_list_t *fields)
type_t *tag_type = name ? find_type(name, tsSTRUCT) : NULL;
type_t *t = make_type(RPC_FC_STRUCT, NULL);
t->name = name;
- t->kind = TKIND_RECORD;
if (defined || (tag_type && tag_type->details.structure))
{
if (tag_type && tag_type->details.structure)
@@ -1363,7 +1361,6 @@ static type_t *type_new_struct(char *name, int defined, var_list_t *fields)
static type_t *type_new_nonencapsulated_union(char *name, var_list_t *fields)
{
type_t *t = get_type(RPC_FC_NON_ENCAPSULATED_UNION, name, tsUNION);
- t->kind = TKIND_UNION;
t->details.structure = xmalloc(sizeof(*t->details.structure));
t->details.structure->fields = fields;
t->defined = TRUE;
@@ -1373,10 +1370,8 @@ static type_t *type_new_nonencapsulated_union(char *name, var_list_t *fields)
static type_t *type_new_encapsulated_union(char *name, var_t *switch_field, var_t *union_field, var_list_t *cases)
{
type_t *t = get_type(RPC_FC_ENCAPSULATED_UNION, name, tsUNION);
- t->kind = TKIND_UNION;
if (!union_field) union_field = make_var( xstrdup("tagged_union") );
union_field->type = make_type(RPC_FC_NON_ENCAPSULATED_UNION, NULL);
- union_field->type->kind = TKIND_UNION;
union_field->type->details.structure = xmalloc(sizeof(*union_field->type->details.structure));
union_field->type->details.structure->fields = cases;
union_field->type->defined = TRUE;
@@ -1706,7 +1701,6 @@ static type_t *make_class(char *name)
{
type_t *c = make_type(RPC_FC_COCLASS, NULL);
c->name = name;
- c->kind = TKIND_COCLASS;
return c;
}
@@ -1850,8 +1844,9 @@ static type_t *reg_typedefs(decl_spec_t *decl_spec, declarator_list_t *decls, at
/* We must generate names for tagless enum, struct or union.
Typedef-ing a tagless enum, struct or union means we want the typedef
to be included in a library hence the public attribute. */
- if ((type->kind == TKIND_ENUM || type->kind == TKIND_RECORD
- || type->kind == TKIND_UNION) && ! type->name && ! parse_only)
+ if ((type->type == RPC_FC_ENUM16 || type->type == RPC_FC_ENUM32 ||
+ is_struct(type->type) || is_union(type->type)) &&
+ !type->name && !parse_only)
{
if (! is_attr(attrs, ATTR_PUBLIC))
attrs = append_attr( attrs, make_attr(ATTR_PUBLIC) );
diff --git a/tools/widl/typetree.c b/tools/widl/typetree.c
index 47ad1f5..54859be 100644
--- a/tools/widl/typetree.c
+++ b/tools/widl/typetree.c
@@ -58,23 +58,22 @@ type_t *type_new_pointer(type_t *ref, attr_list_t *attrs)
type_t *type_new_alias(type_t *t, const char *name)
{
- type_t *a = duptype(t, 0);
+ type_t *a = duptype(t, 0);
- a->name = xstrdup(name);
- a->kind = TKIND_ALIAS;
- a->attrs = NULL;
- a->declarray = FALSE;
- a->orig = t;
- init_loc_info(&a->loc_info);
+ a->name = xstrdup(name);
+ a->attrs = NULL;
+ a->declarray = FALSE;
+ a->orig = t;
+ a->is_alias = TRUE;
+ init_loc_info(&a->loc_info);
- return a;
+ return a;
}
type_t *type_new_module(char *name)
{
type_t *type = make_type(RPC_FC_MODULE, NULL);
type->name = name;
- type->kind = TKIND_MODULE;
/* FIXME: register type to detect multiple definitions */
return type;
}
diff --git a/tools/widl/typetree.h b/tools/widl/typetree.h
index a0f819a..0fcfb3a 100644
--- a/tools/widl/typetree.h
+++ b/tools/widl/typetree.h
@@ -142,7 +142,7 @@ static inline expr_t *type_array_get_variance(const type_t *type)
static inline type_t *type_get_real_type(const type_t *type)
{
- if (type->kind == TKIND_ALIAS)
+ if (type->is_alias)
return type_get_real_type(type->orig);
else
return (type_t *)type;
@@ -150,7 +150,7 @@ static inline type_t *type_get_real_type(const type_t *type)
static inline int type_is_alias(const type_t *type)
{
- return (type->kind == TKIND_ALIAS);
+ return type->is_alias;
}
#endif /* WIDL_TYPE_TREE_H */
diff --git a/tools/widl/widltypes.h b/tools/widl/widltypes.h
index 7a55ee7..6835e62 100644
--- a/tools/widl/widltypes.h
+++ b/tools/widl/widltypes.h
@@ -298,7 +298,6 @@ struct array_details
struct _type_t {
const char *name;
- enum type_kind kind;
unsigned char type;
struct _type_t *ref;
attr_list_t *attrs;
@@ -324,6 +323,7 @@ struct _type_t {
unsigned int user_types_registered : 1;
unsigned int tfswrite : 1; /* if the type needs to be written to the TFS */
unsigned int checked : 1;
+ unsigned int is_alias : 1; /* is the type an alias? */
int sign : 2;
};
diff --git a/tools/widl/write_msft.c b/tools/widl/write_msft.c
index 85dcb0d..d7bbd60 100644
--- a/tools/widl/write_msft.c
+++ b/tools/widl/write_msft.c
@@ -2197,24 +2197,42 @@ static void add_module_typeinfo(msft_typelib_t *typelib, type_t *module)
static void add_type_typeinfo(msft_typelib_t *typelib, type_t *type)
{
- switch (type->kind) {
- case TKIND_INTERFACE:
- case TKIND_DISPATCH:
+ switch (type->type) {
+ case RPC_FC_IP:
add_interface_typeinfo(typelib, type);
break;
- case TKIND_RECORD:
+ case RPC_FC_STRUCT:
add_structure_typeinfo(typelib, type);
break;
- case TKIND_ENUM:
+ case RPC_FC_ENUM16:
+ case RPC_FC_ENUM32:
add_enum_typeinfo(typelib, type);
break;
- case TKIND_COCLASS:
+ case RPC_FC_COCLASS:
add_coclass_typeinfo(typelib, type);
break;
- case TKIND_PRIMITIVE:
+ case RPC_FC_BYTE:
+ case RPC_FC_CHAR:
+ case RPC_FC_USMALL:
+ case RPC_FC_SMALL:
+ case RPC_FC_WCHAR:
+ case RPC_FC_USHORT:
+ case RPC_FC_SHORT:
+ case RPC_FC_ULONG:
+ case RPC_FC_LONG:
+ case RPC_FC_HYPER:
+ case RPC_FC_IGNORE:
+ case RPC_FC_FLOAT:
+ case RPC_FC_DOUBLE:
+ case RPC_FC_ERROR_STATUS_T:
+ case RPC_FC_BIND_PRIMITIVE:
+ case RPC_FC_RP:
+ case RPC_FC_UP:
+ case RPC_FC_OP:
+ case RPC_FC_FP:
break;
default:
- error("add_entry: unhandled type %d for %s\n", type->kind, type->name);
+ error("add_entry: unhandled type 0x%x for %s\n", type->type, type->name);
break;
}
}
More information about the wine-cvs
mailing list