Synchronize with current WINE widl 20060729.
[reactos.git] / reactos / tools / widl / widltypes.h
1 /*
2 * IDL Compiler
3 *
4 * Copyright 2002 Ove Kaaven
5 *
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.
10 *
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.
15 *
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
19 */
20
21 #ifndef __WIDL_WIDLTYPES_H
22 #define __WIDL_WIDLTYPES_H
23
24 #include <stdarg.h>
25 #include "guiddef.h"
26 #include "wine/rpcfc.h"
27
28 #ifndef UUID_DEFINED
29 #define UUID_DEFINED
30 typedef GUID UUID;
31 #endif
32
33 #define TRUE 1
34 #define FALSE 0
35
36 typedef struct _attr_t attr_t;
37 typedef struct _expr_t expr_t;
38 typedef struct _type_t type_t;
39 typedef struct _typeref_t typeref_t;
40 typedef struct _var_t var_t;
41 typedef struct _func_t func_t;
42 typedef struct _ifref_t ifref_t;
43 typedef struct _typelib_entry_t typelib_entry_t;
44 typedef struct _importlib_t importlib_t;
45 typedef struct _importinfo_t importinfo_t;
46 typedef struct _typelib_t typelib_t;
47
48 #define DECL_LINK(type) \
49 type *l_next; \
50 type *l_prev
51
52 #define LINK(x,y) do { x->l_next = y; if (y) y->l_prev = x; } while (0)
53
54 #define INIT_LINK(x) do { x->l_next = NULL; x->l_prev = NULL; } while (0)
55 #define NEXT_LINK(x) ((x)->l_next)
56 #define PREV_LINK(x) ((x)->l_prev)
57
58 #define END_OF_LIST(list) \
59 do { \
60 if (list) { \
61 while (NEXT_LINK(list)) \
62 list = NEXT_LINK(list); \
63 } \
64 } while(0)
65
66 enum attr_type
67 {
68 ATTR_AGGREGATABLE,
69 ATTR_APPOBJECT,
70 ATTR_ASYNC,
71 ATTR_AUTO_HANDLE,
72 ATTR_BINDABLE,
73 ATTR_CALLAS,
74 ATTR_CASE,
75 ATTR_CONTEXTHANDLE,
76 ATTR_CONTROL,
77 ATTR_DEFAULT,
78 ATTR_DEFAULTCOLLELEM,
79 ATTR_DEFAULTVALUE_EXPR,
80 ATTR_DEFAULTVALUE_STRING,
81 ATTR_DEFAULTVTABLE,
82 ATTR_DISPINTERFACE,
83 ATTR_DISPLAYBIND,
84 ATTR_DLLNAME,
85 ATTR_DUAL,
86 ATTR_ENDPOINT,
87 ATTR_ENTRY_ORDINAL,
88 ATTR_ENTRY_STRING,
89 ATTR_EXPLICIT_HANDLE,
90 ATTR_HANDLE,
91 ATTR_HELPCONTEXT,
92 ATTR_HELPFILE,
93 ATTR_HELPSTRING,
94 ATTR_HELPSTRINGCONTEXT,
95 ATTR_HELPSTRINGDLL,
96 ATTR_HIDDEN,
97 ATTR_ID,
98 ATTR_IDEMPOTENT,
99 ATTR_IIDIS,
100 ATTR_IMMEDIATEBIND,
101 ATTR_IMPLICIT_HANDLE,
102 ATTR_IN,
103 ATTR_INPUTSYNC,
104 ATTR_LENGTHIS,
105 ATTR_LOCAL,
106 ATTR_NONBROWSABLE,
107 ATTR_NONCREATABLE,
108 ATTR_NONEXTENSIBLE,
109 ATTR_OBJECT,
110 ATTR_ODL,
111 ATTR_OLEAUTOMATION,
112 ATTR_OPTIONAL,
113 ATTR_OUT,
114 ATTR_POINTERDEFAULT,
115 ATTR_POINTERTYPE,
116 ATTR_PROPGET,
117 ATTR_PROPPUT,
118 ATTR_PROPPUTREF,
119 ATTR_PUBLIC,
120 ATTR_RANGE,
121 ATTR_READONLY,
122 ATTR_REQUESTEDIT,
123 ATTR_RESTRICTED,
124 ATTR_RETVAL,
125 ATTR_SIZEIS,
126 ATTR_SOURCE,
127 ATTR_STRING,
128 ATTR_SWITCHIS,
129 ATTR_SWITCHTYPE,
130 ATTR_TRANSMITAS,
131 ATTR_UUID,
132 ATTR_V1ENUM,
133 ATTR_VARARG,
134 ATTR_VERSION,
135 ATTR_WIREMARSHAL
136 };
137
138 enum expr_type
139 {
140 EXPR_VOID,
141 EXPR_NUM,
142 EXPR_HEXNUM,
143 EXPR_IDENTIFIER,
144 EXPR_NEG,
145 EXPR_NOT,
146 EXPR_PPTR,
147 EXPR_CAST,
148 EXPR_SIZEOF,
149 EXPR_SHL,
150 EXPR_SHR,
151 EXPR_MUL,
152 EXPR_DIV,
153 EXPR_ADD,
154 EXPR_SUB,
155 EXPR_AND,
156 EXPR_OR,
157 EXPR_COND,
158 EXPR_TRUEFALSE,
159 };
160
161 enum type_kind
162 {
163 TKIND_PRIMITIVE = -1,
164 TKIND_ENUM,
165 TKIND_RECORD,
166 TKIND_MODULE,
167 TKIND_INTERFACE,
168 TKIND_DISPATCH,
169 TKIND_COCLASS,
170 TKIND_ALIAS,
171 TKIND_UNION,
172 TKIND_MAX
173 };
174
175 struct _attr_t {
176 enum attr_type type;
177 union {
178 unsigned long ival;
179 void *pval;
180 } u;
181 /* parser-internal */
182 DECL_LINK(attr_t);
183 };
184
185 struct _expr_t {
186 enum expr_type type;
187 const expr_t *ref;
188 union {
189 long lval;
190 const char *sval;
191 const expr_t *ext;
192 const typeref_t *tref;
193 } u;
194 const expr_t *ext2;
195 int is_const;
196 long cval;
197 /* parser-internal */
198 DECL_LINK(expr_t);
199 };
200
201 struct _type_t {
202 const char *name;
203 enum type_kind kind;
204 unsigned char type;
205 struct _type_t *ref;
206 const attr_t *attrs;
207 func_t *funcs; /* interfaces and modules */
208 var_t *fields; /* interfaces, structures and enumerations */
209 ifref_t *ifaces; /* coclasses */
210 int ignore, is_const, sign;
211 int defined, written, user_types_registered;
212 int typelib_idx;
213 /* parser-internal */
214 DECL_LINK(type_t);
215 };
216
217 struct _typeref_t {
218 char *name;
219 type_t *ref;
220 int uniq;
221 };
222
223 struct _var_t {
224 char *name;
225 int ptr_level;
226 expr_t *array;
227 type_t *type;
228 var_t *args; /* for function pointers */
229 const char *tname;
230 attr_t *attrs;
231 expr_t *eval;
232
233 /* parser-internal */
234 DECL_LINK(var_t);
235 };
236
237 struct _func_t {
238 var_t *def;
239 var_t *args;
240 int ignore, idx;
241
242 /* parser-internal */
243 DECL_LINK(func_t);
244 };
245
246 struct _ifref_t {
247 type_t *iface;
248 attr_t *attrs;
249
250 /* parser-internal */
251 DECL_LINK(ifref_t);
252 };
253
254 struct _typelib_entry_t {
255 enum type_kind kind;
256 union {
257 type_t *class;
258 type_t *interface;
259 type_t *module;
260 type_t *structure;
261 type_t *enumeration;
262 var_t *tdef;
263 } u;
264 DECL_LINK(typelib_entry_t);
265 };
266
267 struct _importinfo_t {
268 int offset;
269 GUID guid;
270 int flags;
271 int id;
272
273 char *name;
274
275 importlib_t *importlib;
276 };
277
278 struct _importlib_t {
279 char *name;
280
281 int version;
282 GUID guid;
283
284 importinfo_t *importinfos;
285 int ntypeinfos;
286
287 int allocated;
288
289 DECL_LINK(importlib_t);
290 };
291
292 struct _typelib_t {
293 char *name;
294 char *filename;
295 attr_t *attrs;
296 typelib_entry_t *entry;
297 importlib_t *importlibs;
298 };
299
300 #endif