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