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