[PATCH 2/4] widl: Support WinRT eventadd/eventremove attributes.

Rémi Bernon rbernon at codeweavers.com
Fri Jan 29 02:50:06 CST 2021


Signed-off-by: Rémi Bernon <rbernon at 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,
-- 
2.30.0




More information about the wine-devel mailing list