From 56995dd3223c59340037d33a6073a42bdbba1d3f Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Tue, 28 Jan 2020 10:10:27 -0600 Subject: [PATCH] widl: Output a registry script for all interfaces written into the typelib. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=46005 Signed-off-by: Zebediah Figura Signed-off-by: Alexandre Julliard --- tools/widl/parser.y | 1 + tools/widl/register.c | 11 +++-------- tools/widl/widltypes.h | 3 +++ tools/widl/write_msft.c | 11 +++++++++++ 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/tools/widl/parser.y b/tools/widl/parser.y index 5f6eb508780..92b4f8ebd5a 100644 --- a/tools/widl/parser.y +++ b/tools/widl/parser.y @@ -1792,6 +1792,7 @@ static type_t *make_safearray(type_t *type) static typelib_t *make_library(const char *name, const attr_list_t *attrs) { typelib_t *typelib = xmalloc(sizeof(*typelib)); + memset(typelib, 0, sizeof(*typelib)); typelib->name = xstrdup(name); typelib->attrs = attrs; list_init( &typelib->importlibs ); diff --git a/tools/widl/register.c b/tools/widl/register.c index f65cbddf531..c03ab3c56b1 100644 --- a/tools/widl/register.c +++ b/tools/widl/register.c @@ -119,8 +119,6 @@ static void write_typelib_interface( const type_t *iface, const typelib_t *typel if (!uuid) return; if (!is_object( iface )) return; - if (!is_attr( iface->attrs, ATTR_OLEAUTOMATION ) && !is_attr( iface->attrs, ATTR_DISPINTERFACE )) - return; put_str( indent, "'%s' = s '%s'\n", format_uuid( uuid ), iface->name ); put_str( indent, "{\n" ); indent++; @@ -137,13 +135,10 @@ static void write_typelib_interface( const type_t *iface, const typelib_t *typel static void write_typelib_interfaces( const typelib_t *typelib ) { - const statement_t *stmt; + unsigned int i; - if (typelib->stmts) LIST_FOR_EACH_ENTRY( stmt, typelib->stmts, const statement_t, entry ) - { - if (stmt->type == STMT_TYPE && type_get_type( stmt->u.type ) == TYPE_INTERFACE) - write_typelib_interface( stmt->u.type, typelib ); - } + for (i = 0; i < typelib->reg_iface_count; ++i) + write_typelib_interface( typelib->reg_ifaces[i], typelib ); } static int write_coclass( const type_t *class, const typelib_t *typelib ) diff --git a/tools/widl/widltypes.h b/tools/widl/widltypes.h index 5e283292785..085a0ff55f5 100644 --- a/tools/widl/widltypes.h +++ b/tools/widl/widltypes.h @@ -538,6 +538,9 @@ struct _typelib_t { const attr_list_t *attrs; struct list importlibs; statement_list_t *stmts; + + type_t **reg_ifaces; + unsigned int reg_iface_count; }; struct _user_type_t { diff --git a/tools/widl/write_msft.c b/tools/widl/write_msft.c index dc0a6cb45b9..3a11d2ddd74 100644 --- a/tools/widl/write_msft.c +++ b/tools/widl/write_msft.c @@ -2068,6 +2068,10 @@ static void add_dispinterface_typeinfo(msft_typelib_t *typelib, type_t *dispinte if(add_func_desc(msft_typeinfo, func, idx) == S_OK) idx++; } + + typelib->typelib->reg_ifaces = xrealloc(typelib->typelib->reg_ifaces, + (typelib->typelib->reg_iface_count + 1) * sizeof(dispinterface)); + typelib->typelib->reg_ifaces[typelib->typelib->reg_iface_count++] = dispinterface; } static void add_interface_typeinfo(msft_typelib_t *typelib, type_t *interface) @@ -2142,6 +2146,13 @@ static void add_interface_typeinfo(msft_typelib_t *typelib, type_t *interface) if(add_func_desc(msft_typeinfo, func, idx) == S_OK) idx++; } + + if (is_attr(interface->attrs, ATTR_OLEAUTOMATION) || is_attr(interface->attrs, ATTR_DUAL)) + { + typelib->typelib->reg_ifaces = xrealloc(typelib->typelib->reg_ifaces, + (typelib->typelib->reg_iface_count + 1) * sizeof(interface)); + typelib->typelib->reg_ifaces[typelib->typelib->reg_iface_count++] = interface; + } } static void add_structure_typeinfo(msft_typelib_t *typelib, type_t *structure)