push 6fe5edf8439c19d3885814583531c2f2b1495177
[wine/hacks.git] / tools / widl / widltypes.h
blob89d593a8358140f1d5ee75b094b9193aa4c71251
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,
166 enum type_kind
168 TKIND_PRIMITIVE = -1,
169 TKIND_ENUM,
170 TKIND_RECORD,
171 TKIND_MODULE,
172 TKIND_INTERFACE,
173 TKIND_DISPATCH,
174 TKIND_COCLASS,
175 TKIND_ALIAS,
176 TKIND_UNION,
177 TKIND_MAX
180 struct _loc_info_t
182 const char *input_name;
183 int line_number;
184 const char *near_text;
187 struct str_list_entry_t
189 char *str;
190 struct list entry;
193 struct _attr_t {
194 enum attr_type type;
195 union {
196 unsigned long ival;
197 void *pval;
198 } u;
199 /* parser-internal */
200 struct list entry;
203 struct _expr_t {
204 enum expr_type type;
205 const expr_t *ref;
206 union {
207 long lval;
208 double dval;
209 const char *sval;
210 const expr_t *ext;
211 type_t *tref;
212 } u;
213 const expr_t *ext2;
214 int is_const;
215 long cval;
216 /* parser-internal */
217 struct list entry;
220 struct _type_t {
221 const char *name;
222 enum type_kind kind;
223 unsigned char type;
224 struct _type_t *ref;
225 const attr_list_t *attrs;
226 func_list_t *funcs; /* interfaces and modules */
227 var_list_t *fields_or_args; /* interfaces, structures, enumerations and functions (for args) */
228 ifref_list_t *ifaces; /* coclasses */
229 unsigned long dim; /* array dimension */
230 expr_t *size_is, *length_is;
231 type_t *orig; /* dup'd types */
232 unsigned int typestring_offset;
233 unsigned int ptrdesc; /* used for complex structs */
234 int typelib_idx;
235 unsigned int declarray : 1; /* if declared as an array */
236 unsigned int ignore : 1;
237 unsigned int is_const : 1;
238 unsigned int defined : 1;
239 unsigned int written : 1;
240 unsigned int user_types_registered : 1;
241 unsigned int tfswrite : 1; /* if the type needs to be written to the TFS */
242 int sign : 2;
245 struct _var_t {
246 char *name;
247 type_t *type;
248 attr_list_t *attrs;
249 expr_t *eval;
251 struct _loc_info_t loc_info;
253 /* parser-internal */
254 struct list entry;
257 struct _pident_t {
258 var_t *var;
259 int ptr_level;
261 int is_func;
262 /* levels of indirection for function pointers */
263 int func_ptr_level;
264 var_list_t *args;
265 char *callconv;
267 /* parser-internal */
268 struct list entry;
271 struct _func_t {
272 var_t *def;
273 var_list_t *args;
274 int ignore, idx;
276 /* parser-internal */
277 struct list entry;
280 struct _ifref_t {
281 type_t *iface;
282 attr_list_t *attrs;
284 /* parser-internal */
285 struct list entry;
288 struct _typelib_entry_t {
289 type_t *type;
290 struct list entry;
293 struct _importinfo_t {
294 int offset;
295 GUID guid;
296 int flags;
297 int id;
299 char *name;
301 importlib_t *importlib;
304 struct _importlib_t {
305 char *name;
307 int version;
308 GUID guid;
310 importinfo_t *importinfos;
311 int ntypeinfos;
313 int allocated;
315 struct list entry;
318 struct _typelib_t {
319 char *name;
320 char *filename;
321 const attr_list_t *attrs;
322 struct list entries;
323 struct list importlibs;
326 struct _user_type_t {
327 struct list entry;
328 const char *name;
331 extern unsigned char pointer_default;
333 extern user_type_list_t user_type_list;
334 void check_for_additional_prototype_types(const var_list_t *list);
336 void init_types(void);
337 type_t *alloc_type(void);
338 void set_all_tfswrite(int val);
340 type_t *duptype(type_t *t, int dupname);
341 type_t *alias(type_t *t, const char *name);
343 int is_ptr(const type_t *t);
344 int is_array(const type_t *t);
345 int is_var_ptr(const var_t *v);
346 int cant_be_null(const var_t *v);
347 int is_struct(unsigned char tc);
348 int is_union(unsigned char tc);
350 static inline type_t *get_func_return_type(const func_t *func)
352 return func->def->type->ref;
355 #endif