widl: Create a list of statements in the whole IDL file, instead of just a list of...
[wine/wine64.git] / tools / widl / widltypes.h
blob10064b7f7c7bbc4959171783259d8bce1f526bce
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 _pident_t pident_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 _statement_t statement_t;
57 typedef struct list attr_list_t;
58 typedef struct list str_list_t;
59 typedef struct list func_list_t;
60 typedef struct list expr_list_t;
61 typedef struct list var_list_t;
62 typedef struct list pident_list_t;
63 typedef struct list ifref_list_t;
64 typedef struct list array_dims_t;
65 typedef struct list user_type_list_t;
66 typedef struct list context_handle_list_t;
67 typedef struct list statement_list_t;
69 enum attr_type
71 ATTR_AGGREGATABLE,
72 ATTR_APPOBJECT,
73 ATTR_ASYNC,
74 ATTR_AUTO_HANDLE,
75 ATTR_BINDABLE,
76 ATTR_BROADCAST,
77 ATTR_CALLAS,
78 ATTR_CALLCONV, /* calling convention pseudo-attribute */
79 ATTR_CASE,
80 ATTR_CONTEXTHANDLE,
81 ATTR_CONTROL,
82 ATTR_DEFAULT,
83 ATTR_DEFAULTCOLLELEM,
84 ATTR_DEFAULTVALUE_EXPR,
85 ATTR_DEFAULTVALUE_STRING,
86 ATTR_DEFAULTVTABLE,
87 ATTR_DISPINTERFACE,
88 ATTR_DISPLAYBIND,
89 ATTR_DLLNAME,
90 ATTR_DUAL,
91 ATTR_ENDPOINT,
92 ATTR_ENTRY_ORDINAL,
93 ATTR_ENTRY_STRING,
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_INPUTSYNC,
109 ATTR_LENGTHIS,
110 ATTR_LIBLCID,
111 ATTR_LOCAL,
112 ATTR_NONBROWSABLE,
113 ATTR_NONCREATABLE,
114 ATTR_NONEXTENSIBLE,
115 ATTR_OBJECT,
116 ATTR_ODL,
117 ATTR_OLEAUTOMATION,
118 ATTR_OPTIONAL,
119 ATTR_OUT,
120 ATTR_POINTERDEFAULT,
121 ATTR_POINTERTYPE,
122 ATTR_PROPGET,
123 ATTR_PROPPUT,
124 ATTR_PROPPUTREF,
125 ATTR_PUBLIC,
126 ATTR_RANGE,
127 ATTR_READONLY,
128 ATTR_REQUESTEDIT,
129 ATTR_RESTRICTED,
130 ATTR_RETVAL,
131 ATTR_SIZEIS,
132 ATTR_SOURCE,
133 ATTR_STRICTCONTEXTHANDLE,
134 ATTR_STRING,
135 ATTR_SWITCHIS,
136 ATTR_SWITCHTYPE,
137 ATTR_TRANSMITAS,
138 ATTR_UUID,
139 ATTR_V1ENUM,
140 ATTR_VARARG,
141 ATTR_VERSION,
142 ATTR_WIREMARSHAL
145 enum expr_type
147 EXPR_VOID,
148 EXPR_NUM,
149 EXPR_HEXNUM,
150 EXPR_DOUBLE,
151 EXPR_IDENTIFIER,
152 EXPR_NEG,
153 EXPR_NOT,
154 EXPR_PPTR,
155 EXPR_CAST,
156 EXPR_SIZEOF,
157 EXPR_SHL,
158 EXPR_SHR,
159 EXPR_MUL,
160 EXPR_DIV,
161 EXPR_ADD,
162 EXPR_SUB,
163 EXPR_AND,
164 EXPR_OR,
165 EXPR_COND,
166 EXPR_TRUEFALSE,
167 EXPR_ADDRESSOF,
168 EXPR_MEMBER,
169 EXPR_ARRAY,
170 EXPR_MOD,
171 EXPR_LOGOR,
172 EXPR_LOGAND,
173 EXPR_XOR,
174 EXPR_EQUALITY,
175 EXPR_INEQUALITY,
176 EXPR_GTR,
177 EXPR_LESS,
178 EXPR_GTREQL,
179 EXPR_LESSEQL,
180 EXPR_LOGNOT,
181 EXPR_POS,
184 enum type_kind
186 TKIND_PRIMITIVE = -1,
187 TKIND_ENUM,
188 TKIND_RECORD,
189 TKIND_MODULE,
190 TKIND_INTERFACE,
191 TKIND_DISPATCH,
192 TKIND_COCLASS,
193 TKIND_ALIAS,
194 TKIND_UNION,
195 TKIND_MAX
198 enum statement_type
200 STMT_LIBRARY,
201 STMT_INITDECL,
202 STMT_EXTERN,
203 STMT_TYPE,
204 STMT_TYPEREF,
205 STMT_MODULE,
206 STMT_TYPEDEF,
207 STMT_IMPORT,
208 STMT_IMPORTLIB,
209 STMT_CPPQUOTE
212 struct _loc_info_t
214 const char *input_name;
215 int line_number;
216 const char *near_text;
219 struct str_list_entry_t
221 char *str;
222 struct list entry;
225 struct _attr_t {
226 enum attr_type type;
227 union {
228 unsigned long ival;
229 void *pval;
230 } u;
231 /* parser-internal */
232 struct list entry;
235 struct _expr_t {
236 enum expr_type type;
237 const expr_t *ref;
238 union {
239 long lval;
240 double dval;
241 const char *sval;
242 const expr_t *ext;
243 type_t *tref;
244 } u;
245 const expr_t *ext2;
246 int is_const;
247 long cval;
248 /* parser-internal */
249 struct list entry;
252 struct _type_t {
253 const char *name;
254 enum type_kind kind;
255 unsigned char type;
256 struct _type_t *ref;
257 const attr_list_t *attrs;
258 func_list_t *funcs; /* interfaces and modules */
259 var_list_t *fields_or_args; /* interfaces, structures, enumerations and functions (for args) */
260 ifref_list_t *ifaces; /* coclasses */
261 unsigned long dim; /* array dimension */
262 expr_t *size_is, *length_is;
263 type_t *orig; /* dup'd types */
264 unsigned int typestring_offset;
265 unsigned int ptrdesc; /* used for complex structs */
266 int typelib_idx;
267 unsigned int declarray : 1; /* if declared as an array */
268 unsigned int ignore : 1;
269 unsigned int is_const : 1;
270 unsigned int defined : 1;
271 unsigned int written : 1;
272 unsigned int user_types_registered : 1;
273 unsigned int tfswrite : 1; /* if the type needs to be written to the TFS */
274 unsigned int checked : 1;
275 int sign : 2;
278 struct _var_t {
279 char *name;
280 type_t *type;
281 attr_list_t *attrs;
282 expr_t *eval;
284 struct _loc_info_t loc_info;
286 /* parser-internal */
287 struct list entry;
290 struct _pident_t {
291 var_t *var;
292 type_t *type;
293 type_t *func_type;
295 /* parser-internal */
296 struct list entry;
299 struct _func_t {
300 var_t *def;
301 var_list_t *args;
302 int ignore, idx;
304 /* parser-internal */
305 struct list entry;
308 struct _ifref_t {
309 type_t *iface;
310 attr_list_t *attrs;
312 /* parser-internal */
313 struct list entry;
316 struct _typelib_entry_t {
317 type_t *type;
318 struct list entry;
321 struct _importinfo_t {
322 int offset;
323 GUID guid;
324 int flags;
325 int id;
327 char *name;
329 importlib_t *importlib;
332 struct _importlib_t {
333 char *name;
335 int version;
336 GUID guid;
338 importinfo_t *importinfos;
339 int ntypeinfos;
341 int allocated;
343 struct list entry;
346 struct _typelib_t {
347 char *name;
348 char *filename;
349 const attr_list_t *attrs;
350 struct list entries;
351 struct list importlibs;
352 statement_list_t *stmts;
355 struct _user_type_t {
356 struct list entry;
357 const char *name;
360 struct _statement_t {
361 struct list entry;
362 enum statement_type type;
363 union
365 ifref_t iface;
366 type_t *type;
367 const char *str;
368 var_t *var;
369 typelib_t *lib;
370 } u;
373 extern unsigned char pointer_default;
375 extern user_type_list_t user_type_list;
376 void check_for_additional_prototype_types(const var_list_t *list);
378 void init_types(void);
379 type_t *alloc_type(void);
380 void set_all_tfswrite(int val);
382 type_t *duptype(type_t *t, int dupname);
383 type_t *alias(type_t *t, const char *name);
385 int is_ptr(const type_t *t);
386 int is_array(const type_t *t);
387 int is_var_ptr(const var_t *v);
388 int cant_be_null(const var_t *v);
389 int is_struct(unsigned char tc);
390 int is_union(unsigned char tc);
392 var_t *find_const(const char *name, int f);
393 type_t *find_type(const char *name, int t);
394 type_t *make_type(unsigned char type, type_t *ref);
396 static inline type_t *get_func_return_type(const func_t *func)
398 return func->def->type->ref;
401 #endif