devenum/tests: Use wide character string literals.
[wine.git] / tools / widl / widltypes.h
blob085a0ff55f58c0bc898e9e02e976d70840af00f9
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 "ndrtypes.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 _decl_spec_t decl_spec_t;
44 typedef struct _declarator_t declarator_t;
45 typedef struct _ifref_t ifref_t;
46 typedef struct _typelib_entry_t typelib_entry_t;
47 typedef struct _importlib_t importlib_t;
48 typedef struct _importinfo_t importinfo_t;
49 typedef struct _typelib_t typelib_t;
50 typedef struct _user_type_t user_type_t;
51 typedef struct _user_type_t context_handle_t;
52 typedef struct _user_type_t generic_handle_t;
53 typedef struct _type_list_t type_list_t;
54 typedef struct _statement_t statement_t;
55 typedef struct _warning_t warning_t;
57 typedef struct list attr_list_t;
58 typedef struct list str_list_t;
59 typedef struct list expr_list_t;
60 typedef struct list var_list_t;
61 typedef struct list declarator_list_t;
62 typedef struct list ifref_list_t;
63 typedef struct list user_type_list_t;
64 typedef struct list context_handle_list_t;
65 typedef struct list generic_handle_list_t;
66 typedef struct list statement_list_t;
67 typedef struct list warning_list_t;
69 enum attr_type
71 ATTR_AGGREGATABLE,
72 ATTR_ANNOTATION,
73 ATTR_APPOBJECT,
74 ATTR_ASYNC,
75 ATTR_ASYNCUUID,
76 ATTR_AUTO_HANDLE,
77 ATTR_BINDABLE,
78 ATTR_BROADCAST,
79 ATTR_CALLAS,
80 ATTR_CALLCONV, /* calling convention pseudo-attribute */
81 ATTR_CASE,
82 ATTR_CODE,
83 ATTR_COMMSTATUS,
84 ATTR_CONTEXTHANDLE,
85 ATTR_CONTROL,
86 ATTR_DECODE,
87 ATTR_DEFAULT,
88 ATTR_DEFAULTBIND,
89 ATTR_DEFAULTCOLLELEM,
90 ATTR_DEFAULTVALUE,
91 ATTR_DEFAULTVTABLE,
92 ATTR_DISABLECONSISTENCYCHECK,
93 ATTR_DISPINTERFACE,
94 ATTR_DISPLAYBIND,
95 ATTR_DLLNAME,
96 ATTR_DUAL,
97 ATTR_ENABLEALLOCATE,
98 ATTR_ENCODE,
99 ATTR_ENDPOINT,
100 ATTR_ENTRY,
101 ATTR_EXPLICIT_HANDLE,
102 ATTR_FAULTSTATUS,
103 ATTR_FORCEALLOCATE,
104 ATTR_HANDLE,
105 ATTR_HELPCONTEXT,
106 ATTR_HELPFILE,
107 ATTR_HELPSTRING,
108 ATTR_HELPSTRINGCONTEXT,
109 ATTR_HELPSTRINGDLL,
110 ATTR_HIDDEN,
111 ATTR_ID,
112 ATTR_IDEMPOTENT,
113 ATTR_IGNORE,
114 ATTR_IIDIS,
115 ATTR_IMMEDIATEBIND,
116 ATTR_IMPLICIT_HANDLE,
117 ATTR_IN,
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 type_qualifier
238 TYPE_QUALIFIER_CONST = 1,
241 enum function_specifier
243 FUNCTION_SPECIFIER_INLINE = 1,
246 enum statement_type
248 STMT_LIBRARY,
249 STMT_DECLARATION,
250 STMT_TYPE,
251 STMT_TYPEREF,
252 STMT_MODULE,
253 STMT_TYPEDEF,
254 STMT_IMPORT,
255 STMT_IMPORTLIB,
256 STMT_PRAGMA,
257 STMT_CPPQUOTE
260 enum threading_type
262 THREADING_APARTMENT = 1,
263 THREADING_NEUTRAL,
264 THREADING_SINGLE,
265 THREADING_FREE,
266 THREADING_BOTH
269 enum type_basic_type
271 TYPE_BASIC_INT8 = 1,
272 TYPE_BASIC_INT16,
273 TYPE_BASIC_INT32,
274 TYPE_BASIC_INT64,
275 TYPE_BASIC_INT,
276 TYPE_BASIC_INT3264,
277 TYPE_BASIC_LONG,
278 TYPE_BASIC_CHAR,
279 TYPE_BASIC_HYPER,
280 TYPE_BASIC_BYTE,
281 TYPE_BASIC_WCHAR,
282 TYPE_BASIC_FLOAT,
283 TYPE_BASIC_DOUBLE,
284 TYPE_BASIC_ERROR_STATUS_T,
285 TYPE_BASIC_HANDLE,
288 #define TYPE_BASIC_MAX TYPE_BASIC_HANDLE
289 #define TYPE_BASIC_INT_MIN TYPE_BASIC_INT8
290 #define TYPE_BASIC_INT_MAX TYPE_BASIC_HYPER
292 struct _loc_info_t
294 const char *input_name;
295 int line_number;
296 const char *near_text;
299 struct str_list_entry_t
301 char *str;
302 struct list entry;
305 struct _decl_spec_t
307 type_t *type;
308 enum storage_class stgclass;
309 enum type_qualifier qualifier;
310 enum function_specifier func_specifier;
313 struct _attr_t {
314 enum attr_type type;
315 union {
316 unsigned int ival;
317 void *pval;
318 } u;
319 /* parser-internal */
320 struct list entry;
323 struct _expr_t {
324 enum expr_type type;
325 const expr_t *ref;
326 union {
327 int lval;
328 double dval;
329 const char *sval;
330 const expr_t *ext;
331 decl_spec_t tref;
332 } u;
333 const expr_t *ext2;
334 int is_const;
335 int cval;
336 /* parser-internal */
337 struct list entry;
340 struct struct_details
342 var_list_t *fields;
345 struct enumeration_details
347 var_list_t *enums;
350 struct func_details
352 var_list_t *args;
353 struct _var_t *retval;
356 struct iface_details
358 statement_list_t *stmts;
359 var_list_t *disp_methods;
360 var_list_t *disp_props;
361 struct _type_t *inherit;
362 struct _type_t *disp_inherit;
363 struct _type_t *async_iface;
366 struct module_details
368 statement_list_t *stmts;
371 struct array_details
373 expr_t *size_is;
374 expr_t *length_is;
375 struct _decl_spec_t elem;
376 unsigned int dim;
377 unsigned char declptr; /* if declared as a pointer */
378 unsigned short ptr_tfsoff; /* offset of pointer definition for declptr */
381 struct coclass_details
383 ifref_list_t *ifaces;
386 struct basic_details
388 enum type_basic_type type;
389 int sign;
392 struct pointer_details
394 struct _decl_spec_t ref;
397 struct bitfield_details
399 struct _type_t *field;
400 const expr_t *bits;
403 struct alias_details
405 struct _decl_spec_t aliasee;
408 #define HASHMAX 64
410 struct namespace {
411 const char *name;
412 struct namespace *parent;
413 struct list entry;
414 struct list children;
415 struct rtype *type_hash[HASHMAX];
418 enum type_type
420 TYPE_VOID,
421 TYPE_BASIC, /* ints, floats and handles */
422 TYPE_ENUM,
423 TYPE_STRUCT,
424 TYPE_ENCAPSULATED_UNION,
425 TYPE_UNION,
426 TYPE_ALIAS,
427 TYPE_MODULE,
428 TYPE_COCLASS,
429 TYPE_FUNCTION,
430 TYPE_INTERFACE,
431 TYPE_POINTER,
432 TYPE_ARRAY,
433 TYPE_BITFIELD,
436 struct _type_t {
437 const char *name;
438 struct namespace *namespace;
439 enum type_type type_type;
440 attr_list_t *attrs;
441 union
443 struct struct_details *structure;
444 struct enumeration_details *enumeration;
445 struct func_details *function;
446 struct iface_details *iface;
447 struct module_details *module;
448 struct array_details array;
449 struct coclass_details coclass;
450 struct basic_details basic;
451 struct pointer_details pointer;
452 struct bitfield_details bitfield;
453 struct alias_details alias;
454 } details;
455 const char *c_name;
456 unsigned int typestring_offset;
457 unsigned int ptrdesc; /* used for complex structs */
458 int typelib_idx;
459 loc_info_t loc_info;
460 unsigned int ignore : 1;
461 unsigned int defined : 1;
462 unsigned int written : 1;
463 unsigned int user_types_registered : 1;
464 unsigned int tfswrite : 1; /* if the type needs to be written to the TFS */
465 unsigned int checked : 1;
468 struct _var_t {
469 char *name;
470 decl_spec_t declspec;
471 attr_list_t *attrs;
472 expr_t *eval;
474 unsigned int typestring_offset;
476 /* fields specific to functions */
477 unsigned int procstring_offset, func_idx;
479 struct _loc_info_t loc_info;
481 unsigned int declonly : 1;
483 /* parser-internal */
484 struct list entry;
487 struct _declarator_t {
488 var_t *var;
489 type_t *type;
490 enum type_qualifier qualifier;
491 expr_t *bits;
493 /* parser-internal */
494 struct list entry;
497 struct _ifref_t {
498 type_t *iface;
499 attr_list_t *attrs;
501 /* parser-internal */
502 struct list entry;
505 struct _typelib_entry_t {
506 type_t *type;
507 struct list entry;
510 struct _importinfo_t {
511 int offset;
512 GUID guid;
513 int flags;
514 int id;
516 char *name;
518 importlib_t *importlib;
521 struct _importlib_t {
522 int offset;
523 char *name;
525 int version;
526 GUID guid;
528 importinfo_t *importinfos;
529 int ntypeinfos;
531 int allocated;
533 struct list entry;
536 struct _typelib_t {
537 char *name;
538 const attr_list_t *attrs;
539 struct list importlibs;
540 statement_list_t *stmts;
542 type_t **reg_ifaces;
543 unsigned int reg_iface_count;
546 struct _user_type_t {
547 struct list entry;
548 const char *name;
551 struct _type_list_t {
552 type_t *type;
553 struct _type_list_t *next;
556 struct _statement_t {
557 struct list entry;
558 enum statement_type type;
559 union
561 ifref_t iface;
562 type_t *type;
563 const char *str;
564 var_t *var;
565 typelib_t *lib;
566 type_list_t *type_list;
567 } u;
568 unsigned int declonly : 1; /* for STMT_TYPE and STMT_TYPEDEF */
571 struct _warning_t {
572 int num;
573 struct list entry;
576 typedef enum {
577 SYS_WIN16,
578 SYS_WIN32,
579 SYS_MAC,
580 SYS_WIN64
581 } syskind_t;
583 extern user_type_list_t user_type_list;
584 extern context_handle_list_t context_handle_list;
585 extern generic_handle_list_t generic_handle_list;
586 void check_for_additional_prototype_types(type_t *type);
588 void init_types(void);
589 type_t *alloc_type(void);
590 void set_all_tfswrite(int val);
591 void clear_all_offsets(void);
593 #define tsENUM 1
594 #define tsSTRUCT 2
595 #define tsUNION 3
597 var_t *find_const(const char *name, int f);
598 type_t *find_type(const char *name, struct namespace *namespace, int t);
599 type_t *make_type(enum type_type type);
600 type_t *get_type(enum type_type type, char *name, struct namespace *namespace, int t);
601 type_t *reg_type(type_t *type, const char *name, struct namespace *namespace, int t);
603 var_t *make_var(char *name);
604 var_list_t *append_var(var_list_t *list, var_t *var);
606 void init_loc_info(loc_info_t *);
608 char *format_namespace(struct namespace *namespace, const char *prefix, const char *separator, const char *suffix);
610 static inline enum type_type type_get_type_detect_alias(const type_t *type)
612 return type->type_type;
615 #define STATEMENTS_FOR_EACH_FUNC(stmt, stmts) \
616 if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, statement_t, entry ) \
617 if (stmt->type == STMT_DECLARATION && stmt->u.var->declspec.stgclass == STG_NONE && \
618 type_get_type_detect_alias(stmt->u.var->declspec.type) == TYPE_FUNCTION)
620 static inline int statements_has_func(const statement_list_t *stmts)
622 const statement_t *stmt;
623 int has_func = 0;
624 STATEMENTS_FOR_EACH_FUNC(stmt, stmts)
626 has_func = 1;
627 break;
629 return has_func;
632 static inline int is_global_namespace(const struct namespace *namespace)
634 return !namespace->name;
637 static inline decl_spec_t *init_declspec(decl_spec_t *declspec, type_t *type)
639 declspec->type = type;
640 declspec->stgclass = STG_NONE;
641 declspec->qualifier = 0;
642 declspec->func_specifier = 0;
644 return declspec;
647 #endif