ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

typetree.h
Go to the documentation of this file.
00001 /*
00002  * IDL Type Tree
00003  *
00004  * Copyright 2008 Robert Shearman
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
00019  */
00020 
00021 #include "widltypes.h"
00022 #include <assert.h>
00023 
00024 #ifndef WIDL_TYPE_TREE_H
00025 #define WIDL_TYPE_TREE_H
00026 
00027 type_t *type_new_function(var_list_t *args);
00028 type_t *type_new_pointer(unsigned char pointer_default, type_t *ref, attr_list_t *attrs);
00029 type_t *type_new_alias(type_t *t, const char *name);
00030 type_t *type_new_module(char *name);
00031 type_t *type_new_array(const char *name, type_t *element, int declptr,
00032                        unsigned int dim, expr_t *size_is, expr_t *length_is,
00033                        unsigned char ptr_default_fc);
00034 type_t *type_new_basic(enum type_basic_type basic_type);
00035 type_t *type_new_int(enum type_basic_type basic_type, int sign);
00036 type_t *type_new_void(void);
00037 type_t *type_new_coclass(char *name);
00038 type_t *type_new_enum(const char *name, int defined, var_list_t *enums);
00039 type_t *type_new_struct(char *name, int defined, var_list_t *fields);
00040 type_t *type_new_nonencapsulated_union(const char *name, int defined, var_list_t *fields);
00041 type_t *type_new_encapsulated_union(char *name, var_t *switch_field, var_t *union_field, var_list_t *cases);
00042 type_t *type_new_bitfield(type_t *field_type, const expr_t *bits);
00043 void type_interface_define(type_t *iface, type_t *inherit, statement_list_t *stmts);
00044 void type_dispinterface_define(type_t *iface, var_list_t *props, var_list_t *methods);
00045 void type_dispinterface_define_from_iface(type_t *dispiface, type_t *iface);
00046 void type_module_define(type_t *module, statement_list_t *stmts);
00047 type_t *type_coclass_define(type_t *coclass, ifref_list_t *ifaces);
00048 int type_is_equal(const type_t *type1, const type_t *type2);
00049 
00050 /* FIXME: shouldn't need to export this */
00051 type_t *duptype(type_t *t, int dupname);
00052 
00053 /* un-alias the type until finding the non-alias type */
00054 static inline type_t *type_get_real_type(const type_t *type)
00055 {
00056     if (type->is_alias)
00057         return type_get_real_type(type->orig);
00058     else
00059         return (type_t *)type;
00060 }
00061 
00062 static inline enum type_type type_get_type(const type_t *type)
00063 {
00064     return type_get_type_detect_alias(type_get_real_type(type));
00065 }
00066 
00067 static inline enum type_basic_type type_basic_get_type(const type_t *type)
00068 {
00069     type = type_get_real_type(type);
00070     assert(type_get_type(type) == TYPE_BASIC);
00071     return type->details.basic.type;
00072 }
00073 
00074 static inline int type_basic_get_sign(const type_t *type)
00075 {
00076     type = type_get_real_type(type);
00077     assert(type_get_type(type) == TYPE_BASIC);
00078     return type->details.basic.sign;
00079 }
00080 
00081 static inline var_list_t *type_struct_get_fields(const type_t *type)
00082 {
00083     type = type_get_real_type(type);
00084     assert(type_get_type(type) == TYPE_STRUCT);
00085     return type->details.structure->fields;
00086 }
00087 
00088 static inline var_list_t *type_function_get_args(const type_t *type)
00089 {
00090     type = type_get_real_type(type);
00091     assert(type_get_type(type) == TYPE_FUNCTION);
00092     return type->details.function->args;
00093 }
00094 
00095 static inline type_t *type_function_get_rettype(const type_t *type)
00096 {
00097     type = type_get_real_type(type);
00098     assert(type_get_type(type) == TYPE_FUNCTION);
00099     return type->details.function->rettype;
00100 }
00101 
00102 static inline var_list_t *type_enum_get_values(const type_t *type)
00103 {
00104     type = type_get_real_type(type);
00105     assert(type_get_type(type) == TYPE_ENUM);
00106     return type->details.enumeration->enums;
00107 }
00108 
00109 static inline var_t *type_union_get_switch_value(const type_t *type)
00110 {
00111     type = type_get_real_type(type);
00112     assert(type_get_type(type) == TYPE_ENCAPSULATED_UNION);
00113     return LIST_ENTRY(list_head(type->details.structure->fields), var_t, entry);
00114 }
00115 
00116 static inline var_list_t *type_encapsulated_union_get_fields(const type_t *type)
00117 {
00118     type = type_get_real_type(type);
00119     assert(type_get_type(type) == TYPE_ENCAPSULATED_UNION);
00120     return type->details.structure->fields;
00121 }
00122 
00123 static inline var_list_t *type_union_get_cases(const type_t *type)
00124 {
00125     enum type_type type_type;
00126 
00127     type = type_get_real_type(type);
00128     type_type = type_get_type(type);
00129 
00130     assert(type_type == TYPE_UNION || type_type == TYPE_ENCAPSULATED_UNION);
00131     if (type_type == TYPE_ENCAPSULATED_UNION)
00132     {
00133         const var_t *uv = LIST_ENTRY(list_tail(type->details.structure->fields), const var_t, entry);
00134         return uv->type->details.structure->fields;
00135     }
00136     else
00137         return type->details.structure->fields;
00138 }
00139 
00140 static inline statement_list_t *type_iface_get_stmts(const type_t *type)
00141 {
00142     type = type_get_real_type(type);
00143     assert(type_get_type(type) == TYPE_INTERFACE);
00144     return type->details.iface->stmts;
00145 }
00146 
00147 static inline type_t *type_iface_get_inherit(const type_t *type)
00148 {
00149     type = type_get_real_type(type);
00150     assert(type_get_type(type) == TYPE_INTERFACE);
00151     return type->details.iface->inherit;
00152 }
00153 
00154 static inline var_list_t *type_dispiface_get_props(const type_t *type)
00155 {
00156     type = type_get_real_type(type);
00157     assert(type_get_type(type) == TYPE_INTERFACE);
00158     return type->details.iface->disp_props;
00159 }
00160 
00161 static inline var_list_t *type_dispiface_get_methods(const type_t *type)
00162 {
00163     type = type_get_real_type(type);
00164     assert(type_get_type(type) == TYPE_INTERFACE);
00165     return type->details.iface->disp_methods;
00166 }
00167 
00168 static inline int type_is_defined(const type_t *type)
00169 {
00170     return type->defined;
00171 }
00172 
00173 static inline int type_is_complete(const type_t *type)
00174 {
00175     switch (type_get_type_detect_alias(type))
00176     {
00177     case TYPE_FUNCTION:
00178         return (type->details.function != NULL);
00179     case TYPE_INTERFACE:
00180         return (type->details.iface != NULL);
00181     case TYPE_ENUM:
00182         return (type->details.enumeration != NULL);
00183     case TYPE_UNION:
00184     case TYPE_ENCAPSULATED_UNION:
00185     case TYPE_STRUCT:
00186         return (type->details.structure != NULL);
00187     case TYPE_VOID:
00188     case TYPE_BASIC:
00189     case TYPE_ALIAS:
00190     case TYPE_MODULE:
00191     case TYPE_COCLASS:
00192     case TYPE_POINTER:
00193     case TYPE_ARRAY:
00194     case TYPE_BITFIELD:
00195         return TRUE;
00196     }
00197     return FALSE;
00198 }
00199 
00200 static inline int type_array_has_conformance(const type_t *type)
00201 {
00202     type = type_get_real_type(type);
00203     assert(type_get_type(type) == TYPE_ARRAY);
00204     return (type->details.array.size_is != NULL);
00205 }
00206 
00207 static inline int type_array_has_variance(const type_t *type)
00208 {
00209     type = type_get_real_type(type);
00210     assert(type_get_type(type) == TYPE_ARRAY);
00211     return (type->details.array.length_is != NULL);
00212 }
00213 
00214 static inline unsigned int type_array_get_dim(const type_t *type)
00215 {
00216     type = type_get_real_type(type);
00217     assert(type_get_type(type) == TYPE_ARRAY);
00218     return type->details.array.dim;
00219 }
00220 
00221 static inline expr_t *type_array_get_conformance(const type_t *type)
00222 {
00223     type = type_get_real_type(type);
00224     assert(type_get_type(type) == TYPE_ARRAY);
00225     return type->details.array.size_is;
00226 }
00227 
00228 static inline expr_t *type_array_get_variance(const type_t *type)
00229 {
00230     type = type_get_real_type(type);
00231     assert(type_get_type(type) == TYPE_ARRAY);
00232     return type->details.array.length_is;
00233 }
00234 
00235 static inline type_t *type_array_get_element(const type_t *type)
00236 {
00237     type = type_get_real_type(type);
00238     assert(type_get_type(type) == TYPE_ARRAY);
00239     return type->details.array.elem;
00240 }
00241 
00242 static inline int type_array_is_decl_as_ptr(const type_t *type)
00243 {
00244     type = type_get_real_type(type);
00245     assert(type_get_type(type) == TYPE_ARRAY);
00246     return type->details.array.declptr;
00247 }
00248 
00249 static inline unsigned char type_array_get_ptr_default_fc(const type_t *type)
00250 {
00251     type = type_get_real_type(type);
00252     assert(type_get_type(type) == TYPE_ARRAY);
00253     return type->details.array.ptr_def_fc;
00254 }
00255 
00256 static inline int type_is_alias(const type_t *type)
00257 {
00258     return type->is_alias;
00259 }
00260 
00261 static inline type_t *type_alias_get_aliasee(const type_t *type)
00262 {
00263     assert(type_is_alias(type));
00264     return type->orig;
00265 }
00266 
00267 static inline ifref_list_t *type_coclass_get_ifaces(const type_t *type)
00268 {
00269     type = type_get_real_type(type);
00270     assert(type_get_type(type) == TYPE_COCLASS);
00271     return type->details.coclass.ifaces;
00272 }
00273 
00274 static inline type_t *type_pointer_get_ref(const type_t *type)
00275 {
00276     type = type_get_real_type(type);
00277     assert(type_get_type(type) == TYPE_POINTER);
00278     return type->details.pointer.ref;
00279 }
00280 
00281 static inline unsigned char type_pointer_get_default_fc(const type_t *type)
00282 {
00283     type = type_get_real_type(type);
00284     assert(type_get_type(type) == TYPE_POINTER);
00285     return type->details.pointer.def_fc;
00286 }
00287 
00288 static inline type_t *type_bitfield_get_field(const type_t *type)
00289 {
00290     type = type_get_real_type(type);
00291     assert(type_get_type(type) == TYPE_BITFIELD);
00292     return type->details.bitfield.field;
00293 }
00294 
00295 static inline const expr_t *type_bitfield_get_bits(const type_t *type)
00296 {
00297     type = type_get_real_type(type);
00298     assert(type_get_type(type) == TYPE_BITFIELD);
00299     return type->details.bitfield.bits;
00300 }
00301 
00302 #endif /* WIDL_TYPE_TREE_H */

Generated on Fri May 25 2012 04:36:15 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.