crypt32: Introduce function to encode an array of items as a set.
[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 #include "wine/list.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 _pident_t pident_t;
43 typedef struct _func_t func_t;
44 typedef struct _ifref_t ifref_t;
45 typedef struct _typelib_entry_t typelib_entry_t;
46 typedef struct _importlib_t importlib_t;
47 typedef struct _importinfo_t importinfo_t;
48 typedef struct _typelib_t typelib_t;
49 typedef struct _user_type_t user_type_t;
50
51 typedef struct list attr_list_t;
52 typedef struct list str_list_t;
53 typedef struct list func_list_t;
54 typedef struct list expr_list_t;
55 typedef struct list var_list_t;
56 typedef struct list pident_list_t;
57 typedef struct list ifref_list_t;
58 typedef struct list array_dims_t;
59 typedef struct list user_type_list_t;
60
61 enum attr_type
62 {
63     ATTR_AGGREGATABLE,
64     ATTR_APPOBJECT,
65     ATTR_ASYNC,
66     ATTR_AUTO_HANDLE,
67     ATTR_BINDABLE,
68     ATTR_CALLAS,
69     ATTR_CASE,
70     ATTR_CONTEXTHANDLE,
71     ATTR_CONTROL,
72     ATTR_DEFAULT,
73     ATTR_DEFAULTCOLLELEM,
74     ATTR_DEFAULTVALUE_EXPR,
75     ATTR_DEFAULTVALUE_STRING,
76     ATTR_DEFAULTVTABLE,
77     ATTR_DISPINTERFACE,
78     ATTR_DISPLAYBIND,
79     ATTR_DLLNAME,
80     ATTR_DUAL,
81     ATTR_ENDPOINT,
82     ATTR_ENTRY_ORDINAL,
83     ATTR_ENTRY_STRING,
84     ATTR_EXPLICIT_HANDLE,
85     ATTR_HANDLE,
86     ATTR_HELPCONTEXT,
87     ATTR_HELPFILE,
88     ATTR_HELPSTRING,
89     ATTR_HELPSTRINGCONTEXT,
90     ATTR_HELPSTRINGDLL,
91     ATTR_HIDDEN,
92     ATTR_ID,
93     ATTR_IDEMPOTENT,
94     ATTR_IIDIS,
95     ATTR_IMMEDIATEBIND,
96     ATTR_IMPLICIT_HANDLE,
97     ATTR_IN,
98     ATTR_INPUTSYNC,
99     ATTR_LENGTHIS,
100     ATTR_LOCAL,
101     ATTR_NONBROWSABLE,
102     ATTR_NONCREATABLE,
103     ATTR_NONEXTENSIBLE,
104     ATTR_OBJECT,
105     ATTR_ODL,
106     ATTR_OLEAUTOMATION,
107     ATTR_OPTIONAL,
108     ATTR_OUT,
109     ATTR_POINTERDEFAULT,
110     ATTR_POINTERTYPE,
111     ATTR_PROPGET,
112     ATTR_PROPPUT,
113     ATTR_PROPPUTREF,
114     ATTR_PUBLIC,
115     ATTR_RANGE,
116     ATTR_READONLY,
117     ATTR_REQUESTEDIT,
118     ATTR_RESTRICTED,
119     ATTR_RETVAL,
120     ATTR_SIZEIS,
121     ATTR_SOURCE,
122     ATTR_STRING,
123     ATTR_SWITCHIS,
124     ATTR_SWITCHTYPE,
125     ATTR_TRANSMITAS,
126     ATTR_UUID,
127     ATTR_V1ENUM,
128     ATTR_VARARG,
129     ATTR_VERSION,
130     ATTR_WIREMARSHAL
131 };
132
133 enum expr_type
134 {
135     EXPR_VOID,
136     EXPR_NUM,
137     EXPR_HEXNUM,
138     EXPR_DOUBLE,
139     EXPR_IDENTIFIER,
140     EXPR_NEG,
141     EXPR_NOT,
142     EXPR_PPTR,
143     EXPR_CAST,
144     EXPR_SIZEOF,
145     EXPR_SHL,
146     EXPR_SHR,
147     EXPR_MUL,
148     EXPR_DIV,
149     EXPR_ADD,
150     EXPR_SUB,
151     EXPR_AND,
152     EXPR_OR,
153     EXPR_COND,
154     EXPR_TRUEFALSE,
155 };
156
157 enum type_kind
158 {
159     TKIND_PRIMITIVE = -1,
160     TKIND_ENUM,
161     TKIND_RECORD,
162     TKIND_MODULE,
163     TKIND_INTERFACE,
164     TKIND_DISPATCH,
165     TKIND_COCLASS,
166     TKIND_ALIAS,
167     TKIND_UNION,
168     TKIND_MAX
169 };
170
171 struct str_list_entry_t
172 {
173     char *str;
174     struct list entry;
175 };
176
177 struct _attr_t {
178   enum attr_type type;
179   union {
180     unsigned long ival;
181     void *pval;
182   } u;
183   /* parser-internal */
184   struct list entry;
185 };
186
187 struct _expr_t {
188   enum expr_type type;
189   const expr_t *ref;
190   union {
191     long lval;
192     double dval;
193     const char *sval;
194     const expr_t *ext;
195     type_t *tref;
196   } u;
197   const expr_t *ext2;
198   int is_const;
199   long cval;
200   /* parser-internal */
201   struct list entry;
202 };
203
204 struct _type_t {
205   const char *name;
206   enum type_kind kind;
207   unsigned char type;
208   struct _type_t *ref;
209   const attr_list_t *attrs;
210   func_list_t *funcs;             /* interfaces and modules */
211   var_list_t *fields;             /* interfaces, structures and enumerations */
212   ifref_list_t *ifaces;           /* coclasses */
213   unsigned long dim;              /* array dimension */
214   expr_t *size_is, *length_is;
215   type_t *orig;                   /* dup'd types */
216   unsigned int typestring_offset;
217   int typelib_idx;
218   unsigned int declarray : 1;     /* if declared as an array */
219   unsigned int ignore : 1;
220   unsigned int is_const : 1;
221   unsigned int defined : 1;
222   unsigned int written : 1;
223   unsigned int user_types_registered : 1;
224   unsigned int tfswrite : 1;   /* if the type needs to be written to the TFS */
225   int sign : 2;
226 };
227
228 struct _var_t {
229   char *name;
230   type_t *type;
231   var_list_t *args;  /* for function pointers */
232   attr_list_t *attrs;
233   expr_t *eval;
234
235   /* parser-internal */
236   struct list entry;
237 };
238
239 struct _pident_t {
240   var_t *var;
241   int ptr_level;
242
243   /* parser-internal */
244   struct list entry;
245 };
246
247 struct _func_t {
248   var_t *def;
249   var_list_t *args;
250   int ignore, idx;
251
252   /* parser-internal */
253   struct list entry;
254 };
255
256 struct _ifref_t {
257   type_t *iface;
258   attr_list_t *attrs;
259
260   /* parser-internal */
261   struct list entry;
262 };
263
264 struct _typelib_entry_t {
265     type_t *type;
266     struct list entry;
267 };
268
269 struct _importinfo_t {
270     int offset;
271     GUID guid;
272     int flags;
273     int id;
274
275     char *name;
276
277     importlib_t *importlib;
278 };
279
280 struct _importlib_t {
281     char *name;
282
283     int version;
284     GUID guid;
285
286     importinfo_t *importinfos;
287     int ntypeinfos;
288
289     int allocated;
290
291     struct list entry;
292 };
293
294 struct _typelib_t {
295     char *name;
296     char *filename;
297     attr_list_t *attrs;
298     struct list entries;
299     struct list importlibs;
300 };
301
302 struct _user_type_t {
303     struct list entry;
304     const char *name;
305 };
306
307 extern user_type_list_t user_type_list;
308 void check_for_user_types(const var_list_t *list);
309
310 void init_types(void);
311
312 type_t *duptype(type_t *t, int dupname);
313 type_t *alias(type_t *t, const char *name);
314
315 int is_ptr(const type_t *t);
316 int is_array(const type_t *t);
317 int is_var_ptr(const var_t *v);
318 int cant_be_null(const var_t *v);
319 int is_struct(unsigned char tc);
320 int is_union(unsigned char tc);
321
322 #endif