Release 1.1.37.
[wine/gsoc-2012-control.git] / tools / widl / widltypes.h
bloba44e02aab7fe56211d488bff4f495996727ca7ea
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_ANNOTATION,
76 ATTR_APPOBJECT,
77 ATTR_ASYNC,
78 ATTR_AUTO_HANDLE,
79 ATTR_BINDABLE,
80 ATTR_BROADCAST,
81 ATTR_CALLAS,
82 ATTR_CALLCONV, /* calling convention pseudo-attribute */
83 ATTR_CASE,
84 ATTR_CONST, /* const pseudo-attribute */
85 ATTR_CONTEXTHANDLE,
86 ATTR_CONTROL,
87 ATTR_DEFAULT,
88 ATTR_DEFAULTCOLLELEM,
89 ATTR_DEFAULTVALUE,
90 ATTR_DEFAULTVTABLE,
91 ATTR_DISPINTERFACE,
92 ATTR_DISPLAYBIND,
93 ATTR_DLLNAME,
94 ATTR_DUAL,
95 ATTR_ENDPOINT,
96 ATTR_ENTRY,
97 ATTR_EXPLICIT_HANDLE,
98 ATTR_HANDLE,
99 ATTR_HELPCONTEXT,
100 ATTR_HELPFILE,
101 ATTR_HELPSTRING,
102 ATTR_HELPSTRINGCONTEXT,
103 ATTR_HELPSTRINGDLL,
104 ATTR_HIDDEN,
105 ATTR_ID,
106 ATTR_IDEMPOTENT,
107 ATTR_IIDIS,
108 ATTR_IMMEDIATEBIND,
109 ATTR_IMPLICIT_HANDLE,
110 ATTR_IN,
111 ATTR_INLINE,
112 ATTR_INPUTSYNC,
113 ATTR_LENGTHIS,
114 ATTR_LIBLCID,
115 ATTR_LOCAL,
116 ATTR_NONBROWSABLE,
117 ATTR_NONCREATABLE,
118 ATTR_NONEXTENSIBLE,
119 ATTR_OBJECT,
120 ATTR_ODL,
121 ATTR_OLEAUTOMATION,
122 ATTR_OPTIONAL,
123 ATTR_OUT,
124 ATTR_PARAMLCID,
125 ATTR_POINTERDEFAULT,
126 ATTR_POINTERTYPE,
127 ATTR_PROPGET,
128 ATTR_PROPPUT,
129 ATTR_PROPPUTREF,
130 ATTR_PUBLIC,
131 ATTR_RANGE,
132 ATTR_READONLY,
133 ATTR_REQUESTEDIT,
134 ATTR_RESTRICTED,
135 ATTR_RETVAL,
136 ATTR_SIZEIS,
137 ATTR_SOURCE,
138 ATTR_STRICTCONTEXTHANDLE,
139 ATTR_STRING,
140 ATTR_SWITCHIS,
141 ATTR_SWITCHTYPE,
142 ATTR_TRANSMITAS,
143 ATTR_UUID,
144 ATTR_V1ENUM,
145 ATTR_VARARG,
146 ATTR_VERSION,
147 ATTR_WIREMARSHAL
150 enum expr_type
152 EXPR_VOID,
153 EXPR_NUM,
154 EXPR_HEXNUM,
155 EXPR_DOUBLE,
156 EXPR_IDENTIFIER,
157 EXPR_NEG,
158 EXPR_NOT,
159 EXPR_PPTR,
160 EXPR_CAST,
161 EXPR_SIZEOF,
162 EXPR_SHL,
163 EXPR_SHR,
164 EXPR_MUL,
165 EXPR_DIV,
166 EXPR_ADD,
167 EXPR_SUB,
168 EXPR_AND,
169 EXPR_OR,
170 EXPR_COND,
171 EXPR_TRUEFALSE,
172 EXPR_ADDRESSOF,
173 EXPR_MEMBER,
174 EXPR_ARRAY,
175 EXPR_MOD,
176 EXPR_LOGOR,
177 EXPR_LOGAND,
178 EXPR_XOR,
179 EXPR_EQUALITY,
180 EXPR_INEQUALITY,
181 EXPR_GTR,
182 EXPR_LESS,
183 EXPR_GTREQL,
184 EXPR_LESSEQL,
185 EXPR_LOGNOT,
186 EXPR_POS,
187 EXPR_STRLIT,
188 EXPR_WSTRLIT,
189 EXPR_CHARCONST,
192 enum type_kind
194 TKIND_PRIMITIVE = -1,
195 TKIND_ENUM,
196 TKIND_RECORD,
197 TKIND_MODULE,
198 TKIND_INTERFACE,
199 TKIND_DISPATCH,
200 TKIND_COCLASS,
201 TKIND_ALIAS,
202 TKIND_UNION,
203 TKIND_MAX
206 enum storage_class
208 STG_NONE,
209 STG_STATIC,
210 STG_EXTERN,
211 STG_REGISTER,
214 enum statement_type
216 STMT_LIBRARY,
217 STMT_DECLARATION,
218 STMT_TYPE,
219 STMT_TYPEREF,
220 STMT_MODULE,
221 STMT_TYPEDEF,
222 STMT_IMPORT,
223 STMT_IMPORTLIB,
224 STMT_CPPQUOTE
227 enum type_basic_type
229 TYPE_BASIC_INT8 = 1,
230 TYPE_BASIC_INT16,
231 TYPE_BASIC_INT32,
232 TYPE_BASIC_INT64,
233 TYPE_BASIC_INT,
234 TYPE_BASIC_INT3264,
235 TYPE_BASIC_CHAR,
236 TYPE_BASIC_HYPER,
237 TYPE_BASIC_BYTE,
238 TYPE_BASIC_WCHAR,
239 TYPE_BASIC_FLOAT,
240 TYPE_BASIC_DOUBLE,
241 TYPE_BASIC_ERROR_STATUS_T,
242 TYPE_BASIC_HANDLE,
245 #define TYPE_BASIC_MAX TYPE_BASIC_HANDLE
246 #define TYPE_BASIC_INT_MIN TYPE_BASIC_INT8
247 #define TYPE_BASIC_INT_MAX TYPE_BASIC_HYPER
249 struct _loc_info_t
251 const char *input_name;
252 int line_number;
253 const char *near_text;
256 struct str_list_entry_t
258 char *str;
259 struct list entry;
262 struct _attr_t {
263 enum attr_type type;
264 union {
265 unsigned long ival;
266 void *pval;
267 } u;
268 /* parser-internal */
269 struct list entry;
272 struct _expr_t {
273 enum expr_type type;
274 const expr_t *ref;
275 union {
276 long lval;
277 double dval;
278 const char *sval;
279 const expr_t *ext;
280 type_t *tref;
281 } u;
282 const expr_t *ext2;
283 int is_const;
284 long cval;
285 /* parser-internal */
286 struct list entry;
289 struct struct_details
291 var_list_t *fields;
294 struct enumeration_details
296 var_list_t *enums;
299 struct func_details
301 var_list_t *args;
302 struct _type_t *rettype;
303 int idx;
306 struct iface_details
308 statement_list_t *stmts;
309 func_list_t *disp_methods;
310 var_list_t *disp_props;
311 struct _type_t *inherit;
314 struct module_details
316 statement_list_t *stmts;
317 func_list_t *funcs;
320 struct array_details
322 expr_t *size_is;
323 expr_t *length_is;
324 struct _type_t *elem;
325 unsigned int dim;
326 unsigned char ptr_def_fc;
327 unsigned char declptr; /* if declared as a pointer */
330 struct coclass_details
332 ifref_list_t *ifaces;
335 struct basic_details
337 enum type_basic_type type;
338 int sign;
341 struct pointer_details
343 struct _type_t *ref;
344 unsigned char def_fc;
347 struct bitfield_details
349 struct _type_t *field;
350 const expr_t *bits;
353 enum type_type
355 TYPE_VOID,
356 TYPE_BASIC, /* ints, floats and handles */
357 TYPE_ENUM,
358 TYPE_STRUCT,
359 TYPE_ENCAPSULATED_UNION,
360 TYPE_UNION,
361 TYPE_ALIAS,
362 TYPE_MODULE,
363 TYPE_COCLASS,
364 TYPE_FUNCTION,
365 TYPE_INTERFACE,
366 TYPE_POINTER,
367 TYPE_ARRAY,
368 TYPE_BITFIELD,
371 struct _type_t {
372 const char *name;
373 enum type_type type_type;
374 attr_list_t *attrs;
375 union
377 struct struct_details *structure;
378 struct enumeration_details *enumeration;
379 struct func_details *function;
380 struct iface_details *iface;
381 struct module_details *module;
382 struct array_details array;
383 struct coclass_details coclass;
384 struct basic_details basic;
385 struct pointer_details pointer;
386 struct bitfield_details bitfield;
387 } details;
388 type_t *orig; /* dup'd types */
389 unsigned int typestring_offset;
390 unsigned int ptrdesc; /* used for complex structs */
391 int typelib_idx;
392 loc_info_t loc_info;
393 unsigned int ignore : 1;
394 unsigned int defined : 1;
395 unsigned int written : 1;
396 unsigned int user_types_registered : 1;
397 unsigned int tfswrite : 1; /* if the type needs to be written to the TFS */
398 unsigned int checked : 1;
399 unsigned int is_alias : 1; /* is the type an alias? */
402 struct _var_t {
403 char *name;
404 type_t *type;
405 attr_list_t *attrs;
406 expr_t *eval;
407 enum storage_class stgclass;
409 struct _loc_info_t loc_info;
411 /* parser-internal */
412 struct list entry;
415 struct _declarator_t {
416 var_t *var;
417 type_t *type;
418 type_t *func_type;
419 array_dims_t *array;
420 expr_t *bits;
422 /* parser-internal */
423 struct list entry;
426 struct _func_t {
427 var_t *def;
429 /* parser-internal */
430 struct list entry;
433 struct _ifref_t {
434 type_t *iface;
435 attr_list_t *attrs;
437 /* parser-internal */
438 struct list entry;
441 struct _typelib_entry_t {
442 type_t *type;
443 struct list entry;
446 struct _importinfo_t {
447 int offset;
448 GUID guid;
449 int flags;
450 int id;
452 char *name;
454 importlib_t *importlib;
457 struct _importlib_t {
458 char *name;
460 int version;
461 GUID guid;
463 importinfo_t *importinfos;
464 int ntypeinfos;
466 int allocated;
468 struct list entry;
471 struct _typelib_t {
472 char *name;
473 char *filename;
474 const attr_list_t *attrs;
475 struct list importlibs;
476 statement_list_t *stmts;
479 struct _user_type_t {
480 struct list entry;
481 const char *name;
484 struct _type_list_t {
485 type_t *type;
486 struct _type_list_t *next;
489 struct _statement_t {
490 struct list entry;
491 enum statement_type type;
492 union
494 ifref_t iface;
495 type_t *type;
496 const char *str;
497 var_t *var;
498 typelib_t *lib;
499 type_list_t *type_list;
500 } u;
503 typedef enum {
504 SYS_WIN16,
505 SYS_WIN32,
506 SYS_MAC,
507 SYS_WIN64
508 } syskind_t;
510 extern syskind_t typelib_kind;
511 extern user_type_list_t user_type_list;
512 void check_for_additional_prototype_types(const var_list_t *list);
514 void init_types(void);
515 type_t *alloc_type(void);
516 void set_all_tfswrite(int val);
517 void clear_all_offsets(void);
519 int is_ptr(const type_t *t);
520 int is_array(const type_t *t);
521 int is_var_ptr(const var_t *v);
522 int cant_be_null(const var_t *v);
523 int is_struct(unsigned char tc);
524 int is_union(unsigned char tc);
526 #define tsENUM 1
527 #define tsSTRUCT 2
528 #define tsUNION 3
530 var_t *find_const(const char *name, int f);
531 type_t *find_type(const char *name, int t);
532 type_t *make_type(enum type_type type);
533 type_t *get_type(enum type_type type, char *name, int t);
534 type_t *reg_type(type_t *type, const char *name, int t);
535 void add_incomplete(type_t *t);
537 var_t *make_var(char *name);
538 var_list_t *append_var(var_list_t *list, var_t *var);
540 void init_loc_info(loc_info_t *);
542 static inline var_list_t *type_get_function_args(const type_t *func_type)
544 return func_type->details.function->args;
547 static inline enum type_type type_get_type_detect_alias(const type_t *type)
549 if (type->is_alias)
550 return TYPE_ALIAS;
551 return type->type_type;
554 #define STATEMENTS_FOR_EACH_FUNC(stmt, stmts) \
555 if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, statement_t, entry ) \
556 if (stmt->type == STMT_DECLARATION && stmt->u.var->stgclass == STG_NONE && \
557 type_get_type_detect_alias(stmt->u.var->type) == TYPE_FUNCTION)
559 static inline int statements_has_func(const statement_list_t *stmts)
561 const statement_t *stmt;
562 int has_func = 0;
563 STATEMENTS_FOR_EACH_FUNC(stmt, stmts)
565 has_func = 1;
566 break;
568 return has_func;
571 #endif