winegstreamer: Add format field to wmv wg_format.
[wine.git] / tools / widl / widltypes.h
blobfd108ecc4733ceffff4d54de64ba6186d97ce839
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_CONTEXTHANDLE,
88 ATTR_CONTRACT,
89 ATTR_CONTRACTVERSION,
90 ATTR_CONTROL,
91 ATTR_CUSTOM,
92 ATTR_DECODE,
93 ATTR_DEFAULT,
94 ATTR_DEFAULTBIND,
95 ATTR_DEFAULTCOLLELEM,
96 ATTR_DEFAULTVALUE,
97 ATTR_DEFAULTVTABLE,
98 ATTR_DISABLECONSISTENCYCHECK,
99 ATTR_DISPINTERFACE,
100 ATTR_DISPLAYBIND,
101 ATTR_DLLNAME,
102 ATTR_DUAL,
103 ATTR_ENABLEALLOCATE,
104 ATTR_ENCODE,
105 ATTR_ENDPOINT,
106 ATTR_ENTRY,
107 ATTR_EVENTADD,
108 ATTR_EVENTREMOVE,
109 ATTR_EXCLUSIVETO,
110 ATTR_EXPLICIT_HANDLE,
111 ATTR_FAULTSTATUS,
112 ATTR_FLAGS,
113 ATTR_FORCEALLOCATE,
114 ATTR_HANDLE,
115 ATTR_HELPCONTEXT,
116 ATTR_HELPFILE,
117 ATTR_HELPSTRING,
118 ATTR_HELPSTRINGCONTEXT,
119 ATTR_HELPSTRINGDLL,
120 ATTR_HIDDEN,
121 ATTR_ID,
122 ATTR_IDEMPOTENT,
123 ATTR_IGNORE,
124 ATTR_IIDIS,
125 ATTR_IMMEDIATEBIND,
126 ATTR_IMPLICIT_HANDLE,
127 ATTR_IN,
128 ATTR_INPUTSYNC,
129 ATTR_LENGTHIS,
130 ATTR_LIBLCID,
131 ATTR_LICENSED,
132 ATTR_LOCAL,
133 ATTR_MARSHALING_BEHAVIOR,
134 ATTR_MAYBE,
135 ATTR_MESSAGE,
136 ATTR_NOCODE,
137 ATTR_NONBROWSABLE,
138 ATTR_NONCREATABLE,
139 ATTR_NONEXTENSIBLE,
140 ATTR_NOTIFY,
141 ATTR_NOTIFYFLAG,
142 ATTR_OBJECT,
143 ATTR_ODL,
144 ATTR_OLEAUTOMATION,
145 ATTR_OPTIMIZE,
146 ATTR_OPTIONAL,
147 ATTR_OUT,
148 ATTR_OVERLOAD,
149 ATTR_PARAMLCID,
150 ATTR_PARTIALIGNORE,
151 ATTR_POINTERDEFAULT,
152 ATTR_POINTERTYPE,
153 ATTR_PROGID,
154 ATTR_PROPGET,
155 ATTR_PROPPUT,
156 ATTR_PROPPUTREF,
157 ATTR_PROXY,
158 ATTR_PUBLIC,
159 ATTR_RANGE,
160 ATTR_READONLY,
161 ATTR_REPRESENTAS,
162 ATTR_REQUESTEDIT,
163 ATTR_RESTRICTED,
164 ATTR_RETVAL,
165 ATTR_SIZEIS,
166 ATTR_SOURCE,
167 ATTR_STATIC,
168 ATTR_STRICTCONTEXTHANDLE,
169 ATTR_STRING,
170 ATTR_SWITCHIS,
171 ATTR_SWITCHTYPE,
172 ATTR_THREADING,
173 ATTR_TRANSMITAS,
174 ATTR_UIDEFAULT,
175 ATTR_USERMARSHAL,
176 ATTR_USESGETLASTERROR,
177 ATTR_UUID,
178 ATTR_V1ENUM,
179 ATTR_VARARG,
180 ATTR_VERSION,
181 ATTR_VIPROGID,
182 ATTR_WIREMARSHAL
185 enum expr_type
187 EXPR_VOID,
188 EXPR_NUM,
189 EXPR_HEXNUM,
190 EXPR_DOUBLE,
191 EXPR_IDENTIFIER,
192 EXPR_NEG,
193 EXPR_NOT,
194 EXPR_PPTR,
195 EXPR_CAST,
196 EXPR_SIZEOF,
197 EXPR_SHL,
198 EXPR_SHR,
199 EXPR_MUL,
200 EXPR_DIV,
201 EXPR_ADD,
202 EXPR_SUB,
203 EXPR_AND,
204 EXPR_OR,
205 EXPR_COND,
206 EXPR_TRUEFALSE,
207 EXPR_ADDRESSOF,
208 EXPR_MEMBER,
209 EXPR_ARRAY,
210 EXPR_MOD,
211 EXPR_LOGOR,
212 EXPR_LOGAND,
213 EXPR_XOR,
214 EXPR_EQUALITY,
215 EXPR_INEQUALITY,
216 EXPR_GTR,
217 EXPR_LESS,
218 EXPR_GTREQL,
219 EXPR_LESSEQL,
220 EXPR_LOGNOT,
221 EXPR_POS,
222 EXPR_STRLIT,
223 EXPR_WSTRLIT,
224 EXPR_CHARCONST,
227 enum type_kind
229 TKIND_PRIMITIVE = -1,
230 TKIND_ENUM,
231 TKIND_RECORD,
232 TKIND_MODULE,
233 TKIND_INTERFACE,
234 TKIND_DISPATCH,
235 TKIND_COCLASS,
236 TKIND_ALIAS,
237 TKIND_UNION,
238 TKIND_MAX
241 enum storage_class
243 STG_NONE,
244 STG_STATIC,
245 STG_EXTERN,
246 STG_REGISTER,
249 enum type_qualifier
251 TYPE_QUALIFIER_CONST = 1,
254 enum function_specifier
256 FUNCTION_SPECIFIER_INLINE = 1,
259 enum statement_type
261 STMT_LIBRARY,
262 STMT_DECLARATION,
263 STMT_TYPE,
264 STMT_TYPEREF,
265 STMT_MODULE,
266 STMT_TYPEDEF,
267 STMT_IMPORT,
268 STMT_IMPORTLIB,
269 STMT_PRAGMA,
270 STMT_CPPQUOTE
273 enum threading_type
275 THREADING_APARTMENT = 1,
276 THREADING_NEUTRAL,
277 THREADING_SINGLE,
278 THREADING_FREE,
279 THREADING_BOTH
282 enum marshaling_type
284 MARSHALING_INVALID = 0,
285 MARSHALING_NONE,
286 MARSHALING_AGILE,
287 MARSHALING_STANDARD,
290 enum type_basic_type
292 TYPE_BASIC_INT8 = 1,
293 TYPE_BASIC_INT16,
294 TYPE_BASIC_INT32,
295 TYPE_BASIC_INT64,
296 TYPE_BASIC_INT,
297 TYPE_BASIC_INT3264,
298 TYPE_BASIC_LONG,
299 TYPE_BASIC_CHAR,
300 TYPE_BASIC_HYPER,
301 TYPE_BASIC_BYTE,
302 TYPE_BASIC_WCHAR,
303 TYPE_BASIC_FLOAT,
304 TYPE_BASIC_DOUBLE,
305 TYPE_BASIC_ERROR_STATUS_T,
306 TYPE_BASIC_HANDLE,
309 #define TYPE_BASIC_MAX TYPE_BASIC_HANDLE
310 #define TYPE_BASIC_INT_MIN TYPE_BASIC_INT8
311 #define TYPE_BASIC_INT_MAX TYPE_BASIC_HYPER
313 struct location
315 const char *input_name;
316 int first_line;
317 int last_line;
318 int first_column;
319 int last_column;
322 struct str_list_entry_t
324 char *str;
325 struct list entry;
328 struct _decl_spec_t
330 type_t *type;
331 enum storage_class stgclass;
332 enum type_qualifier qualifier;
333 enum function_specifier func_specifier;
336 struct _attr_t {
337 enum attr_type type;
338 union {
339 unsigned int ival;
340 void *pval;
341 } u;
342 /* parser-internal */
343 struct list entry;
346 struct _expr_t {
347 enum expr_type type;
348 const expr_t *ref;
349 union {
350 int lval;
351 double dval;
352 const char *sval;
353 const expr_t *ext;
354 decl_spec_t tref;
355 } u;
356 const expr_t *ext2;
357 int is_const;
358 int cval;
359 /* parser-internal */
360 struct list entry;
363 struct _attr_custdata_t {
364 struct uuid id;
365 expr_t *pval;
368 struct struct_details
370 var_list_t *fields;
373 struct enumeration_details
375 var_list_t *enums;
378 struct func_details
380 var_list_t *args;
381 struct _var_t *retval;
384 struct iface_details
386 statement_list_t *stmts;
387 var_list_t *disp_methods;
388 var_list_t *disp_props;
389 struct _type_t *inherit;
390 struct _type_t *disp_inherit;
391 struct _type_t *async_iface;
392 typeref_list_t *requires;
395 struct module_details
397 statement_list_t *stmts;
400 struct array_details
402 expr_t *size_is;
403 expr_t *length_is;
404 struct _decl_spec_t elem;
405 unsigned int dim;
406 unsigned char declptr; /* if declared as a pointer */
407 unsigned short ptr_tfsoff; /* offset of pointer definition for declptr */
410 struct coclass_details
412 typeref_list_t *ifaces;
415 struct basic_details
417 enum type_basic_type type;
418 int sign;
421 struct pointer_details
423 struct _decl_spec_t ref;
426 struct bitfield_details
428 struct _type_t *field;
429 const expr_t *bits;
432 struct alias_details
434 struct _decl_spec_t aliasee;
437 struct runtimeclass_details
439 typeref_list_t *ifaces;
442 struct parameterized_details
444 type_t *type;
445 typeref_list_t *params;
448 struct delegate_details
450 type_t *iface;
453 #define HASHMAX 64
455 struct namespace {
456 const char *name;
457 struct namespace *parent;
458 struct list entry;
459 struct list children;
460 struct rtype *type_hash[HASHMAX];
463 enum type_type
465 TYPE_VOID,
466 TYPE_BASIC, /* ints, floats and handles */
467 TYPE_ENUM,
468 TYPE_STRUCT,
469 TYPE_ENCAPSULATED_UNION,
470 TYPE_UNION,
471 TYPE_ALIAS,
472 TYPE_MODULE,
473 TYPE_COCLASS,
474 TYPE_FUNCTION,
475 TYPE_INTERFACE,
476 TYPE_POINTER,
477 TYPE_ARRAY,
478 TYPE_BITFIELD,
479 TYPE_APICONTRACT,
480 TYPE_RUNTIMECLASS,
481 TYPE_PARAMETERIZED_TYPE,
482 TYPE_PARAMETER,
483 TYPE_DELEGATE,
486 struct _type_t {
487 const char *name; /* C++ name with parameters in brackets */
488 struct namespace *namespace;
489 enum type_type type_type;
490 attr_list_t *attrs;
491 union
493 struct struct_details *structure;
494 struct enumeration_details *enumeration;
495 struct func_details *function;
496 struct iface_details *iface;
497 struct module_details *module;
498 struct array_details array;
499 struct coclass_details coclass;
500 struct basic_details basic;
501 struct pointer_details pointer;
502 struct bitfield_details bitfield;
503 struct alias_details alias;
504 struct runtimeclass_details runtimeclass;
505 struct parameterized_details parameterized;
506 struct delegate_details delegate;
507 } details;
508 const char *c_name; /* mangled C name, with namespaces and parameters */
509 const char *signature;
510 const char *qualified_name; /* C++ fully qualified name */
511 const char *impl_name; /* C++ parameterized types impl base class name */
512 const char *param_name; /* used to build c_name of a parameterized type, when used as a parameter */
513 const char *short_name; /* widl specific short name */
514 unsigned int typestring_offset;
515 unsigned int ptrdesc; /* used for complex structs */
516 int typelib_idx;
517 struct location where;
518 unsigned int ignore : 1;
519 unsigned int defined : 1;
520 unsigned int written : 1;
521 unsigned int user_types_registered : 1;
522 unsigned int tfswrite : 1; /* if the type needs to be written to the TFS */
523 unsigned int checked : 1;
526 struct _var_t {
527 char *name;
528 decl_spec_t declspec;
529 attr_list_t *attrs;
530 expr_t *eval;
532 unsigned int typestring_offset;
534 /* fields specific to functions */
535 unsigned int procstring_offset, func_idx;
537 struct location where;
539 unsigned int declonly : 1;
541 /* parser-internal */
542 struct list entry;
545 struct _declarator_t {
546 var_t *var;
547 type_t *type;
548 enum type_qualifier qualifier;
549 expr_t *bits;
551 /* parser-internal */
552 struct list entry;
555 struct _typeref_t {
556 type_t *type;
557 attr_list_t *attrs;
559 /* parser-internal */
560 struct list entry;
563 struct _typelib_entry_t {
564 type_t *type;
565 struct list entry;
568 struct _importinfo_t {
569 int offset;
570 struct uuid guid;
571 int flags;
572 int id;
574 char *name;
576 importlib_t *importlib;
579 struct _importlib_t {
580 int offset;
581 char *name;
583 int version;
584 struct uuid guid;
586 importinfo_t *importinfos;
587 int ntypeinfos;
589 int allocated;
591 struct list entry;
594 struct _typelib_t {
595 char *name;
596 const attr_list_t *attrs;
597 struct list importlibs;
598 statement_list_t *stmts;
600 type_t **reg_ifaces;
601 unsigned int reg_iface_count;
604 struct _user_type_t {
605 struct list entry;
606 const char *name;
609 struct _statement_t {
610 struct list entry;
611 enum statement_type type;
612 union
614 type_t *type;
615 const char *str;
616 var_t *var;
617 typelib_t *lib;
618 typeref_list_t *type_list;
619 } u;
620 unsigned int declonly : 1; /* for STMT_TYPE and STMT_TYPEDEF */
623 struct _warning_t {
624 int num;
625 struct list entry;
628 typedef enum {
629 SYS_WIN16,
630 SYS_WIN32,
631 SYS_MAC,
632 SYS_WIN64
633 } syskind_t;
635 extern user_type_list_t user_type_list;
636 extern context_handle_list_t context_handle_list;
637 extern generic_handle_list_t generic_handle_list;
638 void check_for_additional_prototype_types(type_t *type);
640 void init_types(void);
641 type_t *alloc_type(void);
642 void set_all_tfswrite(int val);
643 void clear_all_offsets(void);
645 #define tsENUM 1
646 #define tsSTRUCT 2
647 #define tsUNION 3
649 var_t *find_const(const char *name, int f);
650 type_t *find_type(const char *name, struct namespace *namespace, int t);
651 type_t *make_type(enum type_type type);
652 type_t *get_type(enum type_type type, char *name, struct namespace *namespace, int t);
653 type_t *reg_type(type_t *type, const char *name, struct namespace *namespace, int t);
655 var_t *make_var(char *name);
656 var_list_t *append_var(var_list_t *list, var_t *var);
658 char *format_namespace(struct namespace *namespace, const char *prefix, const char *separator, const char *suffix,
659 const char *abi_prefix);
660 char *format_parameterized_type_name(type_t *type, typeref_list_t *params);
662 static inline enum type_type type_get_type_detect_alias(const type_t *type)
664 return type->type_type;
667 #define STATEMENTS_FOR_EACH_FUNC(stmt, stmts) \
668 if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, statement_t, entry ) \
669 if (stmt->type == STMT_DECLARATION && stmt->u.var->declspec.stgclass == STG_NONE && \
670 type_get_type_detect_alias(stmt->u.var->declspec.type) == TYPE_FUNCTION)
672 static inline int statements_has_func(const statement_list_t *stmts)
674 const statement_t *stmt;
675 int has_func = 0;
676 STATEMENTS_FOR_EACH_FUNC(stmt, stmts)
678 has_func = 1;
679 break;
681 return has_func;
684 static inline int is_global_namespace(const struct namespace *namespace)
686 return !namespace->name;
689 static inline decl_spec_t *init_declspec(decl_spec_t *declspec, type_t *type)
691 declspec->type = type;
692 declspec->stgclass = STG_NONE;
693 declspec->qualifier = 0;
694 declspec->func_specifier = 0;
696 return declspec;
699 #endif