widl: Create exactly one type_t object per named enum type.

Based on a patch by Richard Pospesel.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47035
Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2019-08-19 21:17:39 -05:00 committed by Alexandre Julliard
parent 833639bd09
commit 0aa6049c8d
1 changed files with 14 additions and 12 deletions

View File

@ -265,25 +265,27 @@ type_t *type_new_void(void)
type_t *type_new_enum(const char *name, struct namespace *namespace, int defined, var_list_t *enums) type_t *type_new_enum(const char *name, struct namespace *namespace, int defined, var_list_t *enums)
{ {
type_t *tag_type = name ? find_type(name, namespace, tsENUM) : NULL; type_t *t = NULL;
type_t *t = make_type(TYPE_ENUM);
if (name)
t = find_type(name, namespace,tsENUM);
if (!t)
{
t = make_type(TYPE_ENUM);
t->name = name; t->name = name;
t->namespace = namespace; t->namespace = namespace;
if (name)
reg_type(t, name, namespace, tsENUM);
}
if (tag_type && tag_type->details.enumeration) if (!t->defined && defined)
t->details.enumeration = tag_type->details.enumeration;
else if (defined)
{ {
t->details.enumeration = xmalloc(sizeof(*t->details.enumeration)); t->details.enumeration = xmalloc(sizeof(*t->details.enumeration));
t->details.enumeration->enums = enums; t->details.enumeration->enums = enums;
t->defined = TRUE; t->defined = TRUE;
} }
if (name)
{
if (defined)
reg_type(t, name, namespace, tsENUM);
}
return t; return t;
} }