From: Hans Leidekker hans@codeweavers.com
--- tools/widl/metadata.c | 60 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 2 deletions(-)
diff --git a/tools/widl/metadata.c b/tools/widl/metadata.c index a58089e3455..4f162976a6f 100644 --- a/tools/widl/metadata.c +++ b/tools/widl/metadata.c @@ -1084,10 +1084,37 @@ enum #define MODULE_ROW 1 #define MSCORLIB_ROW 1
+static char *make_shortname( const char *src ) +{ + char *dst; + const char *ptr = strchr( src, '<' ); + UINT len, count = 1, level = 0; + + if (!ptr) return (char *)src; + + len = ptr - src; + dst = xmalloc( len + 12 ); + memcpy( dst, src, ptr - src ); + while (*ptr) + { + if (*ptr == '<') level++; + if (*ptr == '>' && !--level) break; + if (level == 1 && *ptr == ',') count++; + ptr++; + } + sprintf( dst + len, "`%u", count ); + return dst; +} + static UINT add_name( type_t *type, UINT *namespace ) { - UINT name = add_string( type->name ); - char *str = format_namespace( type->namespace, "", ".", NULL, NULL ); + char *str = make_shortname( type->name ); + UINT name; + + name = add_string( str ); + if (str != type->name) free( str ); + + str = format_namespace( type->namespace, "", ".", NULL, NULL ); *namespace = add_string( str ); free( str ); return name; @@ -1396,6 +1423,29 @@ static void add_struct_type_step2( type_t *type ) add_contract_attr_step2( type ); }
+static void add_interface_type_step1( type_t *type ) +{ + UINT name, namespace; + + name = add_name( type, &namespace ); + + type->md.ref = add_typeref_row( resolution_scope(TABLE_MODULE, MODULE_ROW), name, namespace ); + + add_contract_attr_step1( type ); +} + +static void add_interface_type_step2( type_t *type ) +{ + UINT name, namespace, flags = TYPE_ATTR_INTERFACE | TYPE_ATTR_ABSTRACT | TYPE_ATTR_UNKNOWN; + + name = add_name( type, &namespace ); + + if (!is_attr( type->attrs, ATTR_EXCLUSIVETO )) flags |= TYPE_ATTR_PUBLIC; + type->md.def = add_typedef_row( flags, name, namespace, 0, 0, 0 ); + + add_contract_attr_step2( type ); +} + static UINT make_contractversion_value( const type_t *type, BYTE *buf ) { UINT version = get_attrv( type->attrs, ATTR_CONTRACTVERSION ), len = 2 + sizeof(version); @@ -1507,6 +1557,9 @@ static void build_tables( const statement_list_t *stmt_list ) case TYPE_STRUCT: add_struct_type_step1( type ); break; + case TYPE_INTERFACE: + add_interface_type_step1( type ); + break; case TYPE_APICONTRACT: add_apicontract_type_step1( type ); break; @@ -1530,6 +1583,9 @@ static void build_tables( const statement_list_t *stmt_list ) case TYPE_STRUCT: add_struct_type_step2( type ); break; + case TYPE_INTERFACE: + add_interface_type_step2( type ); + break; case TYPE_APICONTRACT: add_apicontract_type_step2( type ); break;