kernel32/tests: Add tests for DEP combined with guard pages and write watches.
[wine/wine-gecko.git] / tools / widl / widltypes.h
blob47c88447d9c4696d3c38be6bd0c2c9034a5b582c
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 "guiddef.h"
27 #include "wine/rpcfc.h"
28 #include "wine/list.h"
30 #ifndef UUID_DEFINED
31 #define UUID_DEFINED
32 typedef GUID UUID;
33 #endif
35 #define TRUE 1
36 #define FALSE 0
38 typedef struct _loc_info_t loc_info_t;
39 typedef struct _attr_t attr_t;
40 typedef struct _expr_t expr_t;
41 typedef struct _type_t type_t;
42 typedef struct _var_t var_t;
43 typedef struct _declarator_t declarator_t;
44 typedef struct _ifref_t ifref_t;
45 typedef struct _typelib_entry_t typelib_entry_t;
46 typedef struct _importlib_t importlib_t;
47 typedef struct _importinfo_t importinfo_t;
48 typedef struct _typelib_t typelib_t;
49 typedef struct _user_type_t user_type_t;
50 typedef struct _user_type_t context_handle_t;
51 typedef struct _user_type_t generic_handle_t;
52 typedef struct _type_list_t type_list_t;
53 typedef struct _statement_t statement_t;
55 typedef struct list attr_list_t;
56 typedef struct list str_list_t;
57 typedef struct list expr_list_t;
58 typedef struct list var_list_t;
59 typedef struct list declarator_list_t;
60 typedef struct list ifref_list_t;
61 typedef struct list array_dims_t;
62 typedef struct list user_type_list_t;
63 typedef struct list context_handle_list_t;
64 typedef struct list generic_handle_list_t;
65 typedef struct list statement_list_t;
67 enum attr_type
69 ATTR_AGGREGATABLE,
70 ATTR_ANNOTATION,
71 ATTR_APPOBJECT,
72 ATTR_ASYNC,
73 ATTR_ASYNCUUID,
74 ATTR_AUTO_HANDLE,
75 ATTR_BINDABLE,
76 ATTR_BROADCAST,
77 ATTR_CALLAS,
78 ATTR_CALLCONV, /* calling convention pseudo-attribute */
79 ATTR_CASE,
80 ATTR_CODE,
81 ATTR_COMMSTATUS,
82 ATTR_CONST, /* const pseudo-attribute */
83 ATTR_CONTEXTHANDLE,
84 ATTR_CONTROL,
85 ATTR_DECODE,
86 ATTR_DEFAULT,
87 ATTR_DEFAULTBIND,
88 ATTR_DEFAULTCOLLELEM,
89 ATTR_DEFAULTVALUE,
90 ATTR_DEFAULTVTABLE,
91 ATTR_DISABLECONSISTENCYCHECK,
92 ATTR_DISPINTERFACE,
93 ATTR_DISPLAYBIND,
94 ATTR_DLLNAME,
95 ATTR_DUAL,
96 ATTR_ENABLEALLOCATE,
97 ATTR_ENCODE,
98 ATTR_ENDPOINT,
99 ATTR_ENTRY,
100 ATTR_EXPLICIT_HANDLE,
101 ATTR_FAULTSTATUS,
102 ATTR_FORCEALLOCATE,
103 ATTR_HANDLE,
104 ATTR_HELPCONTEXT,
105 ATTR_HELPFILE,
106 ATTR_HELPSTRING,
107 ATTR_HELPSTRINGCONTEXT,
108 ATTR_HELPSTRINGDLL,
109 ATTR_HIDDEN,
110 ATTR_ID,
111 ATTR_IDEMPOTENT,
112 ATTR_IGNORE,
113 ATTR_IIDIS,
114 ATTR_IMMEDIATEBIND,
115 ATTR_IMPLICIT_HANDLE,
116 ATTR_IN,
117 ATTR_INLINE,
118 ATTR_INPUTSYNC,
119 ATTR_LENGTHIS,
120 ATTR_LIBLCID,
121 ATTR_LICENSED,
122 ATTR_LOCAL,
123 ATTR_MAYBE,
124 ATTR_MESSAGE,
125 ATTR_NOCODE,
126 ATTR_NONBROWSABLE,
127 ATTR_NONCREATABLE,
128 ATTR_NONEXTENSIBLE,
129 ATTR_NOTIFY,
130 ATTR_NOTIFYFLAG,
131 ATTR_OBJECT,
132 ATTR_ODL,
133 ATTR_OLEAUTOMATION,
134 ATTR_OPTIMIZE,
135 ATTR_OPTIONAL,
136 ATTR_OUT,
137 ATTR_PARAMLCID,
138 ATTR_PARTIALIGNORE,
139 ATTR_POINTERDEFAULT,
140 ATTR_POINTERTYPE,
141 ATTR_PROGID,
142 ATTR_PROPGET,
143 ATTR_PROPPUT,
144 ATTR_PROPPUTREF,
145 ATTR_PROXY,
146 ATTR_PUBLIC,
147 ATTR_RANGE,
148 ATTR_READONLY,
149 ATTR_REPRESENTAS,
150 ATTR_REQUESTEDIT,
151 ATTR_RESTRICTED,
152 ATTR_RETVAL,
153 ATTR_SIZEIS,
154 ATTR_SOURCE,
155 ATTR_STRICTCONTEXTHANDLE,
156 ATTR_STRING,
157 ATTR_SWITCHIS,
158 ATTR_SWITCHTYPE,
159 ATTR_THREADING,
160 ATTR_TRANSMITAS,
161 ATTR_UIDEFAULT,
162 ATTR_USERMARSHAL,
163 ATTR_USESGETLASTERROR,
164 ATTR_UUID,
165 ATTR_V1ENUM,
166 ATTR_VARARG,
167 ATTR_VERSION,
168 ATTR_VIPROGID,
169 ATTR_WIREMARSHAL
172 enum expr_type
174 EXPR_VOID,
175 EXPR_NUM,
176 EXPR_HEXNUM,
177 EXPR_DOUBLE,
178 EXPR_IDENTIFIER,
179 EXPR_NEG,
180 EXPR_NOT,
181 EXPR_PPTR,
182 EXPR_CAST,
183 EXPR_SIZEOF,
184 EXPR_SHL,
185 EXPR_SHR,
186 EXPR_MUL,
187 EXPR_DIV,
188 EXPR_ADD,
189 EXPR_SUB,
190 EXPR_AND,
191 EXPR_OR,
192 EXPR_COND,
193 EXPR_TRUEFALSE,
194 EXPR_ADDRESSOF,
195 EXPR_MEMBER,
196 EXPR_ARRAY,
197 EXPR_MOD,
198 EXPR_LOGOR,
199 EXPR_LOGAND,
200 EXPR_XOR,
201 EXPR_EQUALITY,
202 EXPR_INEQUALITY,
203 EXPR_GTR,
204 EXPR_LESS,
205 EXPR_GTREQL,
206 EXPR_LESSEQL,
207 EXPR_LOGNOT,
208 EXPR_POS,
209 EXPR_STRLIT,
210 EXPR_WSTRLIT,
211 EXPR_CHARCONST,
214 enum type_kind
216 TKIND_PRIMITIVE = -1,
217 TKIND_ENUM,
218 TKIND_RECORD,
219 TKIND_MODULE,
220 TKIND_INTERFACE,
221 TKIND_DISPATCH,
222 TKIND_COCLASS,
223 TKIND_ALIAS,
224 TKIND_UNION,
225 TKIND_MAX
228 enum storage_class
230 STG_NONE,
231 STG_STATIC,
232 STG_EXTERN,
233 STG_REGISTER,
236 enum statement_type
238 STMT_LIBRARY,
239 STMT_DECLARATION,
240 STMT_TYPE,
241 STMT_TYPEREF,
242 STMT_MODULE,
243 STMT_TYPEDEF,
244 STMT_IMPORT,
245 STMT_IMPORTLIB,
246 STMT_PRAGMA,
247 STMT_CPPQUOTE
250 enum threading_type
252 THREADING_APARTMENT = 1,
253 THREADING_NEUTRAL,
254 THREADING_SINGLE,
255 THREADING_FREE,
256 THREADING_BOTH
259 enum type_basic_type
261 TYPE_BASIC_INT8 = 1,
262 TYPE_BASIC_INT16,
263 TYPE_BASIC_INT32,
264 TYPE_BASIC_INT64,
265 TYPE_BASIC_INT,
266 TYPE_BASIC_INT3264,
267 TYPE_BASIC_CHAR,
268 TYPE_BASIC_HYPER,
269 TYPE_BASIC_BYTE,
270 TYPE_BASIC_WCHAR,
271 TYPE_BASIC_FLOAT,
272 TYPE_BASIC_DOUBLE,
273 TYPE_BASIC_ERROR_STATUS_T,
274 TYPE_BASIC_HANDLE,
277 #define TYPE_BASIC_MAX TYPE_BASIC_HANDLE
278 #define TYPE_BASIC_INT_MIN TYPE_BASIC_INT8
279 #define TYPE_BASIC_INT_MAX TYPE_BASIC_HYPER
281 struct _loc_info_t
283 const char *input_name;
284 int line_number;
285 const char *near_text;
288 struct str_list_entry_t
290 char *str;
291 struct list entry;
294 struct _attr_t {
295 enum attr_type type;
296 union {
297 unsigned int ival;
298 void *pval;
299 } u;
300 /* parser-internal */
301 struct list entry;
304 struct _expr_t {
305 enum expr_type type;
306 const expr_t *ref;
307 union {
308 int lval;
309 double dval;
310 const char *sval;
311 const expr_t *ext;
312 type_t *tref;
313 } u;
314 const expr_t *ext2;
315 int is_const;
316 int cval;
317 /* parser-internal */
318 struct list entry;
321 struct struct_details
323 var_list_t *fields;
326 struct enumeration_details
328 var_list_t *enums;
331 struct func_details
333 var_list_t *args;
334 struct _var_t *retval;
335 int idx;
338 struct iface_details
340 statement_list_t *stmts;
341 var_list_t *disp_methods;
342 var_list_t *disp_props;
343 struct _type_t *inherit;
346 struct module_details
348 statement_list_t *stmts;
351 struct array_details
353 expr_t *size_is;
354 expr_t *length_is;
355 struct _type_t *elem;
356 unsigned int dim;
357 unsigned char ptr_def_fc;
358 unsigned char declptr; /* if declared as a pointer */
359 unsigned short ptr_tfsoff; /* offset of pointer definition for declptr */
362 struct coclass_details
364 ifref_list_t *ifaces;
367 struct basic_details
369 enum type_basic_type type;
370 int sign;
373 struct pointer_details
375 struct _type_t *ref;
376 unsigned char def_fc;
379 struct bitfield_details
381 struct _type_t *field;
382 const expr_t *bits;
385 enum type_type
387 TYPE_VOID,
388 TYPE_BASIC, /* ints, floats and handles */
389 TYPE_ENUM,
390 TYPE_STRUCT,
391 TYPE_ENCAPSULATED_UNION,
392 TYPE_UNION,
393 TYPE_ALIAS,
394 TYPE_MODULE,
395 TYPE_COCLASS,
396 TYPE_FUNCTION,
397 TYPE_INTERFACE,
398 TYPE_POINTER,
399 TYPE_ARRAY,
400 TYPE_BITFIELD,
403 struct _type_t {
404 const char *name;
405 enum type_type type_type;
406 attr_list_t *attrs;
407 union
409 struct struct_details *structure;
410 struct enumeration_details *enumeration;
411 struct func_details *function;
412 struct iface_details *iface;
413 struct module_details *module;
414 struct array_details array;
415 struct coclass_details coclass;
416 struct basic_details basic;
417 struct pointer_details pointer;
418 struct bitfield_details bitfield;
419 } details;
420 type_t *orig; /* dup'd types */
421 unsigned int typestring_offset;
422 unsigned int ptrdesc; /* used for complex structs */
423 int typelib_idx;
424 loc_info_t loc_info;
425 unsigned int ignore : 1;
426 unsigned int defined : 1;
427 unsigned int written : 1;
428 unsigned int user_types_registered : 1;
429 unsigned int tfswrite : 1; /* if the type needs to be written to the TFS */
430 unsigned int checked : 1;
431 unsigned int is_alias : 1; /* is the type an alias? */
434 struct _var_t {
435 char *name;
436 type_t *type;
437 attr_list_t *attrs;
438 expr_t *eval;
439 enum storage_class stgclass;
440 unsigned int procstring_offset;
441 unsigned int typestring_offset;
443 struct _loc_info_t loc_info;
445 /* parser-internal */
446 struct list entry;
449 struct _declarator_t {
450 var_t *var;
451 type_t *type;
452 type_t *func_type;
453 array_dims_t *array;
454 expr_t *bits;
456 /* parser-internal */
457 struct list entry;
460 struct _ifref_t {
461 type_t *iface;
462 attr_list_t *attrs;
464 /* parser-internal */
465 struct list entry;
468 struct _typelib_entry_t {
469 type_t *type;
470 struct list entry;
473 struct _importinfo_t {
474 int offset;
475 GUID guid;
476 int flags;
477 int id;
479 char *name;
481 importlib_t *importlib;
484 struct _importlib_t {
485 char *name;
487 int version;
488 GUID guid;
490 importinfo_t *importinfos;
491 int ntypeinfos;
493 int allocated;
495 struct list entry;
498 struct _typelib_t {
499 char *name;
500 const attr_list_t *attrs;
501 struct list importlibs;
502 statement_list_t *stmts;
505 struct _user_type_t {
506 struct list entry;
507 const char *name;
510 struct _type_list_t {
511 type_t *type;
512 struct _type_list_t *next;
515 struct _statement_t {
516 struct list entry;
517 enum statement_type type;
518 union
520 ifref_t iface;
521 type_t *type;
522 const char *str;
523 var_t *var;
524 typelib_t *lib;
525 type_list_t *type_list;
526 } u;
529 typedef enum {
530 SYS_WIN16,
531 SYS_WIN32,
532 SYS_MAC,
533 SYS_WIN64
534 } syskind_t;
536 extern syskind_t typelib_kind;
537 extern user_type_list_t user_type_list;
538 extern context_handle_list_t context_handle_list;
539 extern generic_handle_list_t generic_handle_list;
540 void check_for_additional_prototype_types(const var_list_t *list);
542 void init_types(void);
543 type_t *alloc_type(void);
544 void set_all_tfswrite(int val);
545 void clear_all_offsets(void);
547 #define tsENUM 1
548 #define tsSTRUCT 2
549 #define tsUNION 3
551 var_t *find_const(const char *name, int f);
552 type_t *find_type(const char *name, int t);
553 type_t *make_type(enum type_type type);
554 type_t *get_type(enum type_type type, char *name, int t);
555 type_t *reg_type(type_t *type, const char *name, int t);
556 void add_incomplete(type_t *t);
558 var_t *make_var(char *name);
559 var_list_t *append_var(var_list_t *list, var_t *var);
561 void init_loc_info(loc_info_t *);
563 static inline var_list_t *type_get_function_args(const type_t *func_type)
565 return func_type->details.function->args;
568 static inline enum type_type type_get_type_detect_alias(const type_t *type)
570 if (type->is_alias)
571 return TYPE_ALIAS;
572 return type->type_type;
575 #define STATEMENTS_FOR_EACH_FUNC(stmt, stmts) \
576 if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, statement_t, entry ) \
577 if (stmt->type == STMT_DECLARATION && stmt->u.var->stgclass == STG_NONE && \
578 type_get_type_detect_alias(stmt->u.var->type) == TYPE_FUNCTION)
580 static inline int statements_has_func(const statement_list_t *stmts)
582 const statement_t *stmt;
583 int has_func = 0;
584 STATEMENTS_FOR_EACH_FUNC(stmt, stmts)
586 has_func = 1;
587 break;
589 return has_func;
592 #endif