widl: Add support for arrays in expressions.
[wine/wine-jacek.git] / tools / widl / widltypes.h
blob31c7599a5547d4fbe300273cc68aaf8e6f780544
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_FUNCTION 0xfe
39 typedef struct _loc_info_t loc_info_t;
40 typedef struct _attr_t attr_t;
41 typedef struct _expr_t expr_t;
42 typedef struct _type_t type_t;
43 typedef struct _typeref_t typeref_t;
44 typedef struct _var_t var_t;
45 typedef struct _pident_t pident_t;
46 typedef struct _func_t func_t;
47 typedef struct _ifref_t ifref_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;
55 typedef struct list attr_list_t;
56 typedef struct list str_list_t;
57 typedef struct list func_list_t;
58 typedef struct list expr_list_t;
59 typedef struct list var_list_t;
60 typedef struct list pident_list_t;
61 typedef struct list ifref_list_t;
62 typedef struct list array_dims_t;
63 typedef struct list user_type_list_t;
64 typedef struct list context_handle_list_t;
66 enum attr_type
68 ATTR_AGGREGATABLE,
69 ATTR_APPOBJECT,
70 ATTR_ASYNC,
71 ATTR_AUTO_HANDLE,
72 ATTR_BINDABLE,
73 ATTR_BROADCAST,
74 ATTR_CALLAS,
75 ATTR_CALLCONV, /* calling convention pseudo-attribute */
76 ATTR_CASE,
77 ATTR_CONTEXTHANDLE,
78 ATTR_CONTROL,
79 ATTR_DEFAULT,
80 ATTR_DEFAULTCOLLELEM,
81 ATTR_DEFAULTVALUE_EXPR,
82 ATTR_DEFAULTVALUE_STRING,
83 ATTR_DEFAULTVTABLE,
84 ATTR_DISPINTERFACE,
85 ATTR_DISPLAYBIND,
86 ATTR_DLLNAME,
87 ATTR_DUAL,
88 ATTR_ENDPOINT,
89 ATTR_ENTRY_ORDINAL,
90 ATTR_ENTRY_STRING,
91 ATTR_EXPLICIT_HANDLE,
92 ATTR_HANDLE,
93 ATTR_HELPCONTEXT,
94 ATTR_HELPFILE,
95 ATTR_HELPSTRING,
96 ATTR_HELPSTRINGCONTEXT,
97 ATTR_HELPSTRINGDLL,
98 ATTR_HIDDEN,
99 ATTR_ID,
100 ATTR_IDEMPOTENT,
101 ATTR_IIDIS,
102 ATTR_IMMEDIATEBIND,
103 ATTR_IMPLICIT_HANDLE,
104 ATTR_IN,
105 ATTR_INPUTSYNC,
106 ATTR_LENGTHIS,
107 ATTR_LOCAL,
108 ATTR_NONBROWSABLE,
109 ATTR_NONCREATABLE,
110 ATTR_NONEXTENSIBLE,
111 ATTR_OBJECT,
112 ATTR_ODL,
113 ATTR_OLEAUTOMATION,
114 ATTR_OPTIONAL,
115 ATTR_OUT,
116 ATTR_POINTERDEFAULT,
117 ATTR_POINTERTYPE,
118 ATTR_PROPGET,
119 ATTR_PROPPUT,
120 ATTR_PROPPUTREF,
121 ATTR_PUBLIC,
122 ATTR_RANGE,
123 ATTR_READONLY,
124 ATTR_REQUESTEDIT,
125 ATTR_RESTRICTED,
126 ATTR_RETVAL,
127 ATTR_SIZEIS,
128 ATTR_SOURCE,
129 ATTR_STRICTCONTEXTHANDLE,
130 ATTR_STRING,
131 ATTR_SWITCHIS,
132 ATTR_SWITCHTYPE,
133 ATTR_TRANSMITAS,
134 ATTR_UUID,
135 ATTR_V1ENUM,
136 ATTR_VARARG,
137 ATTR_VERSION,
138 ATTR_WIREMARSHAL
141 enum expr_type
143 EXPR_VOID,
144 EXPR_NUM,
145 EXPR_HEXNUM,
146 EXPR_DOUBLE,
147 EXPR_IDENTIFIER,
148 EXPR_NEG,
149 EXPR_NOT,
150 EXPR_PPTR,
151 EXPR_CAST,
152 EXPR_SIZEOF,
153 EXPR_SHL,
154 EXPR_SHR,
155 EXPR_MUL,
156 EXPR_DIV,
157 EXPR_ADD,
158 EXPR_SUB,
159 EXPR_AND,
160 EXPR_OR,
161 EXPR_COND,
162 EXPR_TRUEFALSE,
163 EXPR_ADDRESSOF,
164 EXPR_MEMBERPTR,
165 EXPR_MEMBER,
166 EXPR_ARRAY,
169 enum type_kind
171 TKIND_PRIMITIVE = -1,
172 TKIND_ENUM,
173 TKIND_RECORD,
174 TKIND_MODULE,
175 TKIND_INTERFACE,
176 TKIND_DISPATCH,
177 TKIND_COCLASS,
178 TKIND_ALIAS,
179 TKIND_UNION,
180 TKIND_MAX
183 struct _loc_info_t
185 const char *input_name;
186 int line_number;
187 const char *near_text;
190 struct str_list_entry_t
192 char *str;
193 struct list entry;
196 struct _attr_t {
197 enum attr_type type;
198 union {
199 unsigned long ival;
200 void *pval;
201 } u;
202 /* parser-internal */
203 struct list entry;
206 struct _expr_t {
207 enum expr_type type;
208 const expr_t *ref;
209 union {
210 long lval;
211 double dval;
212 const char *sval;
213 const expr_t *ext;
214 type_t *tref;
215 } u;
216 const expr_t *ext2;
217 int is_const;
218 long cval;
219 /* parser-internal */
220 struct list entry;
223 struct _type_t {
224 const char *name;
225 enum type_kind kind;
226 unsigned char type;
227 struct _type_t *ref;
228 const attr_list_t *attrs;
229 func_list_t *funcs; /* interfaces and modules */
230 var_list_t *fields_or_args; /* interfaces, structures, enumerations and functions (for args) */
231 ifref_list_t *ifaces; /* coclasses */
232 unsigned long dim; /* array dimension */
233 expr_t *size_is, *length_is;
234 type_t *orig; /* dup'd types */
235 unsigned int typestring_offset;
236 unsigned int ptrdesc; /* used for complex structs */
237 int typelib_idx;
238 unsigned int declarray : 1; /* if declared as an array */
239 unsigned int ignore : 1;
240 unsigned int is_const : 1;
241 unsigned int defined : 1;
242 unsigned int written : 1;
243 unsigned int user_types_registered : 1;
244 unsigned int tfswrite : 1; /* if the type needs to be written to the TFS */
245 unsigned int checked : 1;
246 int sign : 2;
249 struct _var_t {
250 char *name;
251 type_t *type;
252 attr_list_t *attrs;
253 expr_t *eval;
255 struct _loc_info_t loc_info;
257 /* parser-internal */
258 struct list entry;
261 struct _pident_t {
262 var_t *var;
263 int ptr_level;
265 int is_func;
266 /* levels of indirection for function pointers */
267 int func_ptr_level;
268 var_list_t *args;
269 char *callconv;
271 /* parser-internal */
272 struct list entry;
275 struct _func_t {
276 var_t *def;
277 var_list_t *args;
278 int ignore, idx;
280 /* parser-internal */
281 struct list entry;
284 struct _ifref_t {
285 type_t *iface;
286 attr_list_t *attrs;
288 /* parser-internal */
289 struct list entry;
292 struct _typelib_entry_t {
293 type_t *type;
294 struct list entry;
297 struct _importinfo_t {
298 int offset;
299 GUID guid;
300 int flags;
301 int id;
303 char *name;
305 importlib_t *importlib;
308 struct _importlib_t {
309 char *name;
311 int version;
312 GUID guid;
314 importinfo_t *importinfos;
315 int ntypeinfos;
317 int allocated;
319 struct list entry;
322 struct _typelib_t {
323 char *name;
324 char *filename;
325 const attr_list_t *attrs;
326 struct list entries;
327 struct list importlibs;
330 struct _user_type_t {
331 struct list entry;
332 const char *name;
335 extern unsigned char pointer_default;
337 extern user_type_list_t user_type_list;
338 void check_for_additional_prototype_types(const var_list_t *list);
340 void init_types(void);
341 type_t *alloc_type(void);
342 void set_all_tfswrite(int val);
344 type_t *duptype(type_t *t, int dupname);
345 type_t *alias(type_t *t, const char *name);
347 int is_ptr(const type_t *t);
348 int is_array(const type_t *t);
349 int is_var_ptr(const var_t *v);
350 int cant_be_null(const var_t *v);
351 int is_struct(unsigned char tc);
352 int is_union(unsigned char tc);
354 static inline type_t *get_func_return_type(const func_t *func)
356 return func->def->type->ref;
359 #endif