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