wineps: Don't use CDECL for private functions.
[wine.git] / tools / widl / widltypes.h
blobad6a4e0b7ecdc7ff8eeb04c8632e728358ce755e
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 "ndrtypes.h"
27 #include "wine/list.h"
29 struct uuid
31 unsigned int Data1;
32 unsigned short Data2;
33 unsigned short Data3;
34 unsigned char Data4[8];
37 #define TRUE 1
38 #define FALSE 0
40 typedef struct _attr_t attr_t;
41 typedef struct _attr_custdata_t attr_custdata_t;
42 typedef struct _expr_t expr_t;
43 typedef struct _type_t type_t;
44 typedef struct _var_t var_t;
45 typedef struct _decl_spec_t decl_spec_t;
46 typedef struct _declarator_t declarator_t;
47 typedef struct _typeref_t typeref_t;
48 typedef struct _typelib_entry_t typelib_entry_t;
49 typedef struct _importlib_t importlib_t;
50 typedef struct _importinfo_t importinfo_t;
51 typedef struct _typelib_t typelib_t;
52 typedef struct _user_type_t user_type_t;
53 typedef struct _user_type_t context_handle_t;
54 typedef struct _user_type_t generic_handle_t;
55 typedef struct _statement_t statement_t;
56 typedef struct _warning_t warning_t;
58 typedef struct list attr_list_t;
59 typedef struct list str_list_t;
60 typedef struct list expr_list_t;
61 typedef struct list var_list_t;
62 typedef struct list declarator_list_t;
63 typedef struct list typeref_list_t;
64 typedef struct list user_type_list_t;
65 typedef struct list context_handle_list_t;
66 typedef struct list generic_handle_list_t;
67 typedef struct list statement_list_t;
68 typedef struct list warning_list_t;
70 enum attr_type
72 ATTR_ACTIVATABLE,
73 ATTR_AGGREGATABLE,
74 ATTR_ALLOCATE,
75 ATTR_ANNOTATION,
76 ATTR_APPOBJECT,
77 ATTR_ASYNC,
78 ATTR_ASYNCUUID,
79 ATTR_AUTO_HANDLE,
80 ATTR_BINDABLE,
81 ATTR_BROADCAST,
82 ATTR_CALLAS,
83 ATTR_CALLCONV, /* calling convention pseudo-attribute */
84 ATTR_CASE,
85 ATTR_CODE,
86 ATTR_COMMSTATUS,
87 ATTR_COMPOSABLE,
88 ATTR_CONTEXTHANDLE,
89 ATTR_CONTRACT,
90 ATTR_CONTRACTVERSION,
91 ATTR_CONTROL,
92 ATTR_CUSTOM,
93 ATTR_DECODE,
94 ATTR_DEFAULT,
95 ATTR_DEFAULTBIND,
96 ATTR_DEFAULTCOLLELEM,
97 ATTR_DEFAULTVALUE,
98 ATTR_DEFAULTVTABLE,
99 ATTR_DISABLECONSISTENCYCHECK,
100 ATTR_DISPINTERFACE,
101 ATTR_DISPLAYBIND,
102 ATTR_DLLNAME,
103 ATTR_DUAL,
104 ATTR_ENABLEALLOCATE,
105 ATTR_ENCODE,
106 ATTR_ENDPOINT,
107 ATTR_ENTRY,
108 ATTR_EVENTADD,
109 ATTR_EVENTREMOVE,
110 ATTR_EXCLUSIVETO,
111 ATTR_EXPLICIT_HANDLE,
112 ATTR_FAULTSTATUS,
113 ATTR_FLAGS,
114 ATTR_FORCEALLOCATE,
115 ATTR_HANDLE,
116 ATTR_HELPCONTEXT,
117 ATTR_HELPFILE,
118 ATTR_HELPSTRING,
119 ATTR_HELPSTRINGCONTEXT,
120 ATTR_HELPSTRINGDLL,
121 ATTR_HIDDEN,
122 ATTR_ID,
123 ATTR_IDEMPOTENT,
124 ATTR_IGNORE,
125 ATTR_IIDIS,
126 ATTR_IMMEDIATEBIND,
127 ATTR_IMPLICIT_HANDLE,
128 ATTR_IN,
129 ATTR_INPUTSYNC,
130 ATTR_LENGTHIS,
131 ATTR_LIBLCID,
132 ATTR_LICENSED,
133 ATTR_LOCAL,
134 ATTR_MARSHALING_BEHAVIOR,
135 ATTR_MAYBE,
136 ATTR_MESSAGE,
137 ATTR_NOCODE,
138 ATTR_NONBROWSABLE,
139 ATTR_NONCREATABLE,
140 ATTR_NONEXTENSIBLE,
141 ATTR_NOTIFY,
142 ATTR_NOTIFYFLAG,
143 ATTR_OBJECT,
144 ATTR_ODL,
145 ATTR_OLEAUTOMATION,
146 ATTR_OPTIMIZE,
147 ATTR_OPTIONAL,
148 ATTR_OUT,
149 ATTR_OVERLOAD,
150 ATTR_PARAMLCID,
151 ATTR_PARTIALIGNORE,
152 ATTR_POINTERDEFAULT,
153 ATTR_POINTERTYPE,
154 ATTR_PROGID,
155 ATTR_PROPGET,
156 ATTR_PROPPUT,
157 ATTR_PROPPUTREF,
158 ATTR_PROTECTED,
159 ATTR_PROXY,
160 ATTR_PUBLIC,
161 ATTR_RANGE,
162 ATTR_READONLY,
163 ATTR_REPRESENTAS,
164 ATTR_REQUESTEDIT,
165 ATTR_RESTRICTED,
166 ATTR_RETVAL,
167 ATTR_SIZEIS,
168 ATTR_SOURCE,
169 ATTR_STATIC,
170 ATTR_STRICTCONTEXTHANDLE,
171 ATTR_STRING,
172 ATTR_SWITCHIS,
173 ATTR_SWITCHTYPE,
174 ATTR_THREADING,
175 ATTR_TRANSMITAS,
176 ATTR_UIDEFAULT,
177 ATTR_USERMARSHAL,
178 ATTR_USESGETLASTERROR,
179 ATTR_UUID,
180 ATTR_V1ENUM,
181 ATTR_VARARG,
182 ATTR_VERSION,
183 ATTR_VIPROGID,
184 ATTR_WIREMARSHAL
187 enum expr_type
189 EXPR_VOID,
190 EXPR_NUM,
191 EXPR_HEXNUM,
192 EXPR_DOUBLE,
193 EXPR_IDENTIFIER,
194 EXPR_NEG,
195 EXPR_NOT,
196 EXPR_PPTR,
197 EXPR_CAST,
198 EXPR_SIZEOF,
199 EXPR_SHL,
200 EXPR_SHR,
201 EXPR_MUL,
202 EXPR_DIV,
203 EXPR_ADD,
204 EXPR_SUB,
205 EXPR_AND,
206 EXPR_OR,
207 EXPR_COND,
208 EXPR_TRUEFALSE,
209 EXPR_ADDRESSOF,
210 EXPR_MEMBER,
211 EXPR_ARRAY,
212 EXPR_MOD,
213 EXPR_LOGOR,
214 EXPR_LOGAND,
215 EXPR_XOR,
216 EXPR_EQUALITY,
217 EXPR_INEQUALITY,
218 EXPR_GTR,
219 EXPR_LESS,
220 EXPR_GTREQL,
221 EXPR_LESSEQL,
222 EXPR_LOGNOT,
223 EXPR_POS,
224 EXPR_STRLIT,
225 EXPR_WSTRLIT,
226 EXPR_CHARCONST,
229 enum type_kind
231 TKIND_PRIMITIVE = -1,
232 TKIND_ENUM,
233 TKIND_RECORD,
234 TKIND_MODULE,
235 TKIND_INTERFACE,
236 TKIND_DISPATCH,
237 TKIND_COCLASS,
238 TKIND_ALIAS,
239 TKIND_UNION,
240 TKIND_MAX
243 enum storage_class
245 STG_NONE,
246 STG_STATIC,
247 STG_EXTERN,
248 STG_REGISTER,
251 enum type_qualifier
253 TYPE_QUALIFIER_CONST = 1,
256 enum function_specifier
258 FUNCTION_SPECIFIER_INLINE = 1,
261 enum statement_type
263 STMT_LIBRARY,
264 STMT_DECLARATION,
265 STMT_TYPE,
266 STMT_TYPEREF,
267 STMT_MODULE,
268 STMT_TYPEDEF,
269 STMT_IMPORT,
270 STMT_IMPORTLIB,
271 STMT_PRAGMA,
272 STMT_CPPQUOTE
275 enum threading_type
277 THREADING_APARTMENT = 1,
278 THREADING_NEUTRAL,
279 THREADING_SINGLE,
280 THREADING_FREE,
281 THREADING_BOTH
284 enum marshaling_type
286 MARSHALING_INVALID = 0,
287 MARSHALING_NONE,
288 MARSHALING_AGILE,
289 MARSHALING_STANDARD,
292 enum type_basic_type
294 TYPE_BASIC_INT8 = 1,
295 TYPE_BASIC_INT16,
296 TYPE_BASIC_INT32,
297 TYPE_BASIC_INT64,
298 TYPE_BASIC_INT,
299 TYPE_BASIC_INT3264,
300 TYPE_BASIC_LONG,
301 TYPE_BASIC_CHAR,
302 TYPE_BASIC_HYPER,
303 TYPE_BASIC_BYTE,
304 TYPE_BASIC_WCHAR,
305 TYPE_BASIC_FLOAT,
306 TYPE_BASIC_DOUBLE,
307 TYPE_BASIC_ERROR_STATUS_T,
308 TYPE_BASIC_HANDLE,
311 #define TYPE_BASIC_MAX TYPE_BASIC_HANDLE
312 #define TYPE_BASIC_INT_MIN TYPE_BASIC_INT8
313 #define TYPE_BASIC_INT_MAX TYPE_BASIC_HYPER
315 struct location
317 const char *input_name;
318 int first_line;
319 int last_line;
320 int first_column;
321 int last_column;
324 struct str_list_entry_t
326 char *str;
327 struct list entry;
330 struct _decl_spec_t
332 type_t *type;
333 enum storage_class stgclass;
334 enum type_qualifier qualifier;
335 enum function_specifier func_specifier;
338 struct _attr_t {
339 enum attr_type type;
340 union {
341 unsigned int ival;
342 void *pval;
343 } u;
344 /* parser-internal */
345 struct list entry;
346 struct location where;
349 struct _expr_t {
350 enum expr_type type;
351 const expr_t *ref;
352 union {
353 int lval;
354 double dval;
355 const char *sval;
356 const expr_t *ext;
357 decl_spec_t tref;
358 } u;
359 const expr_t *ext2;
360 int is_const;
361 int cval;
362 /* parser-internal */
363 struct list entry;
366 struct _attr_custdata_t {
367 struct uuid id;
368 expr_t *pval;
371 struct struct_details
373 var_list_t *fields;
376 struct enumeration_details
378 var_list_t *enums;
381 struct func_details
383 var_list_t *args;
384 struct _var_t *retval;
387 struct iface_details
389 statement_list_t *stmts;
390 var_list_t *disp_methods;
391 var_list_t *disp_props;
392 struct _type_t *inherit;
393 struct _type_t *disp_inherit;
394 struct _type_t *async_iface;
395 typeref_list_t *requires;
398 struct module_details
400 statement_list_t *stmts;
403 struct array_details
405 expr_t *size_is;
406 expr_t *length_is;
407 struct _decl_spec_t elem;
408 unsigned int dim;
409 unsigned char declptr; /* if declared as a pointer */
410 unsigned short ptr_tfsoff; /* offset of pointer definition for declptr */
413 struct coclass_details
415 typeref_list_t *ifaces;
418 struct basic_details
420 enum type_basic_type type;
421 int sign;
424 struct pointer_details
426 struct _decl_spec_t ref;
429 struct bitfield_details
431 struct _type_t *field;
432 const expr_t *bits;
435 struct alias_details
437 struct _decl_spec_t aliasee;
440 struct runtimeclass_details
442 typeref_list_t *ifaces;
445 struct parameterized_details
447 type_t *type;
448 typeref_list_t *params;
451 struct delegate_details
453 type_t *iface;
456 #define HASHMAX 64
458 struct namespace {
459 const char *name;
460 struct namespace *parent;
461 struct list entry;
462 struct list children;
463 struct rtype *type_hash[HASHMAX];
466 enum type_type
468 TYPE_VOID,
469 TYPE_BASIC, /* ints, floats and handles */
470 TYPE_ENUM,
471 TYPE_STRUCT,
472 TYPE_ENCAPSULATED_UNION,
473 TYPE_UNION,
474 TYPE_ALIAS,
475 TYPE_MODULE,
476 TYPE_COCLASS,
477 TYPE_FUNCTION,
478 TYPE_INTERFACE,
479 TYPE_POINTER,
480 TYPE_ARRAY,
481 TYPE_BITFIELD,
482 TYPE_APICONTRACT,
483 TYPE_RUNTIMECLASS,
484 TYPE_PARAMETERIZED_TYPE,
485 TYPE_PARAMETER,
486 TYPE_DELEGATE,
489 struct _type_t {
490 const char *name; /* C++ name with parameters in brackets */
491 struct namespace *namespace;
492 enum type_type type_type;
493 attr_list_t *attrs;
494 union
496 struct struct_details *structure;
497 struct enumeration_details *enumeration;
498 struct func_details *function;
499 struct iface_details *iface;
500 struct module_details *module;
501 struct array_details array;
502 struct coclass_details coclass;
503 struct basic_details basic;
504 struct pointer_details pointer;
505 struct bitfield_details bitfield;
506 struct alias_details alias;
507 struct runtimeclass_details runtimeclass;
508 struct parameterized_details parameterized;
509 struct delegate_details delegate;
510 } details;
511 const char *c_name; /* mangled C name, with namespaces and parameters */
512 const char *signature;
513 const char *qualified_name; /* C++ fully qualified name */
514 const char *impl_name; /* C++ parameterized types impl base class name */
515 const char *param_name; /* used to build c_name of a parameterized type, when used as a parameter */
516 const char *short_name; /* widl specific short name */
517 unsigned int typestring_offset;
518 unsigned int ptrdesc; /* used for complex structs */
519 int typelib_idx;
520 struct location where;
521 unsigned int ignore : 1;
522 unsigned int defined : 1;
523 unsigned int written : 1;
524 unsigned int user_types_registered : 1;
525 unsigned int tfswrite : 1; /* if the type needs to be written to the TFS */
526 unsigned int checked : 1;
529 struct _var_t {
530 char *name;
531 decl_spec_t declspec;
532 attr_list_t *attrs;
533 expr_t *eval;
535 unsigned int typestring_offset;
537 /* fields specific to functions */
538 unsigned int procstring_offset, func_idx;
540 struct location where;
542 unsigned int declonly : 1;
544 /* parser-internal */
545 struct list entry;
548 struct _declarator_t {
549 var_t *var;
550 type_t *type;
551 enum type_qualifier qualifier;
552 expr_t *bits;
554 /* parser-internal */
555 struct list entry;
558 struct _typeref_t {
559 type_t *type;
560 attr_list_t *attrs;
562 /* parser-internal */
563 struct list entry;
566 struct _typelib_entry_t {
567 type_t *type;
568 struct list entry;
571 struct _importinfo_t {
572 int offset;
573 struct uuid guid;
574 int flags;
575 int id;
577 char *name;
579 importlib_t *importlib;
582 struct _importlib_t {
583 int offset;
584 char *name;
586 int version;
587 struct uuid guid;
589 importinfo_t *importinfos;
590 int ntypeinfos;
592 int allocated;
594 struct list entry;
597 struct _typelib_t {
598 char *name;
599 const attr_list_t *attrs;
600 struct list importlibs;
601 statement_list_t *stmts;
603 type_t **reg_ifaces;
604 unsigned int reg_iface_count;
607 struct _user_type_t {
608 struct list entry;
609 const char *name;
612 struct _statement_t {
613 struct list entry;
614 enum statement_type type;
615 union
617 type_t *type;
618 const char *str;
619 var_t *var;
620 typelib_t *lib;
621 typeref_list_t *type_list;
622 } u;
623 unsigned int declonly : 1; /* for STMT_TYPE and STMT_TYPEDEF */
626 struct _warning_t {
627 int num;
628 struct list entry;
631 typedef enum {
632 SYS_WIN16,
633 SYS_WIN32,
634 SYS_MAC,
635 SYS_WIN64
636 } syskind_t;
638 extern user_type_list_t user_type_list;
639 extern context_handle_list_t context_handle_list;
640 extern generic_handle_list_t generic_handle_list;
641 void check_for_additional_prototype_types(type_t *type);
643 void init_types(void);
644 type_t *alloc_type(void);
645 void set_all_tfswrite(int val);
646 void clear_all_offsets(void);
648 #define tsENUM 1
649 #define tsSTRUCT 2
650 #define tsUNION 3
652 var_t *find_const(const char *name, int f);
653 type_t *find_type(const char *name, struct namespace *namespace, int t);
654 type_t *make_type(enum type_type type);
655 type_t *get_type(enum type_type type, char *name, struct namespace *namespace, int t);
656 type_t *reg_type(type_t *type, const char *name, struct namespace *namespace, int t);
658 var_t *make_var(char *name);
659 var_list_t *append_var(var_list_t *list, var_t *var);
661 char *format_namespace(struct namespace *namespace, const char *prefix, const char *separator, const char *suffix,
662 const char *abi_prefix);
663 char *format_parameterized_type_name(type_t *type, typeref_list_t *params);
665 static inline enum type_type type_get_type_detect_alias(const type_t *type)
667 return type->type_type;
670 #define STATEMENTS_FOR_EACH_FUNC(stmt, stmts) \
671 if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, statement_t, entry ) \
672 if (stmt->type == STMT_DECLARATION && stmt->u.var->declspec.stgclass == STG_NONE && \
673 type_get_type_detect_alias(stmt->u.var->declspec.type) == TYPE_FUNCTION)
675 static inline int statements_has_func(const statement_list_t *stmts)
677 const statement_t *stmt;
678 int has_func = 0;
679 STATEMENTS_FOR_EACH_FUNC(stmt, stmts)
681 has_func = 1;
682 break;
684 return has_func;
687 static inline int is_global_namespace(const struct namespace *namespace)
689 return !namespace->name;
692 static inline decl_spec_t *init_declspec(decl_spec_t *declspec, type_t *type)
694 declspec->type = type;
695 declspec->stgclass = STG_NONE;
696 declspec->qualifier = 0;
697 declspec->func_specifier = 0;
699 return declspec;
702 #endif