[PATCH 2/5] widl: Support WinRT marshaling_behavior attribute parsing.

Zebediah Figura (she/her) zfigura at codeweavers.com
Tue Jan 19 11:34:53 CST 2021


On 1/19/21 7:04 AM, Rémi Bernon wrote:
> Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
> ---
>  tools/widl/header.c    |  7 +++++++
>  tools/widl/parser.l    |  4 ++++
>  tools/widl/parser.y    | 18 ++++++++++++++++--
>  tools/widl/widltypes.h |  9 +++++++++
>  4 files changed, 36 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/widl/header.c b/tools/widl/header.c
> index 223ab5c5ca9..21f8528c31d 100644
> --- a/tools/widl/header.c
> +++ b/tools/widl/header.c
> @@ -1494,6 +1494,13 @@ 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);
>      }
> +    switch (get_attrv(type->attrs, ATTR_MARSHALING_BEHAVIOR))
> +    {
> +        case MARSHALING_AGILE: fprintf(header, " * Class Marshaling Behavior:  Agile - Class is agile\n *\n"); break;
> +        case MARSHALING_STANDARD: fprintf(header, " * Class Marshaling Behavior:  Standard - Class marshals using the standard marshaler\n *\n"); break;
> +        case MARSHALING_NONE: fprintf(header, " * Class Marshaling Behavior:  None - Class cannot be marshaled\n *\n"); break;
> +        default: break;
> +    }
>  }
>  

I guess I should have asked this earlier, but is there a point in
writing these comments?

