Signed-off-by: Zebediah Figura z.figura12@gmail.com --- tools/widl/parser.y | 3 +-- tools/widl/typetree.c | 2 +- tools/widl/typetree.h | 1 + 3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/widl/parser.y b/tools/widl/parser.y index 072e138ecf..8496109299 100644 --- a/tools/widl/parser.y +++ b/tools/widl/parser.y @@ -82,7 +82,6 @@ static var_t *reg_const(var_t *var); static void push_namespace(const char *name); static void pop_namespace(const char *name);
-static char *gen_name(void); static void check_arg_attrs(const var_t *arg); static void check_statements(const statement_list_t *stmts, int is_inside_library); static void check_all_user_types(const statement_list_t *stmts); @@ -2033,7 +2032,7 @@ var_t *find_const(const char *name, int f) return cur->var; }
-static char *gen_name(void) +char *gen_name(void) { static const char format[] = "__WIDL_%s_generated_name_%08lX"; static unsigned long n = 0; diff --git a/tools/widl/typetree.c b/tools/widl/typetree.c index 524d00571f..e9afc6fdd2 100644 --- a/tools/widl/typetree.c +++ b/tools/widl/typetree.c @@ -366,7 +366,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(NULL, TRUE, cases); + union_field->declspec.type = type_new_nonencapsulated_union(gen_name(), 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 f025f25e59..e288c57400 100644 --- a/tools/widl/typetree.h +++ b/tools/widl/typetree.h @@ -51,6 +51,7 @@ void type_module_define(type_t *module, statement_list_t *stmts); type_t *type_coclass_define(type_t *coclass, ifref_list_t *ifaces); int type_is_equal(const type_t *type1, const type_t *type2); const char *type_get_name(const type_t *type, enum name_type name_type); +char *gen_name(void);
/* FIXME: shouldn't need to export this */ type_t *duptype(type_t *t, int dupname);
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- tools/widl/write_msft.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/tools/widl/write_msft.c b/tools/widl/write_msft.c index 420404af6d..5d5fd891d4 100644 --- a/tools/widl/write_msft.c +++ b/tools/widl/write_msft.c @@ -976,6 +976,7 @@ static int encode_type( switch (type_get_type(type)) { case TYPE_STRUCT: + case TYPE_ENCAPSULATED_UNION: add_structure_typeinfo(typelib, type); break; case TYPE_INTERFACE: @@ -2119,6 +2120,7 @@ static void add_interface_typeinfo(msft_typelib_t *typelib, type_t *interface)
static void add_structure_typeinfo(msft_typelib_t *typelib, type_t *structure) { + var_list_t *fields; int idx = 0; var_t *cur; msft_typeinfo_t *msft_typeinfo; @@ -2130,9 +2132,16 @@ static void add_structure_typeinfo(msft_typelib_t *typelib, type_t *structure) msft_typeinfo = create_msft_typeinfo(typelib, TKIND_RECORD, structure->name, structure->attrs); msft_typeinfo->typeinfo->size = 0;
- if (type_struct_get_fields(structure)) - LIST_FOR_EACH_ENTRY( cur, type_struct_get_fields(structure), var_t, entry ) + if (type_get_type(structure) == TYPE_STRUCT) + fields = type_struct_get_fields(structure); + else + fields = type_encapsulated_union_get_fields(structure); + + if (fields) + { + LIST_FOR_EACH_ENTRY( cur, fields, var_t, entry ) add_var_desc(msft_typeinfo, idx++, cur); + } }
static void add_enum_typeinfo(msft_typelib_t *typelib, type_t *enumeration) @@ -2320,6 +2329,7 @@ static void add_type_typeinfo(msft_typelib_t *typelib, type_t *type) add_interface_typeinfo(typelib, type); break; case TYPE_STRUCT: + case TYPE_ENCAPSULATED_UNION: add_structure_typeinfo(typelib, type); break; case TYPE_ENUM:
I.e. write "apple_t" into the typelib given the following snippet:
typedef [public] struct { ... } apple_t; library { interface IFoo { HRESULT a(apple_t arg); } }
Based on a patch by Richard Pospesel.
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- tools/widl/write_msft.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/tools/widl/write_msft.c b/tools/widl/write_msft.c index 5d5fd891d4..e972a26b59 100644 --- a/tools/widl/write_msft.c +++ b/tools/widl/write_msft.c @@ -763,6 +763,7 @@ static void add_enum_typeinfo(msft_typelib_t *typelib, type_t *enumeration); static void add_union_typeinfo(msft_typelib_t *typelib, type_t *tunion); static void add_coclass_typeinfo(msft_typelib_t *typelib, type_t *cls); static void add_dispinterface_typeinfo(msft_typelib_t *typelib, type_t *dispinterface); +static void add_typedef_typeinfo(msft_typelib_t *typelib, type_t *dispinterface);
/**************************************************************************** @@ -973,7 +974,7 @@ static int encode_type( chat("encode_type: VT_USERDEFINED - adding new type %s, real type %d\n", type->name, type_get_type(type));
- switch (type_get_type(type)) + switch (type_get_type_detect_alias(type)) { case TYPE_STRUCT: case TYPE_ENCAPSULATED_UNION: @@ -991,6 +992,9 @@ static int encode_type( case TYPE_COCLASS: add_coclass_typeinfo(typelib, type); break; + case TYPE_ALIAS: + add_typedef_typeinfo(typelib, type); + break; default: error("encode_type: VT_USERDEFINED - unhandled type %d\n", type_get_type(type));
From: Richard Pospesel richard@torproject.org
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47050
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- Changes from https://source.winehq.org/patches/data/167613: * remove not particularly necessary comment * don't bother checking do_typelib, because ATTR_PUBLIC only matters for typelibs anyway
tools/widl/parser.y | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/tools/widl/parser.y b/tools/widl/parser.y index 8496109299..59875a5b16 100644 --- a/tools/widl/parser.y +++ b/tools/widl/parser.y @@ -1895,7 +1895,11 @@ static type_t *reg_typedefs(decl_spec_t *decl_spec, declarator_list_t *decls, at type_get_type_detect_alias(type) == TYPE_ENCAPSULATED_UNION) { if (!type->name) + { type->name = gen_name(); + if (!is_attr(attrs, ATTR_PUBLIC)) + attrs = append_attr(attrs, make_attr(ATTR_PUBLIC)); + }
/* replace existing attributes when generating a typelib */ if (do_typelib)
From: Richard Pospesel richard@torproject.org
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47041 Signed-off-by: Zebediah Figura z.figura12@gmail.com --- tools/widl/typelib.c | 3 ++- tools/widl/write_msft.c | 19 ++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/tools/widl/typelib.c b/tools/widl/typelib.c index 4f6b4fc38a..79e72e0472 100644 --- a/tools/widl/typelib.c +++ b/tools/widl/typelib.c @@ -129,7 +129,8 @@ unsigned short get_type_vt(type_t *t) if (vt) return vt; }
- if (type_is_alias(t) && is_attr(t->attrs, ATTR_PUBLIC)) + if (type_is_alias(t) && + (is_attr(t->attrs, ATTR_PUBLIC) || is_attr(t->attrs, ATTR_WIREMARSHAL))) return VT_USERDEFINED;
switch (type_get_type(t)) { diff --git a/tools/widl/write_msft.c b/tools/widl/write_msft.c index e972a26b59..0e6ef087e5 100644 --- a/tools/widl/write_msft.c +++ b/tools/widl/write_msft.c @@ -967,9 +967,22 @@ static int encode_type( } else { - /* typedef'd types without public attribute aren't included in the typelib */ - while (type_is_alias(type) && !is_attr(type->attrs, ATTR_PUBLIC)) - type = type_alias_get_aliasee_type(type); + /* Typedefs without the [public] attribute aren't included in the + * typelib, unless the aliasee is an anonymous UDT or the typedef + * is wire-marshalled. In the latter case the wire-marshal type, + * which may be a non-public alias, is used instead. */ + while (type_is_alias(type)) + { + if (is_attr(type->attrs, ATTR_WIREMARSHAL)) + { + type = get_attrp(type->attrs, ATTR_WIREMARSHAL); + break; + } + else if (!is_attr(type->attrs, ATTR_PUBLIC)) + type = type_alias_get_aliasee_type(type); + else + break; + }
chat("encode_type: VT_USERDEFINED - adding new type %s, real type %d\n", type->name, type_get_type(type));