[PATCH 4/5] widl: Support WinRT exclusiveto attribute parsing.

Rémi Bernon rbernon at codeweavers.com
Tue Jan 19 07:04:54 CST 2021


Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---
 tools/widl/header.c    | 7 +++++++
 tools/widl/parser.l    | 1 +
 tools/widl/parser.y    | 3 +++
 tools/widl/widltypes.h | 1 +
 4 files changed, 12 insertions(+)

diff --git a/tools/widl/header.c b/tools/widl/header.c
index b6cf43e7228..b13bc1bee79 100644
--- a/tools/widl/header.c
+++ b/tools/widl/header.c
@@ -1485,6 +1485,7 @@ static char *format_apicontract_macro(const type_t *type)
 static void write_winrt_type_comments(FILE *header, const type_t *type)
 {
     expr_t *contract = get_attrp(type->attrs, ATTR_CONTRACT);
+    type_t *exclusiveto = get_attrp(type->attrs, ATTR_EXCLUSIVETO);
     fprintf(header, " *\n");
     if (contract)
     {
@@ -1494,6 +1495,12 @@ static void write_winrt_type_comments(FILE *header, const type_t *type)
         fprintf(header, " * Introduced to %s in version %d.%d\n *\n", name, (ver >> 16) & 0xffff, ver & 0xffff);
         free(name);
     }
+    if (exclusiveto)
+    {
+        char *name = format_namespace(exclusiveto->namespace, "", ".", exclusiveto->name, NULL);
+        fprintf(header, " * Interface is a part of the implementation of type %s\n *\n", name);
+        free(name);
+    }
     switch (get_attrv(type->attrs, ATTR_THREADING))
     {
         case THREADING_SINGLE: fprintf(header, " * Class Threading Model:  Single Threaded Apartment\n *\n"); break;
diff --git a/tools/widl/parser.l b/tools/widl/parser.l
index 067966a85d4..de25b7d12c4 100644
--- a/tools/widl/parser.l
+++ b/tools/widl/parser.l
@@ -358,6 +358,7 @@ static const struct keyword attr_keywords[] =
 	{"encode",                      tENCODE,                    0},
 	{"endpoint",                    tENDPOINT,                  0},
 	{"entry",                       tENTRY,                     0},
+	{"exclusiveto",                 tEXCLUSIVETO,               1},
 	{"explicit_handle",             tEXPLICITHANDLE,            0},
 	{"fault_status",                tFAULTSTATUS,               0},
 	{"force_allocate",              tFORCEALLOCATE,             0},
diff --git a/tools/widl/parser.y b/tools/widl/parser.y
index 4ce84cc2440..351bbd12107 100644
--- a/tools/widl/parser.y
+++ b/tools/widl/parser.y
@@ -196,6 +196,7 @@ static typelib_t *current_typelib;
 %token tDLLNAME tDONTFREE tDOUBLE tDUAL
 %token tENABLEALLOCATE tENCODE tENDPOINT
 %token tENTRY tENUM tERRORSTATUST
+%token tEXCLUSIVETO
 %token tEXPLICITHANDLE tEXTERN
 %token tFALSE
 %token tFASTCALL tFAULTSTATUS
@@ -561,6 +562,7 @@ attribute:					{ $$ = NULL; }
 	| tENCODE				{ $$ = make_attr(ATTR_ENCODE); }
 	| tENDPOINT '(' str_list ')'		{ $$ = make_attrp(ATTR_ENDPOINT, $3); }
 	| tENTRY '(' expr_const ')'		{ $$ = make_attrp(ATTR_ENTRY, $3); }
+	| tEXCLUSIVETO '(' decl_spec ')'	{ $$ = make_attrp(ATTR_EXCLUSIVETO, $3->type); }
 	| tEXPLICITHANDLE			{ $$ = make_attr(ATTR_EXPLICIT_HANDLE); }
 	| tFAULTSTATUS				{ $$ = make_attr(ATTR_FAULTSTATUS); }
 	| tFORCEALLOCATE			{ $$ = make_attr(ATTR_FORCEALLOCATE); }
@@ -2223,6 +2225,7 @@ struct allowed_attr allowed_attr[] =
     /* ATTR_ENCODE */              { 0, 0, 0,  1, 1, 0, 1, 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, "endpoint" },
     /* ATTR_ENTRY */               { 0, 0, 0,  0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "entry" },
+    /* ATTR_EXCLUSIVETO */         { 0, 0, 0,  1, 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, "explicit_handle" },
     /* ATTR_FAULTSTATUS */         { 0, 0, 0,  0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "fault_status" },
     /* ATTR_FORCEALLOCATE */       { 0, 0, 0,  0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "force_allocate" },
diff --git a/tools/widl/widltypes.h b/tools/widl/widltypes.h
index 6c130d4701e..fbaabfbc8c3 100644
--- a/tools/widl/widltypes.h
+++ b/tools/widl/widltypes.h
@@ -103,6 +103,7 @@ enum attr_type
     ATTR_ENCODE,
     ATTR_ENDPOINT,
     ATTR_ENTRY,
+    ATTR_EXCLUSIVETO,
     ATTR_EXPLICIT_HANDLE,
     ATTR_FAULTSTATUS,
     ATTR_FORCEALLOCATE,
-- 
2.30.0




More information about the wine-devel mailing list