5 * Copyright 2002 Ove Kaaven
6 * Copyright 2006-2008 Robert Shearman
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
47 static str_list_t
*append_str
(str_list_t
*list
, char *str
);
48 static attr_list_t
*append_attr_list
(attr_list_t
*new_list
, attr_list_t
*old_list
);
49 static decl_spec_t
*make_decl_spec
(type_t
*type
, decl_spec_t
*left
, decl_spec_t
*right
,
50 enum storage_class stgclass
, enum type_qualifier qual
, enum function_specifier func_specifier
);
51 static attr_t
*make_attr
(enum attr_type type
);
52 static attr_t
*make_attrv
(enum attr_type type
, unsigned int val
);
53 static attr_t
*make_custom_attr
(struct uuid
*id
, expr_t
*pval
);
54 static expr_list_t
*append_expr
(expr_list_t
*list
, expr_t
*expr
);
55 static var_t
*declare_var
(attr_list_t
*attrs
, decl_spec_t
*decl_spec
, declarator_t
*decl
, int top
);
56 static var_list_t
*set_var_types
(attr_list_t
*attrs
, decl_spec_t
*decl_spec
, declarator_list_t
*decls
);
57 static var_list_t
*append_var_list
(var_list_t
*list
, var_list_t
*vars
);
58 static declarator_list_t
*append_declarator
(declarator_list_t
*list
, declarator_t
*p
);
59 static declarator_t
*make_declarator
(var_t
*var
);
60 static type_t
*make_safearray
(type_t
*type
);
61 static typelib_t
*make_library
(const char *name
, const attr_list_t
*attrs
);
62 static void append_array
(declarator_t
*decl
, expr_t
*expr
);
63 static void append_chain_type
(declarator_t
*decl
, type_t
*type
, enum type_qualifier qual
);
64 static void append_chain_callconv
(type_t
*chain
, char *callconv
);
65 static warning_list_t
*append_warning
(warning_list_t
*, int);
67 static type_t
*reg_typedefs
(decl_spec_t
*decl_spec
, var_list_t
*names
, attr_list_t
*attrs
);
68 static type_t
*find_type_or_error
(struct namespace
*parent
, const char *name
);
69 static struct namespace
*find_namespace_or_error
(struct namespace
*namespace
, const char *name
);
71 static var_t
*reg_const
(var_t
*var
);
73 static void push_namespace
(const char *name
);
74 static void pop_namespace
(const char *name
);
75 static void push_parameters_namespace
(const char *name
);
76 static void pop_parameters_namespace
(const char *name
);
78 static statement_list_t
*append_parameterized_type_stmts
(statement_list_t
*stmts
);
79 static void check_arg_attrs
(const var_t
*arg
);
80 static void check_statements
(const statement_list_t
*stmts
, int is_inside_library
);
81 static void check_all_user_types
(const statement_list_t
*stmts
);
82 static attr_list_t
*check_function_attrs
(const char *name
, attr_list_t
*attrs
);
83 static attr_list_t
*check_typedef_attrs
(attr_list_t
*attrs
);
84 static attr_list_t
*check_enum_attrs
(attr_list_t
*attrs
);
85 static attr_list_t
*check_enum_member_attrs
(attr_list_t
*attrs
);
86 static attr_list_t
*check_struct_attrs
(attr_list_t
*attrs
);
87 static attr_list_t
*check_union_attrs
(attr_list_t
*attrs
);
88 static attr_list_t
*check_field_attrs
(const char *name
, attr_list_t
*attrs
);
89 static attr_list_t
*check_library_attrs
(const char *name
, attr_list_t
*attrs
);
90 const char *get_attr_display_name
(enum attr_type type
);
91 static void add_explicit_handle_if_necessary
(const type_t
*iface
, var_t
*func
);
93 static void check_async_uuid
(type_t
*iface
);
95 static statement_t
*make_statement
(enum statement_type type
);
96 static statement_t
*make_statement_type_decl
(type_t
*type
);
97 static statement_t
*make_statement_reference
(type_t
*type
);
98 static statement_t
*make_statement_declaration
(var_t
*var
);
99 static statement_t
*make_statement_library
(typelib_t
*typelib
);
100 static statement_t
*make_statement_pragma
(const char *str
);
101 static statement_t
*make_statement_cppquote
(const char *str
);
102 static statement_t
*make_statement_importlib
(const char *str
);
103 static statement_t
*make_statement_module
(type_t
*type
);
104 static statement_t
*make_statement_typedef
(var_list_t
*names
, int declonly
);
105 static statement_t
*make_statement_import
(const char *str
);
106 static statement_t
*make_statement_parameterized_type
(type_t
*type
, typeref_list_t
*params
);
107 static statement_t
*make_statement_delegate
(type_t
*ret
, var_list_t
*args
);
108 static statement_list_t
*append_statement
(statement_list_t
*list
, statement_t
*stmt
);
109 static statement_list_t
*append_statements
(statement_list_t
*, statement_list_t
*);
110 static attr_list_t
*append_attribs
(attr_list_t
*, attr_list_t
*);
112 static struct namespace global_namespace
= {
113 NULL
, NULL
, LIST_INIT
(global_namespace.entry
), LIST_INIT
(global_namespace.children
)
116 static struct namespace
*current_namespace
= &global_namespace
;
117 static struct namespace
*parameters_namespace
= NULL
;
118 static statement_list_t
*parameterized_type_stmts
= NULL
;
120 static typelib_t
*current_typelib
;
124 %define api.prefix
{parser_
}
128 attr_list_t
*attr_list
;
129 str_list_t
*str_list
;
131 expr_list_t
*expr_list
;
134 var_list_t
*var_list
;
135 declarator_t
*declarator
;
136 declarator_list_t
*declarator_list
;
137 statement_t
*statement
;
138 statement_list_t
*stmt_list
;
140 warning_list_t
*warning_list
;
142 typeref_list_t
*typeref_list
;
148 struct _import_t
*import
;
149 struct _decl_spec_t
*declspec
;
150 enum storage_class stgclass
;
151 enum type_qualifier type_qualifier
;
152 enum function_specifier function_specifier
;
153 struct namespace
*namespace
;
156 %token
<str
> aIDENTIFIER aPRAGMA
157 %token
<str
> aKNOWNTYPE
158 %token
<num
> aNUM aHEXNUM
160 %token
<str
> aSTRING aWSTRING aSQSTRING
165 %token EQUALITY INEQUALITY
166 %token GREATEREQUAL LESSEQUAL
167 %token LOGICALOR LOGICALAND
172 %token tALLNODES tALLOCATE tANNOTATION
174 %token tAPPOBJECT tASYNC tASYNCUUID
175 %token tAUTOHANDLE tBINDABLE tBOOLEAN tBROADCAST tBYTE tBYTECOUNT
176 %token tCALLAS tCALLBACK tCASE tCDECL tCHAR tCOCLASS tCODE tCOMMSTATUS
177 %token tCONST tCONTEXTHANDLE tCONTEXTHANDLENOSERIALIZE
178 %token tCONTEXTHANDLESERIALIZE
180 %token tCONTRACTVERSION
181 %token tCONTROL tCPPQUOTE
184 %token tDECODE tDEFAULT tDEFAULTBIND
186 %token tDEFAULTCOLLELEM
188 %token tDEFAULTVTABLE
189 %token tDISABLECONSISTENCYCHECK tDISPLAYBIND
190 %token tDISPINTERFACE
191 %token tDLLNAME tDONTFREE tDOUBLE tDUAL
192 %token tENABLEALLOCATE tENCODE tENDPOINT
193 %token tENTRY tENUM tERRORSTATUST
194 %token tEVENTADD tEVENTREMOVE
196 %token tEXPLICITHANDLE tEXTERN
198 %token tFASTCALL tFAULTSTATUS
200 %token tFLOAT tFORCEALLOCATE
203 %token tHELPCONTEXT tHELPFILE
204 %token tHELPSTRING tHELPSTRINGCONTEXT tHELPSTRINGDLL
206 %token tHYPER tID tIDEMPOTENT
207 %token tIGNORE tIIDIS
208 %token tIMMEDIATEBIND
209 %token tIMPLICITHANDLE
210 %token tIMPORT tIMPORTLIB
211 %token tIN tIN_LINE tINLINE
213 %token tINT tINT32 tINT3264 tINT64
216 %token tLENGTHIS tLIBRARY
217 %token tLICENSED tLOCAL
219 %token tMARSHALINGBEHAVIOR
220 %token tMAYBE tMESSAGE
225 %token tNOCODE tNONBROWSABLE
228 %token tNONEXTENSIBLE
229 %token tNOTIFY tNOTIFYFLAG
231 %token tOBJECT tODL tOLEAUTOMATION
232 %token tOPTIMIZE tOPTIONAL
235 %token tPARTIALIGNORE tPASCAL
236 %token tPOINTERDEFAULT
237 %token tPRAGMA_WARNING
238 %token tPROGID tPROPERTIES
239 %token tPROPGET tPROPPUT tPROPPUTREF
243 %token tREADONLY tREF
244 %token tREGISTER tREPRESENTAS
252 %token tSIGNED tSINGLENODE
253 %token tSIZEIS tSIZEOF
259 %token tSTRICTCONTEXTHANDLE
260 %token tSTRING tSTRUCT
261 %token tSWITCH tSWITCHIS tSWITCHTYPE
262 %token tTHREADING tTRANSMITAS
265 %token tUIDEFAULT tUNION
268 %token tUSESGETLASTERROR tUSERMARSHAL tUUID
271 %token tVERSION tVIPROGID
273 %token tWCHAR tWIREMARSHAL
274 %token tAPARTMENT tNEUTRAL tSINGLE tFREE tBOTH
276 %type
<attr
> attribute acf_attribute
277 %type
<attr_list
> m_attributes attributes attrib_list
278 %type
<attr_list
> acf_attributes acf_attribute_list
279 %type
<attr_list
> dispattributes
280 %type
<str_list
> str_list
281 %type
<expr
> m_expr expr expr_const expr_int_const array m_bitfield
282 %type
<expr_list
> m_exprs
/* exprs expr_list */ expr_list_int_const
283 %type
<expr
> contract_req
284 %type
<expr
> static_attr
285 %type
<expr
> activatable_attr
286 %type
<type
> delegatedef
287 %type
<stgclass
> storage_cls_spec
288 %type
<type_qualifier
> type_qualifier m_type_qual_list
289 %type
<function_specifier
> function_specifier
290 %type
<declspec
> decl_spec unqualified_decl_spec decl_spec_no_type m_decl_spec_no_type
291 %type
<type
> inherit interface interfacedef
292 %type
<type
> interfaceref
293 %type
<type
> dispinterfaceref
294 %type
<type
> dispinterface dispinterfacedef
295 %type
<type
> module moduledef
296 %type
<str
> namespacedef
297 %type
<type
> base_type int_std
298 %type
<type
> enumdef structdef uniondef typedecl
299 %type
<type
> type unqualified_type qualified_type
300 %type
<type
> type_parameter
301 %type
<typeref_list
> type_parameters
302 %type
<type
> parameterized_type
303 %type
<type
> parameterized_type_arg
304 %type
<typeref_list
> parameterized_type_args
305 %type
<typeref
> class_interface
306 %type
<typeref_list
> class_interfaces
307 %type
<typeref_list
> requires required_types
308 %type
<var
> arg ne_union_field union_field s_field case
enum enum_member declaration
310 %type
<var_list
> m_args arg_list args dispint_meths
311 %type
<var_list
> fields ne_union_fields cases enums enum_list dispint_props field
312 %type
<var
> m_ident ident
313 %type
<declarator
> declarator direct_declarator init_declarator struct_declarator
314 %type
<declarator
> m_any_declarator any_declarator any_declarator_no_direct any_direct_declarator
315 %type
<declarator
> m_abstract_declarator abstract_declarator abstract_declarator_no_direct abstract_direct_declarator
316 %type
<declarator_list
> declarator_list struct_declarator_list
317 %type
<type
> coclass coclassdef
318 %type
<type
> runtimeclass runtimeclass_def
319 %type
<type
> apicontract apicontract_def
320 %type
<num
> contract_ver
321 %type
<num
> pointer_type threading_type marshaling_behavior version
322 %type
<str
> libraryhdr callconv cppquote importlib import
323 %type
<str
> typename m_typename
324 %type
<uuid
> uuid_string
325 %type
<import
> import_start
326 %type
<typelib
> library_start librarydef
327 %type
<statement
> statement typedef pragma_warning
328 %type
<stmt_list
> gbl_statements imp_statements int_statements
329 %type
<stmt_list
> decl_block decl_statements
330 %type
<stmt_list
> imp_decl_block imp_decl_statements
331 %type
<warning_list
> warnings
332 %type
<num
> allocate_option_list allocate_option
333 %type
<namespace
> namespace_pfx
342 %left EQUALITY INEQUALITY
343 %left
'<' '>' LESSEQUAL GREATEREQUAL
347 %right
'!' '~' CAST PPTR POS NEG ADDRESSOF tSIZEOF
348 %left
'.' MEMBERPTR
'[' ']'
350 %define parse.
error verbose
354 input: gbl_statements m_acf
{ $1 = append_parameterized_type_stmts
($1);
355 check_statements
($1, FALSE
);
356 check_all_user_types
($1);
363 write_typelib_regscript
($1);
365 write_local_stubs
($1);
369 m_acf: /* empty */ | aACF acf_statements
371 decl_statements: { $$
= NULL
; }
372 | decl_statements tINTERFACE qualified_type
'<' parameterized_type_args
'>' ';'
373 { parameterized_type_stmts
= append_statement
(parameterized_type_stmts
, make_statement_parameterized_type
($3, $5));
374 $$
= append_statement
($1, make_statement_reference
(type_parameterized_type_specialize_declare
($3, $5)));
378 decl_block: tDECLARE
'{' decl_statements
'}' { $$
= $3; }
380 imp_decl_statements: { $$
= NULL
; }
381 | imp_decl_statements tINTERFACE qualified_type
'<' parameterized_type_args
'>' ';'
382 { $$
= append_statement
($1, make_statement_reference
(type_parameterized_type_specialize_declare
($3, $5))); }
385 imp_decl_block: tDECLARE
'{' imp_decl_statements
'}' { $$
= $3; }
387 gbl_statements: { $$
= NULL
; }
388 | gbl_statements namespacedef
'{' { push_namespace
($2); } gbl_statements
'}'
389 { pop_namespace
($2); $$
= append_statements
($1, $5); }
390 | gbl_statements interface
';' { $$
= append_statement
($1, make_statement_reference
($2)); }
391 | gbl_statements dispinterface
';' { $$
= append_statement
($1, make_statement_reference
($2)); }
392 | gbl_statements interfacedef
{ $$
= append_statement
($1, make_statement_type_decl
($2)); }
393 | gbl_statements delegatedef
{ $$
= append_statement
($1, make_statement_type_decl
($2)); }
394 | gbl_statements coclass
';' { $$
= $1;
395 reg_type
($2, $2->name
, current_namespace
, 0);
397 | gbl_statements coclassdef
{ $$
= append_statement
($1, make_statement_type_decl
($2));
398 reg_type
($2, $2->name
, current_namespace
, 0);
400 | gbl_statements apicontract
';' { $$
= $1; reg_type
($2, $2->name
, current_namespace
, 0); }
401 | gbl_statements apicontract_def
{ $$
= append_statement
($1, make_statement_type_decl
($2));
402 reg_type
($2, $2->name
, current_namespace
, 0); }
403 | gbl_statements runtimeclass
';' { $$
= $1; reg_type
($2, $2->name
, current_namespace
, 0); }
404 | gbl_statements runtimeclass_def
{ $$
= append_statement
($1, make_statement_type_decl
($2));
405 reg_type
($2, $2->name
, current_namespace
, 0); }
406 | gbl_statements moduledef
{ $$
= append_statement
($1, make_statement_module
($2)); }
407 | gbl_statements librarydef
{ $$
= append_statement
($1, make_statement_library
($2)); }
408 | gbl_statements statement
{ $$
= append_statement
($1, $2); }
409 | gbl_statements decl_block
{ $$
= append_statements
($1, $2); }
412 imp_statements: { $$
= NULL
; }
413 | imp_statements interface
';' { $$
= append_statement
($1, make_statement_reference
($2)); }
414 | imp_statements dispinterface
';' { $$
= append_statement
($1, make_statement_reference
($2)); }
415 | imp_statements namespacedef
'{' { push_namespace
($2); } imp_statements
'}'
416 { pop_namespace
($2); $$
= append_statements
($1, $5); }
417 | imp_statements interfacedef
{ $$
= append_statement
($1, make_statement_type_decl
($2)); }
418 | imp_statements delegatedef
{ $$
= append_statement
($1, make_statement_type_decl
($2)); }
419 | imp_statements coclass
';' { $$
= $1; reg_type
($2, $2->name
, current_namespace
, 0); }
420 | imp_statements coclassdef
{ $$
= append_statement
($1, make_statement_type_decl
($2));
421 reg_type
($2, $2->name
, current_namespace
, 0);
423 | imp_statements apicontract
';' { $$
= $1; reg_type
($2, $2->name
, current_namespace
, 0); }
424 | imp_statements apicontract_def
{ $$
= append_statement
($1, make_statement_type_decl
($2));
425 reg_type
($2, $2->name
, current_namespace
, 0); }
426 | imp_statements runtimeclass
';' { $$
= $1; reg_type
($2, $2->name
, current_namespace
, 0); }
427 | imp_statements runtimeclass_def
{ $$
= append_statement
($1, make_statement_type_decl
($2));
428 reg_type
($2, $2->name
, current_namespace
, 0); }
429 | imp_statements moduledef
{ $$
= append_statement
($1, make_statement_module
($2)); }
430 | imp_statements statement
{ $$
= append_statement
($1, $2); }
431 | imp_statements importlib
{ $$
= append_statement
($1, make_statement_importlib
($2)); }
432 | imp_statements librarydef
{ $$
= append_statement
($1, make_statement_library
($2)); }
433 | imp_statements imp_decl_block
{ $$
= append_statements
($1, $2); }
436 int_statements: { $$
= NULL
; }
437 | int_statements statement
{ $$
= append_statement
($1, $2); }
445 cppquote
{ $$
= make_statement_cppquote
($1); }
446 | typedecl
';' { $$
= make_statement_type_decl
($1); }
447 | declaration
';' { $$
= make_statement_declaration
($1); }
448 | import
{ $$
= make_statement_import
($1); }
449 | typedef
';' { $$
= $1; }
450 | aPRAGMA
{ $$
= make_statement_pragma
($1); }
451 | pragma_warning
{ $$
= NULL
; }
454 pragma_warning: tPRAGMA_WARNING
'(' aIDENTIFIER
':' warnings
')'
458 result
= do_warning
($3, $5);
460 error_loc
("expected \"disable\", \"enable\" or \"default\"\n");
462 | tPRAGMA_WARNING
'(' tDEFAULT
':' warnings
')'
465 do_warning
("default", $5);
470 aNUM
{ $$
= append_warning
(NULL
, $1); }
471 | warnings aNUM
{ $$
= append_warning
($1, $2); }
476 | tENUM aIDENTIFIER
{ $$
= type_new_enum
($2, current_namespace
, FALSE
, NULL
); }
478 | tSTRUCT aIDENTIFIER
{ $$
= type_new_struct
($2, current_namespace
, FALSE
, NULL
); }
480 | tUNION aIDENTIFIER
{ $$
= type_new_nonencapsulated_union
($2, FALSE
, NULL
); }
481 | attributes enumdef
{ $$
= $2; $$
->attrs
= check_enum_attrs
($1); }
482 | attributes structdef
{ $$
= $2; $$
->attrs
= check_struct_attrs
($1); }
483 | attributes uniondef
{ $$
= $2; $$
->attrs
= check_union_attrs
($1); }
486 cppquote: tCPPQUOTE
'(' aSTRING
')' { $$
= $3; }
488 import_start: tIMPORT aSTRING
';' { $$
= xmalloc
(sizeof
(struct _import_t
));
490 $$
->import_performed
= do_import
($2);
491 if
(!$$
->import_performed
) yychar = aEOF
;
495 import: import_start imp_statements aEOF
{ $$
= $1->name
;
496 if
($1->import_performed
) pop_import
();
501 importlib: tIMPORTLIB
'(' aSTRING
')'
502 semicolon_opt
{ $$
= $3; if
(!parse_only
) add_importlib
($3, current_typelib
); }
505 libraryhdr: tLIBRARY typename
{ $$
= $2; }
507 library_start: attributes libraryhdr
'{' { $$
= make_library
($2, check_library_attrs
($2, $1));
508 if
(!parse_only
&& do_typelib
) current_typelib
= $$
;
511 librarydef: library_start imp_statements
'}'
512 semicolon_opt
{ $$
= $1; $$
->stmts
= $2; }
515 m_args: { $$
= NULL
; }
519 arg_list: arg
{ check_arg_attrs
($1); $$
= append_var
( NULL
, $1 ); }
520 | arg_list
',' arg
{ check_arg_attrs
($3); $$
= append_var
( $1, $3 ); }
524 | arg_list
',' ELLIPSIS
{ $$
= append_var
( $1, make_var
(xstrdup
("...")) ); }
527 /* split into two rules to get bison to resolve a tVOID conflict */
528 arg: attributes decl_spec m_any_declarator
{ if
($2->stgclass
!= STG_NONE
&& $2->stgclass
!= STG_REGISTER
)
529 error_loc
("invalid storage class for function parameter\n");
530 $$
= declare_var
($1, $2, $3, TRUE
);
533 | decl_spec m_any_declarator
{ if
($1->stgclass
!= STG_NONE
&& $1->stgclass
!= STG_REGISTER
)
534 error_loc
("invalid storage class for function parameter\n");
535 $$
= declare_var
(NULL
, $1, $2, TRUE
);
540 array: '[' expr
']' { $$
= $2;
541 if
(!$$
->is_const || $$
->cval
<= 0)
542 error_loc
("array dimension is not a positive integer constant\n");
544 |
'[' '*' ']' { $$
= make_expr
(EXPR_VOID
); }
545 |
'[' ']' { $$
= make_expr
(EXPR_VOID
); }
548 m_attributes: { $$
= NULL
; }
553 '[' attrib_list
']' { $$
= $2; }
556 attrib_list: attribute
{ $$
= append_attr
( NULL
, $1 ); }
557 | attrib_list
',' attribute
{ $$
= append_attr
( $1, $3 ); }
558 | attrib_list
']' '[' attribute
{ $$
= append_attr
( $1, $4 ); }
561 str_list: aSTRING
{ $$
= append_str
( NULL
, $1 ); }
562 | str_list
',' aSTRING
{ $$
= append_str
( $1, $3 ); }
566 tAGILE
{ $$
= MARSHALING_AGILE
; }
567 | tNONE
{ $$
= MARSHALING_NONE
; }
568 | tSTANDARD
{ $$
= MARSHALING_STANDARD
; }
572 aNUM
{ $$
= MAKEVERSION
(0, $1); }
573 | aNUM
'.' aNUM
{ $$
= MAKEVERSION
($3, $1); }
576 contract_req: decl_spec
',' contract_ver
{ if
($1->type
->type_type
!= TYPE_APICONTRACT
)
577 error_loc
("type %s is not an apicontract\n", $1->type
->name
);
578 $$
= make_exprl
(EXPR_NUM
, $3);
579 $$
= make_exprt
(EXPR_GTREQL
, declare_var
(NULL
, $1, make_declarator
(NULL
), 0), $$
);
582 static_attr: decl_spec
',' contract_req
{ if
($1->type
->type_type
!= TYPE_INTERFACE
)
583 error_loc
("type %s is not an interface\n", $1->type
->name
);
584 $$
= make_exprt
(EXPR_MEMBER
, declare_var
(NULL
, $1, make_declarator
(NULL
), 0), $3);
588 decl_spec
',' contract_req
{ if
($1->type
->type_type
!= TYPE_INTERFACE
)
589 error_loc
("type %s is not an interface\n", $1->type
->name
);
590 $$
= make_exprt
(EXPR_MEMBER
, declare_var
(NULL
, $1, make_declarator
(NULL
), 0), $3);
592 | contract_req
{ $$
= $1; } /* activatable on the default activation factory */
594 attribute: { $$
= NULL
; }
595 | tACTIVATABLE
'(' activatable_attr
')' { $$
= make_attrp
(ATTR_ACTIVATABLE
, $3); }
596 | tAGGREGATABLE
{ $$
= make_attr
(ATTR_AGGREGATABLE
); }
597 | tANNOTATION
'(' aSTRING
')' { $$
= make_attrp
(ATTR_ANNOTATION
, $3); }
598 | tAPPOBJECT
{ $$
= make_attr
(ATTR_APPOBJECT
); }
599 | tASYNC
{ $$
= make_attr
(ATTR_ASYNC
); }
600 | tAUTOHANDLE
{ $$
= make_attr
(ATTR_AUTO_HANDLE
); }
601 | tBINDABLE
{ $$
= make_attr
(ATTR_BINDABLE
); }
602 | tBROADCAST
{ $$
= make_attr
(ATTR_BROADCAST
); }
603 | tCALLAS
'(' ident
')' { $$
= make_attrp
(ATTR_CALLAS
, $3); }
604 | tCASE
'(' expr_list_int_const
')' { $$
= make_attrp
(ATTR_CASE
, $3); }
605 | tCODE
{ $$
= make_attr
(ATTR_CODE
); }
606 | tCOMMSTATUS
{ $$
= make_attr
(ATTR_COMMSTATUS
); }
607 | tCONTEXTHANDLE
{ $$
= make_attrv
(ATTR_CONTEXTHANDLE
, 0); }
608 | tCONTEXTHANDLENOSERIALIZE
{ $$
= make_attrv
(ATTR_CONTEXTHANDLE
, 0); /* RPC_CONTEXT_HANDLE_DONT_SERIALIZE */ }
609 | tCONTEXTHANDLESERIALIZE
{ $$
= make_attrv
(ATTR_CONTEXTHANDLE
, 0); /* RPC_CONTEXT_HANDLE_SERIALIZE */ }
610 | tCONTRACT
'(' contract_req
')' { $$
= make_attrp
(ATTR_CONTRACT
, $3); }
611 | tCONTRACTVERSION
'(' contract_ver
')' { $$
= make_attrv
(ATTR_CONTRACTVERSION
, $3); }
612 | tCONTROL
{ $$
= make_attr
(ATTR_CONTROL
); }
613 | tCUSTOM
'(' uuid_string
',' expr_const
')' { $$
= make_custom_attr
($3, $5); }
614 | tDECODE
{ $$
= make_attr
(ATTR_DECODE
); }
615 | tDEFAULT
{ $$
= make_attr
(ATTR_DEFAULT
); }
616 | tDEFAULTBIND
{ $$
= make_attr
(ATTR_DEFAULTBIND
); }
617 | tDEFAULTCOLLELEM
{ $$
= make_attr
(ATTR_DEFAULTCOLLELEM
); }
618 | tDEFAULTVALUE
'(' expr_const
')' { $$
= make_attrp
(ATTR_DEFAULTVALUE
, $3); }
619 | tDEFAULTVTABLE
{ $$
= make_attr
(ATTR_DEFAULTVTABLE
); }
620 | tDISABLECONSISTENCYCHECK
{ $$
= make_attr
(ATTR_DISABLECONSISTENCYCHECK
); }
621 | tDISPLAYBIND
{ $$
= make_attr
(ATTR_DISPLAYBIND
); }
622 | tDLLNAME
'(' aSTRING
')' { $$
= make_attrp
(ATTR_DLLNAME
, $3); }
623 | tDUAL
{ $$
= make_attr
(ATTR_DUAL
); }
624 | tENABLEALLOCATE
{ $$
= make_attr
(ATTR_ENABLEALLOCATE
); }
625 | tENCODE
{ $$
= make_attr
(ATTR_ENCODE
); }
626 | tENDPOINT
'(' str_list
')' { $$
= make_attrp
(ATTR_ENDPOINT
, $3); }
627 | tENTRY
'(' expr_const
')' { $$
= make_attrp
(ATTR_ENTRY
, $3); }
628 | tEVENTADD
{ $$
= make_attr
(ATTR_EVENTADD
); }
629 | tEVENTREMOVE
{ $$
= make_attr
(ATTR_EVENTREMOVE
); }
630 | tEXCLUSIVETO
'(' decl_spec
')' { if
($3->type
->type_type
!= TYPE_RUNTIMECLASS
)
631 error_loc
("type %s is not a runtimeclass\n", $3->type
->name
);
632 $$
= make_attrp
(ATTR_EXCLUSIVETO
, $3->type
); }
633 | tEXPLICITHANDLE
{ $$
= make_attr
(ATTR_EXPLICIT_HANDLE
); }
634 | tFAULTSTATUS
{ $$
= make_attr
(ATTR_FAULTSTATUS
); }
635 | tFLAGS
{ $$
= make_attr
(ATTR_FLAGS
); }
636 | tFORCEALLOCATE
{ $$
= make_attr
(ATTR_FORCEALLOCATE
); }
637 | tHANDLE
{ $$
= make_attr
(ATTR_HANDLE
); }
638 | tHELPCONTEXT
'(' expr_int_const
')' { $$
= make_attrp
(ATTR_HELPCONTEXT
, $3); }
639 | tHELPFILE
'(' aSTRING
')' { $$
= make_attrp
(ATTR_HELPFILE
, $3); }
640 | tHELPSTRING
'(' aSTRING
')' { $$
= make_attrp
(ATTR_HELPSTRING
, $3); }
641 | tHELPSTRINGCONTEXT
'(' expr_int_const
')' { $$
= make_attrp
(ATTR_HELPSTRINGCONTEXT
, $3); }
642 | tHELPSTRINGDLL
'(' aSTRING
')' { $$
= make_attrp
(ATTR_HELPSTRINGDLL
, $3); }
643 | tHIDDEN
{ $$
= make_attr
(ATTR_HIDDEN
); }
644 | tID
'(' expr_int_const
')' { $$
= make_attrp
(ATTR_ID
, $3); }
645 | tIDEMPOTENT
{ $$
= make_attr
(ATTR_IDEMPOTENT
); }
646 | tIGNORE
{ $$
= make_attr
(ATTR_IGNORE
); }
647 | tIIDIS
'(' expr
')' { $$
= make_attrp
(ATTR_IIDIS
, $3); }
648 | tIMMEDIATEBIND
{ $$
= make_attr
(ATTR_IMMEDIATEBIND
); }
649 | tIMPLICITHANDLE
'(' arg
')' { $$
= make_attrp
(ATTR_IMPLICIT_HANDLE
, $3); }
650 | tIN
{ $$
= make_attr
(ATTR_IN
); }
651 | tINPUTSYNC
{ $$
= make_attr
(ATTR_INPUTSYNC
); }
652 | tLENGTHIS
'(' m_exprs
')' { $$
= make_attrp
(ATTR_LENGTHIS
, $3); }
653 | tLCID
'(' expr_int_const
')' { $$
= make_attrp
(ATTR_LIBLCID
, $3); }
654 | tLCID
{ $$
= make_attr
(ATTR_PARAMLCID
); }
655 | tLICENSED
{ $$
= make_attr
(ATTR_LICENSED
); }
656 | tLOCAL
{ $$
= make_attr
(ATTR_LOCAL
); }
657 | tMARSHALINGBEHAVIOR
'(' marshaling_behavior
')'
658 { $$
= make_attrv
(ATTR_MARSHALING_BEHAVIOR
, $3); }
659 | tMAYBE
{ $$
= make_attr
(ATTR_MAYBE
); }
660 | tMESSAGE
{ $$
= make_attr
(ATTR_MESSAGE
); }
661 | tNOCODE
{ $$
= make_attr
(ATTR_NOCODE
); }
662 | tNONBROWSABLE
{ $$
= make_attr
(ATTR_NONBROWSABLE
); }
663 | tNONCREATABLE
{ $$
= make_attr
(ATTR_NONCREATABLE
); }
664 | tNONEXTENSIBLE
{ $$
= make_attr
(ATTR_NONEXTENSIBLE
); }
665 | tNOTIFY
{ $$
= make_attr
(ATTR_NOTIFY
); }
666 | tNOTIFYFLAG
{ $$
= make_attr
(ATTR_NOTIFYFLAG
); }
667 | tOBJECT
{ $$
= make_attr
(ATTR_OBJECT
); }
668 | tODL
{ $$
= make_attr
(ATTR_ODL
); }
669 | tOLEAUTOMATION
{ $$
= make_attr
(ATTR_OLEAUTOMATION
); }
670 | tOPTIMIZE
'(' aSTRING
')' { $$
= make_attrp
(ATTR_OPTIMIZE
, $3); }
671 | tOPTIONAL
{ $$
= make_attr
(ATTR_OPTIONAL
); }
672 | tOUT
{ $$
= make_attr
(ATTR_OUT
); }
673 | tOVERLOAD
'(' aSTRING
')' { $$
= make_attrp
(ATTR_OVERLOAD
, $3); }
674 | tPARTIALIGNORE
{ $$
= make_attr
(ATTR_PARTIALIGNORE
); }
675 | tPOINTERDEFAULT
'(' pointer_type
')' { $$
= make_attrv
(ATTR_POINTERDEFAULT
, $3); }
676 | tPROGID
'(' aSTRING
')' { $$
= make_attrp
(ATTR_PROGID
, $3); }
677 | tPROPGET
{ $$
= make_attr
(ATTR_PROPGET
); }
678 | tPROPPUT
{ $$
= make_attr
(ATTR_PROPPUT
); }
679 | tPROPPUTREF
{ $$
= make_attr
(ATTR_PROPPUTREF
); }
680 | tPROXY
{ $$
= make_attr
(ATTR_PROXY
); }
681 | tPUBLIC
{ $$
= make_attr
(ATTR_PUBLIC
); }
682 | tRANGE
'(' expr_int_const
',' expr_int_const
')'
683 { expr_list_t
*list
= append_expr
( NULL
, $3 );
684 list
= append_expr
( list
, $5 );
685 $$
= make_attrp
(ATTR_RANGE
, list
); }
686 | tREADONLY
{ $$
= make_attr
(ATTR_READONLY
); }
687 | tREPRESENTAS
'(' type
')' { $$
= make_attrp
(ATTR_REPRESENTAS
, $3); }
688 | tREQUESTEDIT
{ $$
= make_attr
(ATTR_REQUESTEDIT
); }
689 | tRESTRICTED
{ $$
= make_attr
(ATTR_RESTRICTED
); }
690 | tRETVAL
{ $$
= make_attr
(ATTR_RETVAL
); }
691 | tSIZEIS
'(' m_exprs
')' { $$
= make_attrp
(ATTR_SIZEIS
, $3); }
692 | tSOURCE
{ $$
= make_attr
(ATTR_SOURCE
); }
693 | tSTATIC
'(' static_attr
')' { $$
= make_attrp
(ATTR_STATIC
, $3); }
694 | tSTRICTCONTEXTHANDLE
{ $$
= make_attr
(ATTR_STRICTCONTEXTHANDLE
); }
695 | tSTRING
{ $$
= make_attr
(ATTR_STRING
); }
696 | tSWITCHIS
'(' expr
')' { $$
= make_attrp
(ATTR_SWITCHIS
, $3); }
697 | tSWITCHTYPE
'(' type
')' { $$
= make_attrp
(ATTR_SWITCHTYPE
, $3); }
698 | tTRANSMITAS
'(' type
')' { $$
= make_attrp
(ATTR_TRANSMITAS
, $3); }
699 | tTHREADING
'(' threading_type
')' { $$
= make_attrv
(ATTR_THREADING
, $3); }
700 | tUIDEFAULT
{ $$
= make_attr
(ATTR_UIDEFAULT
); }
701 | tUSESGETLASTERROR
{ $$
= make_attr
(ATTR_USESGETLASTERROR
); }
702 | tUSERMARSHAL
'(' type
')' { $$
= make_attrp
(ATTR_USERMARSHAL
, $3); }
703 | tUUID
'(' uuid_string
')' { $$
= make_attrp
(ATTR_UUID
, $3); }
704 | tASYNCUUID
'(' uuid_string
')' { $$
= make_attrp
(ATTR_ASYNCUUID
, $3); }
705 | tV1ENUM
{ $$
= make_attr
(ATTR_V1ENUM
); }
706 | tVARARG
{ $$
= make_attr
(ATTR_VARARG
); }
707 | tVERSION
'(' version
')' { $$
= make_attrv
(ATTR_VERSION
, $3); }
708 | tVIPROGID
'(' aSTRING
')' { $$
= make_attrp
(ATTR_VIPROGID
, $3); }
709 | tWIREMARSHAL
'(' type
')' { $$
= make_attrp
(ATTR_WIREMARSHAL
, $3); }
710 | pointer_type
{ $$
= make_attrv
(ATTR_POINTERTYPE
, $1); }
715 | aSTRING
{ if
(!is_valid_uuid
($1))
716 error_loc
("invalid UUID: %s\n", $1);
717 $$
= parse_uuid
($1); }
720 callconv: tCDECL
{ $$
= xstrdup
("__cdecl"); }
721 | tFASTCALL
{ $$
= xstrdup
("__fastcall"); }
722 | tPASCAL
{ $$
= xstrdup
("__pascal"); }
723 | tSTDCALL
{ $$
= xstrdup
("__stdcall"); }
726 cases: { $$
= NULL
; }
727 | cases case
{ $$
= append_var
( $1, $2 ); }
730 case: tCASE expr_int_const
':' union_field
{ attr_t
*a
= make_attrp
(ATTR_CASE
, append_expr
( NULL
, $2 ));
731 $$
= $4; if
(!$$
) $$
= make_var
(NULL
);
732 $$
->attrs
= append_attr
( $$
->attrs
, a
);
734 | tDEFAULT
':' union_field
{ attr_t
*a
= make_attr
(ATTR_DEFAULT
);
735 $$
= $3; if
(!$$
) $$
= make_var
(NULL
);
736 $$
->attrs
= append_attr
( $$
->attrs
, a
);
740 enums: { $$
= NULL
; }
741 | enum_list
',' { $$
= $1; }
745 enum_list: enum { if
(!$1->eval
)
746 $1->eval
= make_exprl
(EXPR_NUM
, 0 /* default for first enum entry */);
747 $$
= append_var
( NULL
, $1 );
749 | enum_list
',' enum { if
(!$3->eval
)
751 var_t
*last
= LIST_ENTRY
( list_tail
($$
), var_t
, entry
);
752 enum expr_type type
= EXPR_NUM
;
753 if
(last
->eval
->type
== EXPR_HEXNUM
) type
= EXPR_HEXNUM
;
754 if
(last
->eval
->cval
+ 1 < 0) type
= EXPR_HEXNUM
;
755 $3->eval
= make_exprl
(type
, last
->eval
->cval
+ 1);
757 $$
= append_var
( $1, $3 );
761 enum_member: m_attributes ident
{ $$
= $2;
762 $$
->attrs
= check_enum_member_attrs
($1);
766 enum: enum_member
'=' expr_int_const
{ $$
= reg_const
($1);
768 $$
->declspec.type
= type_new_int
(TYPE_BASIC_INT
, 0);
770 | enum_member
{ $$
= reg_const
($1);
771 $$
->declspec.type
= type_new_int
(TYPE_BASIC_INT
, 0);
775 enumdef: tENUM m_typename
'{' enums
'}' { $$
= type_new_enum
($2, current_namespace
, TRUE
, $4); }
778 m_exprs: m_expr
{ $$
= append_expr
( NULL
, $1 ); }
779 | m_exprs
',' m_expr
{ $$
= append_expr
( $1, $3 ); }
782 m_expr: { $$
= make_expr
(EXPR_VOID
); }
786 expr: aNUM
{ $$
= make_exprl
(EXPR_NUM
, $1); }
787 | aHEXNUM
{ $$
= make_exprl
(EXPR_HEXNUM
, $1); }
788 | aDOUBLE
{ $$
= make_exprd
(EXPR_DOUBLE
, $1); }
789 | tFALSE
{ $$
= make_exprl
(EXPR_TRUEFALSE
, 0); }
790 | tNULL
{ $$
= make_exprl
(EXPR_NUM
, 0); }
791 | tTRUE
{ $$
= make_exprl
(EXPR_TRUEFALSE
, 1); }
792 | aSTRING
{ $$
= make_exprs
(EXPR_STRLIT
, $1); }
793 | aWSTRING
{ $$
= make_exprs
(EXPR_WSTRLIT
, $1); }
794 | aSQSTRING
{ $$
= make_exprs
(EXPR_CHARCONST
, $1); }
795 | aIDENTIFIER
{ $$
= make_exprs
(EXPR_IDENTIFIER
, $1); }
796 | expr
'?' expr
':' expr
{ $$
= make_expr3
(EXPR_COND
, $1, $3, $5); }
797 | expr LOGICALOR expr
{ $$
= make_expr2
(EXPR_LOGOR
, $1, $3); }
798 | expr LOGICALAND expr
{ $$
= make_expr2
(EXPR_LOGAND
, $1, $3); }
799 | expr
'|' expr
{ $$
= make_expr2
(EXPR_OR
, $1, $3); }
800 | expr
'^' expr
{ $$
= make_expr2
(EXPR_XOR
, $1, $3); }
801 | expr
'&' expr
{ $$
= make_expr2
(EXPR_AND
, $1, $3); }
802 | expr EQUALITY expr
{ $$
= make_expr2
(EXPR_EQUALITY
, $1, $3); }
803 | expr INEQUALITY expr
{ $$
= make_expr2
(EXPR_INEQUALITY
, $1, $3); }
804 | expr
'>' expr
{ $$
= make_expr2
(EXPR_GTR
, $1, $3); }
805 | expr
'<' expr
{ $$
= make_expr2
(EXPR_LESS
, $1, $3); }
806 | expr GREATEREQUAL expr
{ $$
= make_expr2
(EXPR_GTREQL
, $1, $3); }
807 | expr LESSEQUAL expr
{ $$
= make_expr2
(EXPR_LESSEQL
, $1, $3); }
808 | expr SHL expr
{ $$
= make_expr2
(EXPR_SHL
, $1, $3); }
809 | expr SHR expr
{ $$
= make_expr2
(EXPR_SHR
, $1, $3); }
810 | expr
'+' expr
{ $$
= make_expr2
(EXPR_ADD
, $1, $3); }
811 | expr
'-' expr
{ $$
= make_expr2
(EXPR_SUB
, $1, $3); }
812 | expr
'%' expr
{ $$
= make_expr2
(EXPR_MOD
, $1, $3); }
813 | expr
'*' expr
{ $$
= make_expr2
(EXPR_MUL
, $1, $3); }
814 | expr
'/' expr
{ $$
= make_expr2
(EXPR_DIV
, $1, $3); }
815 |
'!' expr
{ $$
= make_expr1
(EXPR_LOGNOT
, $2); }
816 |
'~' expr
{ $$
= make_expr1
(EXPR_NOT
, $2); }
817 |
'+' expr %prec POS
{ $$
= make_expr1
(EXPR_POS
, $2); }
818 |
'-' expr %prec NEG
{ $$
= make_expr1
(EXPR_NEG
, $2); }
819 |
'&' expr %prec ADDRESSOF
{ $$
= make_expr1
(EXPR_ADDRESSOF
, $2); }
820 |
'*' expr %prec PPTR
{ $$
= make_expr1
(EXPR_PPTR
, $2); }
821 | expr MEMBERPTR aIDENTIFIER
{ $$
= make_expr2
(EXPR_MEMBER
, make_expr1
(EXPR_PPTR
, $1), make_exprs
(EXPR_IDENTIFIER
, $3)); }
822 | expr
'.' aIDENTIFIER
{ $$
= make_expr2
(EXPR_MEMBER
, $1, make_exprs
(EXPR_IDENTIFIER
, $3)); }
823 |
'(' unqualified_decl_spec m_abstract_declarator
')' expr %prec CAST
824 { $$
= make_exprt
(EXPR_CAST
, declare_var
(NULL
, $2, $3, 0), $5); free
($2); free
($3); }
825 | tSIZEOF
'(' unqualified_decl_spec m_abstract_declarator
')'
826 { $$
= make_exprt
(EXPR_SIZEOF
, declare_var
(NULL
, $3, $4, 0), NULL
); free
($3); free
($4); }
827 | expr
'[' expr
']' { $$
= make_expr2
(EXPR_ARRAY
, $1, $3); }
828 |
'(' expr
')' { $$
= $2; }
831 expr_list_int_const: expr_int_const
{ $$
= append_expr
( NULL
, $1 ); }
832 | expr_list_int_const
',' expr_int_const
{ $$
= append_expr
( $1, $3 ); }
835 expr_int_const: expr
{ $$
= $1;
837 error_loc
("expression is not an integer constant\n");
841 expr_const: expr
{ $$
= $1;
842 if
(!$$
->is_const
&& $$
->type
!= EXPR_STRLIT
&& $$
->type
!= EXPR_WSTRLIT
)
843 error_loc
("expression is not constant\n");
847 fields: { $$
= NULL
; }
848 | fields field
{ $$
= append_var_list
($1, $2); }
851 field: m_attributes decl_spec struct_declarator_list
';'
852 { const char *first
= LIST_ENTRY
(list_head
($3), declarator_t
, entry
)->var
->name
;
853 check_field_attrs
(first
, $1);
854 $$
= set_var_types
($1, $2, $3);
856 | m_attributes uniondef
';' { var_t
*v
= make_var
(NULL
);
857 v
->declspec.type
= $2; v
->attrs
= $1;
858 $$
= append_var
(NULL
, v
);
863 s_field
';' { $$
= $1; }
864 | attributes
';' { $$
= make_var
(NULL
); $$
->attrs
= $1; }
867 ne_union_fields: { $$
= NULL
; }
868 | ne_union_fields ne_union_field
{ $$
= append_var
( $1, $2 ); }
872 s_field
';' { $$
= $1; }
876 s_field: m_attributes decl_spec declarator
{ $$
= declare_var
(check_field_attrs
($3->var
->name
, $1),
880 | m_attributes structdef
{ var_t
*v
= make_var
(NULL
);
881 v
->declspec.type
= $2; v
->attrs
= $1;
886 funcdef: declaration
{ $$
= $1;
887 if
(type_get_type
($$
->declspec.type
) != TYPE_FUNCTION
)
888 error_loc
("only methods may be declared inside the methods section of a dispinterface\n");
889 check_function_attrs
($$
->name
, $$
->attrs
);
894 attributes decl_spec init_declarator
895 { $$
= declare_var
($1, $2, $3, FALSE
);
898 | decl_spec init_declarator
{ $$
= declare_var
(NULL
, $1, $2, FALSE
);
903 m_ident: { $$
= NULL
; }
907 m_typename: { $$
= NULL
; }
911 typename: aIDENTIFIER
915 ident: typename
{ $$
= make_var
($1); }
918 base_type: tBYTE
{ $$
= find_type_or_error
(NULL
, $
<str
>1); }
919 | tWCHAR
{ $$
= find_type_or_error
(NULL
, $
<str
>1); }
921 | tSIGNED int_std
{ $$
= type_new_int
(type_basic_get_type
($2), -1); }
922 | tUNSIGNED int_std
{ $$
= type_new_int
(type_basic_get_type
($2), 1); }
923 | tUNSIGNED
{ $$
= type_new_int
(TYPE_BASIC_INT
, 1); }
924 | tFLOAT
{ $$
= find_type_or_error
(NULL
, $
<str
>1); }
925 | tDOUBLE
{ $$
= find_type_or_error
(NULL
, $
<str
>1); }
926 | tBOOLEAN
{ $$
= find_type_or_error
(NULL
, $
<str
>1); }
927 | tERRORSTATUST
{ $$
= find_type_or_error
(NULL
, $
<str
>1); }
928 | tHANDLET
{ $$
= find_type_or_error
(NULL
, $
<str
>1); }
935 int_std: tINT
{ $$
= type_new_int
(TYPE_BASIC_INT
, 0); }
936 | tSHORT m_int
{ $$
= type_new_int
(TYPE_BASIC_INT16
, 0); }
937 | tSMALL
{ $$
= type_new_int
(TYPE_BASIC_INT8
, 0); }
938 | tLONG m_int
{ $$
= type_new_int
(TYPE_BASIC_LONG
, 0); }
939 | tHYPER m_int
{ $$
= type_new_int
(TYPE_BASIC_HYPER
, 0); }
940 | tINT64
{ $$
= type_new_int
(TYPE_BASIC_INT64
, 0); }
941 | tCHAR
{ $$
= type_new_int
(TYPE_BASIC_CHAR
, 0); }
942 | tINT32
{ $$
= type_new_int
(TYPE_BASIC_INT32
, 0); }
943 | tINT3264
{ $$
= type_new_int
(TYPE_BASIC_INT3264
, 0); }
947 aIDENTIFIER
'.' { $$
= find_namespace_or_error
(&global_namespace
, $1); }
948 | namespace_pfx aIDENTIFIER
'.' { $$
= find_namespace_or_error
($1, $2); }
952 typename
{ $$
= find_type_or_error
(current_namespace
, $1); }
953 | namespace_pfx typename
{ $$
= find_type_or_error
($1, $2); }
956 parameterized_type: qualified_type
'<' parameterized_type_args
'>'
957 { $$
= find_parameterized_type
($1, $3); }
960 parameterized_type_arg:
961 base_type
{ $$
= $1; }
962 | qualified_type
{ $$
= $1; }
963 | qualified_type
'*' { $$
= type_new_pointer
($1); }
964 | parameterized_type
{ $$
= $1; }
965 | parameterized_type
'*' { $$
= type_new_pointer
($1); }
968 parameterized_type_args:
969 parameterized_type_arg
{ $$
= append_typeref
(NULL
, make_typeref
($1)); }
970 | parameterized_type_args
',' parameterized_type_arg
971 { $$
= append_typeref
($1, make_typeref
($3)); }
974 coclass: tCOCLASS typename
{ $$
= type_coclass_declare
($2); }
977 coclassdef: attributes coclass
'{' class_interfaces
'}' semicolon_opt
978 { $$
= type_coclass_define
($2, $1, $4); }
981 runtimeclass: tRUNTIMECLASS typename
{ $$
= type_runtimeclass_declare
($2, current_namespace
); }
984 runtimeclass_def: attributes runtimeclass
'{' class_interfaces
'}' semicolon_opt
985 { $$
= type_runtimeclass_define
($2, $1, $4); }
988 apicontract: tAPICONTRACT typename
{ $$
= type_apicontract_declare
($2, current_namespace
); }
991 apicontract_def: attributes apicontract
'{' '}' semicolon_opt
992 { $$
= type_apicontract_define
($2, $1); }
995 namespacedef: tNAMESPACE aIDENTIFIER
{ $$
= $2; }
998 class_interfaces: { $$
= NULL
; }
999 | class_interfaces class_interface
{ $$
= append_typeref
( $1, $2 ); }
1003 m_attributes interfaceref
';' { $$
= make_typeref
($2); $$
->attrs
= $1; }
1004 | m_attributes dispinterfaceref
';' { $$
= make_typeref
($2); $$
->attrs
= $1; }
1007 dispinterface: tDISPINTERFACE typename
{ $$
= type_dispinterface_declare
($2); }
1010 dispattributes: attributes
{ $$
= append_attr
($1, make_attr
(ATTR_DISPINTERFACE
)); }
1013 dispint_props: tPROPERTIES
':' { $$
= NULL
; }
1014 | dispint_props s_field
';' { $$
= append_var
( $1, $2 ); }
1017 dispint_meths: tMETHODS
':' { $$
= NULL
; }
1018 | dispint_meths funcdef
';' { $$
= append_var
( $1, $2 ); }
1022 dispattributes dispinterface
'{' dispint_props dispint_meths
'}'
1023 { $$
= type_dispinterface_define
($2, $1, $4, $5); }
1024 | dispattributes dispinterface
'{' interface
';' '}'
1025 { $$
= type_dispinterface_define_from_iface
($2, $1, $4); }
1028 inherit: { $$
= NULL
; }
1029 |
':' qualified_type
{ $$
= $2; }
1030 |
':' parameterized_type
{ $$
= $2; }
1033 type_parameter: typename
{ $$
= get_type
(TYPE_PARAMETER
, $1, parameters_namespace
, 0); }
1037 type_parameter
{ $$
= append_typeref
(NULL
, make_typeref
($1)); }
1038 | type_parameters
',' type_parameter
{ $$
= append_typeref
($1, make_typeref
($3)); }
1042 tINTERFACE typename
{ $$
= type_interface_declare
($2, current_namespace
); }
1043 | tINTERFACE typename
'<' { push_parameters_namespace
($2); } type_parameters
{ pop_parameters_namespace
($2); } '>'
1044 { $$
= type_parameterized_interface_declare
($2, current_namespace
, $5); }
1047 delegatedef: m_attributes tDELEGATE type ident
'(' m_args
')' semicolon_opt
1048 { $$
= type_delegate_declare
($4->name
, current_namespace
);
1049 $$
= type_delegate_define
($$
, $1, append_statement
(NULL
, make_statement_delegate
($3, $6)));
1051 | m_attributes tDELEGATE type ident
1052 '<' { push_parameters_namespace
($4->name
); } type_parameters
'>'
1053 '(' m_args
')' { pop_parameters_namespace
($4->name
); } semicolon_opt
1054 { $$
= type_parameterized_delegate_declare
($4->name
, current_namespace
, $7);
1055 $$
= type_parameterized_delegate_define
($$
, $1, append_statement
(NULL
, make_statement_delegate
($3, $10)));
1060 qualified_type
{ $$
= append_typeref
(NULL
, make_typeref
($1)); }
1061 | parameterized_type
{ $$
= append_typeref
(NULL
, make_typeref
($1)); }
1062 | required_types
',' qualified_type
{ $$
= append_typeref
($1, make_typeref
($3)); }
1063 | required_types
',' parameterized_type
{ $$
= append_typeref
($1, make_typeref
($3)); }
1065 requires: { $$
= NULL
; }
1066 | tREQUIRES required_types
{ $$
= $2; }
1069 interfacedef: attributes interface
{ if
($2->type_type
== TYPE_PARAMETERIZED_TYPE
) push_parameters_namespace
($2->name
); }
1070 inherit requires
'{' int_statements
'}' semicolon_opt
1071 { if
($2->type_type
== TYPE_PARAMETERIZED_TYPE
)
1073 $$
= type_parameterized_interface_define
($2, $1, $4, $7, $5);
1074 pop_parameters_namespace
($2->name
);
1078 $$
= type_interface_define
($2, $1, $4, $7, $5);
1079 check_async_uuid
($$
);
1082 | dispinterfacedef semicolon_opt
{ $$
= $1; }
1086 tINTERFACE typename
{ $$
= get_type
(TYPE_INTERFACE
, $2, current_namespace
, 0); }
1087 | tINTERFACE namespace_pfx typename
{ $$
= get_type
(TYPE_INTERFACE
, $3, $2, 0); }
1091 tDISPINTERFACE typename
{ $$
= get_type
(TYPE_INTERFACE
, $2, current_namespace
, 0); }
1094 module: tMODULE typename
{ $$
= type_module_declare
($2); }
1097 moduledef: m_attributes module
'{' int_statements
'}' semicolon_opt
1098 { $$
= type_module_define
($2, $1, $4); }
1102 tEXTERN
{ $$
= STG_EXTERN
; }
1103 | tSTATIC
{ $$
= STG_STATIC
; }
1104 | tREGISTER
{ $$
= STG_REGISTER
; }
1108 tINLINE
{ $$
= FUNCTION_SPECIFIER_INLINE
; }
1112 tCONST
{ $$
= TYPE_QUALIFIER_CONST
; }
1115 m_type_qual_list: { $$
= 0; }
1116 | m_type_qual_list type_qualifier
{ $$
= $1 |
$2; }
1119 decl_spec: type m_decl_spec_no_type
{ $$
= make_decl_spec
($1, $2, NULL
, STG_NONE
, 0, 0); }
1120 | decl_spec_no_type type m_decl_spec_no_type
1121 { $$
= make_decl_spec
($2, $1, $3, STG_NONE
, 0, 0); }
1124 unqualified_decl_spec: unqualified_type m_decl_spec_no_type
1125 { $$
= make_decl_spec
($1, $2, NULL
, STG_NONE
, 0, 0); }
1126 | decl_spec_no_type unqualified_type m_decl_spec_no_type
1127 { $$
= make_decl_spec
($2, $1, $3, STG_NONE
, 0, 0); }
1130 m_decl_spec_no_type: { $$
= NULL
; }
1135 type_qualifier m_decl_spec_no_type
{ $$
= make_decl_spec
(NULL
, $2, NULL
, STG_NONE
, $1, 0); }
1136 | function_specifier m_decl_spec_no_type
{ $$
= make_decl_spec
(NULL
, $2, NULL
, STG_NONE
, 0, $1); }
1137 | storage_cls_spec m_decl_spec_no_type
{ $$
= make_decl_spec
(NULL
, $2, NULL
, $1, 0, 0); }
1141 '*' m_type_qual_list declarator %prec PPTR
1142 { $$
= $3; append_chain_type
($$
, type_new_pointer
(NULL
), $2); }
1143 | callconv declarator
{ $$
= $2; append_chain_callconv
($$
->type
, $1); }
1148 ident
{ $$
= make_declarator
($1); }
1149 |
'(' declarator
')' { $$
= $2; }
1150 | direct_declarator array
{ $$
= $1; append_array
($$
, $2); }
1151 | direct_declarator
'(' m_args
')' { $$
= $1; append_chain_type
($$
, type_new_function
($3), 0); }
1154 /* abstract declarator */
1155 abstract_declarator:
1156 '*' m_type_qual_list m_abstract_declarator %prec PPTR
1157 { $$
= $3; append_chain_type
($$
, type_new_pointer
(NULL
), $2); }
1158 | callconv m_abstract_declarator
{ $$
= $2; append_chain_callconv
($$
->type
, $1); }
1159 | abstract_direct_declarator
1162 /* abstract declarator without accepting direct declarator */
1163 abstract_declarator_no_direct:
1164 '*' m_type_qual_list m_any_declarator %prec PPTR
1165 { $$
= $3; append_chain_type
($$
, type_new_pointer
(NULL
), $2); }
1166 | callconv m_any_declarator
{ $$
= $2; append_chain_callconv
($$
->type
, $1); }
1169 /* abstract declarator or empty */
1170 m_abstract_declarator: { $$
= make_declarator
(NULL
); }
1171 | abstract_declarator
1174 /* abstract direct declarator */
1175 abstract_direct_declarator:
1176 '(' abstract_declarator_no_direct
')' { $$
= $2; }
1177 | abstract_direct_declarator array
{ $$
= $1; append_array
($$
, $2); }
1178 | array
{ $$
= make_declarator
(NULL
); append_array
($$
, $1); }
1180 { $$
= make_declarator
(NULL
);
1181 append_chain_type
($$
, type_new_function
($2), 0);
1183 | abstract_direct_declarator
'(' m_args
')'
1185 append_chain_type
($$
, type_new_function
($3), 0);
1189 /* abstract or non-abstract declarator */
1191 '*' m_type_qual_list m_any_declarator %prec PPTR
1192 { $$
= $3; append_chain_type
($$
, type_new_pointer
(NULL
), $2); }
1193 | callconv m_any_declarator
{ $$
= $2; append_chain_callconv
($$
->type
, $1); }
1194 | any_direct_declarator
1197 /* abstract or non-abstract declarator without accepting direct declarator */
1198 any_declarator_no_direct:
1199 '*' m_type_qual_list m_any_declarator %prec PPTR
1200 { $$
= $3; append_chain_type
($$
, type_new_pointer
(NULL
), $2); }
1201 | callconv m_any_declarator
{ $$
= $2; append_chain_callconv
($$
->type
, $1); }
1204 /* abstract or non-abstract declarator or empty */
1205 m_any_declarator: { $$
= make_declarator
(NULL
); }
1209 /* abstract or non-abstract direct declarator. note: direct declarators
1210 * aren't accepted inside brackets to avoid ambiguity with the rule for
1211 * function arguments */
1212 any_direct_declarator:
1213 ident
{ $$
= make_declarator
($1); }
1214 |
'(' any_declarator_no_direct
')' { $$
= $2; }
1215 | any_direct_declarator array
{ $$
= $1; append_array
($$
, $2); }
1216 | array
{ $$
= make_declarator
(NULL
); append_array
($$
, $1); }
1218 { $$
= make_declarator
(NULL
);
1219 append_chain_type
($$
, type_new_function
($2), 0);
1221 | any_direct_declarator
'(' m_args
')'
1223 append_chain_type
($$
, type_new_function
($3), 0);
1228 declarator
{ $$
= append_declarator
( NULL
, $1 ); }
1229 | declarator_list
',' declarator
{ $$
= append_declarator
( $1, $3 ); }
1232 m_bitfield: { $$
= NULL
; }
1233 |
':' expr_const
{ $$
= $2; }
1236 struct_declarator: any_declarator m_bitfield
{ $$
= $1; $$
->bits
= $2;
1237 if
(!$$
->bits
&& !$$
->var
->name
)
1238 error_loc
("unnamed fields are not allowed\n");
1242 struct_declarator_list:
1243 struct_declarator
{ $$
= append_declarator
( NULL
, $1 ); }
1244 | struct_declarator_list
',' struct_declarator
1245 { $$
= append_declarator
( $1, $3 ); }
1249 declarator
{ $$
= $1; }
1250 | declarator
'=' expr_const
{ $$
= $1; $1->var
->eval
= $3; }
1254 tAPARTMENT
{ $$
= THREADING_APARTMENT
; }
1255 | tNEUTRAL
{ $$
= THREADING_NEUTRAL
; }
1256 | tSINGLE
{ $$
= THREADING_SINGLE
; }
1257 | tFREE
{ $$
= THREADING_FREE
; }
1258 | tBOTH
{ $$
= THREADING_BOTH
; }
1259 | tMTA
{ $$
= THREADING_FREE
; }
1263 tREF
{ $$
= FC_RP
; }
1264 | tUNIQUE
{ $$
= FC_UP
; }
1265 | tPTR
{ $$
= FC_FP
; }
1268 structdef: tSTRUCT m_typename
'{' fields
'}' { $$
= type_new_struct
($2, current_namespace
, TRUE
, $4); }
1272 tVOID
{ $$
= type_new_void
(); }
1273 | base_type
{ $$
= $1; }
1274 | enumdef
{ $$
= $1; }
1275 | tENUM aIDENTIFIER
{ $$
= type_new_enum
($2, current_namespace
, FALSE
, NULL
); }
1276 | structdef
{ $$
= $1; }
1277 | tSTRUCT aIDENTIFIER
{ $$
= type_new_struct
($2, current_namespace
, FALSE
, NULL
); }
1278 | uniondef
{ $$
= $1; }
1279 | tUNION aIDENTIFIER
{ $$
= type_new_nonencapsulated_union
($2, FALSE
, NULL
); }
1280 | tSAFEARRAY
'(' type
')' { $$
= make_safearray
($3); }
1281 | aKNOWNTYPE
{ $$
= find_type_or_error
(current_namespace
, $1); }
1286 | namespace_pfx typename
{ $$
= find_type_or_error
($1, $2); }
1287 | parameterized_type
{ $$
= $1; }
1290 typedef: m_attributes tTYPEDEF m_attributes decl_spec declarator_list
1291 { $1 = append_attribs
($1, $3);
1292 reg_typedefs
($4, $5, check_typedef_attrs
($1));
1293 $$
= make_statement_typedef
($5, !$4->type
->defined
);
1297 uniondef: tUNION m_typename
'{' ne_union_fields
'}'
1298 { $$
= type_new_nonencapsulated_union
($2, TRUE
, $4); }
1300 tSWITCH
'(' s_field
')'
1301 m_ident
'{' cases
'}' { $$
= type_new_encapsulated_union
($2, $5, $7, $9); }
1305 aNUM
{ $$
= MAKEVERSION
($1, 0); }
1306 | aNUM
'.' aNUM
{ $$
= MAKEVERSION
($1, $3); }
1307 | aHEXNUM
{ $$
= $1; }
1312 | acf_interface acf_statements
1317 | acf_int_statement acf_int_statements
1321 : tTYPEDEF acf_attributes aKNOWNTYPE
';'
1322 { type_t
*type
= find_type_or_error
(current_namespace
, $3);
1323 type
->attrs
= append_attr_list
(type
->attrs
, $2);
1328 : acf_attributes tINTERFACE aKNOWNTYPE
'{' acf_int_statements
'}'
1329 { type_t
*iface
= find_type_or_error
(current_namespace
, $3);
1330 if
(type_get_type
(iface
) != TYPE_INTERFACE
)
1331 error_loc
("%s is not an interface\n", iface
->name
);
1332 iface
->attrs
= append_attr_list
(iface
->attrs
, $1);
1337 : /* empty */ { $$
= NULL
; };
1338 |
'[' acf_attribute_list
']' { $$
= $2; };
1342 : acf_attribute
{ $$
= append_attr
(NULL
, $1); }
1343 | acf_attribute_list
',' acf_attribute
{ $$
= append_attr
($1, $3); }
1347 : tALLOCATE
'(' allocate_option_list
')'
1348 { $$
= make_attrv
(ATTR_ALLOCATE
, $3); }
1349 | tENCODE
{ $$
= make_attr
(ATTR_ENCODE
); }
1350 | tDECODE
{ $$
= make_attr
(ATTR_DECODE
); }
1351 | tEXPLICITHANDLE
{ $$
= make_attr
(ATTR_EXPLICIT_HANDLE
); }
1354 allocate_option_list
1355 : allocate_option
{ $$
= $1; }
1356 | allocate_option_list
',' allocate_option
1361 : tDONTFREE
{ $$
= FC_DONT_FREE
; }
1363 | tALLNODES
{ $$
= FC_ALLOCATE_ALL_NODES
; }
1364 | tSINGLENODE
{ $$
= 0; }
1369 static void decl_builtin_basic
(const char *name
, enum type_basic_type type
)
1371 type_t
*t
= type_new_basic
(type
);
1372 reg_type
(t
, name
, NULL
, 0);
1375 static void decl_builtin_alias
(const char *name
, type_t
*t
)
1377 const decl_spec_t ds
= {.type
= t
};
1378 reg_type
(type_new_alias
(&ds
, name
), name
, NULL
, 0);
1381 void init_types
(void)
1383 decl_builtin_basic
("byte", TYPE_BASIC_BYTE
);
1384 decl_builtin_basic
("wchar_t", TYPE_BASIC_WCHAR
);
1385 decl_builtin_basic
("float", TYPE_BASIC_FLOAT
);
1386 decl_builtin_basic
("double", TYPE_BASIC_DOUBLE
);
1387 decl_builtin_basic
("error_status_t", TYPE_BASIC_ERROR_STATUS_T
);
1388 decl_builtin_basic
("handle_t", TYPE_BASIC_HANDLE
);
1389 decl_builtin_alias
("boolean", type_new_basic
(TYPE_BASIC_CHAR
));
1392 static str_list_t
*append_str
(str_list_t
*list
, char *str
)
1394 struct str_list_entry_t
*entry
;
1396 if
(!str
) return list
;
1399 list
= xmalloc
( sizeof
(*list
) );
1402 entry
= xmalloc
( sizeof
(*entry
) );
1404 list_add_tail
( list
, &entry
->entry
);
1408 static attr_list_t
*move_attr
(attr_list_t
*dst
, attr_list_t
*src
, enum attr_type type
)
1411 if
(!src
) return dst
;
1412 LIST_FOR_EACH_ENTRY
(attr
, src
, attr_t
, entry
)
1413 if
(attr
->type
== type
)
1415 list_remove
(&attr
->entry
);
1416 return append_attr
(dst
, attr
);
1421 static attr_list_t
*append_attr_list
(attr_list_t
*new_list
, attr_list_t
*old_list
)
1425 if
(!old_list
) return new_list
;
1427 while
((entry
= list_head
(old_list
)))
1429 attr_t
*attr
= LIST_ENTRY
(entry
, attr_t
, entry
);
1431 new_list
= append_attr
(new_list
, attr
);
1436 typedef
int (*map_attrs_filter_t
)(attr_list_t
*,const attr_t
*);
1438 static attr_list_t
*map_attrs
(const attr_list_t
*list
, map_attrs_filter_t filter
)
1440 attr_list_t
*new_list
;
1444 if
(!list
) return NULL
;
1446 new_list
= xmalloc
( sizeof
(*list
) );
1447 list_init
( new_list
);
1448 LIST_FOR_EACH_ENTRY
(attr
, list
, const attr_t
, entry
)
1450 if
(filter
&& !filter
(new_list
, attr
)) continue
;
1451 new_attr
= xmalloc
(sizeof
(*new_attr
));
1453 list_add_tail
(new_list
, &new_attr
->entry
);
1458 static decl_spec_t
*make_decl_spec
(type_t
*type
, decl_spec_t
*left
, decl_spec_t
*right
,
1459 enum storage_class stgclass
, enum type_qualifier qual
, enum function_specifier func_specifier
)
1461 decl_spec_t
*declspec
= left ? left
: right
;
1464 declspec
= xmalloc
(sizeof
(*declspec
));
1465 declspec
->type
= NULL
;
1466 declspec
->stgclass
= STG_NONE
;
1467 declspec
->qualifier
= 0;
1468 declspec
->func_specifier
= 0;
1470 declspec
->type
= type
;
1471 if
(left
&& declspec
!= left
)
1473 if
(declspec
->stgclass
== STG_NONE
)
1474 declspec
->stgclass
= left
->stgclass
;
1475 else if
(left
->stgclass
!= STG_NONE
)
1476 error_loc
("only one storage class can be specified\n");
1477 declspec
->qualifier |
= left
->qualifier
;
1478 declspec
->func_specifier |
= left
->func_specifier
;
1479 assert
(!left
->type
);
1482 if
(right
&& declspec
!= right
)
1484 if
(declspec
->stgclass
== STG_NONE
)
1485 declspec
->stgclass
= right
->stgclass
;
1486 else if
(right
->stgclass
!= STG_NONE
)
1487 error_loc
("only one storage class can be specified\n");
1488 declspec
->qualifier |
= right
->qualifier
;
1489 declspec
->func_specifier |
= right
->func_specifier
;
1490 assert
(!right
->type
);
1494 if
(declspec
->stgclass
== STG_NONE
)
1495 declspec
->stgclass
= stgclass
;
1496 else if
(stgclass
!= STG_NONE
)
1497 error_loc
("only one storage class can be specified\n");
1498 declspec
->qualifier |
= qual
;
1499 declspec
->func_specifier |
= func_specifier
;
1504 static attr_t
*make_attr
(enum attr_type type
)
1506 attr_t
*a
= xmalloc
(sizeof
(attr_t
));
1512 static attr_t
*make_attrv
(enum attr_type type
, unsigned int val
)
1514 attr_t
*a
= xmalloc
(sizeof
(attr_t
));
1520 attr_t
*make_attrp
(enum attr_type type
, void *val
)
1522 attr_t
*a
= xmalloc
(sizeof
(attr_t
));
1528 static attr_t
*make_custom_attr
(struct uuid
*id
, expr_t
*pval
)
1530 attr_t
*a
= xmalloc
(sizeof
(attr_t
));
1531 attr_custdata_t
*cstdata
= xmalloc
(sizeof
(attr_custdata_t
));
1532 a
->type
= ATTR_CUSTOM
;
1534 cstdata
->pval
= pval
;
1535 a
->u.pval
= cstdata
;
1539 static expr_list_t
*append_expr
(expr_list_t
*list
, expr_t
*expr
)
1541 if
(!expr
) return list
;
1544 list
= xmalloc
( sizeof
(*list
) );
1547 list_add_tail
( list
, &expr
->entry
);
1551 static void append_array
(declarator_t
*decl
, expr_t
*expr
)
1558 /* An array is always a reference pointer unless explicitly marked otherwise
1559 * (regardless of what the default pointer attribute is). */
1560 array
= type_new_array
(NULL
, NULL
, FALSE
, expr
->is_const ? expr
->cval
: 0,
1561 expr
->is_const ? NULL
: expr
, NULL
);
1563 append_chain_type
(decl
, array
, 0);
1566 static struct list type_pool
= LIST_INIT
(type_pool
);
1573 type_t
*alloc_type
(void)
1575 type_pool_node_t
*node
= xmalloc
(sizeof
*node
);
1576 list_add_tail
(&type_pool
, &node
->link
);
1580 void set_all_tfswrite
(int val
)
1582 type_pool_node_t
*node
;
1583 LIST_FOR_EACH_ENTRY
(node
, &type_pool
, type_pool_node_t
, link
)
1584 node
->data.tfswrite
= val
;
1587 void clear_all_offsets
(void)
1589 type_pool_node_t
*node
;
1590 LIST_FOR_EACH_ENTRY
(node
, &type_pool
, type_pool_node_t
, link
)
1591 node
->data.typestring_offset
= node
->data.ptrdesc
= 0;
1594 static void type_function_add_head_arg
(type_t
*type
, var_t
*arg
)
1596 if
(!type
->details.function
->args
)
1598 type
->details.function
->args
= xmalloc
( sizeof
(*type
->details.function
->args
) );
1599 list_init
( type
->details.function
->args
);
1601 list_add_head
( type
->details.function
->args
, &arg
->entry
);
1604 static int is_allowed_range_type
(const type_t
*type
)
1606 switch
(type_get_type
(type
))
1611 switch
(type_basic_get_type
(type
))
1613 case TYPE_BASIC_INT8
:
1614 case TYPE_BASIC_INT16
:
1615 case TYPE_BASIC_INT32
:
1616 case TYPE_BASIC_INT64
:
1617 case TYPE_BASIC_INT
:
1618 case TYPE_BASIC_INT3264
:
1619 case TYPE_BASIC_LONG
:
1620 case TYPE_BASIC_BYTE
:
1621 case TYPE_BASIC_CHAR
:
1622 case TYPE_BASIC_WCHAR
:
1623 case TYPE_BASIC_HYPER
:
1625 case TYPE_BASIC_FLOAT
:
1626 case TYPE_BASIC_DOUBLE
:
1627 case TYPE_BASIC_ERROR_STATUS_T
:
1628 case TYPE_BASIC_HANDLE
:
1637 static type_t
*get_chain_ref
(type_t
*type
)
1640 return type_pointer_get_ref_type
(type
);
1641 else if
(is_array
(type
))
1642 return type_array_get_element_type
(type
);
1643 else if
(is_func
(type
))
1644 return type_function_get_rettype
(type
);
1648 static type_t
*get_chain_end
(type_t
*type
)
1651 while
((inner
= get_chain_ref
(type
)))
1656 static void append_chain_type
(declarator_t
*decl
, type_t
*type
, enum type_qualifier qual
)
1663 decl
->qualifier
= qual
;
1666 chain_type
= get_chain_end
(decl
->type
);
1668 if
(is_ptr
(chain_type
))
1670 chain_type
->details.pointer.ref.type
= type
;
1671 chain_type
->details.pointer.ref.qualifier
= qual
;
1673 else if
(is_array
(chain_type
))
1675 chain_type
->details.array.elem.type
= type
;
1676 chain_type
->details.array.elem.qualifier
= qual
;
1678 else if
(is_func
(chain_type
))
1680 chain_type
->details.function
->retval
->declspec.type
= type
;
1681 chain_type
->details.function
->retval
->declspec.qualifier
= qual
;
1686 if
(!is_func
(chain_type
))
1687 type
->attrs
= move_attr
(type
->attrs
, chain_type
->attrs
, ATTR_CALLCONV
);
1690 static void append_chain_callconv
(type_t
*chain
, char *callconv
)
1694 if
(chain
&& (chain_end
= get_chain_end
(chain
)))
1695 chain_end
->attrs
= append_attr
(chain_end
->attrs
, make_attrp
(ATTR_CALLCONV
, callconv
));
1697 error_loc
("calling convention applied to non-function type\n");
1700 static warning_list_t
*append_warning
(warning_list_t
*list
, int num
)
1706 list
= xmalloc
( sizeof
(*list
) );
1709 entry
= xmalloc
( sizeof
(*entry
) );
1711 list_add_tail
( list
, &entry
->entry
);
1715 static var_t
*declare_var
(attr_list_t
*attrs
, decl_spec_t
*decl_spec
, declarator_t
*decl
,
1718 var_t
*v
= decl
->var
;
1719 expr_list_t
*sizes
= get_attrp
(attrs
, ATTR_SIZEIS
);
1720 expr_list_t
*lengs
= get_attrp
(attrs
, ATTR_LENGTHIS
);
1723 type_t
*type
= decl_spec
->type
;
1725 if
(decl_spec
->func_specifier
& FUNCTION_SPECIFIER_INLINE
)
1727 if
(!decl ||
!is_func
(decl
->type
))
1728 error_loc
("inline attribute applied to non-function type\n");
1731 /* add type onto the end of the pointers in pident->type */
1732 append_chain_type
(decl
, type
, decl_spec
->qualifier
);
1733 v
->declspec
= *decl_spec
;
1734 v
->declspec.type
= decl
->type
;
1735 v
->declspec.qualifier
= decl
->qualifier
;
1737 v
->declonly
= !type
->defined
;
1739 if
(is_attr
(type
->attrs
, ATTR_CALLCONV
) && !is_func
(type
))
1740 error_loc
("calling convention applied to non-function type\n");
1742 /* check for pointer attribute being applied to non-pointer, non-array
1744 if
(!is_array
(v
->declspec.type
))
1746 int ptr_attr
= get_attrv
(v
->attrs
, ATTR_POINTERTYPE
);
1747 const type_t
*ptr
= NULL
;
1748 for
(ptr
= v
->declspec.type
; ptr
&& !ptr_attr
; )
1750 ptr_attr
= get_attrv
(ptr
->attrs
, ATTR_POINTERTYPE
);
1751 if
(!ptr_attr
&& type_is_alias
(ptr
))
1752 ptr
= type_alias_get_aliasee_type
(ptr
);
1758 if
(ptr_attr
&& ptr_attr
!= FC_UP
&&
1759 type_get_type
(type_pointer_get_ref_type
(ptr
)) == TYPE_INTERFACE
)
1760 warning_loc_info
(&v
->loc_info
,
1761 "%s: pointer attribute applied to interface "
1762 "pointer type has no effect\n", v
->name
);
1763 if
(!ptr_attr
&& top
)
1765 /* FIXME: this is a horrible hack to cope with the issue that we
1766 * store an offset to the typeformat string in the type object, but
1767 * two typeformat strings may be written depending on whether the
1768 * pointer is a toplevel parameter or not */
1769 v
->declspec.type
= duptype
(v
->declspec.type
, 1);
1773 error_loc
("%s: pointer attribute applied to non-pointer type\n", v
->name
);
1776 if
(is_attr
(v
->attrs
, ATTR_STRING
))
1780 if
(!is_ptr
(v
->declspec.type
) && !is_array
(v
->declspec.type
))
1781 error_loc
("'%s': [string] attribute applied to non-pointer, non-array type\n",
1787 t
= type_pointer_get_ref_type
(t
);
1788 else if
(is_array
(t
))
1789 t
= type_array_get_element_type
(t
);
1794 if
(type_get_type
(t
) != TYPE_BASIC
&&
1795 (get_basic_fc
(t
) != FC_CHAR
&&
1796 get_basic_fc
(t
) != FC_BYTE
&&
1797 get_basic_fc
(t
) != FC_WCHAR
))
1799 error_loc
("'%s': [string] attribute is only valid on 'char', 'byte', or 'wchar_t' pointers and arrays\n",
1804 if
(is_attr
(v
->attrs
, ATTR_V1ENUM
))
1806 if
(type_get_type_detect_alias
(v
->declspec.type
) != TYPE_ENUM
)
1807 error_loc
("'%s': [v1_enum] attribute applied to non-enum type\n", v
->name
);
1810 if
(is_attr
(v
->attrs
, ATTR_RANGE
) && !is_allowed_range_type
(v
->declspec.type
))
1811 error_loc
("'%s': [range] attribute applied to non-integer type\n",
1814 ptype
= &v
->declspec.type
;
1815 if
(sizes
) LIST_FOR_EACH_ENTRY
(dim
, sizes
, expr_t
, entry
)
1817 if
(dim
->type
!= EXPR_VOID
)
1819 if
(is_array
(*ptype
))
1821 if
(!type_array_get_conformance
(*ptype
) ||
1822 type_array_get_conformance
(*ptype
)->type
!= EXPR_VOID
)
1823 error_loc
("%s: cannot specify size_is for an already sized array\n", v
->name
);
1825 *ptype
= type_new_array
((*ptype
)->name
,
1826 type_array_get_element
(*ptype
), FALSE
,
1829 else if
(is_ptr
(*ptype
))
1830 *ptype
= type_new_array
((*ptype
)->name
, type_pointer_get_ref
(*ptype
), TRUE
,
1833 error_loc
("%s: size_is attribute applied to illegal type\n", v
->name
);
1837 ptype
= &(*ptype
)->details.pointer.ref.type
;
1838 else if
(is_array
(*ptype
))
1839 ptype
= &(*ptype
)->details.array.elem.type
;
1841 error_loc
("%s: too many expressions in size_is attribute\n", v
->name
);
1844 ptype
= &v
->declspec.type
;
1845 if
(lengs
) LIST_FOR_EACH_ENTRY
(dim
, lengs
, expr_t
, entry
)
1847 if
(dim
->type
!= EXPR_VOID
)
1849 if
(is_array
(*ptype
))
1851 *ptype
= type_new_array
((*ptype
)->name
,
1852 type_array_get_element
(*ptype
),
1853 type_array_is_decl_as_ptr
(*ptype
),
1854 type_array_get_dim
(*ptype
),
1855 type_array_get_conformance
(*ptype
), dim
);
1858 error_loc
("%s: length_is attribute applied to illegal type\n", v
->name
);
1862 ptype
= &(*ptype
)->details.pointer.ref.type
;
1863 else if
(is_array
(*ptype
))
1864 ptype
= &(*ptype
)->details.array.elem.type
;
1866 error_loc
("%s: too many expressions in length_is attribute\n", v
->name
);
1870 v
->declspec.type
= type_new_bitfield
(v
->declspec.type
, decl
->bits
);
1875 static var_list_t
*set_var_types
(attr_list_t
*attrs
, decl_spec_t
*decl_spec
, declarator_list_t
*decls
)
1877 declarator_t
*decl
, *next
;
1878 var_list_t
*var_list
= NULL
;
1880 LIST_FOR_EACH_ENTRY_SAFE
( decl
, next
, decls
, declarator_t
, entry
)
1882 var_t
*var
= declare_var
(attrs
, decl_spec
, decl
, 0);
1883 var_list
= append_var
(var_list
, var
);
1890 typeref_list_t
*append_typeref
(typeref_list_t
*list
, typeref_t
*ref
)
1892 if
(!ref
) return list
;
1895 list
= xmalloc
( sizeof
(*list
) );
1898 list_add_tail
( list
, &ref
->entry
);
1902 typeref_t
*make_typeref
(type_t
*type
)
1904 typeref_t
*ref
= xmalloc
(sizeof
(typeref_t
));
1910 var_list_t
*append_var
(var_list_t
*list
, var_t
*var
)
1912 if
(!var
) return list
;
1915 list
= xmalloc
( sizeof
(*list
) );
1918 list_add_tail
( list
, &var
->entry
);
1922 static var_list_t
*append_var_list
(var_list_t
*list
, var_list_t
*vars
)
1924 if
(!vars
) return list
;
1927 list
= xmalloc
( sizeof
(*list
) );
1930 list_move_tail
( list
, vars
);
1934 var_t
*make_var
(char *name
)
1936 var_t
*v
= xmalloc
(sizeof
(var_t
));
1938 init_declspec
(&v
->declspec
, NULL
);
1941 init_loc_info
(&v
->loc_info
);
1942 v
->declonly
= FALSE
;
1946 static var_t
*copy_var
(var_t
*src
, char *name
, map_attrs_filter_t attr_filter
)
1948 var_t
*v
= xmalloc
(sizeof
(var_t
));
1950 v
->declspec
= src
->declspec
;
1951 v
->attrs
= map_attrs
(src
->attrs
, attr_filter
);
1952 v
->eval
= src
->eval
;
1953 v
->loc_info
= src
->loc_info
;
1957 static declarator_list_t
*append_declarator
(declarator_list_t
*list
, declarator_t
*d
)
1959 if
(!d
) return list
;
1961 list
= xmalloc
(sizeof
(*list
));
1964 list_add_tail
(list
, &d
->entry
);
1968 static declarator_t
*make_declarator
(var_t
*var
)
1970 declarator_t
*d
= xmalloc
(sizeof
(*d
));
1971 d
->var
= var ? var
: make_var
(NULL
);
1978 static type_t
*make_safearray
(type_t
*type
)
1980 decl_spec_t ds
= {.type
= type
};
1981 ds.type
= type_new_alias
(&ds
, "SAFEARRAY");
1982 return type_new_array
(NULL
, &ds
, TRUE
, 0, NULL
, NULL
);
1985 static typelib_t
*make_library
(const char *name
, const attr_list_t
*attrs
)
1987 typelib_t
*typelib
= xmalloc
(sizeof
(*typelib
));
1988 memset
(typelib
, 0, sizeof
(*typelib
));
1989 typelib
->name
= xstrdup
(name
);
1990 typelib
->attrs
= attrs
;
1991 list_init
( &typelib
->importlibs
);
1995 static int hash_ident
(const char *name
)
1997 const char *p
= name
;
1999 /* a simple sum hash is probably good enough */
2004 return sum
& (HASHMAX
-1);
2007 /***** type repository *****/
2009 static struct namespace
*find_sub_namespace
(struct namespace
*namespace
, const char *name
)
2011 struct namespace
*cur
;
2013 LIST_FOR_EACH_ENTRY
(cur
, &namespace
->children
, struct namespace
, entry
) {
2014 if
(!strcmp
(cur
->name
, name
))
2021 static void push_namespace
(const char *name
)
2023 struct namespace
*namespace
;
2025 namespace
= find_sub_namespace
(current_namespace
, name
);
2027 namespace
= xmalloc
(sizeof
(*namespace
));
2028 namespace
->name
= xstrdup
(name
);
2029 namespace
->parent
= current_namespace
;
2030 list_add_tail
(¤t_namespace
->children
, &namespace
->entry
);
2031 list_init
(&namespace
->children
);
2032 memset
(namespace
->type_hash
, 0, sizeof
(namespace
->type_hash
));
2035 current_namespace
= namespace
;
2038 static void pop_namespace
(const char *name
)
2040 assert
(!strcmp
(current_namespace
->name
, name
) && current_namespace
->parent
);
2041 current_namespace
= current_namespace
->parent
;
2044 static void push_parameters_namespace
(const char *name
)
2046 struct namespace
*namespace
;
2048 if
(!(namespace
= find_sub_namespace
(current_namespace
, name
)))
2050 namespace
= xmalloc
(sizeof
(*namespace
));
2051 namespace
->name
= xstrdup
(name
);
2052 namespace
->parent
= current_namespace
;
2053 list_add_tail
(¤t_namespace
->children
, &namespace
->entry
);
2054 list_init
(&namespace
->children
);
2055 memset
(namespace
->type_hash
, 0, sizeof
(namespace
->type_hash
));
2058 parameters_namespace
= namespace
;
2061 static void pop_parameters_namespace
(const char *name
)
2063 assert
(!strcmp
(parameters_namespace
->name
, name
) && parameters_namespace
->parent
);
2064 parameters_namespace
= NULL
;
2074 type_t
*reg_type
(type_t
*type
, const char *name
, struct namespace
*namespace
, int t
)
2079 error_loc
("registering named type without name\n");
2083 namespace
= &global_namespace
;
2084 hash
= hash_ident
(name
);
2085 nt
= xmalloc
(sizeof
(struct rtype
));
2087 if
(is_global_namespace
(namespace
))
2089 type
->c_name
= name
;
2090 type
->qualified_name
= name
;
2094 type
->c_name
= format_namespace
(namespace
, "__x_", "_C", name
, use_abi_namespace ?
"ABI" : NULL
);
2095 type
->qualified_name
= format_namespace
(namespace
, "", "::", name
, use_abi_namespace ?
"ABI" : NULL
);
2099 nt
->next
= namespace
->type_hash
[hash
];
2100 namespace
->type_hash
[hash
] = nt
;
2104 static type_t
*reg_typedefs
(decl_spec_t
*decl_spec
, declarator_list_t
*decls
, attr_list_t
*attrs
)
2107 type_t
*type
= decl_spec
->type
;
2109 if
(is_attr
(attrs
, ATTR_UUID
) && !is_attr
(attrs
, ATTR_PUBLIC
))
2110 attrs
= append_attr
( attrs
, make_attr
(ATTR_PUBLIC
) );
2112 /* We must generate names for tagless enum, struct or union.
2113 Typedef-ing a tagless enum, struct or union means we want the typedef
2114 to be included in a library hence the public attribute. */
2115 if
(type_get_type_detect_alias
(type
) == TYPE_ENUM ||
2116 type_get_type_detect_alias
(type
) == TYPE_STRUCT ||
2117 type_get_type_detect_alias
(type
) == TYPE_UNION ||
2118 type_get_type_detect_alias
(type
) == TYPE_ENCAPSULATED_UNION
)
2122 type
->name
= gen_name
();
2123 if
(!is_attr
(attrs
, ATTR_PUBLIC
))
2124 attrs
= append_attr
(attrs
, make_attr
(ATTR_PUBLIC
));
2127 /* replace existing attributes when generating a typelib */
2129 type
->attrs
= attrs
;
2132 LIST_FOR_EACH_ENTRY
( decl
, decls
, declarator_t
, entry
)
2135 if
(decl
->var
->name
) {
2139 cur
= find_type
(decl
->var
->name
, current_namespace
, 0);
2142 * MIDL allows shadowing types that are declared in imported files.
2143 * We don't throw an error in this case and instead add a new type
2144 * (which is earlier on the list in hash table, so it will be used
2145 * instead of shadowed type).
2147 * FIXME: We may consider string separated type tables for each input
2148 * for cleaner solution.
2150 if
(cur
&& input_name
== cur
->loc_info.input_name
)
2151 error_loc
("%s: redefinition error; original definition was at %s:%d\n",
2152 cur
->name
, cur
->loc_info.input_name
,
2153 cur
->loc_info.line_number
);
2155 name
= declare_var
(attrs
, decl_spec
, decl
, 0);
2156 cur
= type_new_alias
(&name
->declspec
, name
->name
);
2159 reg_type
(cur
, cur
->name
, current_namespace
, 0);
2165 type_t
*find_type
(const char *name
, struct namespace
*namespace
, int t
)
2169 if
(namespace
&& namespace
!= &global_namespace
) {
2170 for
(cur
= namespace
->type_hash
[hash_ident
(name
)]; cur
; cur
= cur
->next
) {
2171 if
(cur
->t
== t
&& !strcmp
(cur
->name
, name
))
2175 for
(cur
= global_namespace.type_hash
[hash_ident
(name
)]; cur
; cur
= cur
->next
) {
2176 if
(cur
->t
== t
&& !strcmp
(cur
->name
, name
))
2182 static type_t
*find_type_or_error
(struct namespace
*namespace
, const char *name
)
2185 if
(!(type
= find_type
(name
, namespace
, 0)) &&
2186 !(type
= find_type
(name
, parameters_namespace
, 0)))
2188 error_loc
("type '%s' not found in %s namespace\n", name
, namespace
&& namespace
->name ? namespace
->name
: "global");
2194 static struct namespace
*find_namespace_or_error
(struct namespace
*parent
, const char *name
)
2196 struct namespace
*namespace
= NULL
;
2199 error_loc
("namespaces are only supported in winrt mode.\n");
2200 else if
(!(namespace
= find_sub_namespace
(parent
, name
)))
2201 error_loc
("namespace '%s' not found in '%s'\n", name
, parent
->name
);
2206 int is_type
(const char *name
)
2208 return find_type
(name
, current_namespace
, 0) != NULL ||
2209 find_type
(name
, parameters_namespace
, 0);
2212 type_t
*get_type
(enum type_type type
, char *name
, struct namespace
*namespace
, int t
)
2216 namespace
= &global_namespace
;
2218 tp
= find_type
(name
, namespace
, t
);
2224 tp
= make_type
(type
);
2226 tp
->namespace
= namespace
;
2227 if
(!name
) return tp
;
2228 return reg_type
(tp
, name
, namespace
, t
);
2231 /***** constant repository *****/
2236 struct rconst
*next
;
2239 struct rconst
*const_hash
[HASHMAX
];
2241 static var_t
*reg_const
(var_t
*var
)
2246 error_loc
("registering constant without name\n");
2249 hash
= hash_ident
(var
->name
);
2250 nc
= xmalloc
(sizeof
(struct rconst
));
2251 nc
->name
= var
->name
;
2253 nc
->next
= const_hash
[hash
];
2254 const_hash
[hash
] = nc
;
2258 var_t
*find_const
(const char *name
, int f
)
2260 struct rconst
*cur
= const_hash
[hash_ident
(name
)];
2261 while
(cur
&& strcmp
(cur
->name
, name
))
2264 if
(f
) error_loc
("constant '%s' not found\n", name
);
2270 char *gen_name
(void)
2272 static unsigned long n
= 0;
2273 static const char *file_id
;
2277 char *dst
= replace_extension
( get_basename
(input_idl_name
), ".idl", "" );
2281 if
(! isalnum
((unsigned char) *dst
))
2284 return strmake
("__WIDL_%s_generated_name_%08lX", file_id
, n
++);
2289 unsigned int dce_compatible
: 1;
2290 unsigned int acf
: 1;
2291 unsigned int multiple
: 1;
2293 unsigned int on_interface
: 1;
2294 unsigned int on_function
: 1;
2295 unsigned int on_arg
: 1;
2296 unsigned int on_type
: 1;
2297 unsigned int on_enum
: 1;
2298 unsigned int on_enum_member
: 1;
2299 unsigned int on_struct
: 2;
2300 unsigned int on_union
: 1;
2301 unsigned int on_field
: 1;
2302 unsigned int on_library
: 1;
2303 unsigned int on_dispinterface
: 1;
2304 unsigned int on_module
: 1;
2305 unsigned int on_coclass
: 1;
2306 unsigned int on_apicontract
: 1;
2307 unsigned int on_runtimeclass
: 1;
2308 const char *display_name
;
2311 struct allowed_attr allowed_attr
[] =
2313 /* attr { D ACF M I Fn ARG T En Enm St Un Fi L DI M C AC R <display name> } */
2314 /* ATTR_ACTIVATABLE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, "activatable" },
2315 /* ATTR_AGGREGATABLE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, "aggregatable" },
2316 /* ATTR_ALLOCATE */ { 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "allocate" },
2317 /* ATTR_ANNOTATION */ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "annotation" },
2318 /* ATTR_APPOBJECT */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, "appobject" },
2319 /* ATTR_ASYNC */ { 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "async" },
2320 /* ATTR_ASYNCUUID */ { 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, "async_uuid" },
2321 /* ATTR_AUTO_HANDLE */ { 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "auto_handle" },
2322 /* ATTR_BINDABLE */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "bindable" },
2323 /* ATTR_BROADCAST */ { 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "broadcast" },
2324 /* ATTR_CALLAS */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "call_as" },
2325 /* ATTR_CALLCONV */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL
},
2326 /* ATTR_CASE */ { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "case" },
2327 /* ATTR_CODE */ { 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "code" },
2328 /* ATTR_COMMSTATUS */ { 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "comm_status" },
2329 /* ATTR_CONTEXTHANDLE */ { 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "context_handle" },
2330 /* ATTR_CONTRACT */ { 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, "contract" },
2331 /* ATTR_CONTRACTVERSION */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, "contractversion" },
2332 /* ATTR_CONTROL */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, "control" },
2333 /* ATTR_CUSTOM */ { 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, "custom" },
2334 /* ATTR_DECODE */ { 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "decode" },
2335 /* ATTR_DEFAULT */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, "default" },
2336 /* ATTR_DEFAULTBIND */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "defaultbind" },
2337 /* ATTR_DEFAULTCOLLELEM */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "defaultcollelem" },
2338 /* ATTR_DEFAULTVALUE */ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "defaultvalue" },
2339 /* ATTR_DEFAULTVTABLE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, "defaultvtable" },
2340 /* ATTR_DISABLECONSISTENCYCHECK */{ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "disable_consistency_check" },
2341 /* ATTR_DISPINTERFACE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, NULL
},
2342 /* ATTR_DISPLAYBIND */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "displaybind" },
2343 /* ATTR_DLLNAME */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, "dllname" },
2344 /* ATTR_DUAL */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "dual" },
2345 /* ATTR_ENABLEALLOCATE */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "enable_allocate" },
2346 /* ATTR_ENCODE */ { 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "encode" },
2347 /* ATTR_ENDPOINT */ { 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "endpoint" },
2348 /* ATTR_ENTRY */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "entry" },
2349 /* ATTR_EVENTADD */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "eventadd" },
2350 /* ATTR_EVENTREMOVE */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "eventremove" },
2351 /* ATTR_EXCLUSIVETO */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "exclusive_to" },
2352 /* ATTR_EXPLICIT_HANDLE */ { 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "explicit_handle" },
2353 /* ATTR_FAULTSTATUS */ { 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "fault_status" },
2354 /* ATTR_FLAGS */ { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "flags" },
2355 /* ATTR_FORCEALLOCATE */ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "force_allocate" },
2356 /* ATTR_HANDLE */ { 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "handle" },
2357 /* ATTR_HELPCONTEXT */ { 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, "helpcontext" },
2358 /* ATTR_HELPFILE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, "helpfile" },
2359 /* ATTR_HELPSTRING */ { 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, "helpstring" },
2360 /* ATTR_HELPSTRINGCONTEXT */ { 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, "helpstringcontext" },
2361 /* ATTR_HELPSTRINGDLL */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, "helpstringdll" },
2362 /* ATTR_HIDDEN */ { 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, "hidden" },
2363 /* ATTR_ID */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, "id" },
2364 /* ATTR_IDEMPOTENT */ { 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "idempotent" },
2365 /* ATTR_IGNORE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "ignore" },
2366 /* ATTR_IIDIS */ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "iid_is" },
2367 /* ATTR_IMMEDIATEBIND */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "immediatebind" },
2368 /* ATTR_IMPLICIT_HANDLE */ { 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "implicit_handle" },
2369 /* ATTR_IN */ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "in" },
2370 /* ATTR_INPUTSYNC */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "inputsync" },
2371 /* ATTR_LENGTHIS */ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "length_is" },
2372 /* ATTR_LIBLCID */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, "lcid" },
2373 /* ATTR_LICENSED */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, "licensed" },
2374 /* ATTR_LOCAL */ { 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "local" },
2375 /* ATTR_MARSHALING_BEHAVIOR */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, "marshaling_behavior" },
2376 /* ATTR_MAYBE */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "maybe" },
2377 /* ATTR_MESSAGE */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "message" },
2378 /* ATTR_NOCODE */ { 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "nocode" },
2379 /* ATTR_NONBROWSABLE */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "nonbrowsable" },
2380 /* ATTR_NONCREATABLE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, "noncreatable" },
2381 /* ATTR_NONEXTENSIBLE */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "nonextensible" },
2382 /* ATTR_NOTIFY */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "notify" },
2383 /* ATTR_NOTIFYFLAG */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "notify_flag" },
2384 /* ATTR_OBJECT */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "object" },
2385 /* ATTR_ODL */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, "odl" },
2386 /* ATTR_OLEAUTOMATION */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "oleautomation" },
2387 /* ATTR_OPTIMIZE */ { 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "optimize" },
2388 /* ATTR_OPTIONAL */ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "optional" },
2389 /* ATTR_OUT */ { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "out" },
2390 /* ATTR_OVERLOAD */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "overload" },
2391 /* ATTR_PARAMLCID */ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "lcid" },
2392 /* ATTR_PARTIALIGNORE */ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "partial_ignore" },
2393 /* ATTR_POINTERDEFAULT */ { 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "pointer_default" },
2394 /* ATTR_POINTERTYPE */ { 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "ref, unique or ptr" },
2395 /* ATTR_PROGID */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, "progid" },
2396 /* ATTR_PROPGET */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "propget" },
2397 /* ATTR_PROPPUT */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "propput" },
2398 /* ATTR_PROPPUTREF */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "propputref" },
2399 /* ATTR_PROXY */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "proxy" },
2400 /* ATTR_PUBLIC */ { 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "public" },
2401 /* ATTR_RANGE */ { 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "range" },
2402 /* ATTR_READONLY */ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "readonly" },
2403 /* ATTR_REPRESENTAS */ { 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "represent_as" },
2404 /* ATTR_REQUESTEDIT */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "requestedit" },
2405 /* ATTR_RESTRICTED */ { 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, "restricted" },
2406 /* ATTR_RETVAL */ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "retval" },
2407 /* ATTR_SIZEIS */ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "size_is" },
2408 /* ATTR_SOURCE */ { 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, "source" },
2409 /* ATTR_STATIC */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, "static" },
2410 /* ATTR_STRICTCONTEXTHANDLE */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "strict_context_handle" },
2411 /* ATTR_STRING */ { 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "string" },
2412 /* ATTR_SWITCHIS */ { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "switch_is" },
2413 /* ATTR_SWITCHTYPE */ { 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "switch_type" },
2414 /* ATTR_THREADING */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, "threading" },
2415 /* ATTR_TRANSMITAS */ { 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "transmit_as" },
2416 /* ATTR_UIDEFAULT */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "uidefault" },
2417 /* ATTR_USESGETLASTERROR */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "usesgetlasterror" },
2418 /* ATTR_USERMARSHAL */ { 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "user_marshal" },
2419 /* ATTR_UUID */ { 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, "uuid" },
2420 /* ATTR_V1ENUM */ { 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "v1_enum" },
2421 /* ATTR_VARARG */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "vararg" },
2422 /* ATTR_VERSION */ { 1, 0, 0, 1, 0, 0, 1, 1, 0, 2, 0, 0, 1, 0, 1, 1, 0, 1, "version" },
2423 /* ATTR_VIPROGID */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, "vi_progid" },
2424 /* ATTR_WIREMARSHAL */ { 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "wire_marshal" },
2427 attr_list_t
*append_attr
(attr_list_t
*list
, attr_t
*attr
)
2429 attr_t
*attr_existing
;
2430 if
(!attr
) return list
;
2433 list
= xmalloc
( sizeof
(*list
) );
2436 if
(!allowed_attr
[attr
->type
].multiple
)
2438 LIST_FOR_EACH_ENTRY
(attr_existing
, list
, attr_t
, entry
)
2439 if
(attr_existing
->type
== attr
->type
)
2441 parser_warning
("duplicate attribute %s\n", get_attr_display_name
(attr
->type
));
2442 /* use the last attribute, like MIDL does */
2443 list_remove
(&attr_existing
->entry
);
2447 list_add_tail
( list
, &attr
->entry
);
2451 const char *get_attr_display_name
(enum attr_type type
)
2453 return allowed_attr
[type
].display_name
;
2456 attr_list_t
*check_interface_attrs
(const char *name
, attr_list_t
*attrs
)
2459 if
(!attrs
) return attrs
;
2460 LIST_FOR_EACH_ENTRY
(attr
, attrs
, const attr_t
, entry
)
2462 if
(!allowed_attr
[attr
->type
].on_interface
)
2463 error_loc
("inapplicable attribute %s for interface %s\n",
2464 allowed_attr
[attr
->type
].display_name
, name
);
2465 if
(attr
->type
== ATTR_IMPLICIT_HANDLE
)
2467 const var_t
*var
= attr
->u.pval
;
2468 if
(type_get_type
( var
->declspec.type
) == TYPE_BASIC
&&
2469 type_basic_get_type
( var
->declspec.type
) == TYPE_BASIC_HANDLE
)
2471 if
(is_aliaschain_attr
( var
->declspec.type
, ATTR_HANDLE
))
2473 error_loc
("attribute %s requires a handle type in interface %s\n",
2474 allowed_attr
[attr
->type
].display_name
, name
);
2480 static attr_list_t
*check_function_attrs
(const char *name
, attr_list_t
*attrs
)
2483 if
(!attrs
) return attrs
;
2484 LIST_FOR_EACH_ENTRY
(attr
, attrs
, const attr_t
, entry
)
2486 if
(!allowed_attr
[attr
->type
].on_function
)
2487 error_loc
("inapplicable attribute %s for function %s\n",
2488 allowed_attr
[attr
->type
].display_name
, name
);
2493 static void check_arg_attrs
(const var_t
*arg
)
2499 LIST_FOR_EACH_ENTRY
(attr
, arg
->attrs
, const attr_t
, entry
)
2501 if
(!allowed_attr
[attr
->type
].on_arg
)
2502 error_loc
("inapplicable attribute %s for argument %s\n",
2503 allowed_attr
[attr
->type
].display_name
, arg
->name
);
2508 static attr_list_t
*check_typedef_attrs
(attr_list_t
*attrs
)
2511 if
(!attrs
) return attrs
;
2512 LIST_FOR_EACH_ENTRY
(attr
, attrs
, const attr_t
, entry
)
2514 if
(!allowed_attr
[attr
->type
].on_type
)
2515 error_loc
("inapplicable attribute %s for typedef\n",
2516 allowed_attr
[attr
->type
].display_name
);
2521 static attr_list_t
*check_enum_attrs
(attr_list_t
*attrs
)
2524 if
(!attrs
) return attrs
;
2525 LIST_FOR_EACH_ENTRY
(attr
, attrs
, const attr_t
, entry
)
2527 if
(!allowed_attr
[attr
->type
].on_enum
)
2528 error_loc
("inapplicable attribute %s for enum\n",
2529 allowed_attr
[attr
->type
].display_name
);
2534 static attr_list_t
*check_enum_member_attrs
(attr_list_t
*attrs
)
2537 if
(!attrs
) return attrs
;
2538 LIST_FOR_EACH_ENTRY
(attr
, attrs
, const attr_t
, entry
)
2540 if
(!allowed_attr
[attr
->type
].on_enum_member
)
2541 error_loc
("inapplicable attribute %s for enum member\n",
2542 allowed_attr
[attr
->type
].display_name
);
2547 static attr_list_t
*check_struct_attrs
(attr_list_t
*attrs
)
2549 int mask
= winrt_mode ?
3 : 1;
2551 if
(!attrs
) return attrs
;
2552 LIST_FOR_EACH_ENTRY
(attr
, attrs
, const attr_t
, entry
)
2554 if
(!(allowed_attr
[attr
->type
].on_struct
& mask
))
2555 error_loc
("inapplicable attribute %s for struct\n",
2556 allowed_attr
[attr
->type
].display_name
);
2561 static attr_list_t
*check_union_attrs
(attr_list_t
*attrs
)
2564 if
(!attrs
) return attrs
;
2565 LIST_FOR_EACH_ENTRY
(attr
, attrs
, const attr_t
, entry
)
2567 if
(!allowed_attr
[attr
->type
].on_union
)
2568 error_loc
("inapplicable attribute %s for union\n",
2569 allowed_attr
[attr
->type
].display_name
);
2574 static attr_list_t
*check_field_attrs
(const char *name
, attr_list_t
*attrs
)
2577 if
(!attrs
) return attrs
;
2578 LIST_FOR_EACH_ENTRY
(attr
, attrs
, const attr_t
, entry
)
2580 if
(!allowed_attr
[attr
->type
].on_field
)
2581 error_loc
("inapplicable attribute %s for field %s\n",
2582 allowed_attr
[attr
->type
].display_name
, name
);
2587 static attr_list_t
*check_library_attrs
(const char *name
, attr_list_t
*attrs
)
2590 if
(!attrs
) return attrs
;
2591 LIST_FOR_EACH_ENTRY
(attr
, attrs
, const attr_t
, entry
)
2593 if
(!allowed_attr
[attr
->type
].on_library
)
2594 error_loc
("inapplicable attribute %s for library %s\n",
2595 allowed_attr
[attr
->type
].display_name
, name
);
2600 attr_list_t
*check_dispiface_attrs
(const char *name
, attr_list_t
*attrs
)
2603 if
(!attrs
) return attrs
;
2604 LIST_FOR_EACH_ENTRY
(attr
, attrs
, const attr_t
, entry
)
2606 if
(!allowed_attr
[attr
->type
].on_dispinterface
)
2607 error_loc
("inapplicable attribute %s for dispinterface %s\n",
2608 allowed_attr
[attr
->type
].display_name
, name
);
2613 attr_list_t
*check_module_attrs
(const char *name
, attr_list_t
*attrs
)
2616 if
(!attrs
) return attrs
;
2617 LIST_FOR_EACH_ENTRY
(attr
, attrs
, const attr_t
, entry
)
2619 if
(!allowed_attr
[attr
->type
].on_module
)
2620 error_loc
("inapplicable attribute %s for module %s\n",
2621 allowed_attr
[attr
->type
].display_name
, name
);
2626 attr_list_t
*check_coclass_attrs
(const char *name
, attr_list_t
*attrs
)
2629 if
(!attrs
) return attrs
;
2630 LIST_FOR_EACH_ENTRY
(attr
, attrs
, const attr_t
, entry
)
2632 if
(!allowed_attr
[attr
->type
].on_coclass
)
2633 error_loc
("inapplicable attribute %s for coclass %s\n",
2634 allowed_attr
[attr
->type
].display_name
, name
);
2639 attr_list_t
*check_runtimeclass_attrs
(const char *name
, attr_list_t
*attrs
)
2642 if
(!attrs
) return attrs
;
2643 LIST_FOR_EACH_ENTRY
(attr
, attrs
, const attr_t
, entry
)
2644 if
(!allowed_attr
[attr
->type
].on_runtimeclass
)
2645 error_loc
("inapplicable attribute %s for runtimeclass %s\n",
2646 allowed_attr
[attr
->type
].display_name
, name
);
2650 attr_list_t
*check_apicontract_attrs
(const char *name
, attr_list_t
*attrs
)
2653 if
(!attrs
) return attrs
;
2654 LIST_FOR_EACH_ENTRY
(attr
, attrs
, const attr_t
, entry
)
2655 if
(!allowed_attr
[attr
->type
].on_apicontract
)
2656 error_loc
("inapplicable attribute %s for apicontract %s\n",
2657 allowed_attr
[attr
->type
].display_name
, name
);
2661 static int is_allowed_conf_type
(const type_t
*type
)
2663 switch
(type_get_type
(type
))
2668 switch
(type_basic_get_type
(type
))
2670 case TYPE_BASIC_INT8
:
2671 case TYPE_BASIC_INT16
:
2672 case TYPE_BASIC_INT32
:
2673 case TYPE_BASIC_INT64
:
2674 case TYPE_BASIC_INT
:
2675 case TYPE_BASIC_LONG
:
2676 case TYPE_BASIC_CHAR
:
2677 case TYPE_BASIC_HYPER
:
2678 case TYPE_BASIC_BYTE
:
2679 case TYPE_BASIC_WCHAR
:
2685 /* shouldn't get here because of type_get_type call above */
2690 case TYPE_ENCAPSULATED_UNION
:
2697 case TYPE_INTERFACE
:
2699 case TYPE_RUNTIMECLASS
:
2702 case TYPE_APICONTRACT
:
2703 case TYPE_PARAMETERIZED_TYPE
:
2704 case TYPE_PARAMETER
:
2705 /* not supposed to be here */
2712 static int is_ptr_guid_type
(const type_t
*type
)
2714 /* first, make sure it is a pointer to something */
2715 if
(!is_ptr
(type
)) return FALSE
;
2717 /* second, make sure it is a pointer to something of size sizeof(GUID),
2719 return
(type_memsize
(type_pointer_get_ref_type
(type
)) == 16);
2722 static void check_conformance_expr_list
(const char *attr_name
, const var_t
*arg
, const type_t
*container_type
, expr_list_t
*expr_list
)
2725 struct expr_loc expr_loc
;
2727 expr_loc.attr
= attr_name
;
2728 if
(expr_list
) LIST_FOR_EACH_ENTRY
(dim
, expr_list
, expr_t
, entry
)
2730 if
(dim
->type
!= EXPR_VOID
)
2732 const type_t
*expr_type
= expr_resolve_type
(&expr_loc
, container_type
, dim
);
2733 if
(!is_allowed_conf_type
(expr_type
))
2734 error_loc_info
(&arg
->loc_info
, "expression must resolve to integral type <= 32bits for attribute %s\n",
2740 static void check_remoting_fields
(const var_t
*var
, type_t
*type
);
2742 /* checks that properties common to fields and arguments are consistent */
2743 static void check_field_common
(const type_t
*container_type
,
2744 const char *container_name
, const var_t
*arg
)
2746 type_t
*type
= arg
->declspec.type
;
2748 const char *container_type_name
;
2749 const char *var_type
;
2751 switch
(type_get_type
(container_type
))
2754 container_type_name
= "struct";
2758 container_type_name
= "union";
2761 case TYPE_ENCAPSULATED_UNION
:
2762 container_type_name
= "encapsulated union";
2766 container_type_name
= "function";
2767 var_type
= "parameter";
2770 /* should be no other container types */
2775 if
(is_attr
(arg
->attrs
, ATTR_LENGTHIS
) &&
2776 (is_attr
(arg
->attrs
, ATTR_STRING
) || is_aliaschain_attr
(arg
->declspec.type
, ATTR_STRING
)))
2777 error_loc_info
(&arg
->loc_info
,
2778 "string and length_is specified for argument %s are mutually exclusive attributes\n",
2781 if
(is_attr
(arg
->attrs
, ATTR_SIZEIS
))
2783 expr_list_t
*size_is_exprs
= get_attrp
(arg
->attrs
, ATTR_SIZEIS
);
2784 check_conformance_expr_list
("size_is", arg
, container_type
, size_is_exprs
);
2786 if
(is_attr
(arg
->attrs
, ATTR_LENGTHIS
))
2788 expr_list_t
*length_is_exprs
= get_attrp
(arg
->attrs
, ATTR_LENGTHIS
);
2789 check_conformance_expr_list
("length_is", arg
, container_type
, length_is_exprs
);
2791 if
(is_attr
(arg
->attrs
, ATTR_IIDIS
))
2793 struct expr_loc expr_loc
;
2794 expr_t
*expr
= get_attrp
(arg
->attrs
, ATTR_IIDIS
);
2795 if
(expr
->type
!= EXPR_VOID
)
2797 const type_t
*expr_type
;
2799 expr_loc.attr
= "iid_is";
2800 expr_type
= expr_resolve_type
(&expr_loc
, container_type
, expr
);
2801 if
(!expr_type ||
!is_ptr_guid_type
(expr_type
))
2802 error_loc_info
(&arg
->loc_info
, "expression must resolve to pointer to GUID type for attribute iid_is\n");
2805 if
(is_attr
(arg
->attrs
, ATTR_SWITCHIS
))
2807 struct expr_loc expr_loc
;
2808 expr_t
*expr
= get_attrp
(arg
->attrs
, ATTR_SWITCHIS
);
2809 if
(expr
->type
!= EXPR_VOID
)
2811 const type_t
*expr_type
;
2813 expr_loc.attr
= "switch_is";
2814 expr_type
= expr_resolve_type
(&expr_loc
, container_type
, expr
);
2815 if
(!expr_type ||
!is_allowed_conf_type
(expr_type
))
2816 error_loc_info
(&arg
->loc_info
, "expression must resolve to integral type <= 32bits for attribute %s\n",
2825 switch
(typegen_detect_type
(type
, arg
->attrs
, TDT_IGNORE_STRINGS
))
2829 check_remoting_fields
(arg
, type
);
2833 const char *reason
= "is invalid";
2834 switch
(type_get_type
(type
))
2837 reason
= "cannot derive from void *";
2840 reason
= "cannot be a function pointer";
2843 reason
= "cannot be a bit-field";
2846 reason
= "cannot be a class";
2848 case TYPE_INTERFACE
:
2849 reason
= "cannot be a non-pointer to an interface";
2852 reason
= "cannot be a module";
2857 error_loc_info
(&arg
->loc_info
, "%s \'%s\' of %s \'%s\' %s\n",
2858 var_type
, arg
->name
, container_type_name
, container_name
, reason
);
2861 case TGT_CTXT_HANDLE
:
2862 case TGT_CTXT_HANDLE_POINTER
:
2863 if
(type_get_type
(container_type
) != TYPE_FUNCTION
)
2864 error_loc_info
(&arg
->loc_info
,
2865 "%s \'%s\' of %s \'%s\' cannot be a context handle\n",
2866 var_type
, arg
->name
, container_type_name
,
2871 const type_t
*t
= type
;
2873 t
= type_pointer_get_ref_type
(t
);
2874 if
(is_aliaschain_attr
(t
, ATTR_RANGE
))
2875 warning_loc_info
(&arg
->loc_info
, "%s: range not verified for a string of ranged types\n", arg
->name
);
2879 type
= type_pointer_get_ref_type
(type
);
2883 type
= type_array_get_element_type
(type
);
2887 type
= type_get_real_type
(type
);
2888 if
(!type_is_complete
(type
))
2890 error_loc_info
(&arg
->loc_info
, "undefined type declaration \"enum %s\"\n", type
->name
);
2893 case TGT_IFACE_POINTER
:
2899 } while
(more_to_do
);
2902 static void check_remoting_fields
(const var_t
*var
, type_t
*type
)
2905 const var_list_t
*fields
= NULL
;
2907 type
= type_get_real_type
(type
);
2912 type
->checked
= TRUE
;
2914 if
(type_get_type
(type
) == TYPE_STRUCT
)
2916 if
(type_is_complete
(type
))
2917 fields
= type_struct_get_fields
(type
);
2919 error_loc_info
(&var
->loc_info
, "undefined type declaration \"struct %s\"\n", type
->name
);
2921 else if
(type_get_type
(type
) == TYPE_UNION || type_get_type
(type
) == TYPE_ENCAPSULATED_UNION
)
2923 if
(type_is_complete
(type
))
2924 fields
= type_union_get_cases
(type
);
2926 error_loc_info
(&var
->loc_info
, "undefined type declaration \"union %s\"\n", type
->name
);
2929 if
(fields
) LIST_FOR_EACH_ENTRY
( field
, fields
, const var_t
, entry
)
2930 if
(field
->declspec.type
) check_field_common
(type
, type
->name
, field
);
2933 /* checks that arguments for a function make sense for marshalling and unmarshalling */
2934 static void check_remoting_args
(const var_t
*func
)
2936 const char *funcname
= func
->name
;
2939 if
(!type_function_get_args
(func
->declspec.type
))
2942 LIST_FOR_EACH_ENTRY
( arg
, type_function_get_args
(func
->declspec.type
), const var_t
, entry
)
2944 const type_t
*type
= arg
->declspec.type
;
2946 /* check that [out] parameters have enough pointer levels */
2947 if
(is_attr
(arg
->attrs
, ATTR_OUT
))
2949 switch
(typegen_detect_type
(type
, arg
->attrs
, TDT_ALL_TYPES
))
2956 case TGT_CTXT_HANDLE
:
2958 error_loc_info
(&arg
->loc_info
, "out parameter \'%s\' of function \'%s\' is not a pointer\n", arg
->name
, funcname
);
2960 case TGT_IFACE_POINTER
:
2961 error_loc_info
(&arg
->loc_info
, "out interface pointer \'%s\' of function \'%s\' is not a double pointer\n", arg
->name
, funcname
);
2966 /* needs conformance or fixed dimension */
2967 if
(type_array_has_conformance
(type
) &&
2968 type_array_get_conformance
(type
)->type
!= EXPR_VOID
) break
;
2969 if
(!type_array_has_conformance
(type
) && type_array_get_dim
(type
)) break
;
2971 if
(is_attr
( arg
->attrs
, ATTR_IN
)) break
;
2972 error_loc_info
(&arg
->loc_info
, "out parameter \'%s\' of function \'%s\' cannot be an unsized string\n", arg
->name
, funcname
);
2975 /* already error'd before we get here */
2976 case TGT_CTXT_HANDLE_POINTER
:
2984 check_field_common
(func
->declspec.type
, funcname
, arg
);
2987 if
(type_get_type
(type_function_get_rettype
(func
->declspec.type
)) != TYPE_VOID
)
2991 var.declspec.type
= type_function_get_rettype
(func
->declspec.type
);
2992 var.name
= xstrdup
("return value");
2993 check_field_common
(func
->declspec.type
, funcname
, &var
);
2998 static void add_explicit_handle_if_necessary
(const type_t
*iface
, var_t
*func
)
3000 unsigned char explicit_fc
, implicit_fc
;
3002 /* check for a defined binding handle */
3003 if
(!get_func_handle_var
( iface
, func
, &explicit_fc
, &implicit_fc
) ||
!explicit_fc
)
3005 /* no explicit handle specified so add
3006 * "[in] handle_t IDL_handle" as the first parameter to the
3008 var_t
*idl_handle
= make_var
(xstrdup
("IDL_handle"));
3009 idl_handle
->attrs
= append_attr
(NULL
, make_attr
(ATTR_IN
));
3010 idl_handle
->declspec.type
= find_type_or_error
(NULL
, "handle_t");
3011 type_function_add_head_arg
(func
->declspec.type
, idl_handle
);
3015 static void check_functions
(const type_t
*iface
, int is_inside_library
)
3017 const statement_t
*stmt
;
3018 /* check for duplicates */
3019 if
(is_attr
(iface
->attrs
, ATTR_DISPINTERFACE
))
3021 var_list_t
*methods
= type_dispiface_get_methods
(iface
);
3022 var_t
*func
, *func_iter
;
3024 if
(methods
) LIST_FOR_EACH_ENTRY
( func
, methods
, var_t
, entry
)
3026 LIST_FOR_EACH_ENTRY
( func_iter
, methods
, var_t
, entry
)
3028 if
(func
== func_iter
) break
;
3029 if
(strcmp
(func
->name
, func_iter
->name
)) continue
;
3030 if
(is_attr
(func
->attrs
, ATTR_EVENTADD
) != is_attr
(func_iter
->attrs
, ATTR_EVENTADD
)) continue
;
3031 if
(is_attr
(func
->attrs
, ATTR_EVENTREMOVE
) != is_attr
(func_iter
->attrs
, ATTR_EVENTREMOVE
)) continue
;
3032 if
(is_attr
(func
->attrs
, ATTR_PROPGET
) != is_attr
(func_iter
->attrs
, ATTR_PROPGET
)) continue
;
3033 if
(is_attr
(func
->attrs
, ATTR_PROPPUT
) != is_attr
(func_iter
->attrs
, ATTR_PROPPUT
)) continue
;
3034 if
(is_attr
(func
->attrs
, ATTR_PROPPUTREF
) != is_attr
(func_iter
->attrs
, ATTR_PROPPUTREF
)) continue
;
3035 error_loc_info
(&func
->loc_info
, "duplicated function \'%s\'\n", func
->name
);
3039 if
(is_attr
(iface
->attrs
, ATTR_EXPLICIT_HANDLE
))
3041 STATEMENTS_FOR_EACH_FUNC
( stmt
, type_iface_get_stmts
(iface
) )
3043 var_t
*func
= stmt
->u.var
;
3044 add_explicit_handle_if_necessary
(iface
, func
);
3047 if
(!is_inside_library
&& !is_attr
(iface
->attrs
, ATTR_LOCAL
))
3049 STATEMENTS_FOR_EACH_FUNC
( stmt
, type_iface_get_stmts
(iface
) )
3051 const var_t
*func
= stmt
->u.var
;
3052 if
(!is_attr
(func
->attrs
, ATTR_LOCAL
))
3053 check_remoting_args
(func
);
3058 static int async_iface_attrs
(attr_list_t
*attrs
, const attr_t
*attr
)
3064 case ATTR_ASYNCUUID
:
3065 append_attr
(attrs
, make_attrp
(ATTR_UUID
, attr
->u.pval
));
3072 static int arg_in_attrs
(attr_list_t
*attrs
, const attr_t
*attr
)
3074 return attr
->type
!= ATTR_OUT
&& attr
->type
!= ATTR_RETVAL
;
3077 static int arg_out_attrs
(attr_list_t
*attrs
, const attr_t
*attr
)
3079 return attr
->type
!= ATTR_IN
;
3082 static void check_async_uuid
(type_t
*iface
)
3084 statement_list_t
*stmts
= NULL
;
3086 type_t
*async_iface
;
3089 if
(!is_attr
(iface
->attrs
, ATTR_ASYNCUUID
)) return
;
3091 inherit
= type_iface_get_inherit
(iface
);
3092 if
(inherit
&& strcmp
(inherit
->name
, "IUnknown"))
3093 inherit
= type_iface_get_async_iface
(inherit
);
3095 error_loc
("async_uuid applied to an interface with incompatible parent\n");
3097 async_iface
= type_interface_declare
(strmake
("Async%s", iface
->name
), iface
->namespace
);
3099 STATEMENTS_FOR_EACH_FUNC
( stmt
, type_iface_get_stmts
(iface
) )
3101 var_t
*begin_func
, *finish_func
, *func
= stmt
->u.var
, *arg
;
3102 var_list_t
*begin_args
= NULL
, *finish_args
= NULL
, *args
;
3104 if
(is_attr
(func
->attrs
, ATTR_CALLAS
)) continue
;
3106 args
= type_function_get_args
(func
->declspec.type
);
3107 if
(args
) LIST_FOR_EACH_ENTRY
(arg
, args
, var_t
, entry
)
3109 if
(is_attr
(arg
->attrs
, ATTR_IN
) ||
!is_attr
(arg
->attrs
, ATTR_OUT
))
3110 begin_args
= append_var
(begin_args
, copy_var
(arg
, xstrdup
(arg
->name
), arg_in_attrs
));
3111 if
(is_attr
(arg
->attrs
, ATTR_OUT
))
3112 finish_args
= append_var
(finish_args
, copy_var
(arg
, xstrdup
(arg
->name
), arg_out_attrs
));
3115 begin_func
= copy_var
(func
, strmake
("Begin_%s", func
->name
), NULL
);
3116 begin_func
->declspec.type
= type_new_function
(begin_args
);
3117 begin_func
->declspec.type
->attrs
= func
->attrs
;
3118 begin_func
->declspec.type
->details.function
->retval
= func
->declspec.type
->details.function
->retval
;
3119 stmts
= append_statement
(stmts
, make_statement_declaration
(begin_func
));
3121 finish_func
= copy_var
(func
, strmake
("Finish_%s", func
->name
), NULL
);
3122 finish_func
->declspec.type
= type_new_function
(finish_args
);
3123 finish_func
->declspec.type
->attrs
= func
->attrs
;
3124 finish_func
->declspec.type
->details.function
->retval
= func
->declspec.type
->details.function
->retval
;
3125 stmts
= append_statement
(stmts
, make_statement_declaration
(finish_func
));
3128 type_interface_define
(async_iface
, map_attrs
(iface
->attrs
, async_iface_attrs
), inherit
, stmts
, NULL
);
3129 iface
->details.iface
->async_iface
= async_iface
->details.iface
->async_iface
= async_iface
;
3132 static statement_list_t
*append_parameterized_type_stmts
(statement_list_t
*stmts
)
3134 statement_t
*stmt
, *next
;
3136 if
(stmts
&& parameterized_type_stmts
) LIST_FOR_EACH_ENTRY_SAFE
(stmt
, next
, parameterized_type_stmts
, statement_t
, entry
)
3141 stmt
->u.type
= type_parameterized_type_specialize_define
(stmt
->u.type
);
3142 stmt
->declonly
= FALSE
;
3143 list_remove
(&stmt
->entry
);
3144 stmts
= append_statement
(stmts
, stmt
);
3147 assert
(0); /* should not be there */
3155 static void check_statements
(const statement_list_t
*stmts
, int is_inside_library
)
3157 const statement_t
*stmt
;
3159 if
(stmts
) LIST_FOR_EACH_ENTRY
(stmt
, stmts
, const statement_t
, entry
)
3161 switch
(stmt
->type
) {
3163 check_statements
(stmt
->u.lib
->stmts
, TRUE
);
3166 switch
(type_get_type
(stmt
->u.type
)) {
3167 case TYPE_INTERFACE
:
3168 check_functions
(stmt
->u.type
, is_inside_library
);
3172 error_loc
("coclass is not allowed in Windows Runtime mode\n");
3184 static void check_all_user_types
(const statement_list_t
*stmts
)
3186 const statement_t
*stmt
;
3189 if
(stmts
) LIST_FOR_EACH_ENTRY
(stmt
, stmts
, const statement_t
, entry
)
3191 if
(stmt
->type
== STMT_LIBRARY
)
3192 check_all_user_types
(stmt
->u.lib
->stmts
);
3193 else if
(stmt
->type
== STMT_TYPE
&& type_get_type
(stmt
->u.type
) == TYPE_INTERFACE
&&
3194 !is_local
(stmt
->u.type
->attrs
))
3196 const statement_t
*stmt_func
;
3197 STATEMENTS_FOR_EACH_FUNC
(stmt_func
, type_iface_get_stmts
(stmt
->u.type
)) {
3198 const var_t
*func
= stmt_func
->u.var
;
3199 if
(type_function_get_args
(func
->declspec.type
))
3200 LIST_FOR_EACH_ENTRY
( v
, type_function_get_args
(func
->declspec.type
), const var_t
, entry
)
3201 check_for_additional_prototype_types
(v
->declspec.type
);
3202 check_for_additional_prototype_types
(type_function_get_rettype
(func
->declspec.type
));
3208 int is_valid_uuid
(const char *s
)
3212 for
(i
= 0; i
< 36; ++i
)
3213 if
(i
== 8 || i
== 13 || i
== 18 || i
== 23)
3219 if
(!isxdigit
(s
[i
]))
3222 return s
[i
] == '\0';
3225 static statement_t
*make_statement
(enum statement_type type
)
3227 statement_t
*stmt
= xmalloc
(sizeof
(*stmt
));
3232 static statement_t
*make_statement_type_decl
(type_t
*type
)
3234 statement_t
*stmt
= make_statement
(STMT_TYPE
);
3235 stmt
->u.type
= type
;
3236 stmt
->declonly
= !type
->defined
;
3240 static statement_t
*make_statement_reference
(type_t
*type
)
3242 statement_t
*stmt
= make_statement
(STMT_TYPEREF
);
3243 stmt
->u.type
= type
;
3247 static statement_t
*make_statement_declaration
(var_t
*var
)
3249 statement_t
*stmt
= make_statement
(STMT_DECLARATION
);
3251 if
(var
->declspec.stgclass
== STG_EXTERN
&& var
->eval
)
3252 warning
("'%s' initialised and declared extern\n", var
->name
);
3253 if
(is_const_decl
(var
))
3258 else if
(type_get_type
(var
->declspec.type
) == TYPE_FUNCTION
)
3259 check_function_attrs
(var
->name
, var
->attrs
);
3260 else if
(var
->declspec.stgclass
== STG_NONE || var
->declspec.stgclass
== STG_REGISTER
)
3261 error_loc
("instantiation of data is illegal\n");
3265 static statement_t
*make_statement_library
(typelib_t
*typelib
)
3267 statement_t
*stmt
= make_statement
(STMT_LIBRARY
);
3268 stmt
->u.lib
= typelib
;
3272 static statement_t
*make_statement_pragma
(const char *str
)
3274 statement_t
*stmt
= make_statement
(STMT_PRAGMA
);
3279 static statement_t
*make_statement_cppquote
(const char *str
)
3281 statement_t
*stmt
= make_statement
(STMT_CPPQUOTE
);
3286 static statement_t
*make_statement_importlib
(const char *str
)
3288 statement_t
*stmt
= make_statement
(STMT_IMPORTLIB
);
3293 static statement_t
*make_statement_import
(const char *str
)
3295 statement_t
*stmt
= make_statement
(STMT_IMPORT
);
3300 static statement_t
*make_statement_module
(type_t
*type
)
3302 statement_t
*stmt
= make_statement
(STMT_MODULE
);
3303 stmt
->u.type
= type
;
3307 static statement_t
*make_statement_typedef
(declarator_list_t
*decls
, int declonly
)
3309 declarator_t
*decl
, *next
;
3312 if
(!decls
) return NULL
;
3314 stmt
= make_statement
(STMT_TYPEDEF
);
3315 stmt
->u.type_list
= NULL
;
3316 stmt
->declonly
= declonly
;
3318 LIST_FOR_EACH_ENTRY_SAFE
( decl
, next
, decls
, declarator_t
, entry
)
3320 var_t
*var
= decl
->var
;
3321 type_t
*type
= find_type_or_error
(current_namespace
, var
->name
);
3322 stmt
->u.type_list
= append_typeref
(stmt
->u.type_list
, make_typeref
(type
));
3330 static statement_t
*make_statement_parameterized_type
(type_t
*type
, typeref_list_t
*params
)
3332 statement_t
*stmt
= make_statement
(STMT_TYPE
);
3333 stmt
->u.type
= type_parameterized_type_specialize_partial
(type
, params
);
3337 static statement_t
*make_statement_delegate
(type_t
*ret
, var_list_t
*args
)
3339 declarator_t
*decl
= make_declarator
(make_var
(xstrdup
("Invoke")));
3340 decl_spec_t
*spec
= make_decl_spec
(ret
, NULL
, NULL
, STG_NONE
, 0, 0);
3341 append_chain_type
(decl
, type_new_function
(args
), 0);
3342 return make_statement_declaration
(declare_var
(NULL
, spec
, decl
, FALSE
));
3345 static statement_list_t
*append_statements
(statement_list_t
*l1
, statement_list_t
*l2
)
3348 if
(!l1 || l1
== l2
) return l2
;
3349 list_move_tail
(l1
, l2
);
3353 static attr_list_t
*append_attribs
(attr_list_t
*l1
, attr_list_t
*l2
)
3356 if
(!l1 || l1
== l2
) return l2
;
3357 list_move_tail
(l1
, l2
);
3361 static statement_list_t
*append_statement
(statement_list_t
*list
, statement_t
*stmt
)
3363 if
(!stmt
) return list
;
3366 list
= xmalloc
( sizeof
(*list
) );
3369 list_add_tail
( list
, &stmt
->entry
);
3373 void init_loc_info
(loc_info_t
*i
)
3375 i
->input_name
= input_name ? input_name
: "stdin";
3376 i
->line_number
= line_number
;
3377 i
->near_text
= parser_text
;
3380 type_t
*find_parameterized_type
(type_t
*type
, typeref_list_t
*params
)
3382 char *name
= format_parameterized_type_name
(type
, params
);
3384 if
(parameters_namespace
)
3386 assert
(type
->type_type
== TYPE_PARAMETERIZED_TYPE
);
3387 type
= type_parameterized_type_specialize_partial
(type
, params
);
3389 else if
((type
= find_type
(name
, type
->namespace
, 0)))
3390 assert
(type
->type_type
!= TYPE_PARAMETERIZED_TYPE
);
3392 error_loc
("parameterized type '%s' not declared\n", name
);