widltypes.h 5.85 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/*
 * IDL Compiler
 *
 * Copyright 2002 Ove Kaaven
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * 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 22 23
 */

#ifndef __WIDL_WIDLTYPES_H
#define __WIDL_WIDLTYPES_H

24
#include <stdarg.h>
25
#include "guiddef.h"
26 27
#include "wine/rpcfc.h"

28 29 30 31 32
#ifndef UUID_DEFINED
#define UUID_DEFINED
typedef GUID UUID;
#endif

33 34 35
#define TRUE 1
#define FALSE 0

36
typedef struct _attr_t attr_t;
37
typedef struct _expr_t expr_t;
38 39 40 41
typedef struct _type_t type_t;
typedef struct _typeref_t typeref_t;
typedef struct _var_t var_t;
typedef struct _func_t func_t;
42
typedef struct _ifref_t ifref_t;
43
typedef struct _typelib_entry_t typelib_entry_t;
44 45
typedef struct _importlib_t importlib_t;
typedef struct _importinfo_t importinfo_t;
46
typedef struct _typelib_t typelib_t;
47 48 49

#define DECL_LINK(type) \
  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 55 56 57

#define INIT_LINK(x) do { x->l_next = NULL; x->l_prev = NULL; } while (0)
#define NEXT_LINK(x) ((x)->l_next)
#define PREV_LINK(x) ((x)->l_prev)

58 59 60 61 62 63 64 65
#define END_OF_LIST(list)       \
  do {                          \
    if (list) {                 \
      while (NEXT_LINK(list))   \
        list = NEXT_LINK(list); \
    }                           \
  } while(0)

66 67
enum attr_type
{
68 69
    ATTR_AGGREGATABLE,
    ATTR_APPOBJECT,
70
    ATTR_ASYNC,
71
    ATTR_AUTO_HANDLE,
72
    ATTR_BINDABLE,
73
    ATTR_CALLAS,
74 75
    ATTR_CASE,
    ATTR_CONTEXTHANDLE,
76
    ATTR_CONTROL,
77
    ATTR_DEFAULT,
78
    ATTR_DEFAULTCOLLELEM,
79 80
    ATTR_DEFAULTVALUE_EXPR,
    ATTR_DEFAULTVALUE_STRING,
81
    ATTR_DEFAULTVTABLE,
82
    ATTR_DISPINTERFACE,
83
    ATTR_DISPLAYBIND,
84 85
    ATTR_DLLNAME,
    ATTR_DUAL,
86
    ATTR_ENDPOINT,
87
    ATTR_ENTRY_ORDINAL,
88
    ATTR_ENTRY_STRING,
89
    ATTR_EXPLICIT_HANDLE,
90
    ATTR_HANDLE,
91 92
    ATTR_HELPCONTEXT,
    ATTR_HELPFILE,
93
    ATTR_HELPSTRING,
94 95
    ATTR_HELPSTRINGCONTEXT,
    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,
Huw Davies's avatar
Huw Davies committed
107
    ATTR_NONCREATABLE,
108
    ATTR_NONEXTENSIBLE,
109
    ATTR_OBJECT,
110
    ATTR_ODL,
111
    ATTR_OLEAUTOMATION,
112
    ATTR_OPTIONAL,
113 114 115
    ATTR_OUT,
    ATTR_POINTERDEFAULT,
    ATTR_POINTERTYPE,
116 117
    ATTR_PROPGET,
    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 129
    ATTR_SWITCHIS,
    ATTR_SWITCHTYPE,
130
    ATTR_TRANSMITAS,
131
    ATTR_UUID,
132
    ATTR_V1ENUM,
133
    ATTR_VARARG,
134
    ATTR_VERSION,
135
    ATTR_WIREMARSHAL
136 137
};

138 139 140 141
enum expr_type
{
    EXPR_VOID,
    EXPR_NUM,
142
    EXPR_HEXNUM,
143 144
    EXPR_IDENTIFIER,
    EXPR_NEG,
145
    EXPR_NOT,
146 147
    EXPR_PPTR,
    EXPR_CAST,
148
    EXPR_SIZEOF,
149 150 151 152 153 154 155 156
    EXPR_SHL,
    EXPR_SHR,
    EXPR_MUL,
    EXPR_DIV,
    EXPR_ADD,
    EXPR_SUB,
    EXPR_AND,
    EXPR_OR,
157
    EXPR_COND,
158
    EXPR_TRUEFALSE,
159 160
};

161 162
enum type_kind
{
163 164
    TKIND_PRIMITIVE = -1,
    TKIND_ENUM,
165 166 167 168 169 170 171 172 173 174
    TKIND_RECORD,
    TKIND_MODULE,
    TKIND_INTERFACE,
    TKIND_DISPATCH,
    TKIND_COCLASS,
    TKIND_ALIAS,
    TKIND_UNION,
    TKIND_MAX
};
   
175
struct _attr_t {
176
  enum attr_type type;
177
  union {
178
    unsigned long ival;
179 180 181
    void *pval;
  } u;
  /* parser-internal */
182
  DECL_LINK(attr_t);
183 184
};

185 186
struct _expr_t {
  enum expr_type type;
187
  const expr_t *ref;
188 189
  union {
    long lval;
190 191 192
    const char *sval;
    const expr_t *ext;
    const typeref_t *tref;
193
  } u;
194
  const expr_t *ext2;
195 196
  int is_const;
  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 208 209
  func_t *funcs;                  /* interfaces and modules */
  var_t *fields;                  /* interfaces, structures and enumerations */
  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 219 220 221 222 223 224 225 226
};

struct _typeref_t {
  char *name;
  type_t *ref;
  int uniq;
};

struct _var_t {
  char *name;
  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 239 240 241 242 243
};

struct _func_t {
  var_t *def;
  var_t *args;
  int ignore, idx;

  /* parser-internal */
244
  DECL_LINK(func_t);
245 246
};

247 248 249 250 251
struct _ifref_t {
  type_t *iface;
  attr_t *attrs;

  /* 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 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284
struct _importinfo_t {
    int offset;
    GUID guid;
    int flags;
    int id;

    char *name;

    importlib_t *importlib;
};

struct _importlib_t {
    char *name;

    int version;
    GUID guid;

    importinfo_t *importinfos;
    int ntypeinfos;

    int allocated;

    DECL_LINK(importlib_t);
};

285 286 287 288 289
struct _typelib_t {
    char *name;
    char *filename;
    attr_t *attrs;
    typelib_entry_t *entry;
290
    importlib_t *importlibs;
291 292
};

293 294 295 296 297
void init_types(void);

type_t *duptype(type_t *t, int dupname);
type_t *alias(type_t *t, const char *name);

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