wininet/tests: Run tests again on systems with IE5.
[wine.git] / tools / widl / widltypes.h
blobc1c07ea252da718e145138b7797006e83333a722
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 #define RPC_FC_MODULE 0xfc
39 #define RPC_FC_COCLASS 0xfd
40 #define RPC_FC_FUNCTION 0xfe
42 typedef struct _loc_info_t loc_info_t;
43 typedef struct _attr_t attr_t;
44 typedef struct _expr_t expr_t;
45 typedef struct _type_t type_t;
46 typedef struct _typeref_t typeref_t;
47 typedef struct _var_t var_t;
48 typedef struct _declarator_t declarator_t;
49 typedef struct _func_t func_t;
50 typedef struct _ifref_t ifref_t;
51 typedef struct _typelib_entry_t typelib_entry_t;
52 typedef struct _importlib_t importlib_t;
53 typedef struct _importinfo_t importinfo_t;
54 typedef struct _typelib_t typelib_t;
55 typedef struct _user_type_t user_type_t;
56 typedef struct _user_type_t context_handle_t;
57 typedef struct _type_list_t type_list_t;
58 typedef struct _statement_t statement_t;
60 typedef struct list attr_list_t;
61 typedef struct list str_list_t;
62 typedef struct list func_list_t;
63 typedef struct list expr_list_t;
64 typedef struct list var_list_t;
65 typedef struct list declarator_list_t;
66 typedef struct list ifref_list_t;
67 typedef struct list array_dims_t;
68 typedef struct list user_type_list_t;
69 typedef struct list context_handle_list_t;
70 typedef struct list statement_list_t;
72 enum attr_type
74 ATTR_AGGREGATABLE,
75 ATTR_APPOBJECT,
76 ATTR_ASYNC,
77 ATTR_AUTO_HANDLE,
78 ATTR_BINDABLE,
79 ATTR_BROADCAST,
80 ATTR_CALLAS,
81 ATTR_CALLCONV, /* calling convention pseudo-attribute */
82 ATTR_CASE,
83 ATTR_CONST, /* const pseudo-attribute */
84 ATTR_CONTEXTHANDLE,
85 ATTR_CONTROL,
86 ATTR_DEFAULT,
87 ATTR_DEFAULTCOLLELEM,
88 ATTR_DEFAULTVALUE,
89 ATTR_DEFAULTVTABLE,
90 ATTR_DISPINTERFACE,
91 ATTR_DISPLAYBIND,
92 ATTR_DLLNAME,
93 ATTR_DUAL,
94 ATTR_ENDPOINT,
95 ATTR_ENTRY,
96 ATTR_EXPLICIT_HANDLE,
97 ATTR_HANDLE,
98 ATTR_HELPCONTEXT,
99 ATTR_HELPFILE,
100 ATTR_HELPSTRING,
101 ATTR_HELPSTRINGCONTEXT,
102 ATTR_HELPSTRINGDLL,
103 ATTR_HIDDEN,
104 ATTR_ID,
105 ATTR_IDEMPOTENT,
106 ATTR_IIDIS,
107 ATTR_IMMEDIATEBIND,
108 ATTR_IMPLICIT_HANDLE,
109 ATTR_IN,
110 ATTR_INLINE,
111 ATTR_INPUTSYNC,
112 ATTR_LENGTHIS,
113 ATTR_LIBLCID,
114 ATTR_LOCAL,
115 ATTR_NONBROWSABLE,
116 ATTR_NONCREATABLE,
117 ATTR_NONEXTENSIBLE,
118 ATTR_OBJECT,
119 ATTR_ODL,
120 ATTR_OLEAUTOMATION,
121 ATTR_OPTIONAL,
122 ATTR_OUT,
123 ATTR_PARAMLCID,
124 ATTR_POINTERDEFAULT,
125 ATTR_POINTERTYPE,
126 ATTR_PROPGET,
127 ATTR_PROPPUT,
128 ATTR_PROPPUTREF,
129 ATTR_PUBLIC,
130 ATTR_RANGE,
131 ATTR_READONLY,
132 ATTR_REQUESTEDIT,
133 ATTR_RESTRICTED,
134 ATTR_RETVAL,
135 ATTR_SIZEIS,
136 ATTR_SOURCE,
137 ATTR_STRICTCONTEXTHANDLE,
138 ATTR_STRING,
139 ATTR_SWITCHIS,
140 ATTR_SWITCHTYPE,
141 ATTR_TRANSMITAS,
142 ATTR_UUID,
143 ATTR_V1ENUM,
144 ATTR_VARARG,
145 ATTR_VERSION,
146 ATTR_WIREMARSHAL
149 enum expr_type
151 EXPR_VOID,
152 EXPR_NUM,
153 EXPR_HEXNUM,
154 EXPR_DOUBLE,
155 EXPR_IDENTIFIER,
156 EXPR_NEG,
157 EXPR_NOT,
158 EXPR_PPTR,
159 EXPR_CAST,
160 EXPR_SIZEOF,
161 EXPR_SHL,
162 EXPR_SHR,
163 EXPR_MUL,
164 EXPR_DIV,
165 EXPR_ADD,
166 EXPR_SUB,
167 EXPR_AND,
168 EXPR_OR,
169 EXPR_COND,
170 EXPR_TRUEFALSE,
171 EXPR_ADDRESSOF,
172 EXPR_MEMBER,
173 EXPR_ARRAY,
174 EXPR_MOD,
175 EXPR_LOGOR,
176 EXPR_LOGAND,
177 EXPR_XOR,
178 EXPR_EQUALITY,
179 EXPR_INEQUALITY,
180 EXPR_GTR,
181 EXPR_LESS,
182 EXPR_GTREQL,
183 EXPR_LESSEQL,
184 EXPR_LOGNOT,
185 EXPR_POS,
186 EXPR_STRLIT,
187 EXPR_WSTRLIT,
190 enum type_kind
192 TKIND_PRIMITIVE = -1,
193 TKIND_ENUM,
194 TKIND_RECORD,
195 TKIND_MODULE,
196 TKIND_INTERFACE,
197 TKIND_DISPATCH,
198 TKIND_COCLASS,
199 TKIND_ALIAS,
200 TKIND_UNION,
201 TKIND_MAX
204 enum storage_class
206 STG_NONE,
207 STG_STATIC,
208 STG_EXTERN,
209 STG_REGISTER,
212 enum statement_type
214 STMT_LIBRARY,
215 STMT_DECLARATION,
216 STMT_TYPE,
217 STMT_TYPEREF,
218 STMT_MODULE,
219 STMT_TYPEDEF,
220 STMT_IMPORT,
221 STMT_IMPORTLIB,
222 STMT_CPPQUOTE
225 enum type_basic_type
227 TYPE_BASIC_INT8 = 1,
228 TYPE_BASIC_INT16,
229 TYPE_BASIC_INT32,
230 TYPE_BASIC_INT64,
231 TYPE_BASIC_INT,
232 TYPE_BASIC_CHAR,
233 TYPE_BASIC_HYPER,
234 TYPE_BASIC_BYTE,
235 TYPE_BASIC_WCHAR,
236 TYPE_BASIC_FLOAT,
237 TYPE_BASIC_DOUBLE,
238 TYPE_BASIC_ERROR_STATUS_T,
239 TYPE_BASIC_HANDLE,
242 #define TYPE_BASIC_MAX TYPE_BASIC_HANDLE
243 #define TYPE_BASIC_INT_MIN TYPE_BASIC_INT8
244 #define TYPE_BASIC_INT_MAX TYPE_BASIC_HYPER
246 struct _loc_info_t
248 const char *input_name;
249 int line_number;
250 const char *near_text;
253 struct str_list_entry_t
255 char *str;
256 struct list entry;
259 struct _attr_t {
260 enum attr_type type;
261 union {
262 unsigned long ival;
263 void *pval;
264 } u;
265 /* parser-internal */
266 struct list entry;
269 struct _expr_t {
270 enum expr_type type;
271 const expr_t *ref;
272 union {
273 long lval;
274 double dval;
275 const char *sval;
276 const expr_t *ext;
277 type_t *tref;
278 } u;
279 const expr_t *ext2;
280 int is_const;
281 long cval;
282 /* parser-internal */
283 struct list entry;
286 struct struct_details
288 var_list_t *fields;
291 struct enumeration_details
293 var_list_t *enums;
296 struct func_details
298 var_list_t *args;
299 struct _type_t *rettype;
300 int idx;
303 struct iface_details
305 statement_list_t *stmts;
306 func_list_t *disp_methods;
307 var_list_t *disp_props;
308 struct _type_t *inherit;
311 struct module_details
313 statement_list_t *stmts;
314 func_list_t *funcs;
317 struct array_details
319 expr_t *size_is;
320 expr_t *length_is;
321 struct _type_t *elem;
322 unsigned int dim;
323 unsigned char ptr_def_fc;
324 unsigned char declptr; /* if declared as a pointer */
327 struct coclass_details
329 ifref_list_t *ifaces;
332 struct basic_details
334 enum type_basic_type type;
335 int sign;
338 struct pointer_details
340 struct _type_t *ref;
341 unsigned char def_fc;
344 enum type_type
346 TYPE_VOID,
347 TYPE_BASIC, /* ints, floats and handles */
348 TYPE_ENUM,
349 TYPE_STRUCT,
350 TYPE_ENCAPSULATED_UNION,
351 TYPE_UNION,
352 TYPE_ALIAS,
353 TYPE_MODULE,
354 TYPE_COCLASS,
355 TYPE_FUNCTION,
356 TYPE_INTERFACE,
357 TYPE_POINTER,
358 TYPE_ARRAY,
361 struct _type_t {
362 const char *name;
363 enum type_type type_type;
364 attr_list_t *attrs;
365 union
367 struct struct_details *structure;
368 struct enumeration_details *enumeration;
369 struct func_details *function;
370 struct iface_details *iface;
371 struct module_details *module;
372 struct array_details array;
373 struct coclass_details coclass;
374 struct basic_details basic;
375 struct pointer_details pointer;
376 } details;
377 type_t *orig; /* dup'd types */
378 unsigned int typestring_offset;
379 unsigned int ptrdesc; /* used for complex structs */
380 int typelib_idx;
381 loc_info_t loc_info;
382 unsigned int ignore : 1;
383 unsigned int defined : 1;
384 unsigned int written : 1;
385 unsigned int user_types_registered : 1;
386 unsigned int tfswrite : 1; /* if the type needs to be written to the TFS */
387 unsigned int checked : 1;
388 unsigned int is_alias : 1; /* is the type an alias? */
391 struct _var_t {
392 char *name;
393 type_t *type;
394 attr_list_t *attrs;
395 expr_t *eval;
396 enum storage_class stgclass;
398 struct _loc_info_t loc_info;
400 /* parser-internal */
401 struct list entry;
404 struct _declarator_t {
405 var_t *var;
406 type_t *type;
407 type_t *func_type;
408 array_dims_t *array;
410 /* parser-internal */
411 struct list entry;
414 struct _func_t {
415 var_t *def;
417 /* parser-internal */
418 struct list entry;
421 struct _ifref_t {
422 type_t *iface;
423 attr_list_t *attrs;
425 /* parser-internal */
426 struct list entry;
429 struct _typelib_entry_t {
430 type_t *type;
431 struct list entry;
434 struct _importinfo_t {
435 int offset;
436 GUID guid;
437 int flags;
438 int id;
440 char *name;
442 importlib_t *importlib;
445 struct _importlib_t {
446 char *name;
448 int version;
449 GUID guid;
451 importinfo_t *importinfos;
452 int ntypeinfos;
454 int allocated;
456 struct list entry;
459 struct _typelib_t {
460 char *name;
461 char *filename;
462 const attr_list_t *attrs;
463 struct list importlibs;
464 statement_list_t *stmts;
467 struct _user_type_t {
468 struct list entry;
469 const char *name;
472 struct _type_list_t {
473 type_t *type;
474 struct _type_list_t *next;
477 struct _statement_t {
478 struct list entry;
479 enum statement_type type;
480 union
482 ifref_t iface;
483 type_t *type;
484 const char *str;
485 var_t *var;
486 typelib_t *lib;
487 type_list_t *type_list;
488 } u;
491 typedef enum {
492 SYS_WIN16,
493 SYS_WIN32,
494 SYS_MAC,
495 SYS_WIN64
496 } syskind_t;
498 extern syskind_t typelib_kind;
499 extern user_type_list_t user_type_list;
500 void check_for_additional_prototype_types(const var_list_t *list);
502 void init_types(void);
503 type_t *alloc_type(void);
504 void set_all_tfswrite(int val);
505 void clear_all_offsets(void);
507 int is_ptr(const type_t *t);
508 int is_array(const type_t *t);
509 int is_var_ptr(const var_t *v);
510 int cant_be_null(const var_t *v);
511 int is_struct(unsigned char tc);
512 int is_union(unsigned char tc);
514 #define tsENUM 1
515 #define tsSTRUCT 2
516 #define tsUNION 3
518 var_t *find_const(const char *name, int f);
519 type_t *find_type(const char *name, int t);
520 type_t *make_type(enum type_type type);
521 type_t *get_type(enum type_type type, char *name, int t);
522 type_t *reg_type(type_t *type, const char *name, int t);
523 void add_incomplete(type_t *t);
525 var_t *make_var(char *name);
526 var_list_t *append_var(var_list_t *list, var_t *var);
528 void init_loc_info(loc_info_t *);
530 static inline var_list_t *type_get_function_args(const type_t *func_type)
532 return func_type->details.function->args;
535 static inline enum type_type type_get_type_detect_alias(const type_t *type)
537 if (type->is_alias)
538 return TYPE_ALIAS;
539 return type->type_type;
542 #define STATEMENTS_FOR_EACH_FUNC(stmt, stmts) \
543 if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, statement_t, entry ) \
544 if (stmt->type == STMT_DECLARATION && stmt->u.var->stgclass == STG_NONE && \
545 type_get_type_detect_alias(stmt->u.var->type) == TYPE_FUNCTION)
547 static inline int statements_has_func(const statement_list_t *stmts)
549 const statement_t *stmt;
550 int has_func = 0;
551 STATEMENTS_FOR_EACH_FUNC(stmt, stmts)
553 has_func = 1;
554 break;
556 return has_func;
559 #endif