widl: Add support for generating 32-bit and/or 64-bit code for proxies/clients/servers.
[wine/wine64.git] / tools / widl / widltypes.h
blob4f1fc1c91162b2f39461a0d98b95ca26ed69085e
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 "guiddef.h"
26 #include "wine/rpcfc.h"
27 #include "wine/list.h"
29 #ifndef UUID_DEFINED
30 #define UUID_DEFINED
31 typedef GUID UUID;
32 #endif
34 #define TRUE 1
35 #define FALSE 0
37 #define RPC_FC_COCLASS 0xfd
38 #define RPC_FC_FUNCTION 0xfe
40 typedef struct _loc_info_t loc_info_t;
41 typedef struct _attr_t attr_t;
42 typedef struct _expr_t expr_t;
43 typedef struct _type_t type_t;
44 typedef struct _typeref_t typeref_t;
45 typedef struct _var_t var_t;
46 typedef struct _declarator_t declarator_t;
47 typedef struct _func_t func_t;
48 typedef struct _ifref_t ifref_t;
49 typedef struct _typelib_entry_t typelib_entry_t;
50 typedef struct _importlib_t importlib_t;
51 typedef struct _importinfo_t importinfo_t;
52 typedef struct _typelib_t typelib_t;
53 typedef struct _user_type_t user_type_t;
54 typedef struct _user_type_t context_handle_t;
55 typedef struct _type_list_t type_list_t;
56 typedef struct _statement_t statement_t;
58 typedef struct list attr_list_t;
59 typedef struct list str_list_t;
60 typedef struct list func_list_t;
61 typedef struct list expr_list_t;
62 typedef struct list var_list_t;
63 typedef struct list declarator_list_t;
64 typedef struct list ifref_list_t;
65 typedef struct list array_dims_t;
66 typedef struct list user_type_list_t;
67 typedef struct list context_handle_list_t;
68 typedef struct list statement_list_t;
70 enum attr_type
72 ATTR_AGGREGATABLE,
73 ATTR_APPOBJECT,
74 ATTR_ASYNC,
75 ATTR_AUTO_HANDLE,
76 ATTR_BINDABLE,
77 ATTR_BROADCAST,
78 ATTR_CALLAS,
79 ATTR_CALLCONV, /* calling convention pseudo-attribute */
80 ATTR_CASE,
81 ATTR_CONST, /* const pseudo-attribute */
82 ATTR_CONTEXTHANDLE,
83 ATTR_CONTROL,
84 ATTR_DEFAULT,
85 ATTR_DEFAULTCOLLELEM,
86 ATTR_DEFAULTVALUE,
87 ATTR_DEFAULTVTABLE,
88 ATTR_DISPINTERFACE,
89 ATTR_DISPLAYBIND,
90 ATTR_DLLNAME,
91 ATTR_DUAL,
92 ATTR_ENDPOINT,
93 ATTR_ENTRY,
94 ATTR_EXPLICIT_HANDLE,
95 ATTR_HANDLE,
96 ATTR_HELPCONTEXT,
97 ATTR_HELPFILE,
98 ATTR_HELPSTRING,
99 ATTR_HELPSTRINGCONTEXT,
100 ATTR_HELPSTRINGDLL,
101 ATTR_HIDDEN,
102 ATTR_ID,
103 ATTR_IDEMPOTENT,
104 ATTR_IIDIS,
105 ATTR_IMMEDIATEBIND,
106 ATTR_IMPLICIT_HANDLE,
107 ATTR_IN,
108 ATTR_INLINE,
109 ATTR_INPUTSYNC,
110 ATTR_LENGTHIS,
111 ATTR_LIBLCID,
112 ATTR_LOCAL,
113 ATTR_NONBROWSABLE,
114 ATTR_NONCREATABLE,
115 ATTR_NONEXTENSIBLE,
116 ATTR_OBJECT,
117 ATTR_ODL,
118 ATTR_OLEAUTOMATION,
119 ATTR_OPTIONAL,
120 ATTR_OUT,
121 ATTR_POINTERDEFAULT,
122 ATTR_POINTERTYPE,
123 ATTR_PROPGET,
124 ATTR_PROPPUT,
125 ATTR_PROPPUTREF,
126 ATTR_PUBLIC,
127 ATTR_RANGE,
128 ATTR_READONLY,
129 ATTR_REQUESTEDIT,
130 ATTR_RESTRICTED,
131 ATTR_RETVAL,
132 ATTR_SIZEIS,
133 ATTR_SOURCE,
134 ATTR_STRICTCONTEXTHANDLE,
135 ATTR_STRING,
136 ATTR_SWITCHIS,
137 ATTR_SWITCHTYPE,
138 ATTR_TRANSMITAS,
139 ATTR_UUID,
140 ATTR_V1ENUM,
141 ATTR_VARARG,
142 ATTR_VERSION,
143 ATTR_WIREMARSHAL
146 enum expr_type
148 EXPR_VOID,
149 EXPR_NUM,
150 EXPR_HEXNUM,
151 EXPR_DOUBLE,
152 EXPR_IDENTIFIER,
153 EXPR_NEG,
154 EXPR_NOT,
155 EXPR_PPTR,
156 EXPR_CAST,
157 EXPR_SIZEOF,
158 EXPR_SHL,
159 EXPR_SHR,
160 EXPR_MUL,
161 EXPR_DIV,
162 EXPR_ADD,
163 EXPR_SUB,
164 EXPR_AND,
165 EXPR_OR,
166 EXPR_COND,
167 EXPR_TRUEFALSE,
168 EXPR_ADDRESSOF,
169 EXPR_MEMBER,
170 EXPR_ARRAY,
171 EXPR_MOD,
172 EXPR_LOGOR,
173 EXPR_LOGAND,
174 EXPR_XOR,
175 EXPR_EQUALITY,
176 EXPR_INEQUALITY,
177 EXPR_GTR,
178 EXPR_LESS,
179 EXPR_GTREQL,
180 EXPR_LESSEQL,
181 EXPR_LOGNOT,
182 EXPR_POS,
183 EXPR_STRLIT,
184 EXPR_WSTRLIT,
187 enum type_kind
189 TKIND_PRIMITIVE = -1,
190 TKIND_ENUM,
191 TKIND_RECORD,
192 TKIND_MODULE,
193 TKIND_INTERFACE,
194 TKIND_DISPATCH,
195 TKIND_COCLASS,
196 TKIND_ALIAS,
197 TKIND_UNION,
198 TKIND_MAX
201 enum storage_class
203 STG_NONE,
204 STG_STATIC,
205 STG_EXTERN,
206 STG_REGISTER,
209 enum statement_type
211 STMT_LIBRARY,
212 STMT_DECLARATION,
213 STMT_TYPE,
214 STMT_TYPEREF,
215 STMT_MODULE,
216 STMT_TYPEDEF,
217 STMT_IMPORT,
218 STMT_IMPORTLIB,
219 STMT_CPPQUOTE
222 struct _loc_info_t
224 const char *input_name;
225 int line_number;
226 const char *near_text;
229 struct str_list_entry_t
231 char *str;
232 struct list entry;
235 struct _attr_t {
236 enum attr_type type;
237 union {
238 unsigned long ival;
239 void *pval;
240 } u;
241 /* parser-internal */
242 struct list entry;
245 struct _expr_t {
246 enum expr_type type;
247 const expr_t *ref;
248 union {
249 long lval;
250 double dval;
251 const char *sval;
252 const expr_t *ext;
253 type_t *tref;
254 } u;
255 const expr_t *ext2;
256 int is_const;
257 long cval;
258 /* parser-internal */
259 struct list entry;
262 struct _type_t {
263 const char *name;
264 enum type_kind kind;
265 unsigned char type;
266 struct _type_t *ref;
267 attr_list_t *attrs;
268 func_list_t *funcs; /* interfaces and modules */
269 var_list_t *fields_or_args; /* interfaces, structures, enumerations and functions (for args) */
270 ifref_list_t *ifaces; /* coclasses */
271 unsigned long dim; /* array dimension */
272 expr_t *size_is, *length_is;
273 type_t *orig; /* dup'd types */
274 unsigned int typestring_offset;
275 unsigned int ptrdesc; /* used for complex structs */
276 int typelib_idx;
277 loc_info_t loc_info;
278 unsigned int declarray : 1; /* if declared as an array */
279 unsigned int ignore : 1;
280 unsigned int defined : 1;
281 unsigned int written : 1;
282 unsigned int user_types_registered : 1;
283 unsigned int tfswrite : 1; /* if the type needs to be written to the TFS */
284 unsigned int checked : 1;
285 int sign : 2;
288 struct _var_t {
289 char *name;
290 type_t *type;
291 attr_list_t *attrs;
292 expr_t *eval;
293 enum storage_class stgclass;
295 struct _loc_info_t loc_info;
297 /* parser-internal */
298 struct list entry;
301 struct _declarator_t {
302 var_t *var;
303 type_t *type;
304 type_t *func_type;
305 array_dims_t *array;
307 /* parser-internal */
308 struct list entry;
311 struct _func_t {
312 var_t *def;
313 var_list_t *args;
314 int ignore, idx;
316 /* parser-internal */
317 struct list entry;
320 struct _ifref_t {
321 type_t *iface;
322 attr_list_t *attrs;
324 /* parser-internal */
325 struct list entry;
328 struct _typelib_entry_t {
329 type_t *type;
330 struct list entry;
333 struct _importinfo_t {
334 int offset;
335 GUID guid;
336 int flags;
337 int id;
339 char *name;
341 importlib_t *importlib;
344 struct _importlib_t {
345 char *name;
347 int version;
348 GUID guid;
350 importinfo_t *importinfos;
351 int ntypeinfos;
353 int allocated;
355 struct list entry;
358 struct _typelib_t {
359 char *name;
360 char *filename;
361 const attr_list_t *attrs;
362 struct list entries;
363 struct list importlibs;
364 statement_list_t *stmts;
367 struct _user_type_t {
368 struct list entry;
369 const char *name;
372 struct _type_list_t {
373 type_t *type;
374 struct _type_list_t *next;
377 struct _statement_t {
378 struct list entry;
379 enum statement_type type;
380 union
382 ifref_t iface;
383 type_t *type;
384 const char *str;
385 var_t *var;
386 typelib_t *lib;
387 type_list_t *type_list;
388 } u;
391 extern unsigned char pointer_default;
393 extern user_type_list_t user_type_list;
394 void check_for_additional_prototype_types(const var_list_t *list);
396 void init_types(void);
397 type_t *alloc_type(void);
398 void set_all_tfswrite(int val);
399 void clear_all_offsets(void);
401 type_t *duptype(type_t *t, int dupname);
402 type_t *alias(type_t *t, const char *name);
404 int is_ptr(const type_t *t);
405 int is_array(const type_t *t);
406 int is_var_ptr(const var_t *v);
407 int cant_be_null(const var_t *v);
408 int is_struct(unsigned char tc);
409 int is_union(unsigned char tc);
411 var_t *find_const(const char *name, int f);
412 type_t *find_type(const char *name, int t);
413 type_t *make_type(unsigned char type, type_t *ref);
415 void init_loc_info(loc_info_t *);
417 static inline type_t *get_func_return_type(const func_t *func)
419 return func->def->type->ref;
422 #endif