Module: wine Branch: master Commit: ba72ef6c22b26ef9addc8c9af6c2e9ab88529ca5 URL: https://source.winehq.org/git/wine.git/?a=commit;h=ba72ef6c22b26ef9addc8c9af...
Author: Eric Kohl eric.kohl@reactos.org Date: Wed Oct 14 23:24:34 2020 +0200
widl: Add the [allocate] acf attribute.
Signed-off-by: Eric Kohl eric.kohl@reactos.org Signed-off-by: Alexandre Julliard julliard@winehq.org
---
tools/widl/parser.l | 3 +++ tools/widl/parser.y | 33 +++++++++++++++++++++++++++++---- tools/widl/typegen.c | 7 +++++++ tools/widl/widltypes.h | 1 + 4 files changed, 40 insertions(+), 4 deletions(-)
diff --git a/tools/widl/parser.l b/tools/widl/parser.l index 925265d00db..f2c09cd8051 100644 --- a/tools/widl/parser.l +++ b/tools/widl/parser.l @@ -318,6 +318,7 @@ static const struct keyword keywords[] = { static const struct keyword attr_keywords[] = { {"aggregatable", tAGGREGATABLE}, + {"all_nodes", tALLNODES}, {"allocate", tALLOCATE}, {"annotation", tANNOTATION}, {"apartment", tAPARTMENT}, @@ -345,6 +346,7 @@ static const struct keyword attr_keywords[] = {"disable_consistency_check", tDISABLECONSISTENCYCHECK}, {"displaybind", tDISPLAYBIND}, {"dllname", tDLLNAME}, + {"dont_free", tDONTFREE}, {"dual", tDUAL}, {"enable_allocate", tENABLEALLOCATE}, {"encode", tENCODE}, @@ -406,6 +408,7 @@ static const struct keyword attr_keywords[] = {"restricted", tRESTRICTED}, {"retval", tRETVAL}, {"single", tSINGLE}, + {"single_node", tSINGLENODE}, {"size_is", tSIZEIS}, {"source", tSOURCE}, {"strict_context_handle", tSTRICTCONTEXTHANDLE}, diff --git a/tools/widl/parser.y b/tools/widl/parser.y index 5bc0d82703e..686aa6b58a8 100644 --- a/tools/widl/parser.y +++ b/tools/widl/parser.y @@ -172,7 +172,7 @@ static typelib_t *current_typelib; %token GREATEREQUAL LESSEQUAL %token LOGICALOR LOGICALAND %token ELLIPSIS -%token tAGGREGATABLE tALLOCATE tANNOTATION tAPPOBJECT tASYNC tASYNCUUID +%token tAGGREGATABLE tALLNODES tALLOCATE tANNOTATION tAPPOBJECT tASYNC tASYNCUUID %token tAUTOHANDLE tBINDABLE tBOOLEAN tBROADCAST tBYTE tBYTECOUNT %token tCALLAS tCALLBACK tCASE tCDECL tCHAR tCOCLASS tCODE tCOMMSTATUS %token tCONST tCONTEXTHANDLE tCONTEXTHANDLENOSERIALIZE @@ -183,7 +183,7 @@ static typelib_t *current_typelib; %token tDEFAULTVTABLE %token tDISABLECONSISTENCYCHECK tDISPLAYBIND %token tDISPINTERFACE -%token tDLLNAME tDOUBLE tDUAL +%token tDLLNAME tDONTFREE tDOUBLE tDUAL %token tENABLEALLOCATE tENCODE tENDPOINT %token tENTRY tENUM tERRORSTATUST %token tEXPLICITHANDLE tEXTERN @@ -235,7 +235,7 @@ static typelib_t *current_typelib; %token tRETVAL %token tSAFEARRAY %token tSHORT -%token tSIGNED +%token tSIGNED tSINGLENODE %token tSIZEIS tSIZEOF %token tSMALL %token tSOURCE @@ -296,6 +296,7 @@ static typelib_t *current_typelib; %type <statement> statement typedef pragma_warning %type <stmt_list> gbl_statements imp_statements int_statements %type <warning_list> warnings +%type <num> allocate_option_list allocate_option
%left ',' %right '?' ':' @@ -1150,16 +1151,20 @@ version: acf_statements : /* empty */ | acf_interface acf_statements + ;
acf_int_statements : /* empty */ | acf_int_statement acf_int_statements + ;
acf_int_statement : tTYPEDEF acf_attributes aKNOWNTYPE ';' { type_t *type = find_type_or_error($3, 0); type->attrs = append_attr_list(type->attrs, $2); } + ; + acf_interface : acf_attributes tINTERFACE aKNOWNTYPE '{' acf_int_statements '}' { type_t *iface = find_type_or_error2($3, 0); @@ -1167,19 +1172,38 @@ acf_interface error_loc("%s is not an interface\n", iface->name); iface->attrs = append_attr_list(iface->attrs, $1); } + ;
acf_attributes : /* empty */ { $$ = NULL; }; | '[' acf_attribute_list ']' { $$ = $2; }; + ;
acf_attribute_list : acf_attribute { $$ = append_attr(NULL, $1); } | acf_attribute_list ',' acf_attribute { $$ = append_attr($1, $3); } + ;
acf_attribute - : tENCODE { $$ = make_attr(ATTR_ENCODE); } + : tALLOCATE '(' allocate_option_list ')' + { $$ = make_attrv(ATTR_ALLOCATE, $3); } + | tENCODE { $$ = make_attr(ATTR_ENCODE); } | tDECODE { $$ = make_attr(ATTR_DECODE); } | tEXPLICITHANDLE { $$ = make_attr(ATTR_EXPLICIT_HANDLE); } + ; + +allocate_option_list + : allocate_option { $$ = $1; } + | allocate_option_list ',' allocate_option + { $$ = $1 | $3; } + ; + +allocate_option + : tDONTFREE { $$ = FC_DONT_FREE; } + | tFREE { $$ = 0; } + | tALLNODES { $$ = FC_ALLOCATE_ALL_NODES; } + | tSINGLENODE { $$ = 0; } + ;
%%
@@ -2122,6 +2146,7 @@ struct allowed_attr allowed_attr[] = { /* attr { D ACF I Fn ARG T En Enm St Un Fi L DI M C <display name> } */ /* ATTR_AGGREGATABLE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, "aggregatable" }, + /* ATTR_ALLOCATE */ { 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "allocate" }, /* ATTR_ANNOTATION */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "annotation" }, /* ATTR_APPOBJECT */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, "appobject" }, /* ATTR_ASYNC */ { 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "async" }, diff --git a/tools/widl/typegen.c b/tools/widl/typegen.c index 04280cbb722..4874dfd6c24 100644 --- a/tools/widl/typegen.c +++ b/tools/widl/typegen.c @@ -2153,6 +2153,9 @@ static unsigned int write_nonsimple_pointer(FILE *file, const attr_list_t *attrs type_t *ref = type_pointer_get_ref_type(type); if(is_declptr(ref) && !is_user_type(ref)) flags |= FC_POINTER_DEREF; + if (pointer_type != FC_RP) { + flags |= get_attrv(type->attrs, ATTR_ALLOCATE); + } }
print_file(file, 2, "0x%x, 0x%x,\t\t/* %s", @@ -2165,6 +2168,10 @@ static unsigned int write_nonsimple_pointer(FILE *file, const attr_list_t *attrs fprintf(file, " [allocated_on_stack]"); if (flags & FC_POINTER_DEREF) fprintf(file, " [pointer_deref]"); + if (flags & FC_DONT_FREE) + fprintf(file, " [dont_free]"); + if (flags & FC_ALLOCATE_ALL_NODES) + fprintf(file, " [all_nodes]"); fprintf(file, " */\n"); }
diff --git a/tools/widl/widltypes.h b/tools/widl/widltypes.h index 085a0ff55f5..2e2ee7a206b 100644 --- a/tools/widl/widltypes.h +++ b/tools/widl/widltypes.h @@ -69,6 +69,7 @@ typedef struct list warning_list_t; enum attr_type { ATTR_AGGREGATABLE, + ATTR_ALLOCATE, ATTR_ANNOTATION, ATTR_APPOBJECT, ATTR_ASYNC,