Commit ba72ef6c authored by Eric Kohl's avatar Eric Kohl Committed by Alexandre Julliard

widl: Add the [allocate] acf attribute.

parent 8c51bcb8
...@@ -318,6 +318,7 @@ static const struct keyword keywords[] = { ...@@ -318,6 +318,7 @@ static const struct keyword keywords[] = {
static const struct keyword attr_keywords[] = static const struct keyword attr_keywords[] =
{ {
{"aggregatable", tAGGREGATABLE}, {"aggregatable", tAGGREGATABLE},
{"all_nodes", tALLNODES},
{"allocate", tALLOCATE}, {"allocate", tALLOCATE},
{"annotation", tANNOTATION}, {"annotation", tANNOTATION},
{"apartment", tAPARTMENT}, {"apartment", tAPARTMENT},
...@@ -345,6 +346,7 @@ static const struct keyword attr_keywords[] = ...@@ -345,6 +346,7 @@ static const struct keyword attr_keywords[] =
{"disable_consistency_check", tDISABLECONSISTENCYCHECK}, {"disable_consistency_check", tDISABLECONSISTENCYCHECK},
{"displaybind", tDISPLAYBIND}, {"displaybind", tDISPLAYBIND},
{"dllname", tDLLNAME}, {"dllname", tDLLNAME},
{"dont_free", tDONTFREE},
{"dual", tDUAL}, {"dual", tDUAL},
{"enable_allocate", tENABLEALLOCATE}, {"enable_allocate", tENABLEALLOCATE},
{"encode", tENCODE}, {"encode", tENCODE},
...@@ -406,6 +408,7 @@ static const struct keyword attr_keywords[] = ...@@ -406,6 +408,7 @@ static const struct keyword attr_keywords[] =
{"restricted", tRESTRICTED}, {"restricted", tRESTRICTED},
{"retval", tRETVAL}, {"retval", tRETVAL},
{"single", tSINGLE}, {"single", tSINGLE},
{"single_node", tSINGLENODE},
{"size_is", tSIZEIS}, {"size_is", tSIZEIS},
{"source", tSOURCE}, {"source", tSOURCE},
{"strict_context_handle", tSTRICTCONTEXTHANDLE}, {"strict_context_handle", tSTRICTCONTEXTHANDLE},
......
...@@ -172,7 +172,7 @@ static typelib_t *current_typelib; ...@@ -172,7 +172,7 @@ static typelib_t *current_typelib;
%token GREATEREQUAL LESSEQUAL %token GREATEREQUAL LESSEQUAL
%token LOGICALOR LOGICALAND %token LOGICALOR LOGICALAND
%token ELLIPSIS %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 tAUTOHANDLE tBINDABLE tBOOLEAN tBROADCAST tBYTE tBYTECOUNT
%token tCALLAS tCALLBACK tCASE tCDECL tCHAR tCOCLASS tCODE tCOMMSTATUS %token tCALLAS tCALLBACK tCASE tCDECL tCHAR tCOCLASS tCODE tCOMMSTATUS
%token tCONST tCONTEXTHANDLE tCONTEXTHANDLENOSERIALIZE %token tCONST tCONTEXTHANDLE tCONTEXTHANDLENOSERIALIZE
...@@ -183,7 +183,7 @@ static typelib_t *current_typelib; ...@@ -183,7 +183,7 @@ static typelib_t *current_typelib;
%token tDEFAULTVTABLE %token tDEFAULTVTABLE
%token tDISABLECONSISTENCYCHECK tDISPLAYBIND %token tDISABLECONSISTENCYCHECK tDISPLAYBIND
%token tDISPINTERFACE %token tDISPINTERFACE
%token tDLLNAME tDOUBLE tDUAL %token tDLLNAME tDONTFREE tDOUBLE tDUAL
%token tENABLEALLOCATE tENCODE tENDPOINT %token tENABLEALLOCATE tENCODE tENDPOINT
%token tENTRY tENUM tERRORSTATUST %token tENTRY tENUM tERRORSTATUST
%token tEXPLICITHANDLE tEXTERN %token tEXPLICITHANDLE tEXTERN
...@@ -235,7 +235,7 @@ static typelib_t *current_typelib; ...@@ -235,7 +235,7 @@ static typelib_t *current_typelib;
%token tRETVAL %token tRETVAL
%token tSAFEARRAY %token tSAFEARRAY
%token tSHORT %token tSHORT
%token tSIGNED %token tSIGNED tSINGLENODE
%token tSIZEIS tSIZEOF %token tSIZEIS tSIZEOF
%token tSMALL %token tSMALL
%token tSOURCE %token tSOURCE
...@@ -296,6 +296,7 @@ static typelib_t *current_typelib; ...@@ -296,6 +296,7 @@ static typelib_t *current_typelib;
%type <statement> statement typedef pragma_warning %type <statement> statement typedef pragma_warning
%type <stmt_list> gbl_statements imp_statements int_statements %type <stmt_list> gbl_statements imp_statements int_statements
%type <warning_list> warnings %type <warning_list> warnings
%type <num> allocate_option_list allocate_option
%left ',' %left ','
%right '?' ':' %right '?' ':'
...@@ -1150,16 +1151,20 @@ version: ...@@ -1150,16 +1151,20 @@ version:
acf_statements acf_statements
: /* empty */ : /* empty */
| acf_interface acf_statements | acf_interface acf_statements
;
acf_int_statements acf_int_statements
: /* empty */ : /* empty */
| acf_int_statement acf_int_statements | acf_int_statement acf_int_statements
;
acf_int_statement acf_int_statement
: tTYPEDEF acf_attributes aKNOWNTYPE ';' : tTYPEDEF acf_attributes aKNOWNTYPE ';'
{ type_t *type = find_type_or_error($3, 0); { type_t *type = find_type_or_error($3, 0);
type->attrs = append_attr_list(type->attrs, $2); type->attrs = append_attr_list(type->attrs, $2);
} }
;
acf_interface acf_interface
: acf_attributes tINTERFACE aKNOWNTYPE '{' acf_int_statements '}' : acf_attributes tINTERFACE aKNOWNTYPE '{' acf_int_statements '}'
{ type_t *iface = find_type_or_error2($3, 0); { type_t *iface = find_type_or_error2($3, 0);
...@@ -1167,19 +1172,38 @@ acf_interface ...@@ -1167,19 +1172,38 @@ acf_interface
error_loc("%s is not an interface\n", iface->name); error_loc("%s is not an interface\n", iface->name);
iface->attrs = append_attr_list(iface->attrs, $1); iface->attrs = append_attr_list(iface->attrs, $1);
} }
;
acf_attributes acf_attributes
: /* empty */ { $$ = NULL; }; : /* empty */ { $$ = NULL; };
| '[' acf_attribute_list ']' { $$ = $2; }; | '[' acf_attribute_list ']' { $$ = $2; };
;
acf_attribute_list acf_attribute_list
: acf_attribute { $$ = append_attr(NULL, $1); } : acf_attribute { $$ = append_attr(NULL, $1); }
| acf_attribute_list ',' acf_attribute { $$ = append_attr($1, $3); } | acf_attribute_list ',' acf_attribute { $$ = append_attr($1, $3); }
;
acf_attribute 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); } | tDECODE { $$ = make_attr(ATTR_DECODE); }
| tEXPLICITHANDLE { $$ = make_attr(ATTR_EXPLICIT_HANDLE); } | 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[] = ...@@ -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 { 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_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_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_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" }, /* ATTR_ASYNC */ { 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "async" },
......
...@@ -2153,6 +2153,9 @@ static unsigned int write_nonsimple_pointer(FILE *file, const attr_list_t *attrs ...@@ -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); type_t *ref = type_pointer_get_ref_type(type);
if(is_declptr(ref) && !is_user_type(ref)) if(is_declptr(ref) && !is_user_type(ref))
flags |= FC_POINTER_DEREF; 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", 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 ...@@ -2165,6 +2168,10 @@ static unsigned int write_nonsimple_pointer(FILE *file, const attr_list_t *attrs
fprintf(file, " [allocated_on_stack]"); fprintf(file, " [allocated_on_stack]");
if (flags & FC_POINTER_DEREF) if (flags & FC_POINTER_DEREF)
fprintf(file, " [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"); fprintf(file, " */\n");
} }
......
...@@ -69,6 +69,7 @@ typedef struct list warning_list_t; ...@@ -69,6 +69,7 @@ typedef struct list warning_list_t;
enum attr_type enum attr_type
{ {
ATTR_AGGREGATABLE, ATTR_AGGREGATABLE,
ATTR_ALLOCATE,
ATTR_ANNOTATION, ATTR_ANNOTATION,
ATTR_APPOBJECT, ATTR_APPOBJECT,
ATTR_ASYNC, ATTR_ASYNC,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment