[PATCH 2/2] widl: Support namespaces for union declarations.

Rémi Bernon wine at gitlab.winehq.org
Tue Jul 5 08:06:48 CDT 2022


From: Rémi Bernon <rbernon at codeweavers.com>

Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---
 tools/widl/parser.y   | 6 +++---
 tools/widl/typetree.c | 9 +++++----
 tools/widl/typetree.h | 2 +-
 3 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/tools/widl/parser.y b/tools/widl/parser.y
index 02db99a55b7..4000f37032c 100644
--- a/tools/widl/parser.y
+++ b/tools/widl/parser.y
@@ -477,7 +477,7 @@ typedecl:
 	| structdef
 	| tSTRUCT aIDENTIFIER                   { $$ = type_new_struct($2, current_namespace, FALSE, NULL); }
 	| uniondef
-	| tUNION aIDENTIFIER                    { $$ = type_new_nonencapsulated_union($2, FALSE, NULL); }
+	| tUNION aIDENTIFIER                    { $$ = type_new_nonencapsulated_union($2, current_namespace, FALSE, NULL); }
 	| attributes enumdef                    { $$ = $2; $$->attrs = check_enum_attrs($1); }
 	| attributes structdef                  { $$ = $2; $$->attrs = check_struct_attrs($1); }
 	| attributes uniondef                   { $$ = $2; $$->attrs = check_union_attrs($1); }
@@ -1277,7 +1277,7 @@ unqualified_type:
 	| structdef				{ $$ = $1; }
 	| tSTRUCT aIDENTIFIER			{ $$ = type_new_struct($2, current_namespace, FALSE, NULL); }
 	| uniondef				{ $$ = $1; }
-	| tUNION aIDENTIFIER			{ $$ = type_new_nonencapsulated_union($2, FALSE, NULL); }
+	| tUNION aIDENTIFIER			{ $$ = type_new_nonencapsulated_union($2, current_namespace, FALSE, NULL); }
 	| tSAFEARRAY '(' type ')'		{ $$ = make_safearray($3); }
 	| aKNOWNTYPE				{ $$ = find_type_or_error(current_namespace, $1); }
 	;
@@ -1296,7 +1296,7 @@ typedef: m_attributes tTYPEDEF m_attributes decl_spec declarator_list
 	;
 
 uniondef: tUNION m_typename '{' ne_union_fields '}'
-						{ $$ = type_new_nonencapsulated_union($2, TRUE, $4); }
+						{ $$ = type_new_nonencapsulated_union($2, current_namespace, TRUE, $4); }
 	| tUNION m_typename
 	  tSWITCH '(' s_field ')'
 	  m_ident '{' cases '}'			{ $$ = type_new_encapsulated_union($2, $5, $7, $9); }
diff --git a/tools/widl/typetree.c b/tools/widl/typetree.c
index 3ad140d520c..fef9d2e5c03 100644
--- a/tools/widl/typetree.c
+++ b/tools/widl/typetree.c
@@ -580,19 +580,20 @@ type_t *type_new_struct(char *name, struct namespace *namespace, int defined, va
     return t;
 }
 
-type_t *type_new_nonencapsulated_union(const char *name, int defined, var_list_t *fields)
+type_t *type_new_nonencapsulated_union(const char *name, struct namespace *namespace, int defined, var_list_t *fields)
 {
     type_t *t = NULL;
 
     if (name)
-        t = find_type(name, NULL, tsUNION);
+        t = find_type(name, namespace, tsUNION);
 
     if (!t)
     {
         t = make_type(TYPE_UNION);
         t->name = name;
+        t->namespace = namespace;
         if (name)
-            reg_type(t, name, NULL, tsUNION);
+            reg_type(t, name, namespace, tsUNION);
     }
 
     if (!t->defined && defined)
@@ -627,7 +628,7 @@ type_t *type_new_encapsulated_union(char *name, var_t *switch_field, var_t *unio
     {
         if (!union_field)
             union_field = make_var(xstrdup("tagged_union"));
-        union_field->declspec.type = type_new_nonencapsulated_union(gen_name(), TRUE, cases);
+        union_field->declspec.type = type_new_nonencapsulated_union(gen_name(), NULL, TRUE, cases);
 
         t->details.structure = xmalloc(sizeof(*t->details.structure));
         t->details.structure->fields = append_var(NULL, switch_field);
diff --git a/tools/widl/typetree.h b/tools/widl/typetree.h
index 8f5e1ebdac5..be2288db021 100644
--- a/tools/widl/typetree.h
+++ b/tools/widl/typetree.h
@@ -53,7 +53,7 @@ type_t *type_new_void(void);
 type_t *type_coclass_declare(char *name);
 type_t *type_new_enum(const char *name, struct namespace *namespace, int defined, var_list_t *enums);
 type_t *type_new_struct(char *name, struct namespace *namespace, int defined, var_list_t *fields);
-type_t *type_new_nonencapsulated_union(const char *name, int defined, var_list_t *fields);
+type_t *type_new_nonencapsulated_union(const char *name, struct namespace *namespace, int defined, var_list_t *fields);
 type_t *type_new_encapsulated_union(char *name, var_t *switch_field, var_t *union_field, var_list_t *cases);
 type_t *type_new_bitfield(type_t *field_type, const expr_t *bits);
 type_t *type_runtimeclass_declare(char *name, struct namespace *namespace);
-- 
GitLab

https://gitlab.winehq.org/wine/wine/-/merge_requests/382



More information about the wine-devel mailing list