gdi32: Add a helper function to get bitmap size.
[wine/multimedia.git] / tools / widl / widltypes.h
blob84e4467e61925ccc5363fb6ed6ec2df8abfbc233
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 _user_type_t generic_handle_t;
52 typedef struct _type_list_t type_list_t;
53 typedef struct _statement_t statement_t;
55 typedef struct list attr_list_t;
56 typedef struct list str_list_t;
57 typedef struct list expr_list_t;
58 typedef struct list var_list_t;
59 typedef struct list declarator_list_t;
60 typedef struct list ifref_list_t;
61 typedef struct list array_dims_t;
62 typedef struct list user_type_list_t;
63 typedef struct list context_handle_list_t;
64 typedef struct list generic_handle_list_t;
65 typedef struct list statement_list_t;
67 enum attr_type
69 ATTR_AGGREGATABLE,
70 ATTR_ANNOTATION,
71 ATTR_APPOBJECT,
72 ATTR_ASYNC,
73 ATTR_AUTO_HANDLE,
74 ATTR_BINDABLE,
75 ATTR_BROADCAST,
76 ATTR_CALLAS,
77 ATTR_CALLCONV, /* calling convention pseudo-attribute */
78 ATTR_CASE,
79 ATTR_CODE,
80 ATTR_COMMSTATUS,
81 ATTR_CONST, /* const pseudo-attribute */
82 ATTR_CONTEXTHANDLE,
83 ATTR_CONTROL,
84 ATTR_DECODE,
85 ATTR_DEFAULT,
86 ATTR_DEFAULTBIND,
87 ATTR_DEFAULTCOLLELEM,
88 ATTR_DEFAULTVALUE,
89 ATTR_DEFAULTVTABLE,
90 ATTR_DISABLECONSISTENCYCHECK,
91 ATTR_DISPINTERFACE,
92 ATTR_DISPLAYBIND,
93 ATTR_DLLNAME,
94 ATTR_DUAL,
95 ATTR_ENABLEALLOCATE,
96 ATTR_ENCODE,
97 ATTR_ENDPOINT,
98 ATTR_ENTRY,
99 ATTR_EXPLICIT_HANDLE,
100 ATTR_FAULTSTATUS,
101 ATTR_FORCEALLOCATE,
102 ATTR_HANDLE,
103 ATTR_HELPCONTEXT,
104 ATTR_HELPFILE,
105 ATTR_HELPSTRING,
106 ATTR_HELPSTRINGCONTEXT,
107 ATTR_HELPSTRINGDLL,
108 ATTR_HIDDEN,
109 ATTR_ID,
110 ATTR_IDEMPOTENT,
111 ATTR_IGNORE,
112 ATTR_IIDIS,
113 ATTR_IMMEDIATEBIND,
114 ATTR_IMPLICIT_HANDLE,
115 ATTR_IN,
116 ATTR_INLINE,
117 ATTR_INPUTSYNC,
118 ATTR_LENGTHIS,
119 ATTR_LIBLCID,
120 ATTR_LICENSED,
121 ATTR_LOCAL,
122 ATTR_MAYBE,
123 ATTR_MESSAGE,
124 ATTR_NOCODE,
125 ATTR_NONBROWSABLE,
126 ATTR_NONCREATABLE,
127 ATTR_NONEXTENSIBLE,
128 ATTR_NOTIFY,
129 ATTR_NOTIFYFLAG,
130 ATTR_OBJECT,
131 ATTR_ODL,
132 ATTR_OLEAUTOMATION,
133 ATTR_OPTIMIZE,
134 ATTR_OPTIONAL,
135 ATTR_OUT,
136 ATTR_PARAMLCID,
137 ATTR_PARTIALIGNORE,
138 ATTR_POINTERDEFAULT,
139 ATTR_POINTERTYPE,
140 ATTR_PROGID,
141 ATTR_PROPGET,
142 ATTR_PROPPUT,
143 ATTR_PROPPUTREF,
144 ATTR_PROXY,
145 ATTR_PUBLIC,
146 ATTR_RANGE,
147 ATTR_READONLY,
148 ATTR_REPRESENTAS,
149 ATTR_REQUESTEDIT,
150 ATTR_RESTRICTED,
151 ATTR_RETVAL,
152 ATTR_SIZEIS,
153 ATTR_SOURCE,
154 ATTR_STRICTCONTEXTHANDLE,
155 ATTR_STRING,
156 ATTR_SWITCHIS,
157 ATTR_SWITCHTYPE,
158 ATTR_THREADING,
159 ATTR_TRANSMITAS,
160 ATTR_UIDEFAULT,
161 ATTR_USERMARSHAL,
162 ATTR_USESGETLASTERROR,
163 ATTR_UUID,
164 ATTR_V1ENUM,
165 ATTR_VARARG,
166 ATTR_VERSION,
167 ATTR_VIPROGID,
168 ATTR_WIREMARSHAL
171 enum expr_type
173 EXPR_VOID,
174 EXPR_NUM,
175 EXPR_HEXNUM,
176 EXPR_DOUBLE,
177 EXPR_IDENTIFIER,
178 EXPR_NEG,
179 EXPR_NOT,
180 EXPR_PPTR,
181 EXPR_CAST,
182 EXPR_SIZEOF,
183 EXPR_SHL,
184 EXPR_SHR,
185 EXPR_MUL,
186 EXPR_DIV,
187 EXPR_ADD,
188 EXPR_SUB,
189 EXPR_AND,
190 EXPR_OR,
191 EXPR_COND,
192 EXPR_TRUEFALSE,
193 EXPR_ADDRESSOF,
194 EXPR_MEMBER,
195 EXPR_ARRAY,
196 EXPR_MOD,
197 EXPR_LOGOR,
198 EXPR_LOGAND,
199 EXPR_XOR,
200 EXPR_EQUALITY,
201 EXPR_INEQUALITY,
202 EXPR_GTR,
203 EXPR_LESS,
204 EXPR_GTREQL,
205 EXPR_LESSEQL,
206 EXPR_LOGNOT,
207 EXPR_POS,
208 EXPR_STRLIT,
209 EXPR_WSTRLIT,
210 EXPR_CHARCONST,
213 enum type_kind
215 TKIND_PRIMITIVE = -1,
216 TKIND_ENUM,
217 TKIND_RECORD,
218 TKIND_MODULE,
219 TKIND_INTERFACE,
220 TKIND_DISPATCH,
221 TKIND_COCLASS,
222 TKIND_ALIAS,
223 TKIND_UNION,
224 TKIND_MAX
227 enum storage_class
229 STG_NONE,
230 STG_STATIC,
231 STG_EXTERN,
232 STG_REGISTER,
235 enum statement_type
237 STMT_LIBRARY,
238 STMT_DECLARATION,
239 STMT_TYPE,
240 STMT_TYPEREF,
241 STMT_MODULE,
242 STMT_TYPEDEF,
243 STMT_IMPORT,
244 STMT_IMPORTLIB,
245 STMT_CPPQUOTE
248 enum threading_type
250 THREADING_APARTMENT = 1,
251 THREADING_NEUTRAL,
252 THREADING_SINGLE,
253 THREADING_FREE,
254 THREADING_BOTH
257 enum type_basic_type
259 TYPE_BASIC_INT8 = 1,
260 TYPE_BASIC_INT16,
261 TYPE_BASIC_INT32,
262 TYPE_BASIC_INT64,
263 TYPE_BASIC_INT,
264 TYPE_BASIC_INT3264,
265 TYPE_BASIC_CHAR,
266 TYPE_BASIC_HYPER,
267 TYPE_BASIC_BYTE,
268 TYPE_BASIC_WCHAR,
269 TYPE_BASIC_FLOAT,
270 TYPE_BASIC_DOUBLE,
271 TYPE_BASIC_ERROR_STATUS_T,
272 TYPE_BASIC_HANDLE,
275 #define TYPE_BASIC_MAX TYPE_BASIC_HANDLE
276 #define TYPE_BASIC_INT_MIN TYPE_BASIC_INT8
277 #define TYPE_BASIC_INT_MAX TYPE_BASIC_HYPER
279 struct _loc_info_t
281 const char *input_name;
282 int line_number;
283 const char *near_text;
286 struct str_list_entry_t
288 char *str;
289 struct list entry;
292 struct _attr_t {
293 enum attr_type type;
294 union {
295 unsigned int ival;
296 void *pval;
297 } u;
298 /* parser-internal */
299 struct list entry;
302 struct _expr_t {
303 enum expr_type type;
304 const expr_t *ref;
305 union {
306 int lval;
307 double dval;
308 const char *sval;
309 const expr_t *ext;
310 type_t *tref;
311 } u;
312 const expr_t *ext2;
313 int is_const;
314 int cval;
315 /* parser-internal */
316 struct list entry;
319 struct struct_details
321 var_list_t *fields;
324 struct enumeration_details
326 var_list_t *enums;
329 struct func_details
331 var_list_t *args;
332 struct _var_t *retval;
333 int idx;
336 struct iface_details
338 statement_list_t *stmts;
339 var_list_t *disp_methods;
340 var_list_t *disp_props;
341 struct _type_t *inherit;
344 struct module_details
346 statement_list_t *stmts;
349 struct array_details
351 expr_t *size_is;
352 expr_t *length_is;
353 struct _type_t *elem;
354 unsigned int dim;
355 unsigned char ptr_def_fc;
356 unsigned char declptr; /* if declared as a pointer */
357 unsigned short ptr_tfsoff; /* offset of pointer definition for declptr */
360 struct coclass_details
362 ifref_list_t *ifaces;
365 struct basic_details
367 enum type_basic_type type;
368 int sign;
371 struct pointer_details
373 struct _type_t *ref;
374 unsigned char def_fc;
377 struct bitfield_details
379 struct _type_t *field;
380 const expr_t *bits;
383 enum type_type
385 TYPE_VOID,
386 TYPE_BASIC, /* ints, floats and handles */
387 TYPE_ENUM,
388 TYPE_STRUCT,
389 TYPE_ENCAPSULATED_UNION,
390 TYPE_UNION,
391 TYPE_ALIAS,
392 TYPE_MODULE,
393 TYPE_COCLASS,
394 TYPE_FUNCTION,
395 TYPE_INTERFACE,
396 TYPE_POINTER,
397 TYPE_ARRAY,
398 TYPE_BITFIELD,
401 struct _type_t {
402 const char *name;
403 enum type_type type_type;
404 attr_list_t *attrs;
405 union
407 struct struct_details *structure;
408 struct enumeration_details *enumeration;
409 struct func_details *function;
410 struct iface_details *iface;
411 struct module_details *module;
412 struct array_details array;
413 struct coclass_details coclass;
414 struct basic_details basic;
415 struct pointer_details pointer;
416 struct bitfield_details bitfield;
417 } details;
418 type_t *orig; /* dup'd types */
419 unsigned int typestring_offset;
420 unsigned int ptrdesc; /* used for complex structs */
421 int typelib_idx;
422 loc_info_t loc_info;
423 unsigned int ignore : 1;
424 unsigned int defined : 1;
425 unsigned int written : 1;
426 unsigned int user_types_registered : 1;
427 unsigned int tfswrite : 1; /* if the type needs to be written to the TFS */
428 unsigned int checked : 1;
429 unsigned int is_alias : 1; /* is the type an alias? */
432 struct _var_t {
433 char *name;
434 type_t *type;
435 attr_list_t *attrs;
436 expr_t *eval;
437 enum storage_class stgclass;
438 unsigned int procstring_offset;
439 unsigned int typestring_offset;
441 struct _loc_info_t loc_info;
443 /* parser-internal */
444 struct list entry;
447 struct _declarator_t {
448 var_t *var;
449 type_t *type;
450 type_t *func_type;
451 array_dims_t *array;
452 expr_t *bits;
454 /* parser-internal */
455 struct list entry;
458 struct _ifref_t {
459 type_t *iface;
460 attr_list_t *attrs;
462 /* parser-internal */
463 struct list entry;
466 struct _typelib_entry_t {
467 type_t *type;
468 struct list entry;
471 struct _importinfo_t {
472 int offset;
473 GUID guid;
474 int flags;
475 int id;
477 char *name;
479 importlib_t *importlib;
482 struct _importlib_t {
483 char *name;
485 int version;
486 GUID guid;
488 importinfo_t *importinfos;
489 int ntypeinfos;
491 int allocated;
493 struct list entry;
496 struct _typelib_t {
497 char *name;
498 const attr_list_t *attrs;
499 struct list importlibs;
500 statement_list_t *stmts;
503 struct _user_type_t {
504 struct list entry;
505 const char *name;
508 struct _type_list_t {
509 type_t *type;
510 struct _type_list_t *next;
513 struct _statement_t {
514 struct list entry;
515 enum statement_type type;
516 union
518 ifref_t iface;
519 type_t *type;
520 const char *str;
521 var_t *var;
522 typelib_t *lib;
523 type_list_t *type_list;
524 } u;
527 typedef enum {
528 SYS_WIN16,
529 SYS_WIN32,
530 SYS_MAC,
531 SYS_WIN64
532 } syskind_t;
534 extern syskind_t typelib_kind;
535 extern user_type_list_t user_type_list;
536 extern context_handle_list_t context_handle_list;
537 extern generic_handle_list_t generic_handle_list;
538 void check_for_additional_prototype_types(const var_list_t *list);
540 void init_types(void);
541 type_t *alloc_type(void);
542 void set_all_tfswrite(int val);
543 void clear_all_offsets(void);
545 int is_ptr(const type_t *t);
546 int is_array(const type_t *t);
548 #define tsENUM 1
549 #define tsSTRUCT 2
550 #define tsUNION 3
552 var_t *find_const(const char *name, int f);
553 type_t *find_type(const char *name, int t);
554 type_t *make_type(enum type_type type);
555 type_t *get_type(enum type_type type, char *name, int t);
556 type_t *reg_type(type_t *type, const char *name, int t);
557 void add_incomplete(type_t *t);
559 var_t *make_var(char *name);
560 var_list_t *append_var(var_list_t *list, var_t *var);
562 void init_loc_info(loc_info_t *);
564 static inline var_list_t *type_get_function_args(const type_t *func_type)
566 return func_type->details.function->args;
569 static inline enum type_type type_get_type_detect_alias(const type_t *type)
571 if (type->is_alias)
572 return TYPE_ALIAS;
573 return type->type_type;
576 #define STATEMENTS_FOR_EACH_FUNC(stmt, stmts) \
577 if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, statement_t, entry ) \
578 if (stmt->type == STMT_DECLARATION && stmt->u.var->stgclass == STG_NONE && \
579 type_get_type_detect_alias(stmt->u.var->type) == TYPE_FUNCTION)
581 static inline int statements_has_func(const statement_list_t *stmts)
583 const statement_t *stmt;
584 int has_func = 0;
585 STATEMENTS_FOR_EACH_FUNC(stmt, stmts)
587 has_func = 1;
588 break;
590 return has_func;
593 #endif