Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- tools/widl/parser.l | 1 + tools/widl/parser.y | 3 +++ tools/widl/widltypes.h | 1 + 3 files changed, 5 insertions(+)
diff --git a/tools/widl/parser.l b/tools/widl/parser.l index 6bbfed5e80b..450d92f5926 100644 --- a/tools/widl/parser.l +++ b/tools/widl/parser.l @@ -362,6 +362,7 @@ static const struct keyword attr_keywords[] = {"exclusiveto", tEXCLUSIVETO, 1}, {"explicit_handle", tEXPLICITHANDLE, 0}, {"fault_status", tFAULTSTATUS, 0}, + {"flags", tFLAGS, 1}, {"force_allocate", tFORCEALLOCATE, 0}, {"free", tFREE, 0}, {"handle", tHANDLE, 0}, diff --git a/tools/widl/parser.y b/tools/widl/parser.y index d12caa06b63..ef54bf13ded 100644 --- a/tools/widl/parser.y +++ b/tools/widl/parser.y @@ -201,6 +201,7 @@ static typelib_t *current_typelib; %token tEXPLICITHANDLE tEXTERN %token tFALSE %token tFASTCALL tFAULTSTATUS +%token tFLAGS %token tFLOAT tFORCEALLOCATE %token tHANDLE %token tHANDLET @@ -576,6 +577,7 @@ attribute: { $$ = NULL; } $$ = make_attrp(ATTR_EXCLUSIVETO, $3->type); } | tEXPLICITHANDLE { $$ = make_attr(ATTR_EXPLICIT_HANDLE); } | tFAULTSTATUS { $$ = make_attr(ATTR_FAULTSTATUS); } + | tFLAGS { $$ = make_attr(ATTR_FLAGS); } | tFORCEALLOCATE { $$ = make_attr(ATTR_FORCEALLOCATE); } | tHANDLE { $$ = make_attr(ATTR_HANDLE); } | tHELPCONTEXT '(' expr_int_const ')' { $$ = make_attrp(ATTR_HELPCONTEXT, $3); } @@ -2259,6 +2261,7 @@ struct allowed_attr allowed_attr[] = /* ATTR_EXCLUSIVETO */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "exclusive_to" }, /* ATTR_EXPLICIT_HANDLE */ { 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "explicit_handle" }, /* ATTR_FAULTSTATUS */ { 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "fault_status" }, + /* ATTR_FLAGS */ { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "flags" }, /* ATTR_FORCEALLOCATE */ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "force_allocate" }, /* ATTR_HANDLE */ { 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "handle" }, /* ATTR_HELPCONTEXT */ { 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, "helpcontext" }, diff --git a/tools/widl/widltypes.h b/tools/widl/widltypes.h index 46a44dac039..7b634c82242 100644 --- a/tools/widl/widltypes.h +++ b/tools/widl/widltypes.h @@ -106,6 +106,7 @@ enum attr_type ATTR_EXCLUSIVETO, ATTR_EXPLICIT_HANDLE, ATTR_FAULTSTATUS, + ATTR_FLAGS, ATTR_FORCEALLOCATE, ATTR_HANDLE, ATTR_HELPCONTEXT,
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- tools/widl/header.c | 4 ++++ tools/widl/parser.l | 2 ++ tools/widl/parser.y | 7 +++++++ tools/widl/widltypes.h | 2 ++ 4 files changed, 15 insertions(+)
diff --git a/tools/widl/header.c b/tools/widl/header.c index ad205df0d05..63389440c94 100644 --- a/tools/widl/header.c +++ b/tools/widl/header.c @@ -185,6 +185,10 @@ const char *get_name(const var_t *v) { static char *buffer; free( buffer ); + if (is_attr( v->attrs, ATTR_EVENTADD )) + return buffer = strmake( "add_%s", v->name ); + if (is_attr( v->attrs, ATTR_EVENTREMOVE )) + return buffer = strmake( "remove_%s", v->name ); if (is_attr( v->attrs, ATTR_PROPGET )) return buffer = strmake( "get_%s", v->name ); if (is_attr( v->attrs, ATTR_PROPPUT )) diff --git a/tools/widl/parser.l b/tools/widl/parser.l index 450d92f5926..7e20d30e7f0 100644 --- a/tools/widl/parser.l +++ b/tools/widl/parser.l @@ -359,6 +359,8 @@ static const struct keyword attr_keywords[] = {"encode", tENCODE, 0}, {"endpoint", tENDPOINT, 0}, {"entry", tENTRY, 0}, + {"eventadd", tEVENTADD, 1}, + {"eventremove", tEVENTREMOVE, 1}, {"exclusiveto", tEXCLUSIVETO, 1}, {"explicit_handle", tEXPLICITHANDLE, 0}, {"fault_status", tFAULTSTATUS, 0}, diff --git a/tools/widl/parser.y b/tools/widl/parser.y index ef54bf13ded..480552e3723 100644 --- a/tools/widl/parser.y +++ b/tools/widl/parser.y @@ -197,6 +197,7 @@ static typelib_t *current_typelib; %token tDLLNAME tDONTFREE tDOUBLE tDUAL %token tENABLEALLOCATE tENCODE tENDPOINT %token tENTRY tENUM tERRORSTATUST +%token tEVENTADD tEVENTREMOVE %token tEXCLUSIVETO %token tEXPLICITHANDLE tEXTERN %token tFALSE @@ -572,6 +573,8 @@ attribute: { $$ = NULL; } | tENCODE { $$ = make_attr(ATTR_ENCODE); } | tENDPOINT '(' str_list ')' { $$ = make_attrp(ATTR_ENDPOINT, $3); } | tENTRY '(' expr_const ')' { $$ = make_attrp(ATTR_ENTRY, $3); } + | tEVENTADD { $$ = make_attr(ATTR_EVENTADD); } + | tEVENTREMOVE { $$ = make_attr(ATTR_EVENTREMOVE); } | tEXCLUSIVETO '(' decl_spec ')' { if ($3->type->type_type != TYPE_RUNTIMECLASS) error_loc("type %s is not a runtimeclass\n", $3->type->name); $$ = make_attrp(ATTR_EXCLUSIVETO, $3->type); } @@ -2258,6 +2261,8 @@ struct allowed_attr allowed_attr[] = /* ATTR_ENCODE */ { 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "encode" }, /* ATTR_ENDPOINT */ { 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "endpoint" }, /* ATTR_ENTRY */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "entry" }, + /* ATTR_EVENTADD */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "eventadd" }, + /* ATTR_EVENTREMOVE */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "eventremove" }, /* ATTR_EXCLUSIVETO */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "exclusive_to" }, /* ATTR_EXPLICIT_HANDLE */ { 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "explicit_handle" }, /* ATTR_FAULTSTATUS */ { 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "fault_status" }, @@ -2932,6 +2937,8 @@ static void check_functions(const type_t *iface, int is_inside_library) { if (func == func_iter) break; if (strcmp(func->name, func_iter->name)) continue; + if (is_attr(func->attrs, ATTR_EVENTADD) != is_attr(func_iter->attrs, ATTR_EVENTADD)) continue; + if (is_attr(func->attrs, ATTR_EVENTREMOVE) != is_attr(func_iter->attrs, ATTR_EVENTREMOVE)) continue; if (is_attr(func->attrs, ATTR_PROPGET) != is_attr(func_iter->attrs, ATTR_PROPGET)) continue; if (is_attr(func->attrs, ATTR_PROPPUT) != is_attr(func_iter->attrs, ATTR_PROPPUT)) continue; if (is_attr(func->attrs, ATTR_PROPPUTREF) != is_attr(func_iter->attrs, ATTR_PROPPUTREF)) continue; diff --git a/tools/widl/widltypes.h b/tools/widl/widltypes.h index 7b634c82242..0fba33d6a09 100644 --- a/tools/widl/widltypes.h +++ b/tools/widl/widltypes.h @@ -103,6 +103,8 @@ enum attr_type ATTR_ENCODE, ATTR_ENDPOINT, ATTR_ENTRY, + ATTR_EVENTADD, + ATTR_EVENTREMOVE, ATTR_EXCLUSIVETO, ATTR_EXPLICIT_HANDLE, ATTR_FAULTSTATUS,
Signed-off-by: Jacek Caban jacek@codeweavers.com
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- include/winnt.h | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/include/winnt.h b/include/winnt.h index 5b3efe61385..bb045fa2745 100644 --- a/include/winnt.h +++ b/include/winnt.h @@ -110,6 +110,8 @@ extern "C" { #ifndef DECLSPEC_SELECTANY #if defined(_MSC_VER) && (_MSC_VER >= 1100) #define DECLSPEC_SELECTANY __declspec(selectany) +#elif defined(__MINGW32__) +#define DECLSPEC_SELECTANY __attribute__((selectany)) #else #define DECLSPEC_SELECTANY #endif
Signed-off-by: Jacek Caban jacek@codeweavers.com
Signed-off-by: Rémi Bernon rbernon@codeweavers.com ---
Note that MIDL generates a L"" string here, I wasn't sure if we can now use them everywhere, and generating the WCHAR array was the safest way.
tools/widl/header.c | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/tools/widl/header.c b/tools/widl/header.c index 63389440c94..4db244fef5d 100644 --- a/tools/widl/header.c +++ b/tools/widl/header.c @@ -1702,6 +1702,7 @@ static void write_runtimeclass(FILE *header, type_t *runtimeclass) { expr_t *contract = get_attrp(runtimeclass->attrs, ATTR_CONTRACT); char *name, *c_name; + size_t i, len; name = format_namespace(runtimeclass->namespace, "", ".", runtimeclass->name, NULL); c_name = format_namespace(runtimeclass->namespace, "", "_", runtimeclass->name, NULL); fprintf(header, "/*\n"); @@ -1710,6 +1711,10 @@ static void write_runtimeclass(FILE *header, type_t *runtimeclass) if (contract) write_apicontract_guard_start(header, contract); fprintf(header, "#ifndef RUNTIMECLASS_%s_DEFINED\n", c_name); fprintf(header, "#define RUNTIMECLASS_%s_DEFINED\n", c_name); + /* FIXME: MIDL generates extern const here but GCC warns if extern is initialized */ + fprintf(header, "/*extern*/ const DECLSPEC_SELECTANY WCHAR RuntimeClass_%s[] = {", c_name); + for (i = 0, len = strlen(name); i < len; ++i) fprintf(header, "'%c',", name[i]); + fprintf(header, "0};\n"); fprintf(header, "#endif /* RUNTIMECLASS_%s_DEFINED */\n", c_name); free(c_name); free(name);
Rémi Bernon rbernon@codeweavers.com wrote:
@@ -1710,6 +1711,10 @@ static void write_runtimeclass(FILE *header, type_t *runtimeclass) if (contract) write_apicontract_guard_start(header, contract); fprintf(header, "#ifndef RUNTIMECLASS_%s_DEFINED\n", c_name); fprintf(header, "#define RUNTIMECLASS_%s_DEFINED\n", c_name);
- /* FIXME: MIDL generates extern const here but GCC warns if extern is initialized */
- fprintf(header, "/*extern*/ const DECLSPEC_SELECTANY WCHAR RuntimeClass_%s[] = {", c_name);
- for (i = 0, len = strlen(name); i < len; ++i) fprintf(header, "'%c',", name[i]);
- fprintf(header, "0};\n");
As I pointed out in https://bugs.winehq.org/show_bug.cgi?id=50559 this won't compile with clang.
On 1/29/21 9:56 AM, Dmitry Timoshkov wrote:
Rémi Bernon rbernon@codeweavers.com wrote:
@@ -1710,6 +1711,10 @@ static void write_runtimeclass(FILE *header, type_t *runtimeclass) if (contract) write_apicontract_guard_start(header, contract); fprintf(header, "#ifndef RUNTIMECLASS_%s_DEFINED\n", c_name); fprintf(header, "#define RUNTIMECLASS_%s_DEFINED\n", c_name);
- /* FIXME: MIDL generates extern const here but GCC warns if extern is initialized */
- fprintf(header, "/*extern*/ const DECLSPEC_SELECTANY WCHAR RuntimeClass_%s[] = {", c_name);
- for (i = 0, len = strlen(name); i < len; ++i) fprintf(header, "'%c',", name[i]);
- fprintf(header, "0};\n");
As I pointed out in https://bugs.winehq.org/show_bug.cgi?id=50559 this won't compile with clang.
I think this will, because it's not static anymore.
On 29.01.2021 09:50, Rémi Bernon wrote:
Signed-off-by: Rémi Bernon rbernon@codeweavers.com
Note that MIDL generates a L"" string here, I wasn't sure if we can now use them everywhere, and generating the WCHAR array was the safest way.
Note that this will still not work on on-PE targets where selectany is not supported. This will cause multiple declarations when included from multiple object files. I would suggest to treat it like we do with wide-char defines in other headers, something like:
#if defined(_MSC_VER) || defined(__MINGW32__) const DECLSPEC_SELECTANY WCHAR RuntimeClass_... = L"...";
#else
static const WCHAR RuntimeClas_... = {...};
#endif
This should take care of all platforms.
Thanks,
Jacek