>  static void write_apicontract_guard_start(FILE *header, const expr_t *expr)
> diff --git a/tools/widl/parser.l b/tools/widl/parser.l
> index 9dce03577c6..01c6f800a08 100644
> --- a/tools/widl/parser.l
> +++ b/tools/widl/parser.l
> @@ -320,6 +320,7 @@ static const struct keyword keywords[] = {
>  static const struct keyword attr_keywords[] =
>  {
>  	{"aggregatable",                tAGGREGATABLE,              0},
> +	{"agile",                       tAGILE,                     1},
>  	{"all_nodes",                   tALLNODES,                  0},
>  	{"allocate",                    tALLOCATE,                  0},
>  	{"annotation",                  tANNOTATION,                0},
> @@ -381,12 +382,14 @@ static const struct keyword attr_keywords[] =
>  	{"length_is",                   tLENGTHIS,                  0},
>  	{"licensed",                    tLICENSED,                  0},
>  	{"local",                       tLOCAL,                     0},
> +	{"marshaling_behavior",         tMARSHALINGBEHAVIOR,        1},
>  	{"maybe",                       tMAYBE,                     0},
>  	{"message",                     tMESSAGE,                   0},
>  	{"neutral",                     tNEUTRAL,                   0},
>  	{"nocode",                      tNOCODE,                    0},
>  	{"nonbrowsable",                tNONBROWSABLE,              0},
>  	{"noncreatable",                tNONCREATABLE,              0},
> +	{"none",                        tNONE,                      1},
>  	{"nonextensible",               tNONEXTENSIBLE,             0},
>  	{"notify",                      tNOTIFY,                    0},
>  	{"notify_flag",                 tNOTIFYFLAG,                0},
> @@ -416,6 +419,7 @@ static const struct keyword attr_keywords[] =
>  	{"single_node",                 tSINGLENODE,                0},
>  	{"size_is",                     tSIZEIS,                    0},
>  	{"source",                      tSOURCE,                    0},
> +	{"standard",                    tSTANDARD,                  1},
>  	{"strict_context_handle",       tSTRICTCONTEXTHANDLE,       0},
>  	{"string",                      tSTRING,                    0},
>  	{"switch_is",                   tSWITCHIS,                  0},
> diff --git a/tools/widl/parser.y b/tools/widl/parser.y
> index b729d772fcd..48f180cdb49 100644
> --- a/tools/widl/parser.y
> +++ b/tools/widl/parser.y
> @@ -174,7 +174,9 @@ static typelib_t *current_typelib;
>  %token GREATEREQUAL LESSEQUAL
>  %token LOGICALOR LOGICALAND
>  %token ELLIPSIS
> -%token tAGGREGATABLE tALLNODES tALLOCATE tANNOTATION
> +%token tAGGREGATABLE
> +%token tAGILE
> +%token tALLNODES tALLOCATE tANNOTATION
>  %token tAPICONTRACT
>  %token tAPPOBJECT tASYNC tASYNCUUID
>  %token tAUTOHANDLE tBINDABLE tBOOLEAN tBROADCAST tBYTE tBYTECOUNT
> @@ -216,12 +218,14 @@ static typelib_t *current_typelib;
>  %token tLENGTHIS tLIBRARY
>  %token tLICENSED tLOCAL
>  %token tLONG
> +%token tMARSHALINGBEHAVIOR
>  %token tMAYBE tMESSAGE
>  %token tMETHODS
>  %token tMODULE
>  %token tNAMESPACE
>  %token tNOCODE tNONBROWSABLE
>  %token tNONCREATABLE
> +%token tNONE
>  %token tNONEXTENSIBLE
>  %token tNOTIFY tNOTIFYFLAG
>  %token tNULL
> @@ -247,6 +251,7 @@ static typelib_t *current_typelib;
>  %token tSIZEIS tSIZEOF
>  %token tSMALL
>  %token tSOURCE
> +%token tSTANDARD
>  %token tSTATIC
>  %token tSTDCALL
>  %token tSTRICTCONTEXTHANDLE
> @@ -299,7 +304,7 @@ static typelib_t *current_typelib;
>  %type <type> coclass coclasshdr coclassdef
>  %type <type> apicontract
>  %type <num> contract_ver
> -%type <num> pointer_type threading_type version
> +%type <num> pointer_type threading_type marshaling_behavior version
>  %type <str> libraryhdr callconv cppquote importlib import t_ident
>  %type <uuid> uuid_string
>  %type <import> import_start
> @@ -505,6 +510,12 @@ str_list: aSTRING                               { $$ = append_str( NULL, $1 ); }
>  	| str_list ',' aSTRING                  { $$ = append_str( $1, $3 ); }
>  	;
>  
> +marshaling_behavior:
> +	  tAGILE				{ $$ = MARSHALING_AGILE; }
> +	| tNONE					{ $$ = MARSHALING_NONE; }
> +	| tSTANDARD				{ $$ = MARSHALING_STANDARD; }
> +	;
> +
>  contract_ver:
>  	  aNUM					{ $$ = MAKEVERSION(0, $1); }
>  	| aNUM '.' aNUM				{ $$ = MAKEVERSION($3, $1); }
> @@ -572,6 +583,8 @@ attribute:					{ $$ = NULL; }
>  	| tLCID					{ $$ = make_attr(ATTR_PARAMLCID); }
>  	| tLICENSED				{ $$ = make_attr(ATTR_LICENSED); }
>  	| tLOCAL				{ $$ = make_attr(ATTR_LOCAL); }
> +	| tMARSHALINGBEHAVIOR '(' marshaling_behavior ')'
> +						{ $$ = make_attrv(ATTR_MARSHALING_BEHAVIOR, $3); }
>  	| tMAYBE				{ $$ = make_attr(ATTR_MAYBE); }
>  	| tMESSAGE				{ $$ = make_attr(ATTR_MESSAGE); }
>  	| tNOCODE				{ $$ = make_attr(ATTR_NOCODE); }
> @@ -2230,6 +2243,7 @@ struct allowed_attr allowed_attr[] =
>      /* ATTR_LIBLCID */             { 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, "lcid" },
>      /* ATTR_LICENSED */            { 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, "licensed" },
>      /* ATTR_LOCAL */               { 1, 0, 0,  1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "local" },
> +    /* ATTR_MARSHALING_BEHAVIOR */ { 0, 0, 0,  0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "marshaling_behavior" },
>      /* ATTR_MAYBE */               { 0, 0, 0,  0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "maybe" },
>      /* ATTR_MESSAGE */             { 0, 0, 0,  0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "message" },
>      /* ATTR_NOCODE */              { 0, 1, 0,  1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "nocode" },
> diff --git a/tools/widl/widltypes.h b/tools/widl/widltypes.h
> index d5862426ad4..6c130d4701e 100644
> --- a/tools/widl/widltypes.h
> +++ b/tools/widl/widltypes.h
> @@ -125,6 +125,7 @@ enum attr_type
>      ATTR_LIBLCID,
>      ATTR_LICENSED,
>      ATTR_LOCAL,
> +    ATTR_MARSHALING_BEHAVIOR,
>      ATTR_MAYBE,
>      ATTR_MESSAGE,
>      ATTR_NOCODE,
> @@ -271,6 +272,14 @@ enum threading_type
>      THREADING_BOTH
>  };
>  
> +enum marshaling_type
> +{
> +    MARSHALING_INVALID = 0,
> +    MARSHALING_NONE,
> +    MARSHALING_AGILE,
> +    MARSHALING_STANDARD,
> +};
> +
>  enum type_basic_type
>  {
>      TYPE_BASIC_INT8 = 1,
> 



More information about the wine-devel mailing list