[1/6] widl: Avoid adding duplicate type definitions if tag and typedef names are the same.

Dmitry Timoshkov dmitry at baikal.ru
Mon Nov 2 23:28:53 CST 2015


This patch fixes handing of the following .idl snippet:

typedef [uuid(b14b6bb5-904e-4ff9-b247-bd361f7a0001)]
struct g { int g1; } g;

[uuid(b14b6bb5-904e-4ff9-b247-bd361f7a0002)]
interface test_iface : IUnknown
{
    HRESULT test([in] g *ptr);
}

Signed-off-by: Dmitry Timoshkov <dmitry at baikal.ru>
---
 tools/widl/write_msft.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/tools/widl/write_msft.c b/tools/widl/write_msft.c
index daa0366..3cbae92 100644
--- a/tools/widl/write_msft.c
+++ b/tools/widl/write_msft.c
@@ -2181,7 +2181,7 @@ static void add_union_typeinfo(msft_typelib_t *typelib, type_t *tunion)
 static void add_typedef_typeinfo(msft_typelib_t *typelib, type_t *tdef)
 {
     msft_typeinfo_t *msft_typeinfo = NULL;
-    int alignment, datatype1, datatype2, size;
+    int alignment, datatype1, datatype2, size, duplicate = 0;
     type_t *type;
 
     if (-1 < tdef->typelib_idx)
@@ -2194,6 +2194,8 @@ static void add_typedef_typeinfo(msft_typelib_t *typelib, type_t *tdef)
         tdef->typelib_idx = typelib->typelib_header.nrtypeinfos;
         msft_typeinfo = create_msft_typeinfo(typelib, TKIND_ALIAS, tdef->name, tdef->attrs);
     }
+    else
+        duplicate = 1;
 
     encode_type(typelib, get_type_vt(type), type,
                 &datatype1, &size, &alignment, &datatype2);
@@ -2205,6 +2207,10 @@ static void add_typedef_typeinfo(msft_typelib_t *typelib, type_t *tdef)
         msft_typeinfo->typeinfo->datatype2 = datatype2;
         msft_typeinfo->typeinfo->typekind |= (alignment << 11 | alignment << 6);
     }
+
+    /* avoid adding duplicate type definitions */
+    if (duplicate)
+        tdef->typelib_idx = type->typelib_idx;
 }
 
 static void add_coclass_typeinfo(msft_typelib_t *typelib, type_t *cls)
-- 
2.6.2




More information about the wine-patches mailing list