rdata_t.h

00001 /*
00002  * Copyright (c) 2011 Jiri Svoboda
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  *
00009  * - Redistributions of source code must retain the above copyright
00010  *   notice, this list of conditions and the following disclaimer.
00011  * - Redistributions in binary form must reproduce the above copyright
00012  *   notice, this list of conditions and the following disclaimer in the
00013  *   documentation and/or other materials provided with the distribution.
00014  * - The name of the author may not be used to endorse or promote products
00015  *   derived from this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
00018  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00019  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
00020  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
00021  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
00022  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00023  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00024  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00025  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00026  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00027  */
00028 
00032 #ifndef RDATA_T_H_
00033 #define RDATA_T_H_
00034 
00035 #include "intmap_t.h"
00036 
00038 typedef struct {
00039         bool_t value;
00040 } rdata_bool_t;
00041 
00047 typedef struct {
00048         bigint_t value;
00049 } rdata_char_t;
00050 
00056 typedef struct {
00057         bigint_t value;
00058 } rdata_int_t;
00059 
00061 typedef struct {
00062         const char *value;
00063 } rdata_string_t;
00064 
00066 typedef struct {
00067         struct rdata_var *vref;
00068 } rdata_ref_t;
00069 
00076 typedef struct {
00078         struct rdata_var *obj;
00079 
00081         struct stree_symbol *sym;
00082 } rdata_deleg_t;
00083 
00085 typedef struct {
00087         struct stree_embr *value;
00088 } rdata_enum_t;
00089 
00091 typedef struct {
00093         int rank;
00094 
00096         int *extent;
00097 
00102         struct rdata_var **element;
00103 } rdata_array_t;
00104 
00106 typedef struct {
00108         struct stree_symbol *class_sym;
00109 
00111         statns_t static_obj;
00112 
00114         intmap_t fields; /* of (rdata_var_t *) */
00115 } rdata_object_t;
00116 
00122 typedef struct {
00124         void *data;
00125 } rdata_resource_t;
00126 
00131 typedef struct {
00133         struct stree_symbol *sym;
00134 } rdata_symbol_t;
00135 
00136 typedef enum var_class {
00138         vc_bool,
00139 
00141         vc_char,
00142 
00144         vc_int,
00145 
00147         vc_string,
00148 
00150         vc_ref,
00151 
00153         vc_deleg,
00154 
00156         vc_enum,
00157 
00159         vc_array,
00160 
00162         vc_object,
00163 
00165         vc_resource,
00166 
00168         vc_symbol
00169 } var_class_t;
00170 
00177 typedef struct rdata_var {
00178         var_class_t vc;
00179 
00180         union {
00181                 rdata_bool_t *bool_v;
00182                 rdata_char_t *char_v;
00183                 rdata_int_t *int_v;
00184                 rdata_string_t *string_v;
00185                 rdata_ref_t *ref_v;
00186                 rdata_deleg_t *deleg_v;
00187                 rdata_enum_t *enum_v;
00188                 rdata_array_t *array_v;
00189                 rdata_object_t *object_v;
00190                 rdata_resource_t *resource_v;
00191                 rdata_symbol_t *symbol_v;
00192         } u;
00193 } rdata_var_t;
00194 
00196 typedef enum {
00198         ac_var,
00199 
00201         ac_prop
00202 } address_class_t;
00203 
00205 typedef struct {
00207         rdata_var_t *vref;
00208 } rdata_addr_var_t;
00209 
00211 typedef struct {
00213         rdata_deleg_t *prop_d;
00214 } rdata_aprop_named_t;
00215 
00217 typedef struct {
00219         rdata_deleg_t *object_d;
00220 
00222         list_t args; /* of rdata_item_t */
00223 } rdata_aprop_indexed_t;
00224 
00225 typedef enum {
00226         /* Named property address */
00227         apc_named,
00228 
00229         /* Indexed property address */
00230         apc_indexed
00231 } aprop_class_t;
00232 
00243 typedef struct {
00244         aprop_class_t apc;
00245 
00247         struct rdata_value *tvalue;
00248 
00253         rdata_var_t *tpos;
00254 
00255         union {
00256                 rdata_aprop_named_t *named;
00257                 rdata_aprop_indexed_t *indexed;
00258         } u;
00259 } rdata_addr_prop_t;
00260 
00262 typedef struct rdata_address {
00263         address_class_t ac;
00264 
00265         union {
00266                 rdata_addr_var_t *var_a;
00267                 rdata_addr_prop_t *prop_a;
00268         } u;
00269 } rdata_address_t;
00270 
00272 typedef struct rdata_value {
00280         rdata_var_t *var;
00281 } rdata_value_t;
00282 
00283 typedef enum {
00285         ic_address,
00287         ic_value
00288 } item_class_t;
00289 
00297 typedef struct rdata_item {
00298         item_class_t ic;
00299 
00300         union {
00301                 rdata_address_t *address;
00302                 rdata_value_t *value;
00303         } u;
00304 } rdata_item_t;
00305 
00306 #endif

Generated on Thu Jun 2 07:45:42 2011 for HelenOS/USB by  doxygen 1.4.7