4 * Copyright 2008 Robert Shearman
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.
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.
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
21 #include "widltypes.h"
24 #ifndef WIDL_TYPE_TREE_H
25 #define WIDL_TYPE_TREE_H
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 void type_module_define(type_t
*module
, statement_list_t
*stmts
);
34 static inline var_list_t
*type_struct_get_fields(const type_t
*type
)
36 assert(is_struct(type
->type
));
37 return type
->details
.structure
->fields
;
40 static inline var_list_t
*type_function_get_args(const type_t
*type
)
42 assert(type
->type
== RPC_FC_FUNCTION
);
43 return type
->details
.function
->args
;
46 static inline var_list_t
*type_enum_get_values(const type_t
*type
)
48 assert(type
->type
== RPC_FC_ENUM16
|| type
->type
== RPC_FC_ENUM32
);
49 return type
->details
.enumeration
->enums
;
52 static inline var_t
*type_union_get_switch_value(const type_t
*type
)
54 assert(type
->type
== RPC_FC_ENCAPSULATED_UNION
);
55 return LIST_ENTRY(list_head(type
->details
.structure
->fields
), var_t
, entry
);
58 static inline var_list_t
*type_encapsulated_union_get_fields(const type_t
*type
)
60 assert(type
->type
== RPC_FC_ENCAPSULATED_UNION
);
61 return type
->details
.structure
->fields
;
64 static inline var_list_t
*type_union_get_cases(const type_t
*type
)
66 assert(type
->type
== RPC_FC_ENCAPSULATED_UNION
||
67 type
->type
== RPC_FC_NON_ENCAPSULATED_UNION
);
68 if (type
->type
== RPC_FC_ENCAPSULATED_UNION
)
70 const var_t
*uv
= LIST_ENTRY(list_tail(type
->details
.structure
->fields
), const var_t
, entry
);
71 return uv
->type
->details
.structure
->fields
;
74 return type
->details
.structure
->fields
;
77 static inline var_list_t
*type_dispiface_get_props(const type_t
*type
)
79 assert(type
->type
== RPC_FC_IP
);
80 return type
->details
.iface
->disp_props
;
83 static inline var_list_t
*type_dispiface_get_methods(const type_t
*type
)
85 assert(type
->type
== RPC_FC_IP
);
86 return type
->details
.iface
->disp_methods
;
89 static inline int type_is_defined(const type_t
*type
)
94 static inline int type_is_complete(const type_t
*type
)
96 if (type
->type
== RPC_FC_FUNCTION
)
97 return (type
->details
.function
!= NULL
);
98 else if (type
->type
== RPC_FC_IP
)
99 return (type
->details
.iface
!= NULL
);
100 else if (type
->type
== RPC_FC_ENUM16
|| type
->type
== RPC_FC_ENUM32
)
101 return (type
->details
.enumeration
!= NULL
);
102 else if (is_struct(type
->type
) || is_union(type
->type
))
103 return (type
->details
.structure
!= NULL
);
108 static inline int type_array_has_conformance(const type_t
*type
)
110 assert(is_array(type
));
111 return (type
->details
.array
.size_is
!= NULL
);
114 static inline int type_array_has_variance(const type_t
*type
)
116 assert(is_array(type
));
117 return (type
->details
.array
.length_is
!= NULL
);
120 static inline unsigned long type_array_get_dim(const type_t
*type
)
122 assert(is_array(type
));
123 return type
->details
.array
.dim
;
126 static inline expr_t
*type_array_get_conformance(const type_t
*type
)
128 assert(is_array(type
));
129 return type
->details
.array
.size_is
;
132 static inline expr_t
*type_array_get_variance(const type_t
*type
)
134 assert(is_array(type
));
135 return type
->details
.array
.length_is
;
138 #endif /* WIDL_TYPE_TREE_H */