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
44 /* Berkeley yacc (byacc) doesn't seem to know about these */
45 /* Some *BSD supplied versions do define these though */
47 # define YYEMPTY (-1) /* Empty lookahead value of yychar */
50 # define YYLEX yylex()
53 #elif defined(YYBISON)
54 /* Bison was used for original development */
55 /* #define YYEMPTY -2 */
56 /* #define YYLEX yylex() */
59 /* No yacc we know yet */
60 # if !defined(YYEMPTY) || !defined(YYLEX)
61 # error Yacc version/type unknown. This version needs to be verified for settings of YYEMPTY and YYLEX.
62 # elif defined(__GNUC__) /* gcc defines the #warning directive */
63 # warning Yacc version/type unknown. It defines YYEMPTY and YYLEX, but is not tested
64 /* #else we just take a chance that it works... */
68 #define YYERROR_VERBOSE
70 unsigned char pointer_default
= RPC_FC_UP
;
71 static int is_object_interface
= FALSE
;
72 /* are we inside a library block? */
73 static int is_inside_library
= FALSE
;
75 typedef
struct list typelist_t
;
81 typelist_t incomplete_types
= LIST_INIT
(incomplete_types
);
83 static void add_incomplete
(type_t
*t
);
84 static void fix_incomplete
(void);
86 static str_list_t
*append_str
(str_list_t
*list
, char *str
);
87 static attr_list_t
*append_attr
(attr_list_t
*list
, attr_t
*attr
);
88 static attr_t
*make_attr
(enum attr_type type
);
89 static attr_t
*make_attrv
(enum attr_type type
, unsigned long val
);
90 static attr_t
*make_attrp
(enum attr_type type
, void *val
);
91 static expr_list_t
*append_expr
(expr_list_t
*list
, expr_t
*expr
);
92 static array_dims_t
*append_array
(array_dims_t
*list
, expr_t
*expr
);
93 static void set_type
(var_t
*v
, type_t
*type
, const declarator_t
*decl
, int top
);
94 static ifref_list_t
*append_ifref
(ifref_list_t
*list
, ifref_t
*iface
);
95 static ifref_t
*make_ifref
(type_t
*iface
);
96 static var_list_t
*append_var
(var_list_t
*list
, var_t
*var
);
97 static var_t
*make_var
(char *name
);
98 static declarator_list_t
*append_declarator
(declarator_list_t
*list
, declarator_t
*p
);
99 static declarator_t
*make_declarator
(var_t
*var
);
100 static func_list_t
*append_func
(func_list_t
*list
, func_t
*func
);
101 static func_t
*make_func
(var_t
*def
);
102 static type_t
*make_class
(char *name
);
103 static type_t
*make_safearray
(type_t
*type
);
104 static type_t
*make_builtin
(char *name
);
105 static type_t
*make_int
(int sign
);
106 static typelib_t
*make_library
(const char *name
, const attr_list_t
*attrs
);
107 static type_t
*make_func_type
(var_list_t
*args
);
108 static void type_set_function_callconv
(type_t
*type
, char *callconv
);
109 static type_t
*append_ptrchain_type
(type_t
*ptrchain
, type_t
*type
);
111 static type_t
*reg_type
(type_t
*type
, const char *name
, int t
);
112 static type_t
*reg_typedefs
(type_t
*type
, var_list_t
*names
, attr_list_t
*attrs
);
113 static type_t
*find_type2
(char *name
, int t
);
114 static type_t
*get_type
(unsigned char type
, char *name
, int t
);
115 static type_t
*get_typev
(unsigned char type
, var_t
*name
, int t
);
116 static int get_struct_type
(var_list_t
*fields
);
118 static var_t
*reg_const
(var_t
*var
);
120 static void write_libid
(const typelib_t
*typelib
);
121 static void write_clsid
(type_t
*cls
);
122 static void write_diid
(type_t
*iface
);
123 static void write_iid
(type_t
*iface
);
125 static int compute_method_indexes
(type_t
*iface
);
126 static char *gen_name
(void);
127 static statement_t
*process_typedefs
(var_list_t
*names
);
128 static void check_arg
(var_t
*arg
);
129 static void check_functions
(const type_t
*iface
);
130 static void check_all_user_types
(const statement_list_t
*stmts
);
131 static const attr_list_t
*check_iface_attrs
(const char *name
, const attr_list_t
*attrs
);
132 static attr_list_t
*check_function_attrs
(const char *name
, attr_list_t
*attrs
);
133 static attr_list_t
*check_typedef_attrs
(attr_list_t
*attrs
);
134 static attr_list_t
*check_field_attrs
(const char *name
, attr_list_t
*attrs
);
135 static const attr_list_t
*check_library_attrs
(const char *name
, const attr_list_t
*attrs
);
136 static attr_list_t
*check_dispiface_attrs
(const char *name
, attr_list_t
*attrs
);
137 static const attr_list_t
*check_module_attrs
(const char *name
, const attr_list_t
*attrs
);
138 static const attr_list_t
*check_coclass_attrs
(const char *name
, const attr_list_t
*attrs
);
139 const char *get_attr_display_name
(enum attr_type type
);
140 static void add_explicit_handle_if_necessary
(func_t
*func
);
142 static statement_t
*make_statement
(enum statement_type type
);
143 static statement_t
*make_statement_type_decl
(type_t
*type
);
144 static statement_t
*make_statement_reference
(type_t
*type
);
145 static statement_t
*make_statement_init_decl
(var_t
*var
);
146 static statement_t
*make_statement_extern
(var_t
*var
);
147 static statement_t
*make_statement_library
(typelib_t
*typelib
);
148 static statement_t
*make_statement_cppquote
(const char *str
);
149 static statement_t
*make_statement_importlib
(const char *str
);
150 static statement_t
*make_statement_module
(type_t
*type
);
151 static statement_list_t
*append_statement
(statement_list_t
*list
, statement_t
*stmt
);
160 attr_list_t
*attr_list
;
161 str_list_t
*str_list
;
163 expr_list_t
*expr_list
;
164 array_dims_t
*array_dims
;
167 var_list_t
*var_list
;
168 declarator_t
*declarator
;
169 declarator_list_t
*declarator_list
;
171 func_list_t
*func_list
;
172 statement_t
*statement
;
173 statement_list_t
*stmt_list
;
175 ifref_list_t
*ifref_list
;
180 interface_info_t ifinfo
;
184 %token
<str
> aIDENTIFIER
185 %token
<str
> aKNOWNTYPE
186 %token
<num
> aNUM aHEXNUM
193 %token EQUALITY INEQUALITY
194 %token GREATEREQUAL LESSEQUAL
195 %token LOGICALOR LOGICALAND
196 %token tAGGREGATABLE tALLOCATE tAPPOBJECT tASYNC tASYNCUUID
197 %token tAUTOHANDLE tBINDABLE tBOOLEAN tBROADCAST tBYTE tBYTECOUNT
198 %token tCALLAS tCALLBACK tCASE tCDECL tCHAR tCOCLASS tCODE tCOMMSTATUS
199 %token tCONST tCONTEXTHANDLE tCONTEXTHANDLENOSERIALIZE
200 %token tCONTEXTHANDLESERIALIZE tCONTROL tCPPQUOTE
202 %token tDEFAULTCOLLELEM
204 %token tDEFAULTVTABLE
206 %token tDISPINTERFACE
207 %token tDLLNAME tDOUBLE tDUAL
209 %token tENTRY tENUM tERRORSTATUST
210 %token tEXPLICITHANDLE tEXTERN
216 %token tHELPCONTEXT tHELPFILE
217 %token tHELPSTRING tHELPSTRINGCONTEXT tHELPSTRINGDLL
219 %token tHYPER tID tIDEMPOTENT
221 %token tIMMEDIATEBIND
222 %token tIMPLICITHANDLE
223 %token tIMPORT tIMPORTLIB
229 %token tLENGTHIS tLIBRARY
236 %token tNONEXTENSIBLE
238 %token tOBJECT tODL tOLEAUTOMATION
242 %token tPOINTERDEFAULT
244 %token tPROPGET tPROPPUT tPROPPUTREF
248 %token tREADONLY tREF
256 %token tSIZEIS tSIZEOF
260 %token tSTRICTCONTEXTHANDLE
261 %token tSTRING tSTRUCT
262 %token tSWITCH tSWITCHIS tSWITCHTYPE
274 %token tWCHAR tWIREMARSHAL
276 %type
<attr
> attribute
277 %type
<attr_list
> m_attributes attributes attrib_list
278 %type
<str_list
> str_list
279 %type
<expr
> m_expr expr expr_const array
280 %type
<expr_list
> m_exprs
/* exprs expr_list */ expr_list_const
281 %type
<ifinfo
> interfacehdr
282 %type
<type
> inherit interface interfacedef interfacedec
283 %type
<type
> dispinterface dispinterfacehdr dispinterfacedef
284 %type
<type
> module modulehdr moduledef
285 %type
<type
> base_type int_std
286 %type
<type
> enumdef structdef uniondef
288 %type
<ifref
> coclass_int
289 %type
<ifref_list
> coclass_ints
290 %type
<var
> arg field ne_union_field union_field s_field case
enum constdef externdef
291 %type
<var_list
> m_args no_args args fields ne_union_fields cases enums enum_list dispint_props
292 %type
<var
> m_ident t_ident ident
293 %type
<declarator
> declarator func_declarator direct_declarator
294 %type
<declarator_list
> declarator_list
296 %type
<func_list
> int_statements dispint_meths
297 %type
<type
> coclass coclasshdr coclassdef
298 %type
<num
> pointer_type version
299 %type
<str
> libraryhdr callconv cppquote importlib
300 %type
<uuid
> uuid_string
301 %type
<num
> import_start
302 %type
<typelib
> library_start librarydef
303 %type
<statement
> statement typedef
304 %type
<stmt_list
> gbl_statements imp_statements
313 %left EQUALITY INEQUALITY
314 %left
'<' '>' LESSEQUAL GREATEREQUAL
318 %right
'!' '~' CAST PPTR POS NEG ADDRESSOF tSIZEOF
319 %left
'.' MEMBERPTR
'[' ']'
323 input: gbl_statements
{ fix_incomplete
();
324 check_all_user_types
($1);
332 gbl_statements: { $$
= NULL
; }
333 | gbl_statements interfacedec
{ $$
= $1; }
334 | gbl_statements interfacedef
{ $$
= append_statement
($1, make_statement_type_decl
($2)); }
335 | gbl_statements coclass
';' { $$
= $1;
336 reg_type
($2, $2->name
, 0);
337 if
(!parse_only
&& do_header
) write_coclass_forward
($2);
339 | gbl_statements coclassdef
{ $$
= append_statement
($1, make_statement_type_decl
($2));
340 add_typelib_entry
($2);
341 reg_type
($2, $2->name
, 0);
342 if
(!parse_only
&& do_header
) write_coclass_forward
($2);
344 | gbl_statements moduledef
{ $$
= append_statement
($1, make_statement_module
($2));
345 add_typelib_entry
($2);
347 | gbl_statements librarydef
{ $$
= append_statement
($1, make_statement_library
($2)); }
348 | gbl_statements statement
{ $$
= append_statement
($1, $2); }
351 imp_statements: { $$
= NULL
; }
352 | imp_statements interfacedec
{ $$
= append_statement
($1, make_statement_reference
($2)); if
(!parse_only
) add_typelib_entry
($2); }
353 | imp_statements interfacedef
{ $$
= append_statement
($1, make_statement_type_decl
($2)); if
(!parse_only
) add_typelib_entry
($2); }
354 | imp_statements coclass
';' { $$
= $1; reg_type
($2, $2->name
, 0); if
(!parse_only
&& do_header
) write_coclass_forward
($2); }
355 | imp_statements coclassdef
{ $$
= append_statement
($1, make_statement_type_decl
($2));
356 if
(!parse_only
) add_typelib_entry
($2);
357 reg_type
($2, $2->name
, 0);
358 if
(!parse_only
&& do_header
) write_coclass_forward
($2);
360 | imp_statements moduledef
{ $$
= append_statement
($1, make_statement_module
($2)); if
(!parse_only
) add_typelib_entry
($2); }
361 | imp_statements statement
{ $$
= append_statement
($1, $2); }
362 | imp_statements importlib
{ $$
= append_statement
($1, make_statement_importlib
($2)); }
363 | imp_statements librarydef
{ $$
= append_statement
($1, make_statement_library
($2)); }
366 int_statements: { $$
= NULL
; }
367 | int_statements funcdef
';' { $$
= append_func
( $1, $2 ); }
368 | int_statements statement
{ $$
= $1; }
375 statement: constdef
';' { $$
= make_statement_init_decl
($1);
376 if
(!parse_only
&& do_header
) { write_constdef
($1); }
378 | cppquote
{ $$
= make_statement_cppquote
($1); }
379 | enumdef
';' { $$
= make_statement_type_decl
($1);
380 if
(!parse_only
&& do_header
) {
381 write_type_def_or_decl
(header
, $1, FALSE
, NULL
);
382 fprintf
(header
, ";\n\n");
385 | externdef
';' { $$
= make_statement_extern
($1);
386 if
(!parse_only
&& do_header
) write_externdef
($1);
388 | import
{ $$
= NULL
; }
389 | structdef
';' { $$
= make_statement_type_decl
($1);
390 if
(!parse_only
&& do_header
) {
391 write_type_def_or_decl
(header
, $1, FALSE
, NULL
);
392 fprintf
(header
, ";\n\n");
395 | typedef
';' { $$
= $1; }
396 | uniondef
';' { $$
= make_statement_type_decl
($1);
397 if
(!parse_only
&& do_header
) {
398 write_type_def_or_decl
(header
, $1, FALSE
, NULL
);
399 fprintf
(header
, ";\n\n");
404 cppquote: tCPPQUOTE
'(' aSTRING
')' { $$
= $3; if
(!parse_only
&& do_header
) fprintf
(header
, "%s\n", $3); }
406 import_start: tIMPORT aSTRING
';' { assert
(yychar == YYEMPTY
);
408 if
(!$$
) yychar = aEOF
;
412 import: import_start imp_statements aEOF
413 { if
($1) pop_import
(); }
416 importlib: tIMPORTLIB
'(' aSTRING
')'
417 semicolon_opt
{ $$
= $3; if
(!parse_only
) add_importlib
($3); }
420 libraryhdr: tLIBRARY aIDENTIFIER
{ $$
= $2; }
422 library_start: attributes libraryhdr
'{' { $$
= make_library
($2, check_library_attrs
($2, $1));
423 if
(!parse_only
) start_typelib
($$
);
424 if
(!parse_only
&& do_header
) write_library
($$
);
425 if
(!parse_only
&& do_idfile
) write_libid
($$
);
426 is_inside_library
= TRUE
;
429 librarydef: library_start imp_statements
'}'
430 semicolon_opt
{ $$
= $1;
432 if
(!parse_only
) end_typelib
();
433 is_inside_library
= FALSE
;
437 m_args: { $$
= NULL
; }
441 no_args: tVOID
{ $$
= NULL
; }
444 args: arg
{ check_arg
($1); $$
= append_var
( NULL
, $1 ); }
445 | args
',' arg
{ check_arg
($3); $$
= append_var
( $1, $3); }
449 /* split into two rules to get bison to resolve a tVOID conflict */
450 arg: attributes type declarator
{ $$
= $3->var
;
452 set_type
($$
, $2, $3, TRUE
);
455 | type declarator
{ $$
= $2->var
;
456 set_type
($$
, $1, $2, TRUE
);
461 array: '[' m_expr
']' { $$
= $2; }
462 |
'[' '*' ']' { $$
= make_expr
(EXPR_VOID
); }
465 m_attributes: { $$
= NULL
; }
470 '[' attrib_list
']' { $$
= $2;
472 error_loc
("empty attribute lists unsupported\n");
476 attrib_list: attribute
{ $$
= append_attr
( NULL
, $1 ); }
477 | attrib_list
',' attribute
{ $$
= append_attr
( $1, $3 ); }
478 | attrib_list
']' '[' attribute
{ $$
= append_attr
( $1, $4 ); }
481 str_list: aSTRING
{ $$
= append_str
( NULL
, $1 ); }
482 | str_list
',' aSTRING
{ $$
= append_str
( $1, $3 ); }
485 attribute: { $$
= NULL
; }
486 | tAGGREGATABLE
{ $$
= make_attr
(ATTR_AGGREGATABLE
); }
487 | tAPPOBJECT
{ $$
= make_attr
(ATTR_APPOBJECT
); }
488 | tASYNC
{ $$
= make_attr
(ATTR_ASYNC
); }
489 | tAUTOHANDLE
{ $$
= make_attr
(ATTR_AUTO_HANDLE
); }
490 | tBINDABLE
{ $$
= make_attr
(ATTR_BINDABLE
); }
491 | tBROADCAST
{ $$
= make_attr
(ATTR_BROADCAST
); }
492 | tCALLAS
'(' ident
')' { $$
= make_attrp
(ATTR_CALLAS
, $3); }
493 | tCASE
'(' expr_list_const
')' { $$
= make_attrp
(ATTR_CASE
, $3); }
494 | tCONTEXTHANDLE
{ $$
= make_attrv
(ATTR_CONTEXTHANDLE
, 0); }
495 | tCONTEXTHANDLENOSERIALIZE
{ $$
= make_attrv
(ATTR_CONTEXTHANDLE
, 0); /* RPC_CONTEXT_HANDLE_DONT_SERIALIZE */ }
496 | tCONTEXTHANDLESERIALIZE
{ $$
= make_attrv
(ATTR_CONTEXTHANDLE
, 0); /* RPC_CONTEXT_HANDLE_SERIALIZE */ }
497 | tCONTROL
{ $$
= make_attr
(ATTR_CONTROL
); }
498 | tDEFAULT
{ $$
= make_attr
(ATTR_DEFAULT
); }
499 | tDEFAULTCOLLELEM
{ $$
= make_attr
(ATTR_DEFAULTCOLLELEM
); }
500 | tDEFAULTVALUE
'(' expr_const
')' { $$
= make_attrp
(ATTR_DEFAULTVALUE_EXPR
, $3); }
501 | tDEFAULTVALUE
'(' aSTRING
')' { $$
= make_attrp
(ATTR_DEFAULTVALUE_STRING
, $3); }
502 | tDEFAULTVTABLE
{ $$
= make_attr
(ATTR_DEFAULTVTABLE
); }
503 | tDISPLAYBIND
{ $$
= make_attr
(ATTR_DISPLAYBIND
); }
504 | tDLLNAME
'(' aSTRING
')' { $$
= make_attrp
(ATTR_DLLNAME
, $3); }
505 | tDUAL
{ $$
= make_attr
(ATTR_DUAL
); }
506 | tENDPOINT
'(' str_list
')' { $$
= make_attrp
(ATTR_ENDPOINT
, $3); }
507 | tENTRY
'(' aSTRING
')' { $$
= make_attrp
(ATTR_ENTRY_STRING
, $3); }
508 | tENTRY
'(' expr_const
')' { $$
= make_attrp
(ATTR_ENTRY_ORDINAL
, $3); }
509 | tEXPLICITHANDLE
{ $$
= make_attr
(ATTR_EXPLICIT_HANDLE
); }
510 | tHANDLE
{ $$
= make_attr
(ATTR_HANDLE
); }
511 | tHELPCONTEXT
'(' expr_const
')' { $$
= make_attrp
(ATTR_HELPCONTEXT
, $3); }
512 | tHELPFILE
'(' aSTRING
')' { $$
= make_attrp
(ATTR_HELPFILE
, $3); }
513 | tHELPSTRING
'(' aSTRING
')' { $$
= make_attrp
(ATTR_HELPSTRING
, $3); }
514 | tHELPSTRINGCONTEXT
'(' expr_const
')' { $$
= make_attrp
(ATTR_HELPSTRINGCONTEXT
, $3); }
515 | tHELPSTRINGDLL
'(' aSTRING
')' { $$
= make_attrp
(ATTR_HELPSTRINGDLL
, $3); }
516 | tHIDDEN
{ $$
= make_attr
(ATTR_HIDDEN
); }
517 | tID
'(' expr_const
')' { $$
= make_attrp
(ATTR_ID
, $3); }
518 | tIDEMPOTENT
{ $$
= make_attr
(ATTR_IDEMPOTENT
); }
519 | tIIDIS
'(' expr
')' { $$
= make_attrp
(ATTR_IIDIS
, $3); }
520 | tIMMEDIATEBIND
{ $$
= make_attr
(ATTR_IMMEDIATEBIND
); }
521 | tIMPLICITHANDLE
'(' tHANDLET aIDENTIFIER
')' { $$
= make_attrp
(ATTR_IMPLICIT_HANDLE
, $4); }
522 | tIN
{ $$
= make_attr
(ATTR_IN
); }
523 | tINPUTSYNC
{ $$
= make_attr
(ATTR_INPUTSYNC
); }
524 | tLENGTHIS
'(' m_exprs
')' { $$
= make_attrp
(ATTR_LENGTHIS
, $3); }
525 | tLCID
'(' expr_const
')' { $$
= make_attrp
(ATTR_LIBLCID
, $3); }
526 | tLOCAL
{ $$
= make_attr
(ATTR_LOCAL
); }
527 | tNONBROWSABLE
{ $$
= make_attr
(ATTR_NONBROWSABLE
); }
528 | tNONCREATABLE
{ $$
= make_attr
(ATTR_NONCREATABLE
); }
529 | tNONEXTENSIBLE
{ $$
= make_attr
(ATTR_NONEXTENSIBLE
); }
530 | tOBJECT
{ $$
= make_attr
(ATTR_OBJECT
); }
531 | tODL
{ $$
= make_attr
(ATTR_ODL
); }
532 | tOLEAUTOMATION
{ $$
= make_attr
(ATTR_OLEAUTOMATION
); }
533 | tOPTIONAL
{ $$
= make_attr
(ATTR_OPTIONAL
); }
534 | tOUT
{ $$
= make_attr
(ATTR_OUT
); }
535 | tPOINTERDEFAULT
'(' pointer_type
')' { $$
= make_attrv
(ATTR_POINTERDEFAULT
, $3); }
536 | tPROPGET
{ $$
= make_attr
(ATTR_PROPGET
); }
537 | tPROPPUT
{ $$
= make_attr
(ATTR_PROPPUT
); }
538 | tPROPPUTREF
{ $$
= make_attr
(ATTR_PROPPUTREF
); }
539 | tPUBLIC
{ $$
= make_attr
(ATTR_PUBLIC
); }
540 | tRANGE
'(' expr_const
',' expr_const
')' { expr_list_t
*list
= append_expr
( NULL
, $3 );
541 list
= append_expr
( list
, $5 );
542 $$
= make_attrp
(ATTR_RANGE
, list
); }
543 | tREADONLY
{ $$
= make_attr
(ATTR_READONLY
); }
544 | tREQUESTEDIT
{ $$
= make_attr
(ATTR_REQUESTEDIT
); }
545 | tRESTRICTED
{ $$
= make_attr
(ATTR_RESTRICTED
); }
546 | tRETVAL
{ $$
= make_attr
(ATTR_RETVAL
); }
547 | tSIZEIS
'(' m_exprs
')' { $$
= make_attrp
(ATTR_SIZEIS
, $3); }
548 | tSOURCE
{ $$
= make_attr
(ATTR_SOURCE
); }
549 | tSTRICTCONTEXTHANDLE
{ $$
= make_attr
(ATTR_STRICTCONTEXTHANDLE
); }
550 | tSTRING
{ $$
= make_attr
(ATTR_STRING
); }
551 | tSWITCHIS
'(' expr
')' { $$
= make_attrp
(ATTR_SWITCHIS
, $3); }
552 | tSWITCHTYPE
'(' type
')' { $$
= make_attrp
(ATTR_SWITCHTYPE
, $3); }
553 | tTRANSMITAS
'(' type
')' { $$
= make_attrp
(ATTR_TRANSMITAS
, $3); }
554 | tUUID
'(' uuid_string
')' { $$
= make_attrp
(ATTR_UUID
, $3); }
555 | tV1ENUM
{ $$
= make_attr
(ATTR_V1ENUM
); }
556 | tVARARG
{ $$
= make_attr
(ATTR_VARARG
); }
557 | tVERSION
'(' version
')' { $$
= make_attrv
(ATTR_VERSION
, $3); }
558 | tWIREMARSHAL
'(' type
')' { $$
= make_attrp
(ATTR_WIREMARSHAL
, $3); }
559 | pointer_type
{ $$
= make_attrv
(ATTR_POINTERTYPE
, $1); }
564 | aSTRING
{ if
(!is_valid_uuid
($1))
565 error_loc
("invalid UUID: %s\n", $1);
566 $$
= parse_uuid
($1); }
569 callconv: tCDECL
{ $$
= $
<str
>1; }
570 | tFASTCALL
{ $$
= $
<str
>1; }
571 | tPASCAL
{ $$
= $
<str
>1; }
572 | tSTDCALL
{ $$
= $
<str
>1; }
575 cases: { $$
= NULL
; }
576 | cases case
{ $$
= append_var
( $1, $2 ); }
579 case: tCASE expr_const
':' union_field
{ attr_t
*a
= make_attrp
(ATTR_CASE
, append_expr
( NULL
, $2 ));
580 $$
= $4; if
(!$$
) $$
= make_var
(NULL
);
581 $$
->attrs
= append_attr
( $$
->attrs
, a
);
583 | tDEFAULT
':' union_field
{ attr_t
*a
= make_attr
(ATTR_DEFAULT
);
584 $$
= $3; if
(!$$
) $$
= make_var
(NULL
);
585 $$
->attrs
= append_attr
( $$
->attrs
, a
);
589 constdef: tCONST type ident
'=' expr_const
{ $$
= reg_const
($3);
590 set_type
($$
, $2, NULL
, FALSE
);
595 enums: { $$
= NULL
; }
596 | enum_list
',' { $$
= $1; }
600 enum_list: enum { if
(!$1->eval
)
601 $1->eval
= make_exprl
(EXPR_NUM
, 0 /* default for first enum entry */);
602 $$
= append_var
( NULL
, $1 );
604 | enum_list
',' enum { if
(!$3->eval
)
606 var_t
*last
= LIST_ENTRY
( list_tail
($$
), var_t
, entry
);
607 $3->eval
= make_exprl
(EXPR_NUM
, last
->eval
->cval
+ 1);
609 $$
= append_var
( $1, $3 );
613 enum: ident
'=' expr_const
{ $$
= reg_const
($1);
615 $$
->type
= make_int
(0);
617 | ident
{ $$
= reg_const
($1);
618 $$
->type
= make_int
(0);
622 enumdef: tENUM t_ident
'{' enums
'}' { $$
= get_typev
(RPC_FC_ENUM16
, $2, tsENUM
);
623 $$
->kind
= TKIND_ENUM
;
624 $$
->fields_or_args
= $4;
627 add_typelib_entry
($$
);
631 m_exprs: m_expr
{ $$
= append_expr
( NULL
, $1 ); }
632 | m_exprs
',' m_expr
{ $$
= append_expr
( $1, $3 ); }
636 exprs: { $$ = make_expr(EXPR_VOID); }
641 | expr_list ',' expr { LINK($3, $1); $$ = $3; }
645 m_expr: { $$
= make_expr
(EXPR_VOID
); }
649 expr: aNUM
{ $$
= make_exprl
(EXPR_NUM
, $1); }
650 | aHEXNUM
{ $$
= make_exprl
(EXPR_HEXNUM
, $1); }
651 | aDOUBLE
{ $$
= make_exprd
(EXPR_DOUBLE
, $1); }
652 | tFALSE
{ $$
= make_exprl
(EXPR_TRUEFALSE
, 0); }
653 | tNULL
{ $$
= make_exprl
(EXPR_NUM
, 0); }
654 | tTRUE
{ $$
= make_exprl
(EXPR_TRUEFALSE
, 1); }
655 | aIDENTIFIER
{ $$
= make_exprs
(EXPR_IDENTIFIER
, $1); }
656 | expr
'?' expr
':' expr
{ $$
= make_expr3
(EXPR_COND
, $1, $3, $5); }
657 | expr LOGICALOR expr
{ $$
= make_expr2
(EXPR_LOGOR
, $1, $3); }
658 | expr LOGICALAND expr
{ $$
= make_expr2
(EXPR_LOGAND
, $1, $3); }
659 | expr
'|' expr
{ $$
= make_expr2
(EXPR_OR
, $1, $3); }
660 | expr
'^' expr
{ $$
= make_expr2
(EXPR_XOR
, $1, $3); }
661 | expr
'&' expr
{ $$
= make_expr2
(EXPR_AND
, $1, $3); }
662 | expr EQUALITY expr
{ $$
= make_expr2
(EXPR_EQUALITY
, $1, $3); }
663 | expr INEQUALITY expr
{ $$
= make_expr2
(EXPR_INEQUALITY
, $1, $3); }
664 | expr
'>' expr
{ $$
= make_expr2
(EXPR_GTR
, $1, $3); }
665 | expr
'<' expr
{ $$
= make_expr2
(EXPR_LESS
, $1, $3); }
666 | expr GREATEREQUAL expr
{ $$
= make_expr2
(EXPR_GTREQL
, $1, $3); }
667 | expr LESSEQUAL expr
{ $$
= make_expr2
(EXPR_LESSEQL
, $1, $3); }
668 | expr SHL expr
{ $$
= make_expr2
(EXPR_SHL
, $1, $3); }
669 | expr SHR expr
{ $$
= make_expr2
(EXPR_SHR
, $1, $3); }
670 | expr
'+' expr
{ $$
= make_expr2
(EXPR_ADD
, $1, $3); }
671 | expr
'-' expr
{ $$
= make_expr2
(EXPR_SUB
, $1, $3); }
672 | expr
'%' expr
{ $$
= make_expr2
(EXPR_MOD
, $1, $3); }
673 | expr
'*' expr
{ $$
= make_expr2
(EXPR_MUL
, $1, $3); }
674 | expr
'/' expr
{ $$
= make_expr2
(EXPR_DIV
, $1, $3); }
675 |
'!' expr
{ $$
= make_expr1
(EXPR_LOGNOT
, $2); }
676 |
'~' expr
{ $$
= make_expr1
(EXPR_NOT
, $2); }
677 |
'+' expr %prec POS
{ $$
= make_expr1
(EXPR_POS
, $2); }
678 |
'-' expr %prec NEG
{ $$
= make_expr1
(EXPR_NEG
, $2); }
679 |
'&' expr %prec ADDRESSOF
{ $$
= make_expr1
(EXPR_ADDRESSOF
, $2); }
680 |
'*' expr %prec PPTR
{ $$
= make_expr1
(EXPR_PPTR
, $2); }
681 | expr MEMBERPTR aIDENTIFIER
{ $$
= make_expr2
(EXPR_MEMBER
, make_expr1
(EXPR_PPTR
, $1), make_exprs
(EXPR_IDENTIFIER
, $3)); }
682 | expr
'.' aIDENTIFIER
{ $$
= make_expr2
(EXPR_MEMBER
, $1, make_exprs
(EXPR_IDENTIFIER
, $3)); }
683 |
'(' type
')' expr %prec CAST
{ $$
= make_exprt
(EXPR_CAST
, $2, $4); }
684 | tSIZEOF
'(' type
')' { $$
= make_exprt
(EXPR_SIZEOF
, $3, NULL
); }
685 | expr
'[' expr
']' { $$
= make_expr2
(EXPR_ARRAY
, $1, $3); }
686 |
'(' expr
')' { $$
= $2; }
689 expr_list_const: expr_const
{ $$
= append_expr
( NULL
, $1 ); }
690 | expr_list_const
',' expr_const
{ $$
= append_expr
( $1, $3 ); }
693 expr_const: expr
{ $$
= $1;
695 error_loc
("expression is not constant\n");
699 externdef: tEXTERN tCONST type ident
{ $$
= $4;
700 set_type
($$
, $3, NULL
, FALSE
);
704 fields: { $$
= NULL
; }
705 | fields field
{ $$
= append_var
( $1, $2 ); }
708 field: s_field
';' { $$
= $1; }
709 | m_attributes uniondef
';' { $$
= make_var
(NULL
); $$
->type
= $2; $$
->attrs
= $1; }
713 s_field
';' { $$
= $1; }
714 | attributes
';' { $$
= make_var
(NULL
); $$
->attrs
= $1; }
716 ne_union_fields: { $$
= NULL
; }
717 | ne_union_fields ne_union_field
{ $$
= append_var
( $1, $2 ); }
721 s_field
';' { $$
= $1; }
724 s_field: m_attributes type declarator
{ $$
= $3->var
;
725 $$
->attrs
= check_field_attrs
($$
->name
, $1);
726 set_type
($$
, $2, $3, FALSE
);
732 m_attributes type declarator
{ var_t
*v
= $3->var
;
733 v
->attrs
= check_function_attrs
(v
->name
, $1);
734 set_type
(v
, $2, $3, FALSE
);
740 m_ident: { $$
= NULL
; }
744 t_ident: { $$
= NULL
; }
745 | aIDENTIFIER
{ $$
= make_var
($1); }
746 | aKNOWNTYPE
{ $$
= make_var
($1); }
749 ident: aIDENTIFIER
{ $$
= make_var
($1); }
750 /* some "reserved words" used in attributes are also used as field names in some MS IDL files */
751 | aKNOWNTYPE
{ $$
= make_var
($
<str
>1); }
754 base_type: tBYTE
{ $$
= make_builtin
($
<str
>1); }
755 | tWCHAR
{ $$
= make_builtin
($
<str
>1); }
757 | tSIGNED int_std
{ $$
= $2; $$
->sign
= 1; }
758 | tUNSIGNED int_std
{ $$
= $2; $$
->sign
= -1;
760 case RPC_FC_CHAR
: break
;
761 case RPC_FC_SMALL
: $$
->type
= RPC_FC_USMALL
; break
;
762 case RPC_FC_SHORT
: $$
->type
= RPC_FC_USHORT
; break
;
763 case RPC_FC_LONG
: $$
->type
= RPC_FC_ULONG
; break
;
765 if
($$
->name
[0] == 'h') /* hyper, as opposed to __int64 */
767 $$
= alias
($$
, "MIDL_uhyper");
774 | tUNSIGNED
{ $$
= make_int
(-1); }
775 | tFLOAT
{ $$
= make_builtin
($
<str
>1); }
776 | tSINGLE
{ $$
= duptype
(find_type
("float", 0), 1); }
777 | tDOUBLE
{ $$
= make_builtin
($
<str
>1); }
778 | tBOOLEAN
{ $$
= make_builtin
($
<str
>1); }
779 | tERRORSTATUST
{ $$
= make_builtin
($
<str
>1); }
780 | tHANDLET
{ $$
= make_builtin
($
<str
>1); }
787 int_std: tINT
{ $$
= make_builtin
($
<str
>1); }
788 | tSHORT m_int
{ $$
= make_builtin
($
<str
>1); }
789 | tSMALL
{ $$
= make_builtin
($
<str
>1); }
790 | tLONG m_int
{ $$
= make_builtin
($
<str
>1); }
791 | tHYPER m_int
{ $$
= make_builtin
($
<str
>1); }
792 | tINT64
{ $$
= make_builtin
($
<str
>1); }
793 | tCHAR
{ $$
= make_builtin
($
<str
>1); }
796 coclass: tCOCLASS aIDENTIFIER
{ $$
= make_class
($2); }
797 | tCOCLASS aKNOWNTYPE
{ $$
= find_type
($2, 0);
798 if
($$
->defined
) error_loc
("multiple definition error\n");
799 if
($$
->kind
!= TKIND_COCLASS
) error_loc
("%s was not declared a coclass\n", $2);
803 coclasshdr: attributes coclass
{ $$
= $2;
804 $$
->attrs
= check_coclass_attrs
($2->name
, $1);
805 if
(!parse_only
&& do_header
)
807 if
(!parse_only
&& do_idfile
)
812 coclassdef: coclasshdr
'{' coclass_ints
'}' semicolon_opt
819 coclass_ints: { $$
= NULL
; }
820 | coclass_ints coclass_int
{ $$
= append_ifref
( $1, $2 ); }
824 m_attributes interfacedec
{ $$
= make_ifref
($2); $$
->attrs
= $1; }
827 dispinterface: tDISPINTERFACE aIDENTIFIER
{ $$
= get_type
(0, $2, 0); $$
->kind
= TKIND_DISPATCH
; }
828 | tDISPINTERFACE aKNOWNTYPE
{ $$
= get_type
(0, $2, 0); $$
->kind
= TKIND_DISPATCH
; }
831 dispinterfacehdr: attributes dispinterface
{ attr_t
*attrs
;
832 is_object_interface
= TRUE
;
834 if
($$
->defined
) error_loc
("multiple definition error\n");
835 attrs
= make_attr
(ATTR_DISPINTERFACE
);
836 $$
->attrs
= append_attr
( check_dispiface_attrs
($2->name
, $1), attrs
);
837 $$
->ref
= find_type
("IDispatch", 0);
838 if
(!$$
->ref
) error_loc
("IDispatch is undefined\n");
840 if
(!parse_only
&& do_header
) write_forward
($$
);
844 dispint_props: tPROPERTIES
':' { $$
= NULL
; }
845 | dispint_props s_field
';' { $$
= append_var
( $1, $2 ); }
848 dispint_meths: tMETHODS
':' { $$
= NULL
; }
849 | dispint_meths funcdef
';' { $$
= append_func
( $1, $2 ); }
852 dispinterfacedef: dispinterfacehdr
'{'
856 $$
->fields_or_args
= $3;
858 if
(!parse_only
&& do_header
) write_dispinterface
($$
);
859 if
(!parse_only
&& do_idfile
) write_diid
($$
);
862 '{' interface
';' '}' { $$
= $1;
863 $$
->fields_or_args
= $3->fields_or_args
;
864 $$
->funcs
= $3->funcs
;
865 if
(!parse_only
&& do_header
) write_dispinterface
($$
);
866 if
(!parse_only
&& do_idfile
) write_diid
($$
);
870 inherit: { $$
= NULL
; }
871 |
':' aKNOWNTYPE
{ $$
= find_type2
($2, 0); }
874 interface: tINTERFACE aIDENTIFIER
{ $$
= get_type
(RPC_FC_IP
, $2, 0); $$
->kind
= TKIND_INTERFACE
; }
875 | tINTERFACE aKNOWNTYPE
{ $$
= get_type
(RPC_FC_IP
, $2, 0); $$
->kind
= TKIND_INTERFACE
; }
878 interfacehdr: attributes interface
{ $$.interface
= $2;
879 $$.old_pointer_default
= pointer_default
;
880 if
(is_attr
($1, ATTR_POINTERDEFAULT
))
881 pointer_default
= get_attrv
($1, ATTR_POINTERDEFAULT
);
882 is_object_interface
= is_object
($1);
883 if
($2->defined
) error_loc
("multiple definition error\n");
884 $2->attrs
= check_iface_attrs
($2->name
, $1);
886 if
(!parse_only
&& do_header
) write_forward
($2);
890 interfacedef: interfacehdr inherit
891 '{' int_statements
'}' semicolon_opt
{ $$
= $1.interface
;
895 compute_method_indexes
($$
);
896 if
(!parse_only
&& do_header
) write_interface
($$
);
897 if
(!parse_only
&& local_stubs
) write_locals
(local_stubs
, $$
, TRUE
);
898 if
(!parse_only
&& do_idfile
) write_iid
($$
);
899 pointer_default
= $1.old_pointer_default
;
901 /* MIDL is able to import the definition of a base class from inside the
902 * definition of a derived class, I'll try to support it with this rule */
903 | interfacehdr
':' aIDENTIFIER
904 '{' import int_statements
'}'
905 semicolon_opt
{ $$
= $1.interface
;
906 $$
->ref
= find_type2
($3, 0);
907 if
(!$$
->ref
) error_loc
("base class '%s' not found in import\n", $3);
909 compute_method_indexes
($$
);
910 if
(!parse_only
&& do_header
) write_interface
($$
);
911 if
(!parse_only
&& local_stubs
) write_locals
(local_stubs
, $$
, TRUE
);
912 if
(!parse_only
&& do_idfile
) write_iid
($$
);
913 pointer_default
= $1.old_pointer_default
;
915 | dispinterfacedef semicolon_opt
{ $$
= $1; }
919 interface
';' { $$
= $1; if
(!parse_only
&& do_header
) write_forward
($$
); }
920 | dispinterface
';' { $$
= $1; if
(!parse_only
&& do_header
) write_forward
($$
); }
923 module: tMODULE aIDENTIFIER
{ $$
= make_type
(0, NULL
); $$
->name
= $2; $$
->kind
= TKIND_MODULE
; }
924 | tMODULE aKNOWNTYPE
{ $$
= make_type
(0, NULL
); $$
->name
= $2; $$
->kind
= TKIND_MODULE
; }
927 modulehdr: attributes module
{ $$
= $2;
928 $$
->attrs
= check_module_attrs
($2->name
, $1);
932 moduledef: modulehdr
'{' int_statements
'}'
933 semicolon_opt
{ $$
= $1;
935 /* FIXME: if (!parse_only && do_header) write_module($$); */
940 '*' declarator %prec PPTR
{ $$
= $2; $$
->type
= make_type
(pointer_default
, $$
->type
); }
941 | tCONST declarator
{ $$
= $2; /* FIXME */ }
942 | callconv declarator
{ $$
= $2; type_set_function_callconv
($$
->func_type
, $1); }
946 func_declarator: direct_declarator
'(' m_args
')'
948 $$
->type
= append_ptrchain_type
($$
->type
, make_func_type
($3));
953 ident
{ $$
= make_declarator
($1); }
954 |
'(' declarator
')' { $$
= $2; }
955 | direct_declarator array
{ $$
= $1; $$
->array
= append_array
($$
->array
, $2); }
956 | func_declarator
{ $$
= $1;
957 $$
->func_type
= $$
->type
;
963 declarator
{ $$
= append_declarator
( NULL
, $1 ); }
964 | declarator_list
',' declarator
{ $$
= append_declarator
( $1, $3 ); }
968 tREF
{ $$
= RPC_FC_RP
; }
969 | tUNIQUE
{ $$
= RPC_FC_UP
; }
970 | tPTR
{ $$
= RPC_FC_FP
; }
973 structdef: tSTRUCT t_ident
'{' fields
'}' { $$
= get_typev
(RPC_FC_STRUCT
, $2, tsSTRUCT
);
974 /* overwrite RPC_FC_STRUCT with a more exact type */
975 $$
->type
= get_struct_type
( $4 );
976 $$
->kind
= TKIND_RECORD
;
977 $$
->fields_or_args
= $4;
980 add_typelib_entry
($$
);
984 type: tVOID
{ $$
= duptype
(find_type
("void", 0), 1); }
985 | aKNOWNTYPE
{ $$
= find_type
($1, 0); }
986 | base_type
{ $$
= $1; }
987 | tCONST type
{ $$
= duptype
($2, 1); $$
->is_const
= TRUE
; }
988 | enumdef
{ $$
= $1; }
989 | tENUM aIDENTIFIER
{ $$
= find_type2
($2, tsENUM
); }
990 | structdef
{ $$
= $1; }
991 | tSTRUCT aIDENTIFIER
{ $$
= get_type
(RPC_FC_STRUCT
, $2, tsSTRUCT
); }
992 | uniondef
{ $$
= $1; }
993 | tUNION aIDENTIFIER
{ $$
= find_type2
($2, tsUNION
); }
994 | tSAFEARRAY
'(' type
')' { $$
= make_safearray
($3); }
997 typedef: tTYPEDEF m_attributes type declarator_list
998 { reg_typedefs
($3, $4, check_typedef_attrs
($2));
999 $$
= process_typedefs
($4);
1003 uniondef: tUNION t_ident
'{' ne_union_fields
'}'
1004 { $$
= get_typev
(RPC_FC_NON_ENCAPSULATED_UNION
, $2, tsUNION
);
1005 $$
->kind
= TKIND_UNION
;
1006 $$
->fields_or_args
= $4;
1010 tSWITCH
'(' s_field
')'
1011 m_ident
'{' cases
'}' { var_t
*u
= $7;
1012 $$
= get_typev
(RPC_FC_ENCAPSULATED_UNION
, $2, tsUNION
);
1013 $$
->kind
= TKIND_UNION
;
1014 if
(!u
) u
= make_var
( xstrdup
("tagged_union") );
1015 u
->type
= make_type
(RPC_FC_NON_ENCAPSULATED_UNION
, NULL
);
1016 u
->type
->kind
= TKIND_UNION
;
1017 u
->type
->fields_or_args
= $9;
1018 u
->type
->defined
= TRUE
;
1019 $$
->fields_or_args
= append_var
( $$
->fields_or_args
, $5 );
1020 $$
->fields_or_args
= append_var
( $$
->fields_or_args
, u
);
1026 aNUM
{ $$
= MAKEVERSION
($1, 0); }
1027 | aNUM
'.' aNUM
{ $$
= MAKEVERSION
($1, $3); }
1032 static void decl_builtin
(const char *name
, unsigned char type
)
1034 type_t
*t
= make_type
(type
, NULL
);
1035 t
->name
= xstrdup
(name
);
1036 reg_type
(t
, name
, 0);
1039 static type_t
*make_builtin
(char *name
)
1041 /* NAME is strdup'd in the lexer */
1042 type_t
*t
= duptype
(find_type
(name
, 0), 0);
1047 static type_t
*make_int
(int sign
)
1049 type_t
*t
= duptype
(find_type
("int", 0), 1);
1053 t
->type
= t
->type
== RPC_FC_LONG ? RPC_FC_ULONG
: RPC_FC_USHORT
;
1058 void init_types
(void)
1060 decl_builtin
("void", 0);
1061 decl_builtin
("byte", RPC_FC_BYTE
);
1062 decl_builtin
("wchar_t", RPC_FC_WCHAR
);
1063 decl_builtin
("int", RPC_FC_LONG
); /* win32 */
1064 decl_builtin
("short", RPC_FC_SHORT
);
1065 decl_builtin
("small", RPC_FC_SMALL
);
1066 decl_builtin
("long", RPC_FC_LONG
);
1067 decl_builtin
("hyper", RPC_FC_HYPER
);
1068 decl_builtin
("__int64", RPC_FC_HYPER
);
1069 decl_builtin
("char", RPC_FC_CHAR
);
1070 decl_builtin
("float", RPC_FC_FLOAT
);
1071 decl_builtin
("double", RPC_FC_DOUBLE
);
1072 decl_builtin
("boolean", RPC_FC_BYTE
);
1073 decl_builtin
("error_status_t", RPC_FC_ERROR_STATUS_T
);
1074 decl_builtin
("handle_t", RPC_FC_BIND_PRIMITIVE
);
1077 static str_list_t
*append_str
(str_list_t
*list
, char *str
)
1079 struct str_list_entry_t
*entry
;
1081 if
(!str
) return list
;
1084 list
= xmalloc
( sizeof
(*list
) );
1087 entry
= xmalloc
( sizeof
(*entry
) );
1089 list_add_tail
( list
, &entry
->entry
);
1093 static attr_list_t
*append_attr
(attr_list_t
*list
, attr_t
*attr
)
1095 attr_t
*attr_existing
;
1096 if
(!attr
) return list
;
1099 list
= xmalloc
( sizeof
(*list
) );
1102 LIST_FOR_EACH_ENTRY
(attr_existing
, list
, attr_t
, entry
)
1103 if
(attr_existing
->type
== attr
->type
)
1105 parser_warning
("duplicate attribute %s\n", get_attr_display_name
(attr
->type
));
1106 /* use the last attribute, like MIDL does */
1107 list_remove
(&attr_existing
->entry
);
1110 list_add_tail
( list
, &attr
->entry
);
1114 static attr_t
*make_attr
(enum attr_type type
)
1116 attr_t
*a
= xmalloc
(sizeof
(attr_t
));
1122 static attr_t
*make_attrv
(enum attr_type type
, unsigned long val
)
1124 attr_t
*a
= xmalloc
(sizeof
(attr_t
));
1130 static attr_t
*make_attrp
(enum attr_type type
, void *val
)
1132 attr_t
*a
= xmalloc
(sizeof
(attr_t
));
1138 static expr_list_t
*append_expr
(expr_list_t
*list
, expr_t
*expr
)
1140 if
(!expr
) return list
;
1143 list
= xmalloc
( sizeof
(*list
) );
1146 list_add_tail
( list
, &expr
->entry
);
1150 static array_dims_t
*append_array
(array_dims_t
*list
, expr_t
*expr
)
1152 if
(!expr
) return list
;
1155 list
= xmalloc
( sizeof
(*list
) );
1158 list_add_tail
( list
, &expr
->entry
);
1162 static struct list type_pool
= LIST_INIT
(type_pool
);
1169 type_t
*alloc_type
(void)
1171 type_pool_node_t
*node
= xmalloc
(sizeof
*node
);
1172 list_add_tail
(&type_pool
, &node
->link
);
1176 void set_all_tfswrite
(int val
)
1178 type_pool_node_t
*node
;
1179 LIST_FOR_EACH_ENTRY
(node
, &type_pool
, type_pool_node_t
, link
)
1180 node
->data.tfswrite
= val
;
1183 type_t
*make_type
(unsigned char type
, type_t
*ref
)
1185 type_t
*t
= alloc_type
();
1187 t
->kind
= TKIND_PRIMITIVE
;
1193 t
->fields_or_args
= NULL
;
1197 t
->length_is
= NULL
;
1198 t
->typestring_offset
= 0;
1200 t
->declarray
= FALSE
;
1201 t
->ignore
= (parse_only
!= 0);
1202 t
->is_const
= FALSE
;
1206 t
->user_types_registered
= FALSE
;
1207 t
->tfswrite
= FALSE
;
1209 t
->typelib_idx
= -1;
1213 static type_t
*make_func_type
(var_list_t
*args
)
1215 type_t
*t
= make_type
(RPC_FC_FUNCTION
, NULL
);
1216 t
->fields_or_args
= args
;
1220 static void type_set_function_callconv
(type_t
*type
, char *callconv
)
1223 error_loc
("calling convention applied to non-function-pointer type\n");
1224 for
(; is_ptr
(type
); type
= type
->ref
)
1226 assert
(type
->type
== RPC_FC_FUNCTION
);
1227 type
->attrs
= append_attr
(NULL
, make_attrp
(ATTR_CALLCONV
, callconv
));
1230 static type_t
*append_ptrchain_type
(type_t
*ptrchain
, type_t
*type
)
1232 type_t
*ptrchain_type
;
1235 for
(ptrchain_type
= ptrchain
; ptrchain_type
->ref
; ptrchain_type
= ptrchain_type
->ref
)
1237 ptrchain_type
->ref
= type
;
1241 static void set_type
(var_t
*v
, type_t
*type
, const declarator_t
*decl
,
1244 expr_list_t
*sizes
= get_attrp
(v
->attrs
, ATTR_SIZEIS
);
1245 expr_list_t
*lengs
= get_attrp
(v
->attrs
, ATTR_LENGTHIS
);
1246 int ptr_attr
= get_attrv
(v
->attrs
, ATTR_POINTERTYPE
);
1247 int sizeless
, has_varconf
;
1249 type_t
*atype
, **ptype
;
1250 array_dims_t
*arr
= decl ? decl
->array
: NULL
;
1252 /* add type onto the end of the pointers in pident->type */
1253 v
->type
= append_ptrchain_type
(decl ? decl
->type
: NULL
, type
);
1255 /* the highest level of pointer specified should default to the var's ptr attr
1256 * or (RPC_FC_RP if not specified and it's a top level ptr), not
1257 * pointer_default so we need to fix that up here */
1260 const type_t
*ptr
= NULL
;
1261 for
(ptr
= v
->type
; ptr
; )
1263 if
(ptr
->kind
== TKIND_ALIAS
)
1268 if
(ptr
&& is_ptr
(ptr
) && (ptr_attr || top
))
1270 /* duplicate type to avoid changing original type */
1271 v
->type
= duptype
(v
->type
, 1);
1272 v
->type
->type
= ptr_attr ? ptr_attr
: RPC_FC_RP
;
1275 error_loc
("%s: pointer attribute applied to non-pointer type\n", v
->name
);
1278 if
(is_attr
(v
->attrs
, ATTR_STRING
) && !is_ptr
(v
->type
) && !arr
)
1279 error_loc
("'%s': [string] attribute applied to non-pointer, non-array type\n",
1283 if
(arr
) LIST_FOR_EACH_ENTRY_REV
(dim
, arr
, expr_t
, entry
)
1286 error_loc
("%s: only the first array dimension can be unspecified\n", v
->name
);
1290 unsigned int align
= 0;
1291 size_t size
= type_memsize
(v
->type
, &align
);
1294 error_loc
("%s: array dimension must be positive\n", v
->name
);
1296 if
(0xffffffffuL
/ size
< (unsigned long) dim
->cval
)
1297 error_loc
("%s: total array size is too large\n", v
->name
);
1298 else if
(0xffffuL
< size
* dim
->cval
)
1299 v
->type
= make_type
(RPC_FC_LGFARRAY
, v
->type
);
1301 v
->type
= make_type
(RPC_FC_SMFARRAY
, v
->type
);
1306 v
->type
= make_type
(RPC_FC_CARRAY
, v
->type
);
1309 v
->type
->declarray
= TRUE
;
1310 v
->type
->dim
= dim
->cval
;
1314 has_varconf
= FALSE
;
1315 if
(sizes
) LIST_FOR_EACH_ENTRY
(dim
, sizes
, expr_t
, entry
)
1317 if
(dim
->type
!= EXPR_VOID
)
1320 atype
= *ptype
= duptype
(*ptype
, 0);
1322 if
(atype
->type
== RPC_FC_SMFARRAY || atype
->type
== RPC_FC_LGFARRAY
)
1323 error_loc
("%s: cannot specify size_is for a fixed sized array\n", v
->name
);
1325 if
(atype
->type
!= RPC_FC_CARRAY
&& !is_ptr
(atype
))
1326 error_loc
("%s: size_is attribute applied to illegal type\n", v
->name
);
1328 atype
->type
= RPC_FC_CARRAY
;
1329 atype
->size_is
= dim
;
1332 ptype
= &(*ptype
)->ref
;
1334 error_loc
("%s: too many expressions in size_is attribute\n", v
->name
);
1338 if
(lengs
) LIST_FOR_EACH_ENTRY
(dim
, lengs
, expr_t
, entry
)
1340 if
(dim
->type
!= EXPR_VOID
)
1343 atype
= *ptype
= duptype
(*ptype
, 0);
1345 if
(atype
->type
== RPC_FC_SMFARRAY
)
1346 atype
->type
= RPC_FC_SMVARRAY
;
1347 else if
(atype
->type
== RPC_FC_LGFARRAY
)
1348 atype
->type
= RPC_FC_LGVARRAY
;
1349 else if
(atype
->type
== RPC_FC_CARRAY
)
1350 atype
->type
= RPC_FC_CVARRAY
;
1352 error_loc
("%s: length_is attribute applied to illegal type\n", v
->name
);
1354 atype
->length_is
= dim
;
1357 ptype
= &(*ptype
)->ref
;
1359 error_loc
("%s: too many expressions in length_is attribute\n", v
->name
);
1362 if
(has_varconf
&& !last_array
(v
->type
))
1365 for
(ptype
= &v
->type
; is_array
(*ptype
); ptype
= &(*ptype
)->ref
)
1367 *ptype
= duptype
(*ptype
, 0);
1368 (*ptype
)->type
= RPC_FC_BOGUS_ARRAY
;
1372 if
(is_array
(v
->type
))
1374 const type_t
*rt
= v
->type
->ref
;
1375 if
(is_user_type
(rt
))
1376 v
->type
->type
= RPC_FC_BOGUS_ARRAY
;
1380 case RPC_FC_BOGUS_STRUCT
:
1381 case RPC_FC_NON_ENCAPSULATED_UNION
:
1382 case RPC_FC_ENCAPSULATED_UNION
:
1384 v
->type
->type
= RPC_FC_BOGUS_ARRAY
;
1386 /* FC_RP should be above, but widl overuses these, and will break things. */
1389 if
(rt
->ref
->type
== RPC_FC_IP
)
1390 v
->type
->type
= RPC_FC_BOGUS_ARRAY
;
1395 /* v->type is currently pointing the the type on the left-side of the
1396 * declaration, so we need to fix this up so that it is the return type of the
1397 * function and make v->type point to the function side of the declaration */
1398 if
(decl
&& decl
->func_type
)
1401 type_t
*return_type
= v
->type
;
1402 v
->type
= decl
->func_type
;
1403 for
(t
= v
->type
; is_ptr
(t
); t
= t
->ref
)
1405 assert
(t
->type
== RPC_FC_FUNCTION
);
1406 t
->ref
= return_type
;
1407 if
(is_object_interface
&& !is_attr
(t
->attrs
, ATTR_CALLCONV
))
1409 static char *stdmethodcalltype
;
1410 if
(!stdmethodcalltype
) stdmethodcalltype
= strdup
("STDMETHODCALLTYPE");
1411 t
->attrs
= append_attr
(NULL
, make_attrp
(ATTR_CALLCONV
, stdmethodcalltype
));
1416 static ifref_list_t
*append_ifref
(ifref_list_t
*list
, ifref_t
*iface
)
1418 if
(!iface
) return list
;
1421 list
= xmalloc
( sizeof
(*list
) );
1424 list_add_tail
( list
, &iface
->entry
);
1428 static ifref_t
*make_ifref
(type_t
*iface
)
1430 ifref_t
*l
= xmalloc
(sizeof
(ifref_t
));
1436 static var_list_t
*append_var
(var_list_t
*list
, var_t
*var
)
1438 if
(!var
) return list
;
1441 list
= xmalloc
( sizeof
(*list
) );
1444 list_add_tail
( list
, &var
->entry
);
1448 static var_t
*make_var
(char *name
)
1450 var_t
*v
= xmalloc
(sizeof
(var_t
));
1455 v
->loc_info.input_name
= input_name ? input_name
: "stdin";
1456 v
->loc_info.line_number
= line_number
;
1457 v
->loc_info.near_text
= parser_text
;
1461 static declarator_list_t
*append_declarator
(declarator_list_t
*list
, declarator_t
*d
)
1463 if
(!d
) return list
;
1465 list
= xmalloc
(sizeof
(*list
));
1468 list_add_tail
(list
, &d
->entry
);
1472 static declarator_t
*make_declarator
(var_t
*var
)
1474 declarator_t
*d
= xmalloc
(sizeof
(*d
));
1477 d
->func_type
= NULL
;
1482 static func_list_t
*append_func
(func_list_t
*list
, func_t
*func
)
1484 if
(!func
) return list
;
1487 list
= xmalloc
( sizeof
(*list
) );
1490 list_add_tail
( list
, &func
->entry
);
1494 static func_t
*make_func
(var_t
*def
)
1496 func_t
*f
= xmalloc
(sizeof
(func_t
));
1498 f
->args
= def
->type
->fields_or_args
;
1499 f
->ignore
= parse_only
;
1504 static type_t
*make_class
(char *name
)
1506 type_t
*c
= make_type
(RPC_FC_COCLASS
, NULL
);
1508 c
->kind
= TKIND_COCLASS
;
1512 static type_t
*make_safearray
(type_t
*type
)
1514 type_t
*sa
= duptype
(find_type
("SAFEARRAY", 0), 1);
1516 return make_type
(pointer_default
, sa
);
1519 static typelib_t
*make_library
(const char *name
, const attr_list_t
*attrs
)
1521 typelib_t
*typelib
= xmalloc
(sizeof
(*typelib
));
1522 typelib
->name
= xstrdup
(name
);
1523 typelib
->filename
= NULL
;
1524 typelib
->attrs
= attrs
;
1525 list_init
( &typelib
->entries
);
1526 list_init
( &typelib
->importlibs
);
1532 static int hash_ident
(const char *name
)
1534 const char *p
= name
;
1536 /* a simple sum hash is probably good enough */
1541 return sum
& (HASHMAX
-1);
1544 /***** type repository *****/
1553 struct rtype
*type_hash
[HASHMAX
];
1555 static type_t
*reg_type
(type_t
*type
, const char *name
, int t
)
1560 error_loc
("registering named type without name\n");
1563 hash
= hash_ident
(name
);
1564 nt
= xmalloc
(sizeof
(struct rtype
));
1568 nt
->next
= type_hash
[hash
];
1569 type_hash
[hash
] = nt
;
1573 static int is_incomplete
(const type_t
*t
)
1575 return
!t
->defined
&& (is_struct
(t
->type
) || is_union
(t
->type
));
1578 static void add_incomplete
(type_t
*t
)
1580 struct typenode
*tn
= xmalloc
(sizeof
*tn
);
1582 list_add_tail
(&incomplete_types
, &tn
->entry
);
1585 static void fix_type
(type_t
*t
)
1587 if
(t
->kind
== TKIND_ALIAS
&& is_incomplete
(t
)) {
1588 type_t
*ot
= t
->orig
;
1590 t
->fields_or_args
= ot
->fields_or_args
;
1591 t
->defined
= ot
->defined
;
1595 static void fix_incomplete
(void)
1597 struct typenode
*tn
, *next
;
1599 LIST_FOR_EACH_ENTRY_SAFE
(tn
, next
, &incomplete_types
, struct typenode
, entry
) {
1605 static type_t
*reg_typedefs
(type_t
*type
, declarator_list_t
*decls
, attr_list_t
*attrs
)
1607 const declarator_t
*decl
;
1608 int is_str
= is_attr
(attrs
, ATTR_STRING
);
1619 if
(c
!= RPC_FC_CHAR
&& c
!= RPC_FC_BYTE
&& c
!= RPC_FC_WCHAR
)
1621 decl
= LIST_ENTRY
( list_head
( decls
), const declarator_t
, entry
);
1622 error_loc
("'%s': [string] attribute is only valid on 'char', 'byte', or 'wchar_t' pointers and arrays\n",
1627 /* We must generate names for tagless enum, struct or union.
1628 Typedef-ing a tagless enum, struct or union means we want the typedef
1629 to be included in a library whether it has other attributes or not,
1630 hence the public attribute. */
1631 if
((type
->kind
== TKIND_ENUM || type
->kind
== TKIND_RECORD
1632 || type
->kind
== TKIND_UNION
) && ! type
->name
&& ! parse_only
)
1634 if
(! is_attr
(attrs
, ATTR_PUBLIC
))
1635 attrs
= append_attr
( attrs
, make_attr
(ATTR_PUBLIC
) );
1636 type
->name
= gen_name
();
1639 LIST_FOR_EACH_ENTRY
( decl
, decls
, const declarator_t
, entry
)
1641 var_t
*name
= decl
->var
;
1646 /* set the attributes to allow set_type to do some checks on them */
1647 name
->attrs
= attrs
;
1648 set_type
(name
, type
, decl
, 0);
1649 cur
= alias
(name
->type
, name
->name
);
1652 if
(is_incomplete
(cur
))
1653 add_incomplete
(cur
);
1654 reg_type
(cur
, cur
->name
, 0);
1660 type_t
*find_type
(const char *name
, int t
)
1662 struct rtype
*cur
= type_hash
[hash_ident
(name
)];
1663 while
(cur
&& (cur
->t
!= t || strcmp
(cur
->name
, name
)))
1666 error_loc
("type '%s' not found\n", name
);
1672 static type_t
*find_type2
(char *name
, int t
)
1674 type_t
*tp
= find_type
(name
, t
);
1679 int is_type
(const char *name
)
1681 struct rtype
*cur
= type_hash
[hash_ident
(name
)];
1682 while
(cur
&& (cur
->t || strcmp
(cur
->name
, name
)))
1684 if
(cur
) return TRUE
;
1688 static type_t
*get_type
(unsigned char type
, char *name
, int t
)
1690 struct rtype
*cur
= NULL
;
1693 cur
= type_hash
[hash_ident
(name
)];
1694 while
(cur
&& (cur
->t
!= t || strcmp
(cur
->name
, name
)))
1701 tp
= make_type
(type
, NULL
);
1703 if
(!name
) return tp
;
1704 return reg_type
(tp
, name
, t
);
1707 static type_t
*get_typev
(unsigned char type
, var_t
*name
, int t
)
1714 return get_type
(type
, sname
, t
);
1717 static int get_struct_type
(var_list_t
*fields
)
1719 int has_pointer
= 0;
1720 int has_conformance
= 0;
1721 int has_variance
= 0;
1724 if
(get_padding
(fields
))
1725 return RPC_FC_BOGUS_STRUCT
;
1727 if
(fields
) LIST_FOR_EACH_ENTRY
( field
, fields
, var_t
, entry
)
1729 type_t
*t
= field
->type
;
1731 if
(is_user_type
(t
))
1732 return RPC_FC_BOGUS_STRUCT
;
1743 case RPC_FC_ENCAPSULATED_UNION
:
1744 case RPC_FC_NON_ENCAPSULATED_UNION
:
1745 case RPC_FC_BOGUS_STRUCT
:
1746 return RPC_FC_BOGUS_STRUCT
;
1753 if
(field
->type
->declarray
)
1755 if
(is_string_type
(field
->attrs
, field
->type
))
1757 if
(is_conformant_array
(field
->type
))
1758 has_conformance
= 1;
1763 if
(is_array
(field
->type
->ref
))
1764 return RPC_FC_BOGUS_STRUCT
;
1766 if
(is_conformant_array
(field
->type
))
1768 has_conformance
= 1;
1769 if
(field
->type
->declarray
&& list_next
(fields
, &field
->entry
))
1770 error_loc
("field '%s' deriving from a conformant array must be the last field in the structure\n",
1773 if
(field
->type
->length_is
)
1776 t
= field
->type
->ref
;
1782 * RPC_FC_BYTE, RPC_FC_STRUCT, etc
1783 * Simple types don't effect the type of struct.
1784 * A struct containing a simple struct is still a simple struct.
1785 * So long as we can block copy the data, we return RPC_FC_STRUCT.
1787 case
0: /* void pointer */
1797 case RPC_FC_INT3264
:
1798 case RPC_FC_UINT3264
:
1811 case RPC_FC_CVARRAY
:
1812 case RPC_FC_BOGUS_ARRAY
:
1817 * Propagate member attributes
1818 * a struct should be at least as complex as its member
1820 case RPC_FC_CVSTRUCT
:
1821 has_conformance
= 1;
1826 case RPC_FC_CPSTRUCT
:
1827 has_conformance
= 1;
1828 if
(list_next
( fields
, &field
->entry
))
1829 error_loc
("field '%s' deriving from a conformant array must be the last field in the structure\n",
1834 case RPC_FC_CSTRUCT
:
1835 has_conformance
= 1;
1836 if
(list_next
( fields
, &field
->entry
))
1837 error_loc
("field '%s' deriving from a conformant array must be the last field in the structure\n",
1841 case RPC_FC_PSTRUCT
:
1846 error_loc
("Unknown struct member %s with type (0x%02x)\n", field
->name
, t
->type
);
1847 /* fallthru - treat it as complex */
1849 /* as soon as we see one of these these members, it's bogus... */
1850 case RPC_FC_ENCAPSULATED_UNION
:
1851 case RPC_FC_NON_ENCAPSULATED_UNION
:
1852 case RPC_FC_BOGUS_STRUCT
:
1854 return RPC_FC_BOGUS_STRUCT
;
1860 if
( has_conformance
)
1861 return RPC_FC_CVSTRUCT
;
1863 return RPC_FC_BOGUS_STRUCT
;
1865 if
( has_conformance
&& has_pointer
)
1866 return RPC_FC_CPSTRUCT
;
1867 if
( has_conformance
)
1868 return RPC_FC_CSTRUCT
;
1870 return RPC_FC_PSTRUCT
;
1871 return RPC_FC_STRUCT
;
1874 /***** constant repository *****/
1879 struct rconst
*next
;
1882 struct rconst
*const_hash
[HASHMAX
];
1884 static var_t
*reg_const
(var_t
*var
)
1889 error_loc
("registering constant without name\n");
1892 hash
= hash_ident
(var
->name
);
1893 nc
= xmalloc
(sizeof
(struct rconst
));
1894 nc
->name
= var
->name
;
1896 nc
->next
= const_hash
[hash
];
1897 const_hash
[hash
] = nc
;
1901 var_t
*find_const
(const char *name
, int f
)
1903 struct rconst
*cur
= const_hash
[hash_ident
(name
)];
1904 while
(cur
&& strcmp
(cur
->name
, name
))
1907 if
(f
) error_loc
("constant '%s' not found\n", name
);
1913 static void write_libid
(const typelib_t
*typelib
)
1915 const UUID
*uuid
= get_attrp
(typelib
->attrs
, ATTR_UUID
);
1916 write_guid
(idfile
, "LIBID", typelib
->name
, uuid
);
1919 static void write_clsid
(type_t
*cls
)
1921 const UUID
*uuid
= get_attrp
(cls
->attrs
, ATTR_UUID
);
1922 write_guid
(idfile
, "CLSID", cls
->name
, uuid
);
1925 static void write_diid
(type_t
*iface
)
1927 const UUID
*uuid
= get_attrp
(iface
->attrs
, ATTR_UUID
);
1928 write_guid
(idfile
, "DIID", iface
->name
, uuid
);
1931 static void write_iid
(type_t
*iface
)
1933 const UUID
*uuid
= get_attrp
(iface
->attrs
, ATTR_UUID
);
1934 write_guid
(idfile
, "IID", iface
->name
, uuid
);
1937 static int compute_method_indexes
(type_t
*iface
)
1943 idx
= compute_method_indexes
(iface
->ref
);
1950 LIST_FOR_EACH_ENTRY
( f
, iface
->funcs
, func_t
, entry
)
1951 if
(! is_callas
(f
->def
->attrs
))
1957 static char *gen_name
(void)
1959 static const char format
[] = "__WIDL_%s_generated_name_%08lX";
1960 static unsigned long n
= 0;
1961 static const char *file_id
;
1967 char *dst
= dup_basename
(input_name
, ".idl");
1971 if
(! isalnum
((unsigned char) *dst
))
1974 size
= sizeof format
- 7 + strlen
(file_id
) + 8;
1977 name
= xmalloc
(size
);
1978 sprintf
(name
, format
, file_id
, n
++);
1984 unsigned int dce_compatible
: 1;
1985 unsigned int acf
: 1;
1986 unsigned int on_interface
: 1;
1987 unsigned int on_function
: 1;
1988 unsigned int on_arg
: 1;
1989 unsigned int on_type
: 1;
1990 unsigned int on_field
: 1;
1991 unsigned int on_library
: 1;
1992 unsigned int on_dispinterface
: 1;
1993 unsigned int on_module
: 1;
1994 unsigned int on_coclass
: 1;
1995 const char *display_name
;
1998 struct allowed_attr allowed_attr
[] =
2000 /* attr { D ACF I Fn ARG T Fi L DI M C <display name> } */
2001 /* ATTR_AGGREGATABLE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, "aggregatable" },
2002 /* ATTR_APPOBJECT */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, "appobject" },
2003 /* ATTR_ASYNC */ { 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, "async" },
2004 /* ATTR_AUTO_HANDLE */ { 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, "auto_handle" },
2005 /* ATTR_BINDABLE */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "bindable" },
2006 /* ATTR_BROADCAST */ { 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "broadcast" },
2007 /* ATTR_CALLAS */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "call_as" },
2008 /* ATTR_CALLCONV */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL
},
2009 /* ATTR_CASE */ { 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, "case" },
2010 /* ATTR_CONTEXTHANDLE */ { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, "context_handle" },
2011 /* ATTR_CONTROL */ { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, "control" },
2012 /* ATTR_DEFAULT */ { 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, "default" },
2013 /* ATTR_DEFAULTCOLLELEM */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "defaultcollelem" },
2014 /* ATTR_DEFAULTVALUE_EXPR */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "defaultvalue" },
2015 /* ATTR_DEFAULTVALUE_STRING */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "defaultvalue" },
2016 /* ATTR_DEFAULTVTABLE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, "defaultvtable" },
2017 /* ATTR_DISPINTERFACE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL
},
2018 /* ATTR_DISPLAYBIND */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "displaybind" },
2019 /* ATTR_DLLNAME */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, "dllname" },
2020 /* ATTR_DUAL */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "dual" },
2021 /* ATTR_ENDPOINT */ { 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "endpoint" },
2022 /* ATTR_ENTRY_ORDINAL */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "entry" },
2023 /* ATTR_ENTRY_STRING */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "entry" },
2024 /* ATTR_EXPLICIT_HANDLE */ { 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, "explicit_handle" },
2025 /* ATTR_HANDLE */ { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, "handle" },
2026 /* ATTR_HELPCONTEXT */ { 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, "helpcontext" },
2027 /* ATTR_HELPFILE */ { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, "helpfile" },
2028 /* ATTR_HELPSTRING */ { 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, "helpstring" },
2029 /* ATTR_HELPSTRINGCONTEXT */ { 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, "helpstringcontext" },
2030 /* ATTR_HELPSTRINGDLL */ { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, "helpstringdll" },
2031 /* ATTR_HIDDEN */ { 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, "hidden" },
2032 /* ATTR_ID */ { 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, "id" },
2033 /* ATTR_IDEMPOTENT */ { 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "idempotent" },
2034 /* ATTR_IIDIS */ { 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, "iid_is" },
2035 /* ATTR_IMMEDIATEBIND */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "immediatebind" },
2036 /* ATTR_IMPLICIT_HANDLE */ { 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, "implicit_handle" },
2037 /* ATTR_IN */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "in" },
2038 /* ATTR_INPUTSYNC */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "inputsync" },
2039 /* ATTR_LENGTHIS */ { 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, "length_is" },
2040 /* ATTR_LIBLCID */ { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, "lcid" },
2041 /* ATTR_LOCAL */ { 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, "local" },
2042 /* ATTR_NONBROWSABLE */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "nonbrowsable" },
2043 /* ATTR_NONCREATABLE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, "noncreatable" },
2044 /* ATTR_NONEXTENSIBLE */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "nonextensible" },
2045 /* ATTR_OBJECT */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "object" },
2046 /* ATTR_ODL */ { 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, "odl" },
2047 /* ATTR_OLEAUTOMATION */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "oleautomation" },
2048 /* ATTR_OPTIONAL */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "optional" },
2049 /* ATTR_OUT */ { 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "out" },
2050 /* ATTR_POINTERDEFAULT */ { 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "pointer_default" },
2051 /* ATTR_POINTERTYPE */ { 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, "ref, unique or ptr" },
2052 /* ATTR_PROPGET */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "propget" },
2053 /* ATTR_PROPPUT */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "propput" },
2054 /* ATTR_PROPPUTREF */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "propputref" },
2055 /* ATTR_PUBLIC */ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, "public" },
2056 /* ATTR_RANGE */ { 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, "range" },
2057 /* ATTR_READONLY */ { 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, "readonly" },
2058 /* ATTR_REQUESTEDIT */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "requestedit" },
2059 /* ATTR_RESTRICTED */ { 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, "restricted" },
2060 /* ATTR_RETVAL */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "retval" },
2061 /* ATTR_SIZEIS */ { 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, "size_is" },
2062 /* ATTR_SOURCE */ { 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, "source" },
2063 /* ATTR_STRICTCONTEXTHANDLE */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "strict_context_handle" },
2064 /* ATTR_STRING */ { 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, "string" },
2065 /* ATTR_SWITCHIS */ { 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, "switch_is" },
2066 /* ATTR_SWITCHTYPE */ { 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, "switch_type" },
2067 /* ATTR_TRANSMITAS */ { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, "transmit_as" },
2068 /* ATTR_UUID */ { 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, "uuid" },
2069 /* ATTR_V1ENUM */ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, "v1_enum" },
2070 /* ATTR_VARARG */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "vararg" },
2071 /* ATTR_VERSION */ { 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, "version" },
2072 /* ATTR_WIREMARSHAL */ { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, "wire_marshal" },
2075 const char *get_attr_display_name
(enum attr_type type
)
2077 return allowed_attr
[type
].display_name
;
2080 static const attr_list_t
*check_iface_attrs
(const char *name
, const attr_list_t
*attrs
)
2083 if
(!attrs
) return attrs
;
2084 LIST_FOR_EACH_ENTRY
(attr
, attrs
, const attr_t
, entry
)
2086 if
(!allowed_attr
[attr
->type
].on_interface
)
2087 error_loc
("inapplicable attribute %s for interface %s\n",
2088 allowed_attr
[attr
->type
].display_name
, name
);
2093 static attr_list_t
*check_function_attrs
(const char *name
, attr_list_t
*attrs
)
2096 if
(!attrs
) return attrs
;
2097 LIST_FOR_EACH_ENTRY
(attr
, attrs
, const attr_t
, entry
)
2099 if
(!allowed_attr
[attr
->type
].on_function
)
2100 error_loc
("inapplicable attribute %s for function %s\n",
2101 allowed_attr
[attr
->type
].display_name
, name
);
2106 static void check_arg
(var_t
*arg
)
2108 const type_t
*t
= arg
->type
;
2111 if
(t
->type
== 0 && ! is_var_ptr
(arg
))
2112 error_loc
("argument '%s' has void type\n", arg
->name
);
2116 LIST_FOR_EACH_ENTRY
(attr
, arg
->attrs
, const attr_t
, entry
)
2118 if
(!allowed_attr
[attr
->type
].on_arg
)
2119 error_loc
("inapplicable attribute %s for argument %s\n",
2120 allowed_attr
[attr
->type
].display_name
, arg
->name
);
2125 static attr_list_t
*check_typedef_attrs
(attr_list_t
*attrs
)
2128 if
(!attrs
) return attrs
;
2129 LIST_FOR_EACH_ENTRY
(attr
, attrs
, const attr_t
, entry
)
2131 if
(!allowed_attr
[attr
->type
].on_type
)
2132 error_loc
("inapplicable attribute %s for typedef\n",
2133 allowed_attr
[attr
->type
].display_name
);
2138 static attr_list_t
*check_field_attrs
(const char *name
, attr_list_t
*attrs
)
2141 if
(!attrs
) return attrs
;
2142 LIST_FOR_EACH_ENTRY
(attr
, attrs
, const attr_t
, entry
)
2144 if
(!allowed_attr
[attr
->type
].on_field
)
2145 error_loc
("inapplicable attribute %s for field %s\n",
2146 allowed_attr
[attr
->type
].display_name
, name
);
2151 static const attr_list_t
*check_library_attrs
(const char *name
, const attr_list_t
*attrs
)
2154 if
(!attrs
) return attrs
;
2155 LIST_FOR_EACH_ENTRY
(attr
, attrs
, const attr_t
, entry
)
2157 if
(!allowed_attr
[attr
->type
].on_library
)
2158 error_loc
("inapplicable attribute %s for library %s\n",
2159 allowed_attr
[attr
->type
].display_name
, name
);
2164 static attr_list_t
*check_dispiface_attrs
(const char *name
, attr_list_t
*attrs
)
2167 if
(!attrs
) return attrs
;
2168 LIST_FOR_EACH_ENTRY
(attr
, attrs
, const attr_t
, entry
)
2170 if
(!allowed_attr
[attr
->type
].on_dispinterface
)
2171 error_loc
("inapplicable attribute %s for dispinterface %s\n",
2172 allowed_attr
[attr
->type
].display_name
, name
);
2177 static const attr_list_t
*check_module_attrs
(const char *name
, const attr_list_t
*attrs
)
2180 if
(!attrs
) return attrs
;
2181 LIST_FOR_EACH_ENTRY
(attr
, attrs
, const attr_t
, entry
)
2183 if
(!allowed_attr
[attr
->type
].on_module
)
2184 error_loc
("inapplicable attribute %s for module %s\n",
2185 allowed_attr
[attr
->type
].display_name
, name
);
2190 static const attr_list_t
*check_coclass_attrs
(const char *name
, const attr_list_t
*attrs
)
2193 if
(!attrs
) return attrs
;
2194 LIST_FOR_EACH_ENTRY
(attr
, attrs
, const attr_t
, entry
)
2196 if
(!allowed_attr
[attr
->type
].on_coclass
)
2197 error_loc
("inapplicable attribute %s for coclass %s\n",
2198 allowed_attr
[attr
->type
].display_name
, name
);
2203 static int is_allowed_conf_type
(const type_t
*type
)
2224 static int is_ptr_guid_type
(const type_t
*type
)
2226 unsigned int align
= 0;
2229 if
(type
->kind
== TKIND_ALIAS
)
2231 else if
(is_ptr
(type
))
2239 return
(type_memsize
(type
, &align
) == 16);
2242 static void check_conformance_expr_list
(const char *attr_name
, const var_t
*arg
, const type_t
*container_type
, expr_list_t
*expr_list
)
2245 struct expr_loc expr_loc
;
2247 expr_loc.attr
= attr_name
;
2248 if
(expr_list
) LIST_FOR_EACH_ENTRY
(dim
, expr_list
, expr_t
, entry
)
2250 if
(dim
->type
!= EXPR_VOID
)
2252 const type_t
*expr_type
= expr_resolve_type
(&expr_loc
, container_type
, dim
);
2253 if
(!is_allowed_conf_type
(expr_type
))
2254 error_loc_info
(&arg
->loc_info
, "expression must resolve to integral type <= 32bits for attribute %s\n",
2260 static void check_remoting_fields
(const var_t
*var
, type_t
*type
);
2262 /* checks that properties common to fields and arguments are consistent */
2263 static void check_field_common
(const type_t
*container_type
,
2264 const char *container_name
, const var_t
*arg
)
2266 type_t
*type
= arg
->type
;
2267 int is_wire_marshal
= 0;
2268 int is_context_handle
= 0;
2269 const char *container_type_name
= NULL
;
2271 if
(is_struct
(container_type
->type
))
2272 container_type_name
= "struct";
2273 else if
(is_union
(container_type
->type
))
2274 container_type_name
= "union";
2275 else if
(container_type
->type
== RPC_FC_FUNCTION
)
2276 container_type_name
= "function";
2278 if
(is_attr
(arg
->attrs
, ATTR_LENGTHIS
) &&
2279 (is_attr
(arg
->attrs
, ATTR_STRING
) || is_aliaschain_attr
(arg
->type
, ATTR_STRING
)))
2280 error_loc_info
(&arg
->loc_info
,
2281 "string and length_is specified for argument %s are mutually exclusive attributes\n",
2284 if
(is_attr
(arg
->attrs
, ATTR_SIZEIS
))
2286 expr_list_t
*size_is_exprs
= get_attrp
(arg
->attrs
, ATTR_SIZEIS
);
2287 check_conformance_expr_list
("size_is", arg
, container_type
, size_is_exprs
);
2289 if
(is_attr
(arg
->attrs
, ATTR_LENGTHIS
))
2291 expr_list_t
*length_is_exprs
= get_attrp
(arg
->attrs
, ATTR_LENGTHIS
);
2292 check_conformance_expr_list
("length_is", arg
, container_type
, length_is_exprs
);
2294 if
(is_attr
(arg
->attrs
, ATTR_IIDIS
))
2296 struct expr_loc expr_loc
;
2297 expr_t
*expr
= get_attrp
(arg
->attrs
, ATTR_IIDIS
);
2298 if
(expr
->type
!= EXPR_VOID
)
2300 const type_t
*expr_type
;
2302 expr_loc.attr
= "iid_is";
2303 expr_type
= expr_resolve_type
(&expr_loc
, container_type
, expr
);
2304 if
(!expr_type ||
!is_ptr_guid_type
(expr_type
))
2305 error_loc_info
(&arg
->loc_info
, "expression must resolve to pointer to GUID type for attribute iid_is\n");
2308 if
(is_attr
(arg
->attrs
, ATTR_SWITCHIS
))
2310 struct expr_loc expr_loc
;
2311 expr_t
*expr
= get_attrp
(arg
->attrs
, ATTR_SWITCHIS
);
2312 if
(expr
->type
!= EXPR_VOID
)
2314 const type_t
*expr_type
;
2316 expr_loc.attr
= "switch_is";
2317 expr_type
= expr_resolve_type
(&expr_loc
, container_type
, expr
);
2318 if
(!expr_type ||
!is_allowed_conf_type
(expr_type
))
2319 error_loc_info
(&arg
->loc_info
, "expression must resolve to integral type <= 32bits for attribute %s\n",
2324 /* get fundamental type for the argument */
2327 if
(is_attr
(type
->attrs
, ATTR_WIREMARSHAL
))
2329 is_wire_marshal
= 1;
2332 if
(is_attr
(type
->attrs
, ATTR_CONTEXTHANDLE
))
2334 is_context_handle
= 1;
2337 if
(type
->kind
== TKIND_ALIAS
)
2339 else if
(is_ptr
(type
) || is_array
(type
))
2345 if
(type
->type
== 0 && !is_attr
(arg
->attrs
, ATTR_IIDIS
) && !is_wire_marshal
&& !is_context_handle
)
2346 error_loc_info
(&arg
->loc_info
, "parameter \'%s\' of %s \'%s\' cannot derive from void *\n", arg
->name
, container_type_name
, container_name
);
2347 else if
(type
->type
== RPC_FC_FUNCTION
)
2348 error_loc_info
(&arg
->loc_info
, "parameter \'%s\' of %s \'%s\' cannot be a function pointer\n", arg
->name
, container_type_name
, container_name
);
2349 else if
(!is_wire_marshal
&& (is_struct
(type
->type
) || is_union
(type
->type
)))
2350 check_remoting_fields
(arg
, type
);
2353 static void check_remoting_fields
(const var_t
*var
, type_t
*type
)
2356 const var_list_t
*fields
= NULL
;
2361 type
->checked
= TRUE
;
2363 if
(is_struct
(type
->type
))
2364 fields
= type
->fields_or_args
;
2365 else if
(is_union
(type
->type
))
2367 if
(type
->type
== RPC_FC_ENCAPSULATED_UNION
)
2369 const var_t
*uv
= LIST_ENTRY
(list_tail
(type
->fields_or_args
), const var_t
, entry
);
2370 fields
= uv
->type
->fields_or_args
;
2373 fields
= type
->fields_or_args
;
2376 if
(fields
) LIST_FOR_EACH_ENTRY
( field
, type
->fields_or_args
, const var_t
, entry
)
2377 if
(field
->type
) check_field_common
(type
, type
->name
, field
);
2380 /* checks that arguments for a function make sense for marshalling and unmarshalling */
2381 static void check_remoting_args
(const func_t
*func
)
2383 const char *funcname
= func
->def
->name
;
2386 if
(func
->args
) LIST_FOR_EACH_ENTRY
( arg
, func
->args
, const var_t
, entry
)
2389 const type_t
*type
= arg
->type
;
2391 /* get pointer level and fundamental type for the argument */
2394 if
(is_attr
(type
->attrs
, ATTR_WIREMARSHAL
))
2396 if
(is_attr
(type
->attrs
, ATTR_CONTEXTHANDLE
))
2398 if
(type
->kind
== TKIND_ALIAS
)
2400 else if
(is_ptr
(type
))
2409 /* check that [out] parameters have enough pointer levels */
2410 if
(is_attr
(arg
->attrs
, ATTR_OUT
))
2412 if
(!is_array
(type
))
2415 error_loc_info
(&arg
->loc_info
, "out parameter \'%s\' of function \'%s\' is not a pointer\n", arg
->name
, funcname
);
2416 if
(type
->type
== RPC_FC_IP
&& ptr_level
== 1)
2417 error_loc_info
(&arg
->loc_info
, "out interface pointer \'%s\' of function \'%s\' is not a double pointer\n", arg
->name
, funcname
);
2421 check_field_common
(func
->def
->type
, funcname
, arg
);
2425 static void add_explicit_handle_if_necessary
(func_t
*func
)
2427 const var_t
* explicit_handle_var
;
2428 const var_t
* explicit_generic_handle_var
= NULL
;
2429 const var_t
* context_handle_var
= NULL
;
2431 /* check for a defined binding handle */
2432 explicit_handle_var
= get_explicit_handle_var
(func
);
2433 if
(!explicit_handle_var
)
2435 explicit_generic_handle_var
= get_explicit_generic_handle_var
(func
);
2436 if
(!explicit_generic_handle_var
)
2438 context_handle_var
= get_context_handle_var
(func
);
2439 if
(!context_handle_var
)
2441 /* no explicit handle specified so add
2442 * "[in] handle_t IDL_handle" as the first parameter to the
2444 var_t
*idl_handle
= make_var
(xstrdup
("IDL_handle"));
2445 idl_handle
->attrs
= append_attr
(NULL
, make_attr
(ATTR_IN
));
2446 idl_handle
->type
= find_type
("handle_t", 0);
2447 if
(!func
->def
->type
->fields_or_args
)
2449 func
->def
->type
->fields_or_args
= xmalloc
( sizeof
(*func
->def
->type
->fields_or_args
) );
2450 list_init
( func
->def
->type
->fields_or_args
);
2452 list_add_head
( func
->def
->type
->fields_or_args
, &idl_handle
->entry
);
2453 func
->args
= func
->def
->type
->fields_or_args
;
2459 static void check_functions
(const type_t
*iface
)
2461 if
(is_attr
(iface
->attrs
, ATTR_EXPLICIT_HANDLE
) && iface
->funcs
)
2464 LIST_FOR_EACH_ENTRY
( func
, iface
->funcs
, func_t
, entry
)
2465 add_explicit_handle_if_necessary
(func
);
2467 if
(!is_inside_library
&& !is_attr
(iface
->attrs
, ATTR_LOCAL
))
2470 if
(iface
->funcs
) LIST_FOR_EACH_ENTRY
( func
, iface
->funcs
, const func_t
, entry
)
2472 if
(!is_attr
(func
->def
->attrs
, ATTR_LOCAL
))
2473 check_remoting_args
(func
);
2478 static void check_all_user_types
(const statement_list_t
*stmts
)
2480 const statement_t
*stmt
;
2482 if
(stmts
) LIST_FOR_EACH_ENTRY
(stmt
, stmts
, const statement_t
, entry
)
2484 if
(stmt
->type
== STMT_LIBRARY
)
2485 check_all_user_types
(stmt
->u.lib
->stmts
);
2486 else if
(stmt
->type
== STMT_TYPE
&& stmt
->u.type
->type
== RPC_FC_IP
)
2489 const func_list_t
*fs
= stmt
->u.type
->funcs
;
2490 if
(fs
) LIST_FOR_EACH_ENTRY
(f
, fs
, const func_t
, entry
)
2491 check_for_additional_prototype_types
(f
->args
);
2496 int is_valid_uuid
(const char *s
)
2500 for
(i
= 0; i
< 36; ++i
)
2501 if
(i
== 8 || i
== 13 || i
== 18 || i
== 23)
2507 if
(!isxdigit
(s
[i
]))
2510 return s
[i
] == '\0';
2513 static statement_t
*make_statement
(enum statement_type type
)
2515 statement_t
*stmt
= xmalloc
(sizeof
(*stmt
));
2520 static statement_t
*make_statement_type_decl
(type_t
*type
)
2522 statement_t
*stmt
= make_statement
(STMT_TYPE
);
2523 stmt
->u.type
= type
;
2527 static statement_t
*make_statement_reference
(type_t
*type
)
2529 statement_t
*stmt
= make_statement
(STMT_TYPEREF
);
2530 stmt
->u.type
= type
;
2534 static statement_t
*make_statement_init_decl
(var_t
*var
)
2536 statement_t
*stmt
= make_statement
(STMT_INITDECL
);
2541 static statement_t
*make_statement_extern
(var_t
*var
)
2543 statement_t
*stmt
= make_statement
(STMT_EXTERN
);
2548 static statement_t
*make_statement_library
(typelib_t
*typelib
)
2550 statement_t
*stmt
= make_statement
(STMT_LIBRARY
);
2551 stmt
->u.lib
= typelib
;
2555 static statement_t
*make_statement_cppquote
(const char *str
)
2557 statement_t
*stmt
= make_statement
(STMT_CPPQUOTE
);
2562 static statement_t
*make_statement_importlib
(const char *str
)
2564 statement_t
*stmt
= make_statement
(STMT_IMPORTLIB
);
2569 static statement_t
*make_statement_module
(type_t
*type
)
2571 statement_t
*stmt
= make_statement
(STMT_MODULE
);
2572 stmt
->u.type
= type
;
2576 static statement_t
*process_typedefs
(declarator_list_t
*decls
)
2578 declarator_t
*decl
, *next
;
2580 type_list_t
**type_list
;
2582 if
(!decls
) return NULL
;
2584 stmt
= make_statement
(STMT_TYPEDEF
);
2585 stmt
->u.type_list
= NULL
;
2586 type_list
= &stmt
->u.type_list
;
2588 LIST_FOR_EACH_ENTRY_SAFE
( decl
, next
, decls
, declarator_t
, entry
)
2590 var_t
*var
= decl
->var
;
2591 type_t
*type
= find_type
(var
->name
, 0);
2592 *type_list
= xmalloc
(sizeof
(type_list_t
));
2593 (*type_list
)->type
= type
;
2594 (*type_list
)->next
= NULL
;
2596 if
(! parse_only
&& do_header
)
2597 write_typedef
(type
);
2598 if
(in_typelib
&& type
->attrs
)
2599 add_typelib_entry
(type
);
2601 type_list
= &(*type_list
)->next
;
2609 static statement_list_t
*append_statement
(statement_list_t
*list
, statement_t
*stmt
)
2611 if
(!stmt
) return list
;
2614 list
= xmalloc
( sizeof
(*list
) );
2617 list_add_tail
( list
, &stmt
->entry
);