ReactOS 0.4.16-dev-92-g0c2cdca
typetree.h
Go to the documentation of this file.
1/*
2 * IDL Type Tree
3 *
4 * Copyright 2008 Robert Shearman
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#include "widltypes.h"
22#include <assert.h>
23
24#ifndef WIDL_TYPE_TREE_H
25#define WIDL_TYPE_TREE_H
26
29 NAME_C
30};
31
34type_t *type_new_alias(type_t *t, const char *name);
36type_t *type_new_array(const char *name, type_t *element, int declptr,
37 unsigned int dim, expr_t *size_is, expr_t *length_is,
38 unsigned char ptr_default_fc);
39type_t *type_new_basic(enum type_basic_type basic_type);
40type_t *type_new_int(enum type_basic_type basic_type, int sign);
43type_t *type_new_enum(const char *name, struct namespace *namespace, int defined, var_list_t *enums);
44type_t *type_new_struct(char *name, struct namespace *namespace, int defined, var_list_t *fields);
46type_t *type_new_encapsulated_union(char *name, var_t *switch_field, var_t *union_field, var_list_t *cases);
47type_t *type_new_bitfield(type_t *field_type, const expr_t *bits);
48void type_interface_define(type_t *iface, type_t *inherit, statement_list_t *stmts);
53int type_is_equal(const type_t *type1, const type_t *type2);
54const char *type_get_name(const type_t *type, enum name_type name_type);
55
56/* FIXME: shouldn't need to export this */
57type_t *duptype(type_t *t, int dupname);
58
59/* un-alias the type until finding the non-alias type */
60static inline type_t *type_get_real_type(const type_t *type)
61{
62 if (type->is_alias)
63 return type_get_real_type(type->orig);
64 else
65 return (type_t *)type;
66}
67
68static inline enum type_type type_get_type(const type_t *type)
69{
71}
72
74{
77 return type->details.basic.type;
78}
79
80static inline int type_basic_get_sign(const type_t *type)
81{
84 return type->details.basic.sign;
85}
86
88{
91 return type->details.structure->fields;
92}
93
95{
98 return type->details.function->args;
99}
100
102{
105 return type->details.function->retval;
106}
107
109{
111}
112
114{
117 return type->details.enumeration->enums;
118}
119
121{
124 return LIST_ENTRY(list_head(type->details.structure->fields), var_t, entry);
125}
126
128{
131 return type->details.structure->fields;
132}
133
135{
136 enum type_type type_type;
137
140
143 {
144 const var_t *uv = LIST_ENTRY(list_tail(type->details.structure->fields), const var_t, entry);
145 return uv->type->details.structure->fields;
146 }
147 else
148 return type->details.structure->fields;
149}
150
152{
155 return type->details.iface->stmts;
156}
157
159{
162 return type->details.iface->inherit;
163}
164
166{
169 return type->details.iface->disp_props;
170}
171
173{
176 return type->details.iface->disp_methods;
177}
178
180{
183 return type->details.iface->disp_inherit;
184}
185
186static inline int type_is_defined(const type_t *type)
187{
188 return type->defined;
189}
190
191static inline int type_is_complete(const type_t *type)
192{
194 {
195 case TYPE_FUNCTION:
196 return (type->details.function != NULL);
197 case TYPE_INTERFACE:
198 return (type->details.iface != NULL);
199 case TYPE_ENUM:
200 return (type->details.enumeration != NULL);
201 case TYPE_UNION:
203 case TYPE_STRUCT:
204 return (type->details.structure != NULL);
205 case TYPE_VOID:
206 case TYPE_BASIC:
207 case TYPE_ALIAS:
208 case TYPE_MODULE:
209 case TYPE_COCLASS:
210 case TYPE_POINTER:
211 case TYPE_ARRAY:
212 case TYPE_BITFIELD:
213 return TRUE;
214 }
215 return FALSE;
216}
217
218static inline int type_array_has_conformance(const type_t *type)
219{
222 return (type->details.array.size_is != NULL);
223}
224
225static inline int type_array_has_variance(const type_t *type)
226{
229 return (type->details.array.length_is != NULL);
230}
231
232static inline unsigned int type_array_get_dim(const type_t *type)
233{
236 return type->details.array.dim;
237}
238
240{
243 return type->details.array.size_is;
244}
245
247{
250 return type->details.array.length_is;
251}
252
254{
257 return type->details.array.elem;
258}
259
260static inline int type_array_is_decl_as_ptr(const type_t *type)
261{
264 return type->details.array.declptr;
265}
266
267static inline unsigned char type_array_get_ptr_default_fc(const type_t *type)
268{
271 return type->details.array.ptr_def_fc;
272}
273
274static inline int type_is_alias(const type_t *type)
275{
276 return type->is_alias;
277}
278
280{
282 return type->orig;
283}
284
286{
289 return type->details.coclass.ifaces;
290}
291
293{
296 return type->details.pointer.ref;
297}
298
299static inline unsigned char type_pointer_get_default_fc(const type_t *type)
300{
303 return type->details.pointer.def_fc;
304}
305
307{
310 return type->details.bitfield.field;
311}
312
313static inline const expr_t *type_bitfield_get_bits(const type_t *type)
314{
317 return type->details.bitfield.bits;
318}
319
320#endif /* WIDL_TYPE_TREE_H */
Definition: list.h:37
coclass PSFactoryBuffer pointer_default(unique)] interface ObjectRpcBaseTypes
Definition: dcom.idl:35
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define assert(x)
Definition: debug.h:53
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLdouble GLdouble t
Definition: gl.h:2047
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929
uint32_t entry
Definition: isohybrid.c:63
#define sign(x)
Definition: mapdesc.cc:613
static const struct encodedInt enums[]
Definition: encode.c:365
const char * fields[10]
Definition: parser.c:313
__WINE_SERVER_LIST_INLINE struct list * list_tail(const struct list *list)
Definition: list.h:137
union _type_t::@5025 details
struct struct_details * structure
Definition: widltypes.h:425
type_t * type
Definition: widltypes.h:453
Definition: match.c:390
Definition: list.h:15
Definition: name.c:39
Definition: send.c:48
#define LIST_ENTRY(type)
Definition: queue.h:175
static int type_array_is_decl_as_ptr(const type_t *type)
Definition: typetree.h:260
static enum type_type type_get_type(const type_t *type)
Definition: typetree.h:68
void type_interface_define(type_t *iface, type_t *inherit, statement_list_t *stmts)
Definition: typetree.c:439
int type_is_equal(const type_t *type1, const type_t *type2)
Definition: typetree.c:495
type_t * type_new_function(var_list_t *args)
Definition: typetree.c:131
type_t * type_new_module(char *name)
Definition: typetree.c:205
type_t * type_new_struct(char *name, struct namespace *namespace, int defined, var_list_t *fields)
Definition: typetree.c:300
static unsigned char type_pointer_get_default_fc(const type_t *type)
Definition: typetree.h:299
static const expr_t * type_bitfield_get_bits(const type_t *type)
Definition: typetree.h:313
static unsigned char type_array_get_ptr_default_fc(const type_t *type)
Definition: typetree.h:267
static type_t * type_get_real_type(const type_t *type)
Definition: typetree.h:60
void type_dispinterface_define(type_t *iface, var_list_t *props, var_list_t *methods)
Definition: typetree.c:452
static int type_basic_get_sign(const type_t *type)
Definition: typetree.h:80
static var_t * type_union_get_switch_value(const type_t *type)
Definition: typetree.h:120
type_t * type_new_alias(type_t *t, const char *name)
Definition: typetree.c:190
static type_t * type_function_get_rettype(const type_t *type)
Definition: typetree.h:108
static expr_t * type_array_get_variance(const type_t *type)
Definition: typetree.h:246
static int type_array_has_conformance(const type_t *type)
Definition: typetree.h:218
static var_list_t * type_union_get_cases(const type_t *type)
Definition: typetree.h:134
static var_list_t * type_dispiface_get_methods(const type_t *type)
Definition: typetree.h:172
static type_t * type_bitfield_get_field(const type_t *type)
Definition: typetree.h:306
type_t * type_new_bitfield(type_t *field_type, const expr_t *bits)
Definition: typetree.c:398
type_t * type_new_basic(enum type_basic_type basic_type)
Definition: typetree.c:243
type_t * type_new_array(const char *name, type_t *element, int declptr, unsigned int dim, expr_t *size_is, expr_t *length_is, unsigned char ptr_default_fc)
Definition: typetree.c:226
name_type
Definition: typetree.h:27
@ NAME_C
Definition: typetree.h:29
@ NAME_DEFAULT
Definition: typetree.h:28
static enum type_basic_type type_basic_get_type(const type_t *type)
Definition: typetree.h:73
static type_t * type_alias_get_aliasee(const type_t *type)
Definition: typetree.h:279
static var_t * type_function_get_retval(const type_t *type)
Definition: typetree.h:101
static type_t * type_dispiface_get_inherit(const type_t *type)
Definition: typetree.h:179
static expr_t * type_array_get_conformance(const type_t *type)
Definition: typetree.h:239
static ifref_list_t * type_coclass_get_ifaces(const type_t *type)
Definition: typetree.h:285
static int type_is_defined(const type_t *type)
Definition: typetree.h:186
type_t * type_new_void(void)
Definition: typetree.c:266
static var_list_t * type_struct_get_fields(const type_t *type)
Definition: typetree.h:87
type_t * type_new_enum(const char *name, struct namespace *namespace, int defined, var_list_t *enums)
Definition: typetree.c:274
void type_module_define(type_t *module, statement_list_t *stmts)
Definition: typetree.c:480
static int type_is_complete(const type_t *type)
Definition: typetree.h:191
type_t * type_new_pointer(unsigned char pointer_default, type_t *ref, attr_list_t *attrs)
Definition: typetree.c:181
static var_list_t * type_encapsulated_union_get_fields(const type_t *type)
Definition: typetree.h:127
const char * type_get_name(const type_t *type, enum name_type name_type)
Definition: typetree.c:81
type_t * type_coclass_define(type_t *coclass, ifref_list_t *ifaces)
Definition: typetree.c:488
static int type_is_alias(const type_t *type)
Definition: typetree.h:274
static type_t * type_iface_get_inherit(const type_t *type)
Definition: typetree.h:158
type_t * type_new_int(enum type_basic_type basic_type, int sign)
Definition: typetree.c:251
static type_t * type_array_get_element(const type_t *type)
Definition: typetree.h:253
static var_list_t * type_function_get_args(const type_t *type)
Definition: typetree.h:94
type_t * duptype(type_t *t, int dupname)
Definition: typetree.c:33
static unsigned int type_array_get_dim(const type_t *type)
Definition: typetree.h:232
void type_dispinterface_define_from_iface(type_t *dispiface, type_t *iface)
Definition: typetree.c:466
static statement_list_t * type_iface_get_stmts(const type_t *type)
Definition: typetree.h:151
static type_t * type_pointer_get_ref(const type_t *type)
Definition: typetree.h:292
static var_list_t * type_enum_get_values(const type_t *type)
Definition: typetree.h:113
type_t * type_new_coclass(char *name)
Definition: typetree.c:215
static int type_array_has_variance(const type_t *type)
Definition: typetree.h:225
type_t * type_new_nonencapsulated_union(const char *name, int defined, var_list_t *fields)
Definition: typetree.c:330
static var_list_t * type_dispiface_get_props(const type_t *type)
Definition: typetree.h:165
type_t * type_new_encapsulated_union(char *name, var_t *switch_field, var_t *union_field, var_list_t *cases)
Definition: typetree.c:353
static const WCHAR props[]
Definition: wbemdisp.c:288
type_type
Definition: widltypes.h:401
@ TYPE_ENUM
Definition: widltypes.h:404
@ TYPE_BITFIELD
Definition: widltypes.h:415
@ TYPE_BASIC
Definition: widltypes.h:403
@ TYPE_UNION
Definition: widltypes.h:407
@ TYPE_ALIAS
Definition: widltypes.h:408
@ TYPE_POINTER
Definition: widltypes.h:413
@ TYPE_VOID
Definition: widltypes.h:402
@ TYPE_ENCAPSULATED_UNION
Definition: widltypes.h:406
@ TYPE_COCLASS
Definition: widltypes.h:410
@ TYPE_STRUCT
Definition: widltypes.h:405
@ TYPE_MODULE
Definition: widltypes.h:409
@ TYPE_INTERFACE
Definition: widltypes.h:412
@ TYPE_ARRAY
Definition: widltypes.h:414
@ TYPE_FUNCTION
Definition: widltypes.h:411
static enum type_type type_get_type_detect_alias(const type_t *type)
Definition: widltypes.h:590
type_basic_type
Definition: widltypes.h:262