dinput: Move SetEventNotification and associated event into base class.
[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., 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 <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 _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;
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; x->l_prev = NULL; 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 #define END_OF_LIST(list)       \
59   do {                          \
60     if (list) {                 \
61       while (NEXT_LINK(list))   \
62         list = NEXT_LINK(list); \
63     }                           \
64   } while(0)
65
66 enum attr_type
67 {
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
136 };
137
138 enum expr_type
139 {
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,
159 };
160
161 enum type_kind
162 {
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
173 };
174    
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);
183 };
184
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);
199 };
200
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);
216 };
217
218 struct _typeref_t {
219   char *name;
220   type_t *ref;
221   int uniq;
222 };
223
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;
233
234   /* parser-internal */
235   DECL_LINK(var_t);
236 };
237
238 struct _func_t {
239   var_t *def;
240   var_t *args;
241   int ignore, idx;
242
243   /* parser-internal */
244   DECL_LINK(func_t);
245 };
246
247 struct _ifref_t {
248   type_t *iface;
249   attr_t *attrs;
250
251   /* parser-internal */
252   DECL_LINK(ifref_t);
253 };
254
255 struct _typelib_entry_t {
256     type_t *type;
257     DECL_LINK(typelib_entry_t);
258 };
259
260 struct _importinfo_t {
261     int offset;
262     GUID guid;
263     int flags;
264     int id;
265
266     char *name;
267
268     importlib_t *importlib;
269 };
270
271 struct _importlib_t {
272     char *name;
273
274     int version;
275     GUID guid;
276
277     importinfo_t *importinfos;
278     int ntypeinfos;
279
280     int allocated;
281
282     DECL_LINK(importlib_t);
283 };
284
285 struct _typelib_t {
286     char *name;
287     char *filename;
288     attr_t *attrs;
289     typelib_entry_t *entry;
290     importlib_t *importlibs;
291 };
292
293 void init_types(void);
294
295 type_t *duptype(type_t *t, int dupname);
296 type_t *alias(type_t *t, const char *name);
297
298 int is_ptr(const type_t *t);
299 int is_var_ptr(var_t *v);
300 int cant_be_null(var_t *v);
301
302 #endif