-- v3: widl: Always store member references in attributes.
From: Hans Leidekker hans@codeweavers.com
--- tools/widl/attribute.c | 11 +++++++++++ tools/widl/client.c | 8 +++++--- tools/widl/header.c | 10 ++++++---- tools/widl/parser.y | 30 ++++++++++++++++++++---------- tools/widl/register.c | 24 +++++++++++++++--------- tools/widl/server.c | 18 +++++++++++------- tools/widl/utils.h | 7 ------- tools/widl/widl.h | 1 + tools/widl/widltypes.h | 6 ++++++ tools/widl/write_msft.c | 13 ++++++++++--- tools/widl/write_sltg.c | 13 +++++++++++-- 11 files changed, 96 insertions(+), 45 deletions(-)
diff --git a/tools/widl/attribute.c b/tools/widl/attribute.c index 2546e88b30a..feb4c2b5db4 100644 --- a/tools/widl/attribute.c +++ b/tools/widl/attribute.c @@ -103,6 +103,17 @@ void *get_aliaschain_attrp( const type_t *type, enum attr_type attr_type ) } }
+void get_version( const attr_list_t *list, unsigned short *major, unsigned short *minor ) +{ + version_t *version = get_attrp( list, ATTR_VERSION ); + if (version) + { + *major = version->major; + *minor = version->minor; + } + else *major = *minor = 0; +} + struct allowed_attr { unsigned int dce_compatible : 1; diff --git a/tools/widl/client.c b/tools/widl/client.c index 795e3ba2104..e5d93cdc1c3 100644 --- a/tools/widl/client.c +++ b/tools/widl/client.c @@ -439,9 +439,11 @@ static void write_stubdescriptor(type_t *iface, int expr_eval_routines)
static void write_clientinterfacedecl(type_t *iface) { - unsigned int ver = get_attrv(iface->attrs, ATTR_VERSION); const struct uuid *uuid = get_attrp(iface->attrs, ATTR_UUID); const str_list_t *endpoints = get_attrp(iface->attrs, ATTR_ENDPOINT); + unsigned short major, minor; + + get_version( iface->attrs, &major, &minor );
if (endpoints) write_endpoints( client, iface->name, endpoints );
@@ -452,7 +454,7 @@ static void write_clientinterfacedecl(type_t *iface) print_client("{{0x%08x,0x%04x,0x%04x,{0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x}},{%d,%d}},\n", uuid->Data1, uuid->Data2, uuid->Data3, uuid->Data4[0], uuid->Data4[1], uuid->Data4[2], uuid->Data4[3], uuid->Data4[4], uuid->Data4[5], uuid->Data4[6], - uuid->Data4[7], MAJORVERSION(ver), MINORVERSION(ver)); + uuid->Data4[7], major, minor); print_client("{{0x8a885d04,0x1ceb,0x11c9,{0x9f,0xe8,0x08,0x00,0x2b,0x10,0x48,0x60}},{2,0}},\n"); /* FIXME */ print_client("0,\n"); if (endpoints) @@ -475,7 +477,7 @@ static void write_clientinterfacedecl(type_t *iface) iface->name, iface->name); else print_client("RPC_IF_HANDLE %s%s_v%d_%d_c_ifspec = (RPC_IF_HANDLE)& %s___RpcClientInterface;\n", - prefix_client, iface->name, MAJORVERSION(ver), MINORVERSION(ver), iface->name); + prefix_client, iface->name, major, minor, iface->name); fprintf(client, "\n"); }
diff --git a/tools/widl/header.c b/tools/widl/header.c index 81a789a74df..b993286a85c 100644 --- a/tools/widl/header.c +++ b/tools/widl/header.c @@ -1760,12 +1760,14 @@ static void write_com_interface_end(FILE *header, type_t *iface)
static void write_rpc_interface_start(FILE *header, const type_t *iface) { - unsigned int ver = get_attrv(iface->attrs, ATTR_VERSION); const var_t *var = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE); expr_t *contract = get_attrp(iface->attrs, ATTR_CONTRACT); + unsigned short major, minor; + + get_version( iface->attrs, &major, &minor );
fprintf(header, "/*****************************************************************************\n"); - fprintf(header, " * %s interface (v%d.%d)\n", iface->name, MAJORVERSION(ver), MINORVERSION(ver)); + fprintf(header, " * %s interface (v%d.%d)\n", iface->name, major, minor); fprintf(header, " */\n"); if (contract) write_apicontract_guard_start(header, contract); fprintf(header,"#ifndef __%s_INTERFACE_DEFINED__\n", iface->name); @@ -1784,9 +1786,9 @@ static void write_rpc_interface_start(FILE *header, const type_t *iface) else { fprintf(header, "extern RPC_IF_HANDLE %s%s_v%d_%d_c_ifspec;\n", - prefix_client, iface->name, MAJORVERSION(ver), MINORVERSION(ver)); + prefix_client, iface->name, major, minor); fprintf(header, "extern RPC_IF_HANDLE %s%s_v%d_%d_s_ifspec;\n", - prefix_server, iface->name, MAJORVERSION(ver), MINORVERSION(ver)); + prefix_server, iface->name, major, minor); } }
diff --git a/tools/widl/parser.y b/tools/widl/parser.y index fb21a2417f1..0ff3de3c179 100644 --- a/tools/widl/parser.y +++ b/tools/widl/parser.y @@ -59,6 +59,7 @@ static void append_array(declarator_t *decl, expr_t *expr); static void append_chain_type(declarator_t *decl, type_t *type, enum type_qualifier qual); static void append_chain_callconv( struct location where, type_t *chain, char *callconv ); static warning_list_t *append_warning(warning_list_t *, int); +static version_t *make_version( unsigned short major, unsigned short minor );
static type_t *reg_typedefs( struct location where, decl_spec_t *decl_spec, var_list_t *names, attr_list_t *attrs ); static type_t *find_type_or_error(struct namespace *parent, const char *name); @@ -148,6 +149,7 @@ PARSER_LTYPE pop_import(void); warning_list_t *warning_list; typeref_t *typeref; typeref_list_t *typeref_list; + version_t *version; char *str; struct uuid *uuid; unsigned int num; @@ -336,8 +338,7 @@ PARSER_LTYPE pop_import(void); %type <type> coclass coclassdef %type <type> runtimeclass runtimeclass_def %type <type> apicontract apicontract_def -%type <num> contract_ver -%type <num> pointer_type threading_type marshaling_behavior version +%type <num> pointer_type threading_type marshaling_behavior %type <str> libraryhdr callconv cppquote importlib import %type <str> typename m_typename %type <str> import_start @@ -349,6 +350,7 @@ PARSER_LTYPE pop_import(void); %type <warning_list> warnings %type <num> allocate_option_list allocate_option %type <namespace> namespace_pfx +%type <version> version contract_ver
%left ',' %right '?' ':' @@ -594,13 +596,13 @@ marshaling_behavior: ;
contract_ver: - aNUM { $$ = MAKEVERSION(0, $1.value); } - | aNUM '.' aNUM { $$ = MAKEVERSION($3.value, $1.value); } + aNUM { $$ = make_version( 0, $1.value ); } + | aNUM '.' aNUM { $$ = make_version( $3.value, $1.value ); } ;
contract_req : decl_spec ',' contract_ver { - struct integer integer = {.value = $3}; + struct integer integer = {.value = $3->major | $3->minor }; if ($1->type->type_type != TYPE_APICONTRACT) error_loc("type %s is not an apicontract\n", $1->type->name); $$ = make_exprl(EXPR_NUM, &integer); @@ -660,7 +662,7 @@ attribute | tCONTEXTHANDLENOSERIALIZE { $$ = attr_int( @$, ATTR_CONTEXTHANDLE, 0 ); /* RPC_CONTEXT_HANDLE_DONT_SERIALIZE */ } | tCONTEXTHANDLESERIALIZE { $$ = attr_int( @$, ATTR_CONTEXTHANDLE, 0 ); /* RPC_CONTEXT_HANDLE_SERIALIZE */ } | tCONTRACT '(' contract_req ')' { $$ = attr_ptr( @$, ATTR_CONTRACT, $3 ); } - | tCONTRACTVERSION '(' contract_ver ')' { $$ = attr_int( @$, ATTR_CONTRACTVERSION, $3 ); } + | tCONTRACTVERSION '(' contract_ver ')' { $$ = attr_ptr( @$, ATTR_CONTRACTVERSION, $3 ); } | tCONTROL { $$ = attr_int( @$, ATTR_CONTROL, 0 ); } | tCUSTOM '(' aUUID ',' expr_const ')' { attr_custdata_t *data = xmalloc( sizeof(*data) ); data->id = *$3; data->pval = $5; @@ -765,7 +767,7 @@ attribute | tASYNCUUID '(' aUUID ')' { $$ = attr_ptr( @$, ATTR_ASYNCUUID, $3 ); } | tV1ENUM { $$ = attr_int( @$, ATTR_V1ENUM, 0 ); } | tVARARG { $$ = attr_int( @$, ATTR_VARARG, 0 ); } - | tVERSION '(' version ')' { $$ = attr_int( @$, ATTR_VERSION, $3 ); } + | tVERSION '(' version ')' { $$ = attr_ptr( @$, ATTR_VERSION, $3 ); } | tVIPROGID '(' aSTRING ')' { $$ = attr_ptr( @$, ATTR_VIPROGID, $3 ); } | tWIREMARSHAL '(' type ')' { $$ = attr_ptr( @$, ATTR_WIREMARSHAL, $3 ); } | pointer_type { $$ = attr_int( @$, ATTR_POINTERTYPE, $1 ); } @@ -1386,9 +1388,9 @@ uniondef: tUNION m_typename '{' ne_union_fields '}' ;
version: - aNUM { $$ = MAKEVERSION($1.value, 0); } - | aNUM '.' aNUM { $$ = MAKEVERSION($1.value, $3.value); } - | aHEXNUM { $$ = $1.value; } + aNUM { $$ = make_version( $1.value, 0 ); } + | aNUM '.' aNUM { $$ = make_version( $1.value, $3.value ); } + | aHEXNUM { $$ = make_version( $1.value >> 16, $1.value & 0xffff ); } ;
acf_statements @@ -1990,6 +1992,14 @@ static typelib_t *make_library(const char *name, const attr_list_t *attrs) return typelib; }
+static version_t *make_version( unsigned short major, unsigned short minor ) +{ + version_t *version = xmalloc( sizeof(*version) ); + version->major = major; + version->minor = minor; + return version; +} + static int hash_ident(const char *name) { const char *p = name; diff --git a/tools/widl/register.c b/tools/widl/register.c index c5600c9e7ea..be3743c9d10 100644 --- a/tools/widl/register.c +++ b/tools/widl/register.c @@ -112,7 +112,9 @@ static void write_typelib_interface( const type_t *iface, const typelib_t *typel { const struct uuid *typelib_uuid = get_attrp( typelib->attrs, ATTR_UUID ); const struct uuid *uuid = get_attrp( iface->attrs, ATTR_UUID ); - unsigned int version = get_attrv( typelib->attrs, ATTR_VERSION ); + unsigned short major, minor; + + get_version( iface->attrs, &major, &minor );
if (!uuid) return; if (!is_object( iface )) return; @@ -121,9 +123,9 @@ static void write_typelib_interface( const type_t *iface, const typelib_t *typel indent++; put_str( indent, "ProxyStubClsid = s '{00020424-0000-0000-C000-000000000046}'\n" ); put_str( indent, "ProxyStubClsid32 = s '{00020424-0000-0000-C000-000000000046}'\n" ); - if (version) + if (major || minor) put_str( indent, "TypeLib = s '%s' { val Version = s '%u.%u' }\n", - format_uuid( typelib_uuid ), MAJORVERSION(version), MINORVERSION(version) ); + format_uuid( typelib_uuid ), major, minor ); else put_str( indent, "TypeLib = s '%s'", format_uuid( typelib_uuid )); indent--; @@ -145,7 +147,9 @@ static int write_coclass( const type_t *class, const typelib_t *typelib ) const char *progid = get_attrp( class->attrs, ATTR_PROGID ); const char *vi_progid = get_attrp( class->attrs, ATTR_VIPROGID ); const char *threading = get_coclass_threading( class ); - unsigned int version = get_attrv( class->attrs, ATTR_VERSION ); + unsigned short major, minor; + + get_version( class->attrs, &major, &minor );
if (!uuid) return 0; if (typelib && !threading && !progid) return 0; @@ -160,9 +164,10 @@ static int write_coclass( const type_t *class, const typelib_t *typelib ) { const struct uuid *typelib_uuid = get_attrp( typelib->attrs, ATTR_UUID ); put_str( indent, "TypeLib = s '%s'\n", format_uuid( typelib_uuid )); - if (!version) version = get_attrv( typelib->attrs, ATTR_VERSION ); + if (!(major && minor)) + get_version( typelib->attrs, &major, &minor ); } - if (version) put_str( indent, "Version = s '%u.%u'\n", MAJORVERSION(version), MINORVERSION(version) ); + if (major || minor) put_str( indent, "Version = s '%u.%u'\n", major, minor ); if (vi_progid) put_str( indent, "VersionIndependentProgId = s '%s'\n", vi_progid ); put_str( --indent, "}\n" ); return 1; @@ -336,12 +341,14 @@ void output_typelib_regscript( const typelib_t *typelib ) const struct uuid *typelib_uuid = get_attrp( typelib->attrs, ATTR_UUID ); const char *descr = get_attrp( typelib->attrs, ATTR_HELPSTRING ); const expr_t *lcid_expr = get_attrp( typelib->attrs, ATTR_LIBLCID ); - unsigned int version = get_attrv( typelib->attrs, ATTR_VERSION ); + unsigned short major, minor; unsigned int flags = 0; char id_part[12] = ""; char *resname = typelib_name; expr_t *expr;
+ get_version( typelib->attrs, &major, &minor ); + if (is_attr( typelib->attrs, ATTR_RESTRICTED )) flags |= 1; /* LIBFLAG_FRESTRICTED */ if (is_attr( typelib->attrs, ATTR_CONTROL )) flags |= 2; /* LIBFLAG_FCONTROL */ if (is_attr( typelib->attrs, ATTR_HIDDEN )) flags |= 4; /* LIBFLAG_FHIDDEN */ @@ -353,8 +360,7 @@ void output_typelib_regscript( const typelib_t *typelib ) put_str( indent++, "{\n" ); put_str( indent, "NoRemove '%s'\n", format_uuid( typelib_uuid )); put_str( indent++, "{\n" ); - put_str( indent, "'%u.%u' = s '%s'\n", - MAJORVERSION(version), MINORVERSION(version), descr ? descr : typelib->name ); + put_str( indent, "'%u.%u' = s '%s'\n", major, minor, descr ? descr : typelib->name ); put_str( indent++, "{\n" ); expr = get_attrp( typelib->attrs, ATTR_ID ); if (expr) diff --git a/tools/widl/server.c b/tools/widl/server.c index 8bc179f1438..4c72b106069 100644 --- a/tools/widl/server.c +++ b/tools/widl/server.c @@ -266,9 +266,11 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset)
static void write_dispatchtable(type_t *iface) { - unsigned int ver = get_attrv(iface->attrs, ATTR_VERSION); unsigned int method_count = 0; const statement_t *stmt; + unsigned short major, minor; + + get_version( iface->attrs, &major, &minor );
print_server("static RPC_DISPATCH_FUNCTION %s_table[] =\n", iface->name); print_server("{\n"); @@ -286,7 +288,7 @@ static void write_dispatchtable(type_t *iface) print_server("0\n"); indent--; print_server("};\n"); - print_server("static RPC_DISPATCH_TABLE %s_v%d_%d_DispatchTable =\n", iface->name, MAJORVERSION(ver), MINORVERSION(ver)); + print_server("static RPC_DISPATCH_TABLE %s_v%d_%d_DispatchTable =\n", iface->name, major, minor); print_server("{\n"); indent++; print_server("%u,\n", method_count); @@ -403,13 +405,15 @@ static void write_stubdescriptor(type_t *iface, int expr_eval_routines)
static void write_serverinterfacedecl(type_t *iface) { - unsigned int ver = get_attrv(iface->attrs, ATTR_VERSION); struct uuid *uuid = get_attrp(iface->attrs, ATTR_UUID); const str_list_t *endpoints = get_attrp(iface->attrs, ATTR_ENDPOINT); + unsigned short major, minor; + + get_version( iface->attrs, &major, &minor );
if (endpoints) write_endpoints( server, iface->name, endpoints );
- print_server("static RPC_DISPATCH_TABLE %s_v%d_%d_DispatchTable;\n", iface->name, MAJORVERSION(ver), MINORVERSION(ver)); + print_server("static RPC_DISPATCH_TABLE %s_v%d_%d_DispatchTable;\n", iface->name, major, minor); print_server( "static const MIDL_SERVER_INFO %s_ServerInfo;\n", iface->name ); fprintf(server, "\n"); print_server("static const RPC_SERVER_INTERFACE %s___RpcServerInterface =\n", iface->name ); @@ -419,9 +423,9 @@ static void write_serverinterfacedecl(type_t *iface) print_server("{{0x%08x,0x%04x,0x%04x,{0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x}},{%d,%d}},\n", uuid->Data1, uuid->Data2, uuid->Data3, uuid->Data4[0], uuid->Data4[1], uuid->Data4[2], uuid->Data4[3], uuid->Data4[4], uuid->Data4[5], uuid->Data4[6], - uuid->Data4[7], MAJORVERSION(ver), MINORVERSION(ver)); + uuid->Data4[7], major, minor); print_server("{{0x8a885d04,0x1ceb,0x11c9,{0x9f,0xe8,0x08,0x00,0x2b,0x10,0x48,0x60}},{2,0}},\n"); /* FIXME */ - print_server("&%s_v%d_%d_DispatchTable,\n", iface->name, MAJORVERSION(ver), MINORVERSION(ver)); + print_server("&%s_v%d_%d_DispatchTable,\n", iface->name, major, minor); if (endpoints) { print_server("%u,\n", list_count(endpoints)); @@ -442,7 +446,7 @@ static void write_serverinterfacedecl(type_t *iface) iface->name, iface->name); else print_server("RPC_IF_HANDLE %s%s_v%d_%d_s_ifspec = (RPC_IF_HANDLE)& %s___RpcServerInterface;\n", - prefix_server, iface->name, MAJORVERSION(ver), MINORVERSION(ver), iface->name); + prefix_server, iface->name, major, minor, iface->name); fprintf(server, "\n"); }
diff --git a/tools/widl/utils.h b/tools/widl/utils.h index 2a6bc7d7930..ac469fe1fca 100644 --- a/tools/widl/utils.h +++ b/tools/widl/utils.h @@ -41,11 +41,4 @@ extern void add_output_to_resources( const char *type, const char *name ); extern void flush_output_resources( const char *name ); extern void put_pword( unsigned int val ); extern void put_str( int indent, const char *format, ... ) __attribute__((format (printf, 2, 3))); - -/* typelibs expect the minor version to be stored in the higher bits and - * major to be stored in the lower bits */ -#define MAKEVERSION(major, minor) ((((minor) & 0xffff) << 16) | ((major) & 0xffff)) -#define MAJORVERSION(version) ((version) & 0xffff) -#define MINORVERSION(version) (((version) >> 16) & 0xffff) - #endif diff --git a/tools/widl/widl.h b/tools/widl/widl.h index 08071e8fdf8..a6d3bc6bf33 100644 --- a/tools/widl/widl.h +++ b/tools/widl/widl.h @@ -105,6 +105,7 @@ extern int is_aliaschain_attr( const type_t *type, enum attr_type attr_type ); extern unsigned int get_attrv( const attr_list_t *list, enum attr_type attr_type ); extern void *get_attrp( const attr_list_t *list, enum attr_type attr_type ); extern void *get_aliaschain_attrp( const type_t *type, enum attr_type attr_type ); +extern void get_version( const attr_list_t *list, unsigned short *major, unsigned short *minor );
typedef int (*map_attrs_filter_t)( attr_list_t *, const attr_t * ); extern attr_list_t *append_attr( attr_list_t *list, attr_t *attr ); diff --git a/tools/widl/widltypes.h b/tools/widl/widltypes.h index 1706f392670..6063aa7ef5e 100644 --- a/tools/widl/widltypes.h +++ b/tools/widl/widltypes.h @@ -55,6 +55,7 @@ typedef struct _user_type_t context_handle_t; typedef struct _user_type_t generic_handle_t; typedef struct _statement_t statement_t; typedef struct _warning_t warning_t; +typedef struct _version_t version_t;
typedef struct list attr_list_t; typedef struct list str_list_t; @@ -674,6 +675,11 @@ struct _statement_t { unsigned int is_defined : 1; };
+struct _version_t { + unsigned short major; + unsigned short minor; +}; + struct _warning_t { int num; struct list entry; diff --git a/tools/widl/write_msft.c b/tools/widl/write_msft.c index b0401d81238..6c63e2716b7 100644 --- a/tools/widl/write_msft.c +++ b/tools/widl/write_msft.c @@ -2006,9 +2006,13 @@ static msft_typeinfo_t *create_msft_typeinfo(msft_typelib_t *typelib, enum type_ break;
case ATTR_VERSION: - typeinfo->version = attr->u.ival; - break; + { + const version_t *version = attr->u.pval; + unsigned short major = version ? version->major : 0, minor = version ? version->minor : 0;
+ typeinfo->version = (minor << 16) | major; + break; + } default: break; } @@ -2507,7 +2511,10 @@ static void set_name(msft_typelib_t *typelib)
static void set_version(msft_typelib_t *typelib) { - typelib->typelib_header.version = get_attrv( typelib->typelib->attrs, ATTR_VERSION ); + unsigned short major, minor; + + get_version( typelib->typelib->attrs, &major, &minor ); + typelib->typelib_header.version = (minor << 16) | major; }
static void set_guid(msft_typelib_t *typelib) diff --git a/tools/widl/write_sltg.c b/tools/widl/write_sltg.c index b4ec340b11a..3c80e21d86b 100644 --- a/tools/widl/write_sltg.c +++ b/tools/widl/write_sltg.c @@ -320,8 +320,13 @@ static void init_library(struct sltg_typelib *sltg) switch (attr->type) { case ATTR_VERSION: - sltg->library.version = attr->u.ival; + { + const version_t *version = attr->u.pval; + unsigned short major = version ? version->major : 0, minor = version ? version->minor : 0; + + sltg->library.version = (minor << 16) | major; break; + } case ATTR_HELPSTRING: sltg->library.helpstring = attr->u.pval; break; @@ -522,12 +527,16 @@ static const char *add_typeinfo_block(struct sltg_typelib *typelib, const type_t static void init_typeinfo(struct sltg_typeinfo_header *ti, const type_t *type, short kind, const struct sltg_hrefmap *hrefmap) { + unsigned short major, minor; + + get_version( type->attrs, &major, &minor ); + ti->magic = 0x0501; ti->href_offset = -1; ti->res06 = -1; ti->member_offset = sizeof(*ti); ti->res0e = -1; - ti->version = get_attrv(type->attrs, ATTR_VERSION); + ti->version = minor << 16 | major; ti->res16 = 0xfffe0000; ti->misc.unknown1 = 0x02; ti->misc.flags = 0; /* FIXME */
From: Hans Leidekker hans@codeweavers.com
winmd stores high and low word in opposite order from typelib. --- tools/widl/metadata.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/tools/widl/metadata.c b/tools/widl/metadata.c index bd953c50d53..e02a82f6647 100644 --- a/tools/widl/metadata.c +++ b/tools/widl/metadata.c @@ -1779,13 +1779,16 @@ static UINT make_contract_value( const type_t *type, BYTE *buf )
static UINT make_version_value( const type_t *type, BYTE *buf ) { - UINT version = get_attrv( type->attrs, ATTR_VERSION ); + const version_t *version = get_attrp( type->attrs, ATTR_VERSION ); + UINT value; + + if (version) value = (version->major << 16) | version->minor; + else value = 1;
buf[0] = 1; buf[1] = 0; - buf[2] = is_attr( type->attrs, ATTR_VERSION ) ? 0 : 1; - buf[3] = 0; - memcpy( buf + 4, &version, sizeof(version) ); + memcpy( buf + 2, &value, sizeof(value) ); + buf[6] = buf[7] = 0; return 8; }
From: Hans Leidekker hans@codeweavers.com
--- tools/widl/metadata.c | 5 +++-- tools/widl/parser.y | 10 +++++----- tools/widl/widl.h | 2 ++ 3 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/tools/widl/metadata.c b/tools/widl/metadata.c index e02a82f6647..ab2e310cedd 100644 --- a/tools/widl/metadata.c +++ b/tools/widl/metadata.c @@ -1669,7 +1669,7 @@ static UINT make_method_sig( const var_t *method, BYTE *buf, BOOL is_static ) /* add remaining parameters */ LIST_FOR_EACH_ENTRY( arg, arg_list, var_t, entry ) { - if (is_attr( arg->attrs, ATTR_RETVAL ) ) continue; + if (is_size_param( arg, arg_list ) || is_attr( arg->attrs, ATTR_RETVAL ) ) continue; len += make_type_sig( arg->declspec.type, buf + len ); buf[1]++; } @@ -2210,6 +2210,7 @@ static void add_method_params_step1( var_list_t *arg_list ) { type_t *type = arg->declspec.type;
+ if (is_size_param( arg, arg_list )) continue; if (type_get_type( type ) == TYPE_POINTER) type = type_pointer_get_ref_type( type ); if (type->name && !strcmp( type->name, "EventRegistrationToken" )) { @@ -2283,7 +2284,7 @@ static UINT add_method_params_step2( var_list_t *arg_list )
LIST_FOR_EACH_ENTRY( arg, arg_list, var_t, entry ) { - if (is_attr( arg->attrs, ATTR_RETVAL )) continue; + if (is_size_param( arg, arg_list) || is_attr( arg->attrs, ATTR_RETVAL )) continue; row = add_param_row( get_param_attrs(arg), seq++, add_string(arg->name) ); if (!first) first = row; } diff --git a/tools/widl/parser.y b/tools/widl/parser.y index 0ff3de3c179..1473054dfc4 100644 --- a/tools/widl/parser.y +++ b/tools/widl/parser.y @@ -2614,7 +2614,7 @@ static void check_eventremove_args( const var_t *func, const var_list_t *args ) } }
-static int is_size_parameter( const var_t *param, const var_list_t *args ) +bool is_size_param( const var_t *param, const var_list_t *args ) { const var_t *arg;
@@ -2627,9 +2627,9 @@ static int is_size_parameter( const var_t *param, const var_list_t *args ) if (type->type_type != TYPE_ARRAY || !(size_is = type_array_get_conformance( type ))) continue;
if (size_is->type == EXPR_PPTR) size_is = size_is->ref; - if (!strcmp( param->name, size_is->u.sval )) return 1; + if (!strcmp( param->name, size_is->u.sval )) return true; } - return 0; + return false; }
static void check_propget_args( const var_t *func, const var_list_t *args ) @@ -2640,7 +2640,7 @@ static void check_propget_args( const var_t *func, const var_list_t *args ) LIST_FOR_EACH_ENTRY_REV( arg, args, const var_t, entry ) { const type_t *type = arg->declspec.type; - int is_size = is_size_parameter( arg, args ); + bool is_size = is_size_param( arg, args );
count++; if (count == 1 && (!is_ptr( type ) || !is_attr( arg->attrs, ATTR_RETVAL ))) @@ -2663,7 +2663,7 @@ static void check_propput_args( const var_t *func, const var_list_t *args )
LIST_FOR_EACH_ENTRY_REV( arg, args, const var_t, entry ) { - int is_size = is_size_parameter( arg, args ); + bool is_size = is_size_param( arg, args );
count++; if (is_attr( arg->attrs, ATTR_OUT )) diff --git a/tools/widl/widl.h b/tools/widl/widl.h index a6d3bc6bf33..2951a6ce1e9 100644 --- a/tools/widl/widl.h +++ b/tools/widl/widl.h @@ -93,6 +93,8 @@ extern void write_metadata(const statement_list_t *stmts); extern void start_cplusplus_guard(FILE *fp); extern void end_cplusplus_guard(FILE *fp);
+extern bool is_size_param( const var_t *param, const var_list_t *args ); + /* attribute.c */
extern attr_t *attr_int( struct location where, enum attr_type attr_type, unsigned int val );
From: Hans Leidekker hans@codeweavers.com
Array return values are encoded as out parameters even if they have a retval attribute. --- tools/widl/metadata.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/tools/widl/metadata.c b/tools/widl/metadata.c index ab2e310cedd..28e8b70df0e 100644 --- a/tools/widl/metadata.c +++ b/tools/widl/metadata.c @@ -1644,6 +1644,15 @@ static UINT make_type_sig( const type_t *type, BYTE *buf ) return len; }
+static BOOL is_retval( const var_t *arg ) +{ + const type_t *type = arg->declspec.type; + + /* array return values are encoded as out parameters even if the retval attribute is present */ + if (!is_attr( arg->attrs, ATTR_RETVAL ) || type_get_type( type ) == TYPE_ARRAY) return FALSE; + return TRUE; +} + static UINT make_method_sig( const var_t *method, BYTE *buf, BOOL is_static ) { const var_t *arg; @@ -1661,7 +1670,7 @@ static UINT make_method_sig( const var_t *method, BYTE *buf, BOOL is_static ) { const type_t *type;
- if (!is_attr( arg->attrs, ATTR_RETVAL )) continue; + if (!is_retval( arg )) continue; type = type_pointer_get_ref_type( arg->declspec.type ); /* retval must be a pointer */ len = make_type_sig( type, buf + 2 ) + 2; } @@ -1669,7 +1678,7 @@ static UINT make_method_sig( const var_t *method, BYTE *buf, BOOL is_static ) /* add remaining parameters */ LIST_FOR_EACH_ENTRY( arg, arg_list, var_t, entry ) { - if (is_size_param( arg, arg_list ) || is_attr( arg->attrs, ATTR_RETVAL ) ) continue; + if (is_size_param( arg, arg_list ) || is_retval( arg ) ) continue; len += make_type_sig( arg->declspec.type, buf + len ); buf[1]++; } @@ -1690,7 +1699,7 @@ static UINT make_property_sig( const var_t *method, BYTE *buf, BOOL is_static ) { const type_t *type;
- if (!is_attr( arg->attrs, ATTR_RETVAL )) continue; + if (!is_retval( arg )) continue; type = type_pointer_get_ref_type( arg->declspec.type ); /* retval must be a pointer */ len = make_type_sig( type, buf + 2 ) + 2; } @@ -1709,7 +1718,7 @@ static UINT make_activation_sig( const var_t *method, BYTE *buf )
if (method) LIST_FOR_EACH_ENTRY( arg, type_function_get_args(method->declspec.type), var_t, entry ) { - if (is_attr( arg->attrs, ATTR_RETVAL )) continue; + if (is_retval( arg )) continue; len += make_type_sig( arg->declspec.type, buf + len ); buf[1]++; } @@ -2275,7 +2284,7 @@ static UINT add_method_params_step2( var_list_t *arg_list )
LIST_FOR_EACH_ENTRY( arg, arg_list, var_t, entry ) { - if (is_attr( arg->attrs, ATTR_RETVAL )) + if (is_retval( arg )) { first = add_param_row( 0, 0, add_string(arg->name) ); break; @@ -2284,7 +2293,7 @@ static UINT add_method_params_step2( var_list_t *arg_list )
LIST_FOR_EACH_ENTRY( arg, arg_list, var_t, entry ) { - if (is_size_param( arg, arg_list) || is_attr( arg->attrs, ATTR_RETVAL )) continue; + if (is_size_param( arg, arg_list) || is_retval( arg )) continue; row = add_param_row( get_param_attrs(arg), seq++, add_string(arg->name) ); if (!first) first = row; } @@ -3181,7 +3190,7 @@ static void add_activation_interfaces( const type_t *class )
LIST_FOR_EACH_ENTRY( arg, type_function_get_args(method->declspec.type), var_t, entry ) { - if (is_attr( arg->attrs, ATTR_RETVAL )) continue; + if (is_retval( arg )) continue; row = add_param_row( get_param_attrs(arg), seq++, add_string(arg->name) ); if (!paramlist) paramlist = row; }
From: Hans Leidekker hans@codeweavers.com
To avoid uninitialized padding. --- tools/widl/metadata.c | 102 +++++++++++++++++++++--------------------- 1 file changed, 52 insertions(+), 50 deletions(-)
diff --git a/tools/widl/metadata.c b/tools/widl/metadata.c index 28e8b70df0e..de093022f66 100644 --- a/tools/widl/metadata.c +++ b/tools/widl/metadata.c @@ -479,14 +479,16 @@ static void add_bytes( struct buffer *buf, const BYTE *data, UINT size ) buf->offset += size; }
-static void serialize_byte( BYTE value ) +static void serialize_byte( UINT value ) { - add_bytes( &tables_disk, (const BYTE *)&value, sizeof(value) ); + assert( !(value >> 24) ); + add_bytes( &tables_disk, (const BYTE *)&value, sizeof(BYTE) ); }
-static void serialize_ushort( USHORT value ) +static void serialize_ushort( UINT value ) { - add_bytes( &tables_disk, (const BYTE *)&value, sizeof(value) ); + assert( !(value >> 16) ); + add_bytes( &tables_disk, (const BYTE *)&value, sizeof(USHORT) ); }
static void serialize_uint( UINT value ) @@ -623,11 +625,11 @@ static enum table has_semantics_to_table( UINT token )
struct module_row { - USHORT generation; - UINT name; - UINT mvid; - UINT encid; - UINT encbaseid; + UINT generation; + UINT name; + UINT mvid; + UINT encid; + UINT encbaseid; };
static UINT add_module_row( UINT name, UINT mvid ) @@ -713,9 +715,9 @@ static void serialize_typedef_table( void )
struct field_row { - USHORT flags; - UINT name; - UINT signature; + UINT flags; + UINT name; + UINT signature; };
static UINT add_field_row( UINT flags, UINT name, UINT signature ) @@ -740,12 +742,12 @@ static void serialize_field_table( void )
struct methoddef_row { - UINT rva; - USHORT implflags; - USHORT flags; - UINT name; - UINT signature; - UINT paramlist; + UINT rva; + UINT implflags; + UINT flags; + UINT name; + UINT signature; + UINT paramlist; };
static UINT add_methoddef_row( UINT implflags, UINT flags, UINT name, UINT signature, UINT paramlist ) @@ -775,9 +777,9 @@ static void serialize_methoddef_table( void )
struct param_row { - USHORT flags; - USHORT sequence; - UINT name; + UINT flags; + UINT sequence; + UINT name; };
static UINT add_param_row( USHORT flags, USHORT sequence, UINT name ) @@ -868,8 +870,8 @@ static void serialize_memberref_table( void )
struct constant_row { - BYTE type; - BYTE padding; + UINT type; + UINT padding; UINT parent; UINT value; }; @@ -947,15 +949,15 @@ static void serialize_customattribute_table( void )
struct assembly_row { - UINT hashalgid; - USHORT majorversion; - USHORT minorversion; - USHORT buildnumber; - USHORT revisionnumber; - UINT flags; - UINT publickey; - UINT name; - UINT culture; + UINT hashalgid; + UINT majorversion; + UINT minorversion; + UINT buildnumber; + UINT revisionnumber; + UINT flags; + UINT publickey; + UINT name; + UINT culture; };
static UINT add_assembly_row( UINT name ) @@ -981,15 +983,15 @@ static void serialize_assembly_table( void )
struct assemblyref_row { - USHORT majorversion; - USHORT minorversion; - USHORT buildnumber; - USHORT revisionnumber; - UINT flags; - UINT publickey; - UINT name; - UINT culture; - UINT hashvalue; + UINT majorversion; + UINT minorversion; + UINT buildnumber; + UINT revisionnumber; + UINT flags; + UINT publickey; + UINT name; + UINT culture; + UINT hashvalue; };
static UINT add_assemblyref_row( UINT flags, UINT publickey, UINT name ) @@ -1045,9 +1047,9 @@ static void serialize_propertymap_table( void )
struct property_row { - USHORT flags; - UINT name; - UINT type; + UINT flags; + UINT name; + UINT type; };
static UINT add_property_row( USHORT flags, UINT name, UINT type ) @@ -1097,9 +1099,9 @@ static void serialize_eventmap_table( void )
struct event_row { - USHORT flags; - UINT name; - UINT type; + UINT flags; + UINT name; + UINT type; };
static UINT add_event_row( USHORT flags, UINT name, UINT type ) @@ -1124,9 +1126,9 @@ static void serialize_event_table( void )
struct methodsemantics_row { - USHORT semantics; - UINT method; - UINT association; + UINT semantics; + UINT method; + UINT association; };
static UINT add_methodsemantics_row( USHORT flags, UINT name, UINT type )
From: Hans Leidekker hans@codeweavers.com
midlrt includes this attribute when generating metadata. Adding this attribute when an apicontract is defined allows us to move member references from types to attributes where they belong. --- tools/widl/attribute.c | 1 + tools/widl/typetree.c | 1 + tools/widl/widltypes.h | 1 + 3 files changed, 3 insertions(+)
diff --git a/tools/widl/attribute.c b/tools/widl/attribute.c index feb4c2b5db4..0268cde417f 100644 --- a/tools/widl/attribute.c +++ b/tools/widl/attribute.c @@ -145,6 +145,7 @@ struct allowed_attr allowed_attr[] = /* ATTR_AGGREGATABLE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, "aggregatable" }, /* ATTR_ALLOCATE */ { 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "allocate" }, /* ATTR_ANNOTATION */ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "annotation" }, + /* ATTR_APICONTACT */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, "apicontract" }, /* ATTR_APPOBJECT */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, "appobject" }, /* ATTR_ASYNC */ { 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "async" }, /* ATTR_ASYNCUUID */ { 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, "async_uuid" }, diff --git a/tools/widl/typetree.c b/tools/widl/typetree.c index 441b6cdcea1..3bfb2efeea2 100644 --- a/tools/widl/typetree.c +++ b/tools/widl/typetree.c @@ -913,6 +913,7 @@ type_t *type_apicontract_declare(char *name, struct namespace *namespace) type_t *type_apicontract_define(type_t *apicontract, attr_list_t *attrs, const struct location *where) { apicontract->attrs = check_apicontract_attrs(apicontract->name, attrs); + apicontract->attrs = append_attr(apicontract->attrs, attr_int(*where, ATTR_APICONTRACT, 1)); define_type(apicontract, where); return apicontract; } diff --git a/tools/widl/widltypes.h b/tools/widl/widltypes.h index 6063aa7ef5e..36d7a179b06 100644 --- a/tools/widl/widltypes.h +++ b/tools/widl/widltypes.h @@ -75,6 +75,7 @@ enum attr_type ATTR_AGGREGATABLE, ATTR_ALLOCATE, ATTR_ANNOTATION, + ATTR_APICONTRACT, /* implicit attribute */ ATTR_APPOBJECT, ATTR_ASYNC, ATTR_ASYNCUUID,
From: Hans Leidekker hans@codeweavers.com
--- tools/widl/metadata.c | 281 +++++++++++++++++++++++------------------ tools/widl/widltypes.h | 22 +--- 2 files changed, 162 insertions(+), 141 deletions(-)
diff --git a/tools/widl/metadata.c b/tools/widl/metadata.c index de093022f66..15cd09bd494 100644 --- a/tools/widl/metadata.c +++ b/tools/widl/metadata.c @@ -1767,12 +1767,12 @@ static UINT make_deprecated_sig( UINT token, BYTE *buf ) return len; }
-static UINT make_contract_value( const type_t *type, BYTE *buf ) +static UINT make_contract_value( const attr_t *attr, BYTE *buf ) { - const expr_t *attr = get_attrp( type->attrs, ATTR_CONTRACT ); - const type_t *contract = attr->u.var->declspec.type; + const expr_t *expr = attr->u.pval; + const type_t *contract = expr->u.var->declspec.type; char *name = format_namespace( contract->namespace, "", ".", contract->name, NULL ); - UINT version = attr->ref->u.integer.value, len = strlen( name ); + UINT version = expr->ref->u.integer.value, len = strlen( name );
buf[0] = 1; buf[1] = 0; @@ -1788,12 +1788,12 @@ static UINT make_contract_value( const type_t *type, BYTE *buf ) return len; }
-static UINT make_version_value( const type_t *type, BYTE *buf ) +static UINT make_version_value( const attr_t *attr, BYTE *buf ) { - const version_t *version = get_attrp( type->attrs, ATTR_VERSION ); + const version_t *version; UINT value;
- if (version) value = (version->major << 16) | version->minor; + if (attr && (version = attr->u.pval)) value = (version->major << 16) | version->minor; else value = 1;
buf[0] = 1; @@ -1803,12 +1803,23 @@ static UINT make_version_value( const type_t *type, BYTE *buf ) return 8; }
-static void add_contract_attr_step1( type_t *type ) +static attr_t *get_attr( const attr_list_t *list, enum attr_type attr_type ) +{ + attr_t *attr; + if (list) LIST_FOR_EACH_ENTRY( attr, list, attr_t, entry ) + { + if (attr->type == attr_type ) return attr; + } + return NULL; +} + +static void add_contract_attr_step1( const type_t *type ) { UINT assemblyref, scope, typeref, typeref_type, class, sig_size; BYTE sig[32]; + attr_t *attr;
- if (!is_attr( type->attrs, ATTR_CONTRACT )) return; + if (!(attr = get_attr( type->attrs, ATTR_CONTRACT ))) return;
add_assemblyref_row( 0x200, 0, add_string("windowscontracts") ); assemblyref = add_assemblyref_row( 0x200, 0, add_string("Windows.Foundation") ); @@ -1821,72 +1832,77 @@ static void add_contract_attr_step1( type_t *type )
class = memberref_parent( TABLE_TYPEREF, typeref ); sig_size = make_member_sig( typedef_or_ref(TABLE_TYPEREF, typeref_type), sig ); - type->md.member[MD_ATTR_CONTRACT] = add_memberref_row( class, add_string(".ctor"), add_blob(sig, sig_size) ); + attr->md_member = add_memberref_row( class, add_string(".ctor"), add_blob(sig, sig_size) ); }
-static void add_contract_attr_step2( type_t *type ) +static void add_contract_attr_step2( const type_t *type ) { UINT parent, attr_type, value_size; BYTE value[MAX_NAME + sizeof(UINT) + 5]; + const attr_t *attr;
- if (!is_attr( type->attrs, ATTR_CONTRACT )) return; + if (!(attr = get_attr( type->attrs, ATTR_CONTRACT ))) return;
parent = has_customattribute( TABLE_TYPEDEF, type->md.def ); - attr_type = customattribute_type( TABLE_MEMBERREF, type->md.member[MD_ATTR_CONTRACT] ); - value_size = make_contract_value( type, value ); + attr_type = customattribute_type( TABLE_MEMBERREF, attr->md_member ); + value_size = make_contract_value( attr, value ); add_customattribute_row( parent, attr_type, add_blob(value, value_size) ); }
-static void add_version_attr_step1( type_t *type ) +static void add_version_attr_step1( const type_t *type ) { static const BYTE sig[] = { SIG_TYPE_HASTHIS, 1, ELEMENT_TYPE_VOID, ELEMENT_TYPE_U4 }; UINT assemblyref, scope, typeref, class; + attr_t *attr;
- if (!is_attr( type->attrs, ATTR_VERSION ) && is_attr( type->attrs, ATTR_CONTRACT )) return; + if (!(attr = get_attr( type->attrs, ATTR_VERSION )) && is_attr( type->attrs, ATTR_CONTRACT )) return;
assemblyref = add_assemblyref_row( 0x200, 0, add_string("Windows.Foundation") ); scope = resolution_scope( TABLE_ASSEMBLYREF, assemblyref );
typeref = add_typeref_row( scope, add_string("VersionAttribute"), add_string("Windows.Foundation.Metadata") ); class = memberref_parent( TABLE_TYPEREF, typeref ); - type->md.member[MD_ATTR_VERSION] = add_memberref_row( class, add_string(".ctor"), add_blob(sig, sizeof(sig)) ); + attr->md_member = add_memberref_row( class, add_string(".ctor"), add_blob(sig, sizeof(sig)) ); }
-static void add_version_attr_step2( type_t *type ) +static void add_version_attr_step2( const type_t *type ) { UINT parent, attr_type, value_size; BYTE value[8]; + const attr_t *attr;
- if (!is_attr( type->attrs, ATTR_VERSION ) && is_attr( type->attrs, ATTR_CONTRACT )) return; + if (!(attr = get_attr( type->attrs, ATTR_VERSION )) && is_attr( type->attrs, ATTR_CONTRACT )) return;
parent = has_customattribute( TABLE_TYPEDEF, type->md.def ); - attr_type = customattribute_type( TABLE_MEMBERREF, type->md.member[MD_ATTR_VERSION] ); - value_size = make_version_value( type, value ); + attr_type = customattribute_type( TABLE_MEMBERREF, attr->md_member ); + value_size = make_version_value( attr, value ); add_customattribute_row( parent, attr_type, add_blob(value, value_size) ); }
-static void add_flags_attr_step1( type_t *type ) +static void add_flags_attr_step1( const type_t *type ) { static const BYTE sig[] = { SIG_TYPE_HASTHIS, 0, ELEMENT_TYPE_VOID }; UINT scope, typeref, class; + attr_t *attr;
- if (!is_attr( type->attrs, ATTR_FLAGS )) return; + if (!(attr = get_attr( type->attrs, ATTR_FLAGS ))) return;
scope = resolution_scope( TABLE_ASSEMBLYREF, MSCORLIB_ROW ); typeref = add_typeref_row( scope, add_string("FlagsAttribute"), add_string("System") ); class = memberref_parent( TABLE_TYPEREF, typeref ); - type->md.member[MD_ATTR_FLAGS] = add_memberref_row( class, add_string(".ctor"), add_blob(sig, sizeof(sig)) ); + attr->md_member = add_memberref_row( class, add_string(".ctor"), add_blob(sig, sizeof(sig)) ); }
-static void add_flags_attr_step2( type_t *type ) +static void add_flags_attr_step2( const type_t *type ) { static const BYTE value[] = { 0x01, 0x00, 0x00, 0x00 }; UINT parent, attr_type; + const attr_t *attr;
- if (!is_attr( type->attrs, ATTR_FLAGS )) return; + if (!(attr = get_attr( type->attrs, ATTR_FLAGS ))) return;
parent = has_customattribute( TABLE_TYPEDEF, type->md.def ); - attr_type = customattribute_type( TABLE_MEMBERREF, type->md.member[MD_ATTR_FLAGS] ); + attr_type = customattribute_type( TABLE_MEMBERREF, attr->md_member ); add_customattribute_row( parent, attr_type, add_blob(value, sizeof(value)) ); }
@@ -1983,42 +1999,46 @@ static void add_struct_type_step2( type_t *type ) add_contract_attr_step2( type ); }
-static void add_uuid_attr_step1( type_t *type ) +static void add_uuid_attr_step1( const type_t *type ) { static const BYTE sig[] = { SIG_TYPE_HASTHIS, 11, ELEMENT_TYPE_VOID, ELEMENT_TYPE_U4, ELEMENT_TYPE_U2, ELEMENT_TYPE_U2, ELEMENT_TYPE_U1, ELEMENT_TYPE_U1, ELEMENT_TYPE_U1, ELEMENT_TYPE_U1, ELEMENT_TYPE_U1, ELEMENT_TYPE_U1, ELEMENT_TYPE_U1, ELEMENT_TYPE_U1 }; UINT assemblyref, scope, typeref, class; + attr_t *attr; + + if (!(attr = get_attr( type->attrs, ATTR_UUID ))) return;
assemblyref = add_assemblyref_row( 0x200, 0, add_string("Windows.Foundation") ); scope = resolution_scope( TABLE_ASSEMBLYREF, assemblyref ); typeref = add_typeref_row( scope, add_string("GuidAttribute"), add_string("Windows.Foundation.Metadata") );
class = memberref_parent( TABLE_TYPEREF, typeref ); - type->md.member[MD_ATTR_UUID] = add_memberref_row( class, add_string(".ctor"), add_blob(sig, sizeof(sig)) ); + attr->md_member = add_memberref_row( class, add_string(".ctor"), add_blob(sig, sizeof(sig)) ); }
-static void add_uuid_attr_step2( type_t *type ) +static void add_uuid_attr_step2( const type_t *type ) { - static const BYTE default_uuid[] = - { 0xe7, 0x1f, 0xb5, 0x67, 0x6e, 0x38, 0x31, 0x5a, 0x8a, 0x1c, 0x89, 0x83, 0xc9, 0x49, 0x5c, 0x33 }; - const struct uuid *uuid = get_attrp( type->attrs, ATTR_UUID ); + const struct uuid *uuid; BYTE value[sizeof(*uuid) + 4] = { 0x01 }; UINT parent, attr_type; + const attr_t *attr; + + if (!(attr = get_attr( type->attrs, ATTR_UUID ))) return;
- if (uuid) memcpy( value + 2, uuid, sizeof(*uuid) ); - else memcpy( value + 2, default_uuid, sizeof(default_uuid) ); + uuid = attr->u.pval; + memcpy( value + 2, uuid, sizeof(*uuid) );
parent = has_customattribute( TABLE_TYPEDEF, type->md.def ); - attr_type = customattribute_type( TABLE_MEMBERREF, type->md.member[MD_ATTR_UUID] ); + attr_type = customattribute_type( TABLE_MEMBERREF, attr->md_member ); add_customattribute_row( parent, attr_type, add_blob(value, sizeof(value)) ); }
-static UINT make_exclusiveto_value( const type_t *type, BYTE *buf ) +static UINT make_exclusiveto_value( const attr_t *attr, BYTE *buf ) { - const type_t *attr = get_attrp( type->attrs, ATTR_EXCLUSIVETO ); - char *name = format_namespace( attr->namespace, "", ".", attr->name, NULL ); + const type_t *type = attr->u.pval; + char *name = format_namespace( type->namespace, "", ".", type->name, NULL ); UINT len = strlen( name );
buf[0] = 1; @@ -2033,12 +2053,13 @@ static UINT make_exclusiveto_value( const type_t *type, BYTE *buf ) return len; }
-static void add_exclusiveto_attr_step1( type_t *type ) +static void add_exclusiveto_attr_step1( const type_t *type ) { UINT assemblyref, scope, typeref, typeref_type, class, sig_size; BYTE sig[32]; + attr_t *attr;
- if (!is_attr( type->attrs, ATTR_EXCLUSIVETO )) return; + if (!(attr = get_attr( type->attrs, ATTR_EXCLUSIVETO ))) return;
scope = resolution_scope( TABLE_ASSEMBLYREF, MSCORLIB_ROW ); typeref_type = add_typeref_row( scope, add_string("Type"), add_string("System") ); @@ -2049,30 +2070,31 @@ static void add_exclusiveto_attr_step1( type_t *type )
class = memberref_parent( TABLE_TYPEREF, typeref ); sig_size = make_member_sig2( ELEMENT_TYPE_CLASS, typedef_or_ref(TABLE_TYPEREF, typeref_type), sig ); - type->md.member[MD_ATTR_EXCLUSIVETO] = add_memberref_row( class, add_string(".ctor"), add_blob(sig, sig_size) ); + attr->md_member = add_memberref_row( class, add_string(".ctor"), add_blob(sig, sig_size) ); }
-static void add_exclusiveto_attr_step2( type_t *type ) +static void add_exclusiveto_attr_step2( const type_t *type ) { UINT parent, attr_type, value_size; BYTE value[MAX_NAME + 5]; + const attr_t *attr;
- if (!is_attr( type->attrs, ATTR_EXCLUSIVETO )) return; + if (!(attr = get_attr( type->attrs, ATTR_EXCLUSIVETO ))) return;
parent = has_customattribute( TABLE_TYPEDEF, type->md.def ); - attr_type = customattribute_type( TABLE_MEMBERREF, type->md.member[MD_ATTR_EXCLUSIVETO] ); - value_size = make_exclusiveto_value( type, value ); + attr_type = customattribute_type( TABLE_MEMBERREF, attr->md_member ); + value_size = make_exclusiveto_value( attr, value ); add_customattribute_row( parent, attr_type, add_blob(value, value_size) ); }
-static UINT make_overload_value( const var_t *method, BYTE *buf ) +static UINT make_overload_value( const char *name, BYTE *buf ) { - UINT len = strlen( method->name ); + UINT len = strlen( name );
buf[0] = 1; buf[1] = 0; buf[2] = len; - memcpy( buf + 3, method->name, len ); + memcpy( buf + 3, name, len ); len += 3; buf[len++] = 0; buf[len++] = 0; @@ -2084,16 +2106,16 @@ static void add_overload_attr_step1( const var_t *method ) { static const BYTE sig[] = { SIG_TYPE_HASTHIS, 1, ELEMENT_TYPE_VOID, ELEMENT_TYPE_STRING }; UINT assemblyref, scope, typeref, class; - type_t *type = method->declspec.type; + attr_t *attr;
- if (!is_attr( method->attrs, ATTR_OVERLOAD )) return; + if (!(attr = get_attr( method->attrs, ATTR_OVERLOAD ))) return;
assemblyref = add_assemblyref_row( 0x200, 0, add_string("Windows.Foundation") ); scope = resolution_scope( TABLE_ASSEMBLYREF, assemblyref ); typeref = add_typeref_row( scope, add_string("OverloadAttribute"), add_string("Windows.Foundation.Metadata") );
class = memberref_parent( TABLE_TYPEREF, typeref ); - type->md.member[MD_ATTR_OVERLOAD] = add_memberref_row( class, add_string(".ctor"), add_blob(sig, sizeof(sig)) ); + attr->md_member = add_memberref_row( class, add_string(".ctor"), add_blob(sig, sizeof(sig)) ); }
static void add_overload_attr_step2( const var_t *method ) @@ -2101,12 +2123,13 @@ static void add_overload_attr_step2( const var_t *method ) const type_t *type = method->declspec.type; UINT parent, attr_type, value_size; BYTE value[MAX_NAME + 5]; + const attr_t *attr;
- if (!is_attr( method->attrs, ATTR_OVERLOAD )) return; + if (!(attr = get_attr( method->attrs, ATTR_OVERLOAD ))) return;
parent = has_customattribute( TABLE_METHODDEF, type->md.def ); - attr_type = customattribute_type( TABLE_MEMBERREF, type->md.member[MD_ATTR_OVERLOAD] ); - value_size = make_overload_value( method, value ); + attr_type = customattribute_type( TABLE_MEMBERREF, attr->md_member ); + value_size = make_overload_value( method->name, value ); add_customattribute_row( parent, attr_type, add_blob(value, value_size) ); }
@@ -2114,16 +2137,16 @@ static void add_default_overload_attr_step1( const var_t *method ) { static const BYTE sig[] = { SIG_TYPE_HASTHIS, 0, ELEMENT_TYPE_VOID }; UINT assemblyref, scope, typeref, class; - type_t *type = method->declspec.type; + attr_t *attr;
- if (!is_attr( method->attrs, ATTR_DEFAULT_OVERLOAD ) || !is_attr( method->attrs, ATTR_OVERLOAD )) return; + if (!(attr = get_attr( method->attrs, ATTR_DEFAULT_OVERLOAD )) || !is_attr( method->attrs, ATTR_OVERLOAD )) return;
assemblyref = add_assemblyref_row( 0x200, 0, add_string("Windows.Foundation") ); scope = resolution_scope( TABLE_ASSEMBLYREF, assemblyref ); typeref = add_typeref_row( scope, add_string("DefaultOverloadAttribute"), add_string("Windows.Foundation.Metadata") );
class = memberref_parent( TABLE_TYPEREF, typeref ); - type->md.member[MD_ATTR_DEFAULT_OVERLOAD] = add_memberref_row( class, add_string(".ctor"), add_blob(sig, sizeof(sig)) ); + attr->md_member = add_memberref_row( class, add_string(".ctor"), add_blob(sig, sizeof(sig)) ); }
static void add_default_overload_attr_step2( const var_t *method ) @@ -2131,21 +2154,22 @@ static void add_default_overload_attr_step2( const var_t *method ) static const BYTE value[] = { 0x01, 0x00, 0x00, 0x00 }; const type_t *type = method->declspec.type; UINT parent, attr_type; + const attr_t *attr;
- if (!is_attr( method->attrs, ATTR_DEFAULT_OVERLOAD ) || !is_attr( method->attrs, ATTR_OVERLOAD )) return; + if (!(attr = get_attr( method->attrs, ATTR_DEFAULT_OVERLOAD )) || !is_attr( method->attrs, ATTR_OVERLOAD )) return;
parent = has_customattribute( TABLE_METHODDEF, type->md.def ); - attr_type = customattribute_type( TABLE_MEMBERREF, type->md.member[MD_ATTR_DEFAULT_OVERLOAD] ); + attr_type = customattribute_type( TABLE_MEMBERREF, attr->md_member ); add_customattribute_row( parent, attr_type, add_blob(value, sizeof(value)) ); }
-static UINT make_deprecated_value( const var_t *method, BYTE **ret_buf ) +static UINT make_deprecated_value( const attr_t *attr, BYTE **ret_buf ) { static const BYTE zero[] = { 0x00, 0x00, 0x00, 0x00 }, one[] = { 0x01, 0x00, 0x00, 0x00 }; - const expr_t *attr = get_attrp( method->attrs, ATTR_DEPRECATED ); - const type_t *type = attr->ext2->u.var->declspec.type; - const char *text = attr->ref->u.sval; - const char *kind = attr->u.ext->u.sval; + const expr_t *expr = attr->u.pval; + const type_t *type = expr->ext2->u.var->declspec.type; + const char *text = expr->ref->u.sval; + const char *kind = expr->u.ext->u.sval; BYTE encoded[4]; UINT len, len_text = strlen( text ), len_encoded = encode_int( len_text, encoded ); BYTE *buf = xmalloc( 2 + len_encoded + len_text + 6 + MAX_NAME + 5 ); @@ -2181,10 +2205,10 @@ static UINT make_deprecated_value( const var_t *method, BYTE **ret_buf ) static void add_deprecated_attr_step1( const var_t *method ) { UINT assemblyref, scope, typeref_type, typeref, class, sig_size; - type_t *type = method->declspec.type; BYTE sig[32]; + attr_t *attr;
- if (!is_attr( method->attrs, ATTR_DEPRECATED )) return; + if (!(attr = get_attr( method->attrs, ATTR_DEPRECATED ))) return;
assemblyref = add_assemblyref_row( 0x200, 0, add_string("Windows.Foundation") ); scope = resolution_scope( TABLE_ASSEMBLYREF, assemblyref ); @@ -2193,7 +2217,7 @@ static void add_deprecated_attr_step1( const var_t *method )
sig_size = make_deprecated_sig( typedef_or_ref(TABLE_TYPEREF, typeref_type), sig ); class = memberref_parent( TABLE_TYPEREF, typeref ); - type->md.member[MD_ATTR_DEPRECATED] = add_memberref_row( class, add_string(".ctor"), add_blob(sig, sig_size) ); + attr->md_member = add_memberref_row( class, add_string(".ctor"), add_blob(sig, sig_size) ); }
static void add_deprecated_attr_step2( const var_t *method ) @@ -2201,12 +2225,13 @@ static void add_deprecated_attr_step2( const var_t *method ) const type_t *type = method->declspec.type; UINT parent, attr_type, value_size; BYTE *value; + const attr_t *attr;
- if (!is_attr( method->attrs, ATTR_DEPRECATED )) return; + if (!(attr = get_attr( method->attrs, ATTR_DEPRECATED ))) return;
parent = has_customattribute( TABLE_METHODDEF, type->md.def ); - attr_type = customattribute_type( TABLE_MEMBERREF, type->md.member[MD_ATTR_DEPRECATED] ); - value_size = make_deprecated_value( method, &value ); + attr_type = customattribute_type( TABLE_MEMBERREF, attr->md_member ); + value_size = make_deprecated_value( attr, &value ); add_customattribute_row( parent, attr_type, add_blob(value, value_size) ); free( value ); } @@ -2593,9 +2618,9 @@ static void add_interface_type_step2( type_t *type ) add_exclusiveto_attr_step2( type ); }
-static UINT make_contractversion_value( const type_t *type, BYTE *buf ) +static UINT make_contractversion_value( const attr_t *attr, BYTE *buf ) { - UINT version = get_attrv( type->attrs, ATTR_CONTRACTVERSION ), len = 2 + sizeof(version); + UINT version = attr ? attr->u.ival : 0, len = 2 + sizeof(version);
buf[0] = 1; buf[1] = 0; @@ -2605,54 +2630,62 @@ static UINT make_contractversion_value( const type_t *type, BYTE *buf ) return len; }
-static void add_contractversion_attr_step1( type_t *type ) +static void add_contractversion_attr_step1( const type_t *type ) { static const BYTE sig[] = { SIG_TYPE_HASTHIS, 1, ELEMENT_TYPE_VOID, ELEMENT_TYPE_U4 }; UINT assemblyref, scope, typeref, class; + attr_t *attr;
- if (!is_attr( type->attrs, ATTR_CONTRACTVERSION )) return; + if (!(attr = get_attr( type->attrs, ATTR_CONTRACTVERSION ))) return;
assemblyref = add_assemblyref_row( 0x200, 0, add_string("Windows.Foundation") ); scope = resolution_scope( TABLE_ASSEMBLYREF, assemblyref ); typeref = add_typeref_row( scope, add_string("ContractVersionAttribute"), add_string("Windows.Foundation.Metadata") );
class = memberref_parent( TABLE_TYPEREF, typeref ); - type->md.member[MD_ATTR_CONTRACTVERSION] = add_memberref_row( class, add_string(".ctor"), add_blob(sig, sizeof(sig)) ); + attr->md_member = add_memberref_row( class, add_string(".ctor"), add_blob(sig, sizeof(sig)) ); }
-static void add_contractversion_attr_step2( type_t *type ) +static void add_contractversion_attr_step2( const type_t *type ) { UINT parent, attr_type, value_size; BYTE value[8]; + const attr_t *attr;
- if (!is_attr( type->attrs, ATTR_CONTRACTVERSION )) return; + if (!(attr = get_attr( type->attrs, ATTR_CONTRACTVERSION ))) return;
parent = has_customattribute( TABLE_TYPEDEF, type->md.def ); - attr_type = customattribute_type( TABLE_MEMBERREF, type->md.member[MD_ATTR_CONTRACTVERSION] ); - value_size = make_contractversion_value( type, value ); + attr_type = customattribute_type( TABLE_MEMBERREF, attr->md_member ); + value_size = make_contractversion_value( attr, value ); add_customattribute_row( parent, attr_type, add_blob(value, value_size) ); }
-static void add_apicontract_attr_step1( type_t *type ) +static void add_apicontract_attr_step1( const type_t *type ) { static const BYTE sig[] = { SIG_TYPE_HASTHIS, 0, ELEMENT_TYPE_VOID }; UINT assemblyref, scope, typeref, class; + attr_t *attr; + + if (!(attr = get_attr( type->attrs, ATTR_APICONTRACT ))) return;
assemblyref = add_assemblyref_row( 0x200, 0, add_string("Windows.Foundation") ); scope = resolution_scope( TABLE_ASSEMBLYREF, assemblyref ); typeref = add_typeref_row( scope, add_string("ApiContractAttribute"), add_string("Windows.Foundation.Metadata") );
class = memberref_parent( TABLE_TYPEREF, typeref ); - type->md.member[MD_ATTR_APICONTRACT] = add_memberref_row( class, add_string(".ctor"), add_blob(sig, sizeof(sig)) ); + attr->md_member = add_memberref_row( class, add_string(".ctor"), add_blob(sig, sizeof(sig)) ); }
-static void add_apicontract_attr_step2( type_t *type ) +static void add_apicontract_attr_step2( const type_t *type ) { static const BYTE value[] = { 0x01, 0x00, 0x00, 0x00 }; UINT parent, attr_type; + const attr_t *attr; + + if (!(attr = get_attr( type->attrs, ATTR_APICONTRACT ))) return;
parent = has_customattribute( TABLE_TYPEDEF, type->md.def ); - attr_type = customattribute_type( TABLE_MEMBERREF, type->md.member[MD_ATTR_APICONTRACT] ); + attr_type = customattribute_type( TABLE_MEMBERREF, attr->md_member ); add_customattribute_row( parent, attr_type, add_blob(value, sizeof(value)) ); }
@@ -2693,7 +2726,7 @@ static void add_runtimeclass_type_step1( type_t *type ) type->md.ref = add_typeref_row( resolution_scope(TABLE_MODULE, MODULE_ROW), name, namespace ); }
-static void add_default_attr( const type_t *type, UINT interfaceimpl_ref ) +static void add_default_attr( UINT interfaceimpl_ref ) { static const BYTE sig[] = { SIG_TYPE_HASTHIS, 0, ELEMENT_TYPE_VOID }; static const BYTE value[] = { 0x01, 0x00, 0x00, 0x00 }; @@ -2733,10 +2766,11 @@ static void add_method_contract_attrs( const type_t *class, const type_t *iface, { UINT parent, attr_type, value_size; BYTE value[MAX_NAME + sizeof(UINT) + 5]; + const attr_t *attr = get_attr( iface->attrs, ATTR_CONTRACT );
parent = has_customattribute( TABLE_METHODDEF, method->md.def ); - attr_type = customattribute_type( TABLE_MEMBERREF, iface->md.member[MD_ATTR_CONTRACT] ); - value_size = make_contract_value( class, value ); + attr_type = customattribute_type( TABLE_MEMBERREF, attr->md_member ); + value_size = make_contract_value( get_attr(class->attrs, ATTR_CONTRACT), value ); add_customattribute_row( parent, attr_type, add_blob(value, value_size) );
if (method->md.class_property) @@ -2781,12 +2815,13 @@ static UINT make_static_value( const expr_t *attr, BYTE *buf ) return len_iface + len_contract + 10; }
-static void add_static_attr_step1( type_t *type ) +static void add_static_attr_step1( const type_t *type ) { UINT assemblyref, scope, typeref, typeref_type, class, sig_size; BYTE sig[32]; + attr_t *attr;
- if (!is_attr( type->attrs, ATTR_STATIC )) return; + if (!(attr = get_attr( type->attrs, ATTR_STATIC ))) return;
assemblyref = add_assemblyref_row( 0x200, 0, add_string("Windows.Foundation") ); scope = resolution_scope( TABLE_ASSEMBLYREF, assemblyref ); @@ -2797,10 +2832,10 @@ static void add_static_attr_step1( type_t *type )
class = memberref_parent( TABLE_TYPEREF, typeref ); sig_size = make_member_sig3( typedef_or_ref(TABLE_TYPEREF, typeref_type), sig ); - type->md.member[MD_ATTR_STATIC] = add_memberref_row( class, add_string(".ctor"), add_blob(sig, sig_size) ); + attr->md_member = add_memberref_row( class, add_string(".ctor"), add_blob(sig, sig_size) ); }
-static void add_static_attr_step2( type_t *type ) +static void add_static_attr_step2( const type_t *type ) { const attr_t *attr;
@@ -2812,7 +2847,7 @@ static void add_static_attr_step2( type_t *type ) if (attr->type != ATTR_STATIC) continue;
parent = has_customattribute( TABLE_TYPEDEF, type->md.def ); - attr_type = customattribute_type( TABLE_MEMBERREF, type->md.member[MD_ATTR_STATIC] ); + attr_type = customattribute_type( TABLE_MEMBERREF, attr->md_member ); value_size = make_static_value( attr->u.pval, value ); add_customattribute_row( parent, attr_type, add_blob(value, value_size) ); } @@ -2870,7 +2905,7 @@ static UINT make_activatable_value( const expr_t *attr, BYTE *buf ) return len_iface + sizeof(version) + len_contract + len_extra; }
-static void add_activatable_attr_step1( type_t *type ) +static void add_activatable_attr_step1( const type_t *type ) { static const BYTE sig_default[] = { SIG_TYPE_HASTHIS, 2, ELEMENT_TYPE_VOID, ELEMENT_TYPE_U4, ELEMENT_TYPE_STRING }; attr_t *attr; @@ -2904,7 +2939,7 @@ static void add_activatable_attr_step1( type_t *type ) } }
-static void add_activatable_attr_step2( type_t *type ) +static void add_activatable_attr_step2( const type_t *type ) { const attr_t *attr;
@@ -2922,9 +2957,9 @@ static void add_activatable_attr_step2( type_t *type ) } }
-static UINT make_threading_value( const type_t *type, BYTE *buf ) +static UINT make_threading_value( const attr_t *attr, BYTE *buf ) { - UINT value, model = get_attrv( type->attrs, ATTR_THREADING ); + UINT value, model = attr->u.ival;
switch (model) { @@ -2949,12 +2984,13 @@ static UINT make_threading_value( const type_t *type, BYTE *buf ) return 8; }
-static void add_threading_attr_step1( type_t *type ) +static void add_threading_attr_step1( const type_t *type ) { UINT assemblyref, scope, typeref, typeref_attr, class, sig_size; BYTE sig[32]; + attr_t *attr;
- if (!is_attr( type->attrs, ATTR_THREADING )) return; + if (!(attr = get_attr( type->attrs, ATTR_THREADING ))) return;
assemblyref = add_assemblyref_row( 0x200, 0, add_string("Windows.Foundation") ); scope = resolution_scope( TABLE_ASSEMBLYREF, assemblyref ); @@ -2965,25 +3001,26 @@ static void add_threading_attr_step1( type_t *type )
class = memberref_parent( TABLE_TYPEREF, typeref_attr ); sig_size = make_member_sig2( ELEMENT_TYPE_VALUETYPE, typedef_or_ref(TABLE_TYPEREF, typeref), sig ); - type->md.member[MD_ATTR_THREADING] = add_memberref_row( class, add_string(".ctor"), add_blob(sig, sig_size) ); + attr->md_member = add_memberref_row( class, add_string(".ctor"), add_blob(sig, sig_size) ); }
-static void add_threading_attr_step2( type_t *type ) +static void add_threading_attr_step2( const type_t *type ) { UINT parent, attr_type, value_size; BYTE value[8]; + const attr_t *attr;
- if (!is_attr( type->attrs, ATTR_THREADING )) return; + if (!(attr = get_attr( type->attrs, ATTR_THREADING ))) return;
parent = has_customattribute( TABLE_TYPEDEF, type->md.def ); - attr_type = customattribute_type( TABLE_MEMBERREF, type->md.member[MD_ATTR_THREADING] ); - value_size = make_threading_value( type, value ); + attr_type = customattribute_type( TABLE_MEMBERREF, attr->md_member ); + value_size = make_threading_value( attr, value ); add_customattribute_row( parent, attr_type, add_blob(value, value_size) ); }
-static UINT make_marshalingbehavior_value( const type_t *type, BYTE *buf ) +static UINT make_marshalingbehavior_value( const attr_t *attr, BYTE *buf ) { - UINT marshaling = get_attrv( type->attrs, ATTR_MARSHALING_BEHAVIOR ); + UINT marshaling = attr->u.ival;
buf[0] = 1; buf[1] = 0; @@ -2992,12 +3029,13 @@ static UINT make_marshalingbehavior_value( const type_t *type, BYTE *buf ) return 8; }
-static void add_marshalingbehavior_attr_step1( type_t *type ) +static void add_marshalingbehavior_attr_step1( const type_t *type ) { UINT assemblyref, scope, typeref, typeref_attr, class, sig_size; BYTE sig[32]; + attr_t *attr;
- if (!is_attr( type->attrs, ATTR_MARSHALING_BEHAVIOR )) return; + if (!(attr = get_attr( type->attrs, ATTR_MARSHALING_BEHAVIOR ))) return;
assemblyref = add_assemblyref_row( 0x200, 0, add_string("Windows.Foundation") ); scope = resolution_scope( TABLE_ASSEMBLYREF, assemblyref ); @@ -3008,19 +3046,20 @@ static void add_marshalingbehavior_attr_step1( type_t *type )
class = memberref_parent( TABLE_TYPEREF, typeref_attr ); sig_size = make_member_sig2( ELEMENT_TYPE_VALUETYPE, typedef_or_ref(TABLE_TYPEREF, typeref), sig ); - type->md.member[MD_ATTR_MARSHALINGBEHAVIOR] = add_memberref_row( class, add_string(".ctor"), add_blob(sig, sig_size) ); + attr->md_member = add_memberref_row( class, add_string(".ctor"), add_blob(sig, sig_size) ); }
-static void add_marshalingbehavior_attr_step2( type_t *type ) +static void add_marshalingbehavior_attr_step2( const type_t *type ) { UINT parent, attr_type, value_size; BYTE value[8]; + const attr_t *attr;
- if (!is_attr( type->attrs, ATTR_MARSHALING_BEHAVIOR )) return; + if (!(attr = get_attr( type->attrs, ATTR_MARSHALING_BEHAVIOR ))) return;
parent = has_customattribute( TABLE_TYPEDEF, type->md.def ); - attr_type = customattribute_type( TABLE_MEMBERREF, type->md.member[MD_ATTR_MARSHALINGBEHAVIOR] ); - value_size = make_marshalingbehavior_value( type, value ); + attr_type = customattribute_type( TABLE_MEMBERREF, attr->md_member ); + value_size = make_marshalingbehavior_value( attr, value ); add_customattribute_row( parent, attr_type, add_blob(value, value_size) ); }
@@ -3063,7 +3102,7 @@ static UINT make_composable_value( const expr_t *attr, BYTE *buf ) return len_iface + sizeof(access_type) + sizeof(contract_version) + len_contract + 6; }
-static void add_composable_attr_step1( type_t *type ) +static void add_composable_attr_step1( const type_t *type ) { attr_t *attr;
@@ -3088,7 +3127,7 @@ static void add_composable_attr_step1( type_t *type ) } }
-static void add_composable_attr_step2( type_t *type ) +static void add_composable_attr_step2( const type_t *type ) { const attr_t *attr;
@@ -3117,7 +3156,7 @@ static void add_member_interfaces( type_t *class ) UINT interfaceimpl_ref = add_interfaceimpl_row( class->md.def, interface ); const statement_t *stmt;
- if (is_attr( iface->attrs, ATTR_DEFAULT )) add_default_attr( class, interfaceimpl_ref ); + if (is_attr( iface->attrs, ATTR_DEFAULT )) add_default_attr( interfaceimpl_ref );
/* add properties in reverse order like midlrt */ STATEMENTS_FOR_EACH_FUNC_REV( stmt, type_iface_get_stmts(iface->type) ) @@ -3168,7 +3207,7 @@ static void add_static_interfaces( type_t *class ) static void add_activation_interfaces( const type_t *class ) { UINT flags = METHOD_ATTR_PUBLIC | METHOD_ATTR_HIDEBYSIG | METHOD_ATTR_SPECIALNAME | METHOD_ATTR_RTSPECIALNAME; - const attr_t *attr; + const attr_t *attr, *contract_attr = get_attr( class->attrs, ATTR_CONTRACT );
if (class->attrs) LIST_FOR_EACH_ENTRY_REV( attr, class->attrs, const attr_t, entry ) { @@ -3203,8 +3242,8 @@ static void add_activation_interfaces( const type_t *class ) methoddef = add_methoddef_row( METHOD_IMPL_RUNTIME, flags, add_string(".ctor"), add_blob(sig, sig_size), paramlist );
parent = has_customattribute( TABLE_METHODDEF, methoddef ); - attr_type = customattribute_type( TABLE_MEMBERREF, class->md.member[MD_ATTR_CONTRACT] ); - value_size = make_contract_value( class, value ); + attr_type = customattribute_type( TABLE_MEMBERREF, contract_attr->md_member ); + value_size = make_contract_value( contract_attr, value ); add_customattribute_row( parent, attr_type, add_blob(value, value_size) ); } } @@ -3212,7 +3251,7 @@ static void add_activation_interfaces( const type_t *class ) static void add_composition_interfaces( const type_t *class ) { UINT flags = METHOD_ATTR_FAMILY | METHOD_ATTR_HIDEBYSIG | METHOD_ATTR_SPECIALNAME | METHOD_ATTR_RTSPECIALNAME; - const attr_t *attr; + const attr_t *attr, *contract_attr = get_attr( class->attrs, ATTR_CONTRACT );
if (class->attrs) LIST_FOR_EACH_ENTRY_REV( attr, class->attrs, const attr_t, entry ) { @@ -3248,8 +3287,8 @@ static void add_composition_interfaces( const type_t *class ) methoddef = add_methoddef_row( METHOD_IMPL_RUNTIME, flags, add_string(".ctor"), add_blob(sig, sig_size), paramlist );
parent = has_customattribute( TABLE_METHODDEF, methoddef ); - attr_type = customattribute_type( TABLE_MEMBERREF, class->md.member[MD_ATTR_CONTRACT] ); - value_size = make_contract_value( class, value ); + attr_type = customattribute_type( TABLE_MEMBERREF, contract_attr->md_member ); + value_size = make_contract_value( contract_attr, value ); add_customattribute_row( parent, attr_type, add_blob(value, value_size) ); } } diff --git a/tools/widl/widltypes.h b/tools/widl/widltypes.h index 36d7a179b06..558699bb2a6 100644 --- a/tools/widl/widltypes.h +++ b/tools/widl/widltypes.h @@ -345,10 +345,11 @@ struct _attr_t { unsigned int ival; void *pval; } u; + /* metadata */ + unsigned int md_member; /* parser-internal */ struct list entry; struct location where; - unsigned int md_member; };
struct integer @@ -500,30 +501,11 @@ enum type_type TYPE_DELEGATE, };
-enum -{ - MD_ATTR_CONTRACT, - MD_ATTR_FLAGS, - MD_ATTR_APICONTRACT, - MD_ATTR_CONTRACTVERSION, - MD_ATTR_VERSION, - MD_ATTR_UUID, - MD_ATTR_EXCLUSIVETO, - MD_ATTR_STATIC, - MD_ATTR_THREADING, - MD_ATTR_MARSHALINGBEHAVIOR, - MD_ATTR_OVERLOAD, - MD_ATTR_DEFAULT_OVERLOAD, - MD_ATTR_DEPRECATED, - MD_ATTR_MAX, -}; - struct metadata { unsigned int ref; unsigned int def; unsigned int extends; - unsigned int member[MD_ATTR_MAX]; /* get/put methods */ unsigned int class_property; unsigned int iface_property;
Rémi Bernon (@rbernon) commented about tools/widl/parser.y:
;
contract_ver:
aNUM { $$ = MAKEVERSION(0, $1.value); }
- | aNUM '.' aNUM { $$ = MAKEVERSION($3.value, $1.value); }
aNUM { $$ = make_version( 0, $1.value ); }
- | aNUM '.' aNUM { $$ = make_version( $3.value, $1.value ); } ;
contract_req : decl_spec ',' contract_ver {
struct integer integer = {.value = $3};
struct integer integer = {.value = $3->major | $3->minor };
```suggestion:-0+0 struct integer integer = {.value = ($3->major << 16) | $3->minor }; ```
I think?