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 void type_interface_define(type_t *iface, type_t *inherit, statement_list_t *stmts);
30 void type_dispinterface_define(type_t *iface, var_list_t *props, func_list_t *methods);
31 void type_dispinterface_define_from_iface(type_t *dispiface, type_t *iface);
32
33 static inline var_list_t *type_struct_get_fields(const type_t *type)
34 {
35 assert(is_struct(type->type));
36 return type->details.structure->fields;
37 }
38
39 static inline var_list_t *type_function_get_args(const type_t *type)
40 {
41 assert(type->type == RPC_FC_FUNCTION);
42 return type->details.function->args;
43 }
44
45 static inline var_list_t *type_enum_get_values(const type_t *type)
46 {
47 assert(type->type == RPC_FC_ENUM16 || type->type == RPC_FC_ENUM32);
48 return type->details.enumeration->enums;
49 }
50
51 static inline var_t *type_union_get_switch_value(const type_t *type)
52 {
53 assert(type->type == RPC_FC_ENCAPSULATED_UNION);
54 return LIST_ENTRY(list_head(type->details.structure->fields), var_t, entry);
55 }
56
57 static inline var_list_t *type_encapsulated_union_get_fields(const type_t *type)
58 {
59 assert(type->type == RPC_FC_ENCAPSULATED_UNION);
60 return type->details.structure->fields;
61 }
62
63 static inline var_list_t *type_union_get_cases(const type_t *type)
64 {
65 assert(type->type == RPC_FC_ENCAPSULATED_UNION ||
66 type->type == RPC_FC_NON_ENCAPSULATED_UNION);
67 if (type->type == RPC_FC_ENCAPSULATED_UNION)
68 {
69 const var_t *uv = LIST_ENTRY(list_tail(type->details.structure->fields), const var_t, entry);
70 return uv->type->details.structure->fields;
71 }
72 else
73 return type->details.structure->fields;
74 }
75
76 static inline var_list_t *type_dispiface_get_props(const type_t *type)
77 {
78 assert(type->type == RPC_FC_IP);
79 return type->details.iface->disp_props;
80 }
81
82 static inline var_list_t *type_dispiface_get_methods(const type_t *type)
83 {
84 assert(type->type == RPC_FC_IP);
85 return type->details.iface->disp_methods;
86 }
87
88 static inline int type_is_defined(const type_t *type)
89 {
90 return type->defined;
91 }
92
93 static inline int type_is_complete(const type_t *type)
94 {
95 if (type->type == RPC_FC_FUNCTION)
96 return (type->details.function != NULL);
97 else if (type->type == RPC_FC_IP)
98 return (type->details.iface != NULL);
99 else if (type->type == RPC_FC_ENUM16 || type->type == RPC_FC_ENUM32)
100 return (type->details.enumeration != NULL);
101 else if (is_struct(type->type) || is_union(type->type))
102 return (type->details.structure != NULL);
103 else
104 return TRUE;
105 }
106
107 #endif /* WIDL_TYPE_TREE_H */
108
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.