makedep: Don't add dependencies for tests of disabled dlls.
[wine.git] / tools / widl / widltypes.h
blob0d88e713433a158ad2afa6a529d1c7c9324af628
1 /*
2 * IDL Compiler
4 * Copyright 2002 Ove Kaaven
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #ifndef __WIDL_WIDLTYPES_H
22 #define __WIDL_WIDLTYPES_H
24 #include <stdarg.h>
25 #include <assert.h>
26 #include "ndrtypes.h"
27 #include "wine/list.h"
29 struct uuid
31 unsigned int Data1;
32 unsigned short Data2;
33 unsigned short Data3;
34 unsigned char Data4[8];
37 #define TRUE 1
38 #define FALSE 0
40 typedef struct _loc_info_t loc_info_t;
41 typedef struct _attr_t attr_t;
42 typedef struct _attr_custdata_t attr_custdata_t;
43 typedef struct _expr_t expr_t;
44 typedef struct _type_t type_t;
45 typedef struct _var_t var_t;
46 typedef struct _decl_spec_t decl_spec_t;
47 typedef struct _declarator_t declarator_t;
48 typedef struct _typeref_t typeref_t;
49 typedef struct _typelib_entry_t typelib_entry_t;
50 typedef struct _importlib_t importlib_t;
51 typedef struct _importinfo_t importinfo_t;
52 typedef struct _typelib_t typelib_t;
53 typedef struct _user_type_t user_type_t;
54 typedef struct _user_type_t context_handle_t;
55 typedef struct _user_type_t generic_handle_t;
56 typedef struct _statement_t statement_t;
57 typedef struct _warning_t warning_t;
59 typedef struct list attr_list_t;
60 typedef struct list str_list_t;
61 typedef struct list expr_list_t;
62 typedef struct list var_list_t;
63 typedef struct list declarator_list_t;
64 typedef struct list typeref_list_t;
65 typedef struct list user_type_list_t;
66 typedef struct list context_handle_list_t;
67 typedef struct list generic_handle_list_t;
68 typedef struct list statement_list_t;
69 typedef struct list warning_list_t;
71 enum attr_type
73 ATTR_ACTIVATABLE,
74 ATTR_AGGREGATABLE,
75 ATTR_ALLOCATE,
76 ATTR_ANNOTATION,
77 ATTR_APPOBJECT,
78 ATTR_ASYNC,
79 ATTR_ASYNCUUID,
80 ATTR_AUTO_HANDLE,
81 ATTR_BINDABLE,
82 ATTR_BROADCAST,
83 ATTR_CALLAS,
84 ATTR_CALLCONV, /* calling convention pseudo-attribute */
85 ATTR_CASE,
86 ATTR_CODE,
87 ATTR_COMMSTATUS,
88 ATTR_CONTEXTHANDLE,
89 ATTR_CONTRACT,
90 ATTR_CONTRACTVERSION,
91 ATTR_CONTROL,
92 ATTR_CUSTOM,
93 ATTR_DECODE,
94 ATTR_DEFAULT,
95 ATTR_DEFAULTBIND,
96 ATTR_DEFAULTCOLLELEM,
97 ATTR_DEFAULTVALUE,
98 ATTR_DEFAULTVTABLE,
99 ATTR_DISABLECONSISTENCYCHECK,
100 ATTR_DISPINTERFACE,
101 ATTR_DISPLAYBIND,
102 ATTR_DLLNAME,
103 ATTR_DUAL,
104 ATTR_ENABLEALLOCATE,
105 ATTR_ENCODE,
106 ATTR_ENDPOINT,
107 ATTR_ENTRY,
108 ATTR_EVENTADD,
109 ATTR_EVENTREMOVE,
110 ATTR_EXCLUSIVETO,
111 ATTR_EXPLICIT_HANDLE,
112 ATTR_FAULTSTATUS,
113 ATTR_FLAGS,
114 ATTR_FORCEALLOCATE,
115 ATTR_HANDLE,
116 ATTR_HELPCONTEXT,
117 ATTR_HELPFILE,
118 ATTR_HELPSTRING,
119 ATTR_HELPSTRINGCONTEXT,
120 ATTR_HELPSTRINGDLL,
121 ATTR_HIDDEN,
122 ATTR_ID,
123 ATTR_IDEMPOTENT,
124 ATTR_IGNORE,
125 ATTR_IIDIS,
126 ATTR_IMMEDIATEBIND,
127 ATTR_IMPLICIT_HANDLE,
128 ATTR_IN,
129 ATTR_INPUTSYNC,
130 ATTR_LENGTHIS,
131 ATTR_LIBLCID,
132 ATTR_LICENSED,
133 ATTR_LOCAL,
134 ATTR_MARSHALING_BEHAVIOR,
135 ATTR_MAYBE,
136 ATTR_MESSAGE,
137 ATTR_NOCODE,
138 ATTR_NONBROWSABLE,
139 ATTR_NONCREATABLE,
140 ATTR_NONEXTENSIBLE,
141 ATTR_NOTIFY,
142 ATTR_NOTIFYFLAG,
143 ATTR_OBJECT,
144 ATTR_ODL,
145 ATTR_OLEAUTOMATION,
146 ATTR_OPTIMIZE,
147 ATTR_OPTIONAL,
148 ATTR_OUT,
149 ATTR_OVERLOAD,
150 ATTR_PARAMLCID,
151 ATTR_PARTIALIGNORE,
152 ATTR_POINTERDEFAULT,
153 ATTR_POINTERTYPE,
154 ATTR_PROGID,
155 ATTR_PROPGET,
156 ATTR_PROPPUT,
157 ATTR_PROPPUTREF,
158 ATTR_PROXY,
159 ATTR_PUBLIC,
160 ATTR_RANGE,
161 ATTR_READONLY,
162 ATTR_REPRESENTAS,
163 ATTR_REQUESTEDIT,
164 ATTR_RESTRICTED,
165 ATTR_RETVAL,
166 ATTR_SIZEIS,
167 ATTR_SOURCE,
168 ATTR_STATIC,
169 ATTR_STRICTCONTEXTHANDLE,
170 ATTR_STRING,
171 ATTR_SWITCHIS,
172 ATTR_SWITCHTYPE,
173 ATTR_THREADING,
174 ATTR_TRANSMITAS,
175 ATTR_UIDEFAULT,
176 ATTR_USERMARSHAL,
177 ATTR_USESGETLASTERROR,
178 ATTR_UUID,
179 ATTR_V1ENUM,
180 ATTR_VARARG,
181 ATTR_VERSION,
182 ATTR_VIPROGID,
183 ATTR_WIREMARSHAL
186 enum expr_type
188 EXPR_VOID,
189 EXPR_NUM,
190 EXPR_HEXNUM,
191 EXPR_DOUBLE,
192 EXPR_IDENTIFIER,
193 EXPR_NEG,
194 EXPR_NOT,
195 EXPR_PPTR,
196 EXPR_CAST,
197 EXPR_SIZEOF,
198 EXPR_SHL,
199 EXPR_SHR,
200 EXPR_MUL,
201 EXPR_DIV,
202 EXPR_ADD,
203 EXPR_SUB,
204 EXPR_AND,
205 EXPR_OR,
206 EXPR_COND,
207 EXPR_TRUEFALSE,
208 EXPR_ADDRESSOF,
209 EXPR_MEMBER,
210 EXPR_ARRAY,
211 EXPR_MOD,
212 EXPR_LOGOR,
213 EXPR_LOGAND,
214 EXPR_XOR,
215 EXPR_EQUALITY,
216 EXPR_INEQUALITY,
217 EXPR_GTR,
218 EXPR_LESS,
219 EXPR_GTREQL,
220 EXPR_LESSEQL,
221 EXPR_LOGNOT,
222 EXPR_POS,
223 EXPR_STRLIT,
224 EXPR_WSTRLIT,
225 EXPR_CHARCONST,
228 enum type_kind
230 TKIND_PRIMITIVE = -1,
231 TKIND_ENUM,
232 TKIND_RECORD,
233 TKIND_MODULE,
234 TKIND_INTERFACE,
235 TKIND_DISPATCH,
236 TKIND_COCLASS,
237 TKIND_ALIAS,
238 TKIND_UNION,
239 TKIND_MAX
242 enum storage_class
244 STG_NONE,
245 STG_STATIC,
246 STG_EXTERN,
247 STG_REGISTER,
250 enum type_qualifier
252 TYPE_QUALIFIER_CONST = 1,
255 enum function_specifier
257 FUNCTION_SPECIFIER_INLINE = 1,
260 enum statement_type
262 STMT_LIBRARY,
263 STMT_DECLARATION,
264 STMT_TYPE,
265 STMT_TYPEREF,
266 STMT_MODULE,
267 STMT_TYPEDEF,
268 STMT_IMPORT,
269 STMT_IMPORTLIB,
270 STMT_PRAGMA,
271 STMT_CPPQUOTE
274 enum threading_type
276 THREADING_APARTMENT = 1,
277 THREADING_NEUTRAL,
278 THREADING_SINGLE,
279 THREADING_FREE,
280 THREADING_BOTH
283 enum marshaling_type
285 MARSHALING_INVALID = 0,
286 MARSHALING_NONE,
287 MARSHALING_AGILE,
288 MARSHALING_STANDARD,
291 enum type_basic_type
293 TYPE_BASIC_INT8 = 1,
294 TYPE_BASIC_INT16,
295 TYPE_BASIC_INT32,
296 TYPE_BASIC_INT64,
297 TYPE_BASIC_INT,
298 TYPE_BASIC_INT3264,
299 TYPE_BASIC_LONG,
300 TYPE_BASIC_CHAR,
301 TYPE_BASIC_HYPER,
302 TYPE_BASIC_BYTE,
303 TYPE_BASIC_WCHAR,
304 TYPE_BASIC_FLOAT,
305 TYPE_BASIC_DOUBLE,
306 TYPE_BASIC_ERROR_STATUS_T,
307 TYPE_BASIC_HANDLE,
310 #define TYPE_BASIC_MAX TYPE_BASIC_HANDLE
311 #define TYPE_BASIC_INT_MIN TYPE_BASIC_INT8
312 #define TYPE_BASIC_INT_MAX TYPE_BASIC_HYPER
314 struct _loc_info_t
316 const char *input_name;
317 int line_number;
318 const char *near_text;
321 struct str_list_entry_t
323 char *str;
324 struct list entry;
327 struct _decl_spec_t
329 type_t *type;
330 enum storage_class stgclass;
331 enum type_qualifier qualifier;
332 enum function_specifier func_specifier;
335 struct _attr_t {
336 enum attr_type type;
337 union {
338 unsigned int ival;
339 void *pval;
340 } u;
341 /* parser-internal */
342 struct list entry;
345 struct _expr_t {
346 enum expr_type type;
347 const expr_t *ref;
348 union {
349 int lval;
350 double dval;
351 const char *sval;
352 const expr_t *ext;
353 decl_spec_t tref;
354 } u;
355 const expr_t *ext2;
356 int is_const;
357 int cval;
358 /* parser-internal */
359 struct list entry;
362 struct _attr_custdata_t {
363 struct uuid id;
364 expr_t *pval;
367 struct struct_details
369 var_list_t *fields;
372 struct enumeration_details
374 var_list_t *enums;
377 struct func_details
379 var_list_t *args;
380 struct _var_t *retval;
383 struct iface_details
385 statement_list_t *stmts;
386 var_list_t *disp_methods;
387 var_list_t *disp_props;
388 struct _type_t *inherit;
389 struct _type_t *disp_inherit;
390 struct _type_t *async_iface;
391 typeref_list_t *requires;
394 struct module_details
396 statement_list_t *stmts;
399 struct array_details
401 expr_t *size_is;
402 expr_t *length_is;
403 struct _decl_spec_t elem;
404 unsigned int dim;
405 unsigned char declptr; /* if declared as a pointer */
406 unsigned short ptr_tfsoff; /* offset of pointer definition for declptr */
409 struct coclass_details
411 typeref_list_t *ifaces;
414 struct basic_details
416 enum type_basic_type type;
417 int sign;
420 struct pointer_details
422 struct _decl_spec_t ref;
425 struct bitfield_details
427 struct _type_t *field;
428 const expr_t *bits;
431 struct alias_details
433 struct _decl_spec_t aliasee;
436 struct runtimeclass_details
438 typeref_list_t *ifaces;
441 struct parameterized_details
443 type_t *type;
444 typeref_list_t *params;
447 struct delegate_details
449 type_t *iface;
452 #define HASHMAX 64
454 struct namespace {
455 const char *name;
456 struct namespace *parent;
457 struct list entry;
458 struct list children;
459 struct rtype *type_hash[HASHMAX];
462 enum type_type
464 TYPE_VOID,
465 TYPE_BASIC, /* ints, floats and handles */
466 TYPE_ENUM,
467 TYPE_STRUCT,
468 TYPE_ENCAPSULATED_UNION,
469 TYPE_UNION,
470 TYPE_ALIAS,
471 TYPE_MODULE,
472 TYPE_COCLASS,
473 TYPE_FUNCTION,
474 TYPE_INTERFACE,
475 TYPE_POINTER,
476 TYPE_ARRAY,
477 TYPE_BITFIELD,
478 TYPE_APICONTRACT,
479 TYPE_RUNTIMECLASS,
480 TYPE_PARAMETERIZED_TYPE,
481 TYPE_PARAMETER,
482 TYPE_DELEGATE,
485 struct _type_t {
486 const char *name; /* C++ name with parameters in brackets */
487 struct namespace *namespace;
488 enum type_type type_type;
489 attr_list_t *attrs;
490 union
492 struct struct_details *structure;
493 struct enumeration_details *enumeration;
494 struct func_details *function;
495 struct iface_details *iface;
496 struct module_details *module;
497 struct array_details array;
498 struct coclass_details coclass;
499 struct basic_details basic;
500 struct pointer_details pointer;
501 struct bitfield_details bitfield;
502 struct alias_details alias;
503 struct runtimeclass_details runtimeclass;
504 struct parameterized_details parameterized;
505 struct delegate_details delegate;
506 } details;
507 const char *c_name; /* mangled C name, with namespaces and parameters */
508 const char *signature;
509 const char *qualified_name; /* C++ fully qualified name */
510 const char *impl_name; /* C++ parameterized types impl base class name */
511 const char *param_name; /* used to build c_name of a parameterized type, when used as a parameter */
512 const char *short_name; /* widl specific short name */
513 unsigned int typestring_offset;
514 unsigned int ptrdesc; /* used for complex structs */
515 int typelib_idx;
516 loc_info_t loc_info;
517 unsigned int ignore : 1;
518 unsigned int defined : 1;
519 unsigned int written : 1;
520 unsigned int user_types_registered : 1;
521 unsigned int tfswrite : 1; /* if the type needs to be written to the TFS */
522 unsigned int checked : 1;
525 struct _var_t {
526 char *name;
527 decl_spec_t declspec;
528 attr_list_t *attrs;
529 expr_t *eval;
531 unsigned int typestring_offset;
533 /* fields specific to functions */
534 unsigned int procstring_offset, func_idx;
536 struct _loc_info_t loc_info;
538 unsigned int declonly : 1;
540 /* parser-internal */
541 struct list entry;
544 struct _declarator_t {
545 var_t *var;
546 type_t *type;
547 enum type_qualifier qualifier;
548 expr_t *bits;
550 /* parser-internal */
551 struct list entry;
554 struct _typeref_t {
555 type_t *type;
556 attr_list_t *attrs;
558 /* parser-internal */
559 struct list entry;
562 struct _typelib_entry_t {
563 type_t *type;
564 struct list entry;
567 struct _importinfo_t {
568 int offset;
569 struct uuid guid;
570 int flags;
571 int id;
573 char *name;
575 importlib_t *importlib;
578 struct _importlib_t {
579 int offset;
580 char *name;
582 int version;
583 struct uuid guid;
585 importinfo_t *importinfos;
586 int ntypeinfos;
588 int allocated;
590 struct list entry;
593 struct _typelib_t {
594 char *name;
595 const attr_list_t *attrs;
596 struct list importlibs;
597 statement_list_t *stmts;
599 type_t **reg_ifaces;
600 unsigned int reg_iface_count;
603 struct _user_type_t {
604 struct list entry;
605 const char *name;
608 struct _statement_t {
609 struct list entry;
610 enum statement_type type;
611 union
613 type_t *type;
614 const char *str;
615 var_t *var;
616 typelib_t *lib;
617 typeref_list_t *type_list;
618 } u;
619 unsigned int declonly : 1; /* for STMT_TYPE and STMT_TYPEDEF */
622 struct _warning_t {
623 int num;
624 struct list entry;
627 typedef enum {
628 SYS_WIN16,
629 SYS_WIN32,
630 SYS_MAC,
631 SYS_WIN64
632 } syskind_t;
634 extern user_type_list_t user_type_list;
635 extern context_handle_list_t context_handle_list;
636 extern generic_handle_list_t generic_handle_list;
637 void check_for_additional_prototype_types(type_t *type);
639 void init_types(void);
640 type_t *alloc_type(void);
641 void set_all_tfswrite(int val);
642 void clear_all_offsets(void);
644 #define tsENUM 1
645 #define tsSTRUCT 2
646 #define tsUNION 3
648 var_t *find_const(const char *name, int f);
649 type_t *find_type(const char *name, struct namespace *namespace, int t);
650 type_t *make_type(enum type_type type);
651 type_t *get_type(enum type_type type, char *name, struct namespace *namespace, int t);
652 type_t *reg_type(type_t *type, const char *name, struct namespace *namespace, int t);
654 var_t *make_var(char *name);
655 var_list_t *append_var(var_list_t *list, var_t *var);
657 void init_loc_info(loc_info_t *);
659 char *format_namespace(struct namespace *namespace, const char *prefix, const char *separator, const char *suffix,
660 const char *abi_prefix);
661 char *format_parameterized_type_name(type_t *type, typeref_list_t *params);
663 static inline enum type_type type_get_type_detect_alias(const type_t *type)
665 return type->type_type;
668 #define STATEMENTS_FOR_EACH_FUNC(stmt, stmts) \
669 if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, statement_t, entry ) \
670 if (stmt->type == STMT_DECLARATION && stmt->u.var->declspec.stgclass == STG_NONE && \
671 type_get_type_detect_alias(stmt->u.var->declspec.type) == TYPE_FUNCTION)
673 static inline int statements_has_func(const statement_list_t *stmts)
675 const statement_t *stmt;
676 int has_func = 0;
677 STATEMENTS_FOR_EACH_FUNC(stmt, stmts)
679 has_func = 1;
680 break;
682 return has_func;
685 static inline int is_global_namespace(const struct namespace *namespace)
687 return !namespace->name;
690 static inline decl_spec_t *init_declspec(decl_spec_t *declspec, type_t *type)
692 declspec->type = type;
693 declspec->stgclass = STG_NONE;
694 declspec->qualifier = 0;
695 declspec->func_specifier = 0;
697 return declspec;
700 #endif