widl: xmalloc shouldn't initialize to zero, do that explicitly where needed.
[wine.git] / tools / widl / widltypes.h
blobeeaa627200f0504692076a5bac5616450e918558
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"
28 #ifndef UUID_DEFINED
29 #define UUID_DEFINED
30 typedef GUID UUID;
31 #endif
33 #define TRUE 1
34 #define FALSE 0
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;
48 #define DECL_LINK(type) \
49 type *l_next; \
50 type *l_prev
52 #define LINK(x,y) do { x->l_next = y; x->l_prev = NULL; if (y) y->l_prev = x; } while (0)
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)
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)
66 enum attr_type
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
138 enum expr_type
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,
161 enum type_kind
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
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);
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);
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 type_t *orig; /* dup'd types */
211 int ignore, is_const, sign;
212 int defined, written, user_types_registered;
213 int typelib_idx;
214 /* parser-internal */
215 DECL_LINK(type_t);
218 struct _typeref_t {
219 char *name;
220 type_t *ref;
221 int uniq;
224 struct _var_t {
225 char *name;
226 int ptr_level;
227 expr_t *array;
228 type_t *type;
229 var_t *args; /* for function pointers */
230 const char *tname;
231 attr_t *attrs;
232 expr_t *eval;
234 /* parser-internal */
235 DECL_LINK(var_t);
238 struct _func_t {
239 var_t *def;
240 var_t *args;
241 int ignore, idx;
243 /* parser-internal */
244 DECL_LINK(func_t);
247 struct _ifref_t {
248 type_t *iface;
249 attr_t *attrs;
251 /* parser-internal */
252 DECL_LINK(ifref_t);
255 struct _typelib_entry_t {
256 enum type_kind kind;
257 union {
258 type_t *class;
259 type_t *interface;
260 type_t *module;
261 type_t *structure;
262 type_t *enumeration;
263 var_t *tdef;
264 } u;
265 DECL_LINK(typelib_entry_t);
268 struct _importinfo_t {
269 int offset;
270 GUID guid;
271 int flags;
272 int id;
274 char *name;
276 importlib_t *importlib;
279 struct _importlib_t {
280 char *name;
282 int version;
283 GUID guid;
285 importinfo_t *importinfos;
286 int ntypeinfos;
288 int allocated;
290 DECL_LINK(importlib_t);
293 struct _typelib_t {
294 char *name;
295 char *filename;
296 attr_t *attrs;
297 typelib_entry_t *entry;
298 importlib_t *importlibs;
301 void init_types(void);
303 type_t *duptype(type_t *t, int dupname);
304 type_t *alias(type_t *t, const char *name);
306 /* Get the actual type field for a type (chase down typedef references). */
307 unsigned char ref_type(const type_t *type);
308 int is_pointer(var_t *v);
309 int cant_be_null(var_t *v);
311 #endif