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
27 type_t *type_new_function(var_list_t *args);
28 type_t *type_new_pointer(type_t *ref, attr_list_t *attrs);
29 type_t *type_new_alias(type_t *t, const char *name);
30 type_t *type_new_module(char *name);
31 type_t *type_new_array(const char *name, type_t *element, int declarray,
32 unsigned long dim, expr_t *size_is, expr_t *length_is);
33 void type_interface_define(type_t *iface, type_t *inherit, statement_list_t *stmts);
34 void type_dispinterface_define(type_t *iface, var_list_t *props, func_list_t *methods);
35 void type_dispinterface_define_from_iface(type_t *dispiface, type_t *iface);
36 void type_module_define(type_t *module, statement_list_t *stmts);
37 type_t *type_coclass_define(type_t *coclass, ifref_list_t *ifaces);
38
39 /* FIXME: shouldn't need to export this */
40 type_t *duptype(type_t *t, int dupname);
41
42 static inline var_list_t *type_struct_get_fields(const type_t *type)
43 {
44 assert(is_struct(type->type));
45 return type->details.structure->fields;
46 }
47
48 static inline var_list_t *type_function_get_args(const type_t *type)
49 {
50 assert(type->type == RPC_FC_FUNCTION);
51 return type->details.function->args;
52 }
53
54 static inline type_t *type_function_get_rettype(const type_t *type)
55 {
56 assert(type->type == RPC_FC_FUNCTION);
57 return type->ref;
58 }
59
60 static inline var_list_t *type_enum_get_values(const type_t *type)
61 {
62 assert(type->type == RPC_FC_ENUM16 || type->type == RPC_FC_ENUM32);
63 return type->details.enumeration->enums;
64 }
65
66 static inline var_t *type_union_get_switch_value(const type_t *type)
67 {
68 assert(type->type == RPC_FC_ENCAPSULATED_UNION);
69 return LIST_ENTRY(list_head(type->details.structure->fields), var_t, entry);
70 }
71
72 static inline var_list_t *type_encapsulated_union_get_fields(const type_t *type)
73 {
74 assert(type->type == RPC_FC_ENCAPSULATED_UNION);
75 return type->details.structure->fields;
76 }
77
78 static inline var_list_t *type_union_get_cases(const type_t *type)
79 {
80 assert(type->type == RPC_FC_ENCAPSULATED_UNION ||
81 type->type == RPC_FC_NON_ENCAPSULATED_UNION);
82 if (type->type == RPC_FC_ENCAPSULATED_UNION)
83 {
84 const var_t *uv = LIST_ENTRY(list_tail(type->details.structure->fields), const var_t, entry);
85 return uv->type->details.structure->fields;
86 }
87 else
88 return type->details.structure->fields;
89 }
90
91 static inline statement_list_t *type_iface_get_stmts(const type_t *type)
92 {
93 assert(type->type == RPC_FC_IP);
94 return type->details.iface->stmts;
95 }
96
97 static inline type_t *type_iface_get_inherit(const type_t *type)
98 {
99 assert(type->type == RPC_FC_IP);
100 return type->ref;
101 }
102
103 static inline var_list_t *type_dispiface_get_props(const type_t *type)
104 {
105 assert(type->type == RPC_FC_IP);
106 return type->details.iface->disp_props;
107 }
108
109 static inline var_list_t *type_dispiface_get_methods(const type_t *type)
110 {
111 assert(type->type == RPC_FC_IP);
112 return type->details.iface->disp_methods;
113 }
114
115 static inline int type_is_defined(const type_t *type)
116 {
117 return type->defined;
118 }
119
120 static inline int type_is_complete(const type_t *type)
121 {
122 if (type->type == RPC_FC_FUNCTION)
123 return (type->details.function != NULL);
124 else if (type->type == RPC_FC_IP)
125 return (type->details.iface != NULL);
126 else if (type->type == RPC_FC_ENUM16 || type->type == RPC_FC_ENUM32)
127 return (type->details.enumeration != NULL);
128 else if (is_struct(type->type) || is_union(type->type))
129 return (type->details.structure != NULL);
130 else
131 return TRUE;
132 }
133
134 static inline int type_array_has_conformance(const type_t *type)
135 {
136 assert(is_array(type));
137 return (type->details.array.size_is != NULL);
138 }
139
140 static inline int type_array_has_variance(const type_t *type)
141 {
142 assert(is_array(type));
143 return (type->details.array.length_is != NULL);
144 }
145
146 static inline unsigned long type_array_get_dim(const type_t *type)
147 {
148 assert(is_array(type));
149 return type->details.array.dim;
150 }
151
152 static inline expr_t *type_array_get_conformance(const type_t *type)
153 {
154 assert(is_array(type));
155 return type->details.array.size_is;
156 }
157
158 static inline expr_t *type_array_get_variance(const type_t *type)
159 {
160 assert(is_array(type));
161 return type->details.array.length_is;
162 }
163
164 static inline type_t *type_array_get_element(const type_t *type)
165 {
166 assert(is_array(type));
167 return type->ref;
168 }
169
170 static inline type_t *type_get_real_type(const type_t *type)
171 {
172 if (type->is_alias)
173 return type_get_real_type(type->orig);
174 else
175 return (type_t *)type;
176 }
177
178 static inline int type_is_alias(const type_t *type)
179 {
180 return type->is_alias;
181 }
182
183 static inline ifref_list_t *type_coclass_get_ifaces(const type_t *type)
184 {
185 assert(type->type == RPC_FC_COCLASS);
186 return type->details.coclass.ifaces;
187 }
188
189 static inline type_t *type_pointer_get_ref(const type_t *type)
190 {
191 assert(is_ptr(type));
192 return type->ref;
193 }
194
195 #endif /* WIDL_TYPE_TREE_H */
196
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.