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