X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=include%2Fbabeltrace%2Ftypes.h;h=cb0044e0471d57e73453452ac60657b3e717674b;hp=3d2b70a4ed92d878588ff5547d7fc85537ac43b8;hb=c5e74408f9786219f6b44400dcf2098ab9cc78fb;hpb=dd2544fde7500d15afb76f588009874cc577f0ac diff --git a/include/babeltrace/types.h b/include/babeltrace/types.h index 3d2b70a4..cb0044e0 100644 --- a/include/babeltrace/types.h +++ b/include/babeltrace/types.h @@ -95,13 +95,6 @@ struct declaration { * definition_free called with definition ref is decremented to 0. */ void (*definition_free)(struct definition *definition); - /* - * Definition copy function. Knows how to find the child - * definition from the parent definition. - */ - void (*copy)(struct stream_pos *dest, const struct format *fdest, - struct stream_pos *src, const struct format *fsrc, - struct definition *definition); }; struct definition { @@ -110,6 +103,26 @@ struct definition { int ref; /* number of references to the definition */ }; +typedef int (*rw_dispatch)(struct stream_pos *pos, + struct definition *definition); + +/* Parent of per-plugin positions */ +struct stream_pos { + /* read/write dispatch table. Specific to plugin used for stream. */ + rw_dispatch *rw_table; /* rw dispatch table */ +}; + +static inline +int generic_rw(struct stream_pos *pos, struct definition *definition) +{ + enum ctf_type_id dispatch_id = definition->declaration->id; + rw_dispatch call; + + assert(pos->rw_table[dispatch_id] != NULL); + call = pos->rw_table[dispatch_id]; + return call(pos, definition); +} + /* * Because we address in bits, bitfields end up being exactly the same as * integers, except that their read/write functions must be able to deal with @@ -144,6 +157,9 @@ struct declaration_float { struct definition_float { struct definition p; struct declaration_float *declaration; + struct definition_integer *sign; + struct definition_integer *mantissa; + struct definition_integer *exp; /* Last values read */ long double value; }; @@ -215,6 +231,7 @@ struct definition_string { struct definition p; struct declaration_string *declaration; char *value; /* freed at definition_string teardown */ + size_t len, alloc_len; }; struct declaration_field { @@ -275,7 +292,7 @@ struct definition_array { struct definition p; struct declaration_array *declaration; struct definition_scope *scope; - struct field current_element; /* struct field */ + GArray *elems; /* struct field */ }; struct declaration_sequence { @@ -290,7 +307,7 @@ struct definition_sequence { struct declaration_sequence *declaration; struct definition_scope *scope; struct definition_integer *len; - struct field current_element; /* struct field */ + GArray *elems; /* struct field */ }; int register_declaration(GQuark declaration_name, @@ -409,17 +426,18 @@ void struct_declaration_add_field(struct declaration_struct *struct_declaration, /* * Returns the index of a field within a structure. */ -unsigned long struct_declaration_lookup_field_index(struct declaration_struct *struct_declaration, +int struct_declaration_lookup_field_index(struct declaration_struct *struct_declaration, GQuark field_name); /* * field returned only valid as long as the field structure is not appended to. */ struct declaration_field * struct_declaration_get_field_from_index(struct declaration_struct *struct_declaration, - unsigned long index); + int index); struct field * -struct_get_field_from_index(struct definition_struct *struct_definition, - unsigned long index); +struct_definition_get_field_from_index(struct definition_struct *struct_definition, + int index); +int struct_rw(struct stream_pos *pos, struct definition *definition); /* * The tag enumeration is validated to ensure that it contains only mappings @@ -448,6 +466,7 @@ int variant_definition_set_tag(struct definition_variant *variant, * to. */ struct field *variant_get_current_field(struct definition_variant *variant); +int variant_rw(struct stream_pos *pos, struct definition *definition); /* * elem_declaration passed as parameter now belongs to the array. No @@ -457,6 +476,9 @@ struct field *variant_get_current_field(struct definition_variant *variant); struct declaration_array * array_declaration_new(size_t len, struct declaration *elem_declaration, struct declaration_scope *parent_scope); +uint64_t array_len(struct definition_array *array); +struct definition *array_index(struct definition_array *array, uint64_t i); +int array_rw(struct stream_pos *pos, struct definition *definition); /* * int_declaration and elem_declaration passed as parameter now belong @@ -466,6 +488,9 @@ struct declaration_sequence * sequence_declaration_new(struct declaration_integer *len_declaration, struct declaration *elem_declaration, struct declaration_scope *parent_scope); +uint64_t sequence_len(struct definition_sequence *sequence); +struct definition *sequence_index(struct definition_sequence *sequence, uint64_t i); +int sequence_rw(struct stream_pos *pos, struct definition *definition); /* * in: path (dot separated), out: q (GArray of GQuark)