Fix build on Linux.
[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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 #include "winglue.h"
28
29 #ifndef UUID_DEFINED
30 #define UUID_DEFINED
31 typedef GUID UUID;
32 #endif
33
34 #define TRUE 1
35 #define FALSE 0
36
37 typedef struct _attr_t attr_t;
38 typedef struct _expr_t expr_t;
39 typedef struct _type_t type_t;
40 typedef struct _typeref_t typeref_t;
41 typedef struct _var_t var_t;
42 typedef struct _func_t func_t;
43 typedef struct _ifref_t ifref_t;
44 typedef struct _class_t class_t;
45 typedef struct _typelib_entry_t typelib_entry_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 enum attr_type
59 {
60 ATTR_ASYNC,
61 ATTR_CALLAS,
62 ATTR_CASE,
63 ATTR_CONTEXTHANDLE,
64 ATTR_CONTROL,
65 ATTR_DEFAULT,
66 ATTR_DEFAULTVALUE_EXPR,
67 ATTR_DEFAULTVALUE_STRING,
68 ATTR_DLLNAME,
69 ATTR_DUAL,
70 ATTR_ENDPOINT,
71 ATTR_ENTRY_STRING,
72 ATTR_ENTRY_ORDINAL,
73 ATTR_HANDLE,
74 ATTR_HELPCONTEXT,
75 ATTR_HELPFILE,
76 ATTR_HELPSTRING,
77 ATTR_HELPSTRINGCONTEXT,
78 ATTR_HELPSTRINGDLL,
79 ATTR_HIDDEN,
80 ATTR_ID,
81 ATTR_IDEMPOTENT,
82 ATTR_IIDIS,
83 ATTR_IN,
84 ATTR_INPUTSYNC,
85 ATTR_LENGTHIS,
86 ATTR_LOCAL,
87 ATTR_NONCREATABLE,
88 ATTR_OBJECT,
89 ATTR_ODL,
90 ATTR_OLEAUTOMATION,
91 ATTR_OPTIONAL,
92 ATTR_OUT,
93 ATTR_POINTERDEFAULT,
94 ATTR_POINTERTYPE,
95 ATTR_PROPGET,
96 ATTR_PROPPUT,
97 ATTR_PROPPUTREF,
98 ATTR_PUBLIC,
99 ATTR_READONLY,
100 ATTR_RESTRICTED,
101 ATTR_RETVAL,
102 ATTR_SIZEIS,
103 ATTR_SOURCE,
104 ATTR_STRING,
105 ATTR_SWITCHIS,
106 ATTR_SWITCHTYPE,
107 ATTR_TRANSMITAS,
108 ATTR_UUID,
109 ATTR_V1ENUM,
110 ATTR_VARARG,
111 ATTR_VERSION,
112 ATTR_WIREMARSHAL,
113 ATTR_DISPINTERFACE
114 };
115
116 enum expr_type
117 {
118 EXPR_VOID,
119 EXPR_NUM,
120 EXPR_HEXNUM,
121 EXPR_IDENTIFIER,
122 EXPR_NEG,
123 EXPR_NOT,
124 EXPR_PPTR,
125 EXPR_CAST,
126 EXPR_SIZEOF,
127 EXPR_SHL,
128 EXPR_SHR,
129 EXPR_MUL,
130 EXPR_DIV,
131 EXPR_ADD,
132 EXPR_SUB,
133 EXPR_AND,
134 EXPR_OR,
135 EXPR_COND,
136 };
137
138 enum type_kind
139 {
140 TKIND_ENUM = 0,
141 TKIND_RECORD,
142 TKIND_MODULE,
143 TKIND_INTERFACE,
144 TKIND_DISPATCH,
145 TKIND_COCLASS,
146 TKIND_ALIAS,
147 TKIND_UNION,
148 TKIND_MAX
149 };
150
151 struct _attr_t {
152 enum attr_type type;
153 union {
154 unsigned long ival;
155 void *pval;
156 } u;
157 /* parser-internal */
158 DECL_LINK(attr_t)
159 };
160
161 struct _expr_t {
162 enum expr_type type;
163 expr_t *ref;
164 union {
165 long lval;
166 char *sval;
167 expr_t *ext;
168 typeref_t *tref;
169 } u;
170 expr_t *ext2;
171 int is_const;
172 long cval;
173 /* parser-internal */
174 DECL_LINK(expr_t)
175 };
176
177 struct _type_t {
178 char *name;
179 unsigned char type;
180 struct _type_t *ref;
181 char *rname;
182 attr_t *attrs;
183 func_t *funcs;
184 var_t *fields;
185 int ignore, is_const, sign;
186 int defined, written;
187 int typelib_idx;
188 /* parser-internal */
189 DECL_LINK(type_t)
190 };
191
192 struct _typeref_t {
193 char *name;
194 type_t *ref;
195 int uniq;
196 };
197
198 struct _var_t {
199 char *name;
200 int ptr_level;
201 expr_t *array;
202 type_t *type;
203 var_t *args; /* for function pointers */
204 char *tname;
205 attr_t *attrs;
206 expr_t *eval;
207 long lval;
208
209 /* parser-internal */
210 DECL_LINK(var_t)
211 };
212
213 struct _func_t {
214 var_t *def;
215 var_t *args;
216 int ignore, idx;
217
218 /* parser-internal */
219 DECL_LINK(func_t)
220 };
221
222 struct _ifref_t {
223 type_t *iface;
224 attr_t *attrs;
225
226 /* parser-internal */
227 DECL_LINK(ifref_t)
228 };
229
230 struct _class_t {
231 char *name;
232 attr_t *attrs;
233 ifref_t *ifaces;
234
235 /* parser-internal */
236 DECL_LINK(class_t)
237 };
238
239 struct _typelib_entry_t {
240 enum type_kind kind;
241 union {
242 class_t *class;
243 type_t *interface;
244 type_t *module;
245 type_t *structure;
246 type_t *enumeration;
247 var_t *tdef;
248 } u;
249 DECL_LINK(typelib_entry_t)
250 };
251
252 struct _typelib_t {
253 char *name;
254 char *filename;
255 attr_t *attrs;
256 typelib_entry_t *entry;
257 };
258
259 #endif