Release 1.3.7.
[wine/gsoc-2012-control.git] / tools / widl / widltypes.h
blob40962ed61c8c2b540647728b44ef69ce941d69a9
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 _type_list_t type_list_t;
52 typedef struct _statement_t statement_t;
54 typedef struct list attr_list_t;
55 typedef struct list str_list_t;
56 typedef struct list expr_list_t;
57 typedef struct list var_list_t;
58 typedef struct list declarator_list_t;
59 typedef struct list ifref_list_t;
60 typedef struct list array_dims_t;
61 typedef struct list user_type_list_t;
62 typedef struct list context_handle_list_t;
63 typedef struct list statement_list_t;
65 enum attr_type
67 ATTR_AGGREGATABLE,
68 ATTR_ANNOTATION,
69 ATTR_APPOBJECT,
70 ATTR_ASYNC,
71 ATTR_AUTO_HANDLE,
72 ATTR_BINDABLE,
73 ATTR_BROADCAST,
74 ATTR_CALLAS,
75 ATTR_CALLCONV, /* calling convention pseudo-attribute */
76 ATTR_CASE,
77 ATTR_CODE,
78 ATTR_COMMSTATUS,
79 ATTR_CONST, /* const pseudo-attribute */
80 ATTR_CONTEXTHANDLE,
81 ATTR_CONTROL,
82 ATTR_DECODE,
83 ATTR_DEFAULT,
84 ATTR_DEFAULTBIND,
85 ATTR_DEFAULTCOLLELEM,
86 ATTR_DEFAULTVALUE,
87 ATTR_DEFAULTVTABLE,
88 ATTR_DISABLECONSISTENCYCHECK,
89 ATTR_DISPINTERFACE,
90 ATTR_DISPLAYBIND,
91 ATTR_DLLNAME,
92 ATTR_DUAL,
93 ATTR_ENABLEALLOCATE,
94 ATTR_ENCODE,
95 ATTR_ENDPOINT,
96 ATTR_ENTRY,
97 ATTR_EXPLICIT_HANDLE,
98 ATTR_FAULTSTATUS,
99 ATTR_FORCEALLOCATE,
100 ATTR_HANDLE,
101 ATTR_HELPCONTEXT,
102 ATTR_HELPFILE,
103 ATTR_HELPSTRING,
104 ATTR_HELPSTRINGCONTEXT,
105 ATTR_HELPSTRINGDLL,
106 ATTR_HIDDEN,
107 ATTR_ID,
108 ATTR_IDEMPOTENT,
109 ATTR_IGNORE,
110 ATTR_IIDIS,
111 ATTR_IMMEDIATEBIND,
112 ATTR_IMPLICIT_HANDLE,
113 ATTR_IN,
114 ATTR_INLINE,
115 ATTR_INPUTSYNC,
116 ATTR_LENGTHIS,
117 ATTR_LIBLCID,
118 ATTR_LICENSED,
119 ATTR_LOCAL,
120 ATTR_MAYBE,
121 ATTR_MESSAGE,
122 ATTR_NOCODE,
123 ATTR_NONBROWSABLE,
124 ATTR_NONCREATABLE,
125 ATTR_NONEXTENSIBLE,
126 ATTR_NOTIFY,
127 ATTR_NOTIFYFLAG,
128 ATTR_OBJECT,
129 ATTR_ODL,
130 ATTR_OLEAUTOMATION,
131 ATTR_OPTIMIZE,
132 ATTR_OPTIONAL,
133 ATTR_OUT,
134 ATTR_PARAMLCID,
135 ATTR_PARTIALIGNORE,
136 ATTR_POINTERDEFAULT,
137 ATTR_POINTERTYPE,
138 ATTR_PROPGET,
139 ATTR_PROPPUT,
140 ATTR_PROPPUTREF,
141 ATTR_PROXY,
142 ATTR_PUBLIC,
143 ATTR_RANGE,
144 ATTR_READONLY,
145 ATTR_REPRESENTAS,
146 ATTR_REQUESTEDIT,
147 ATTR_RESTRICTED,
148 ATTR_RETVAL,
149 ATTR_SIZEIS,
150 ATTR_SOURCE,
151 ATTR_STRICTCONTEXTHANDLE,
152 ATTR_STRING,
153 ATTR_SWITCHIS,
154 ATTR_SWITCHTYPE,
155 ATTR_TRANSMITAS,
156 ATTR_UIDEFAULT,
157 ATTR_USERMARSHAL,
158 ATTR_USESGETLASTERROR,
159 ATTR_UUID,
160 ATTR_V1ENUM,
161 ATTR_VARARG,
162 ATTR_VERSION,
163 ATTR_WIREMARSHAL
166 enum expr_type
168 EXPR_VOID,
169 EXPR_NUM,
170 EXPR_HEXNUM,
171 EXPR_DOUBLE,
172 EXPR_IDENTIFIER,
173 EXPR_NEG,
174 EXPR_NOT,
175 EXPR_PPTR,
176 EXPR_CAST,
177 EXPR_SIZEOF,
178 EXPR_SHL,
179 EXPR_SHR,
180 EXPR_MUL,
181 EXPR_DIV,
182 EXPR_ADD,
183 EXPR_SUB,
184 EXPR_AND,
185 EXPR_OR,
186 EXPR_COND,
187 EXPR_TRUEFALSE,
188 EXPR_ADDRESSOF,
189 EXPR_MEMBER,
190 EXPR_ARRAY,
191 EXPR_MOD,
192 EXPR_LOGOR,
193 EXPR_LOGAND,
194 EXPR_XOR,
195 EXPR_EQUALITY,
196 EXPR_INEQUALITY,
197 EXPR_GTR,
198 EXPR_LESS,
199 EXPR_GTREQL,
200 EXPR_LESSEQL,
201 EXPR_LOGNOT,
202 EXPR_POS,
203 EXPR_STRLIT,
204 EXPR_WSTRLIT,
205 EXPR_CHARCONST,
208 enum type_kind
210 TKIND_PRIMITIVE = -1,
211 TKIND_ENUM,
212 TKIND_RECORD,
213 TKIND_MODULE,
214 TKIND_INTERFACE,
215 TKIND_DISPATCH,
216 TKIND_COCLASS,
217 TKIND_ALIAS,
218 TKIND_UNION,
219 TKIND_MAX
222 enum storage_class
224 STG_NONE,
225 STG_STATIC,
226 STG_EXTERN,
227 STG_REGISTER,
230 enum statement_type
232 STMT_LIBRARY,
233 STMT_DECLARATION,
234 STMT_TYPE,
235 STMT_TYPEREF,
236 STMT_MODULE,
237 STMT_TYPEDEF,
238 STMT_IMPORT,
239 STMT_IMPORTLIB,
240 STMT_CPPQUOTE
243 enum type_basic_type
245 TYPE_BASIC_INT8 = 1,
246 TYPE_BASIC_INT16,
247 TYPE_BASIC_INT32,
248 TYPE_BASIC_INT64,
249 TYPE_BASIC_INT,
250 TYPE_BASIC_INT3264,
251 TYPE_BASIC_CHAR,
252 TYPE_BASIC_HYPER,
253 TYPE_BASIC_BYTE,
254 TYPE_BASIC_WCHAR,
255 TYPE_BASIC_FLOAT,
256 TYPE_BASIC_DOUBLE,
257 TYPE_BASIC_ERROR_STATUS_T,
258 TYPE_BASIC_HANDLE,
261 #define TYPE_BASIC_MAX TYPE_BASIC_HANDLE
262 #define TYPE_BASIC_INT_MIN TYPE_BASIC_INT8
263 #define TYPE_BASIC_INT_MAX TYPE_BASIC_HYPER
265 struct _loc_info_t
267 const char *input_name;
268 int line_number;
269 const char *near_text;
272 struct str_list_entry_t
274 char *str;
275 struct list entry;
278 struct _attr_t {
279 enum attr_type type;
280 union {
281 unsigned int ival;
282 void *pval;
283 } u;
284 /* parser-internal */
285 struct list entry;
288 struct _expr_t {
289 enum expr_type type;
290 const expr_t *ref;
291 union {
292 int lval;
293 double dval;
294 const char *sval;
295 const expr_t *ext;
296 type_t *tref;
297 } u;
298 const expr_t *ext2;
299 int is_const;
300 int cval;
301 /* parser-internal */
302 struct list entry;
305 struct struct_details
307 var_list_t *fields;
310 struct enumeration_details
312 var_list_t *enums;
315 struct func_details
317 var_list_t *args;
318 struct _type_t *rettype;
319 int idx;
322 struct iface_details
324 statement_list_t *stmts;
325 var_list_t *disp_methods;
326 var_list_t *disp_props;
327 struct _type_t *inherit;
330 struct module_details
332 statement_list_t *stmts;
335 struct array_details
337 expr_t *size_is;
338 expr_t *length_is;
339 struct _type_t *elem;
340 unsigned int dim;
341 unsigned char ptr_def_fc;
342 unsigned char declptr; /* if declared as a pointer */
345 struct coclass_details
347 ifref_list_t *ifaces;
350 struct basic_details
352 enum type_basic_type type;
353 int sign;
356 struct pointer_details
358 struct _type_t *ref;
359 unsigned char def_fc;
362 struct bitfield_details
364 struct _type_t *field;
365 const expr_t *bits;
368 enum type_type
370 TYPE_VOID,
371 TYPE_BASIC, /* ints, floats and handles */
372 TYPE_ENUM,
373 TYPE_STRUCT,
374 TYPE_ENCAPSULATED_UNION,
375 TYPE_UNION,
376 TYPE_ALIAS,
377 TYPE_MODULE,
378 TYPE_COCLASS,
379 TYPE_FUNCTION,
380 TYPE_INTERFACE,
381 TYPE_POINTER,
382 TYPE_ARRAY,
383 TYPE_BITFIELD,
386 struct _type_t {
387 const char *name;
388 enum type_type type_type;
389 attr_list_t *attrs;
390 union
392 struct struct_details *structure;
393 struct enumeration_details *enumeration;
394 struct func_details *function;
395 struct iface_details *iface;
396 struct module_details *module;
397 struct array_details array;
398 struct coclass_details coclass;
399 struct basic_details basic;
400 struct pointer_details pointer;
401 struct bitfield_details bitfield;
402 } details;
403 type_t *orig; /* dup'd types */
404 unsigned int typestring_offset;
405 unsigned int ptrdesc; /* used for complex structs */
406 int typelib_idx;
407 loc_info_t loc_info;
408 unsigned int ignore : 1;
409 unsigned int defined : 1;
410 unsigned int written : 1;
411 unsigned int user_types_registered : 1;
412 unsigned int tfswrite : 1; /* if the type needs to be written to the TFS */
413 unsigned int checked : 1;
414 unsigned int is_alias : 1; /* is the type an alias? */
417 struct _var_t {
418 char *name;
419 type_t *type;
420 attr_list_t *attrs;
421 expr_t *eval;
422 enum storage_class stgclass;
423 unsigned int procstring_offset;
425 struct _loc_info_t loc_info;
427 /* parser-internal */
428 struct list entry;
431 struct _declarator_t {
432 var_t *var;
433 type_t *type;
434 type_t *func_type;
435 array_dims_t *array;
436 expr_t *bits;
438 /* parser-internal */
439 struct list entry;
442 struct _ifref_t {
443 type_t *iface;
444 attr_list_t *attrs;
446 /* parser-internal */
447 struct list entry;
450 struct _typelib_entry_t {
451 type_t *type;
452 struct list entry;
455 struct _importinfo_t {
456 int offset;
457 GUID guid;
458 int flags;
459 int id;
461 char *name;
463 importlib_t *importlib;
466 struct _importlib_t {
467 char *name;
469 int version;
470 GUID guid;
472 importinfo_t *importinfos;
473 int ntypeinfos;
475 int allocated;
477 struct list entry;
480 struct _typelib_t {
481 char *name;
482 char *filename;
483 const attr_list_t *attrs;
484 struct list importlibs;
485 statement_list_t *stmts;
488 struct _user_type_t {
489 struct list entry;
490 const char *name;
493 struct _type_list_t {
494 type_t *type;
495 struct _type_list_t *next;
498 struct _statement_t {
499 struct list entry;
500 enum statement_type type;
501 union
503 ifref_t iface;
504 type_t *type;
505 const char *str;
506 var_t *var;
507 typelib_t *lib;
508 type_list_t *type_list;
509 } u;
512 typedef enum {
513 SYS_WIN16,
514 SYS_WIN32,
515 SYS_MAC,
516 SYS_WIN64
517 } syskind_t;
519 extern syskind_t typelib_kind;
520 extern user_type_list_t user_type_list;
521 void check_for_additional_prototype_types(const var_list_t *list);
523 void init_types(void);
524 type_t *alloc_type(void);
525 void set_all_tfswrite(int val);
526 void clear_all_offsets(void);
528 int is_ptr(const type_t *t);
529 int is_array(const type_t *t);
530 int is_var_ptr(const var_t *v);
531 int cant_be_null(const var_t *v);
533 #define tsENUM 1
534 #define tsSTRUCT 2
535 #define tsUNION 3
537 var_t *find_const(const char *name, int f);
538 type_t *find_type(const char *name, int t);
539 type_t *make_type(enum type_type type);
540 type_t *get_type(enum type_type type, char *name, int t);
541 type_t *reg_type(type_t *type, const char *name, int t);
542 void add_incomplete(type_t *t);
544 var_t *make_var(char *name);
545 var_list_t *append_var(var_list_t *list, var_t *var);
547 void init_loc_info(loc_info_t *);
549 static inline var_list_t *type_get_function_args(const type_t *func_type)
551 return func_type->details.function->args;
554 static inline enum type_type type_get_type_detect_alias(const type_t *type)
556 if (type->is_alias)
557 return TYPE_ALIAS;
558 return type->type_type;
561 #define STATEMENTS_FOR_EACH_FUNC(stmt, stmts) \
562 if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, statement_t, entry ) \
563 if (stmt->type == STMT_DECLARATION && stmt->u.var->stgclass == STG_NONE && \
564 type_get_type_detect_alias(stmt->u.var->type) == TYPE_FUNCTION)
566 static inline int statements_has_func(const statement_list_t *stmts)
568 const statement_t *stmt;
569 int has_func = 0;
570 STATEMENTS_FOR_EACH_FUNC(stmt, stmts)
572 has_func = 1;
573 break;
575 return has_func;
578 #endif