Add array and sequence "len" accessor
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 5 May 2011 04:41:15 +0000 (00:41 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 5 May 2011 04:41:15 +0000 (00:41 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
formats/ctf/ctf.c
include/babeltrace/types.h
types/array.c
types/sequence.c

index 0c635d5701a987542409c8c1fcb8346e4e210832..515e478357b3e519d1f4cb5e43fbf8bd5f83fb0d 100644 (file)
@@ -247,7 +247,7 @@ int create_stream_packet_index(struct trace_descriptor *td,
                                field = struct_definition_get_field_from_index(td->ctf_trace.packet_header, len_index);
                                assert(field->definition->declaration->id == CTF_TYPE_ARRAY);
                                defarray = container_of(field->definition, struct definition_array, p);
-                               assert(defarray->declaration->len == UUID_LEN);
+                               assert(array_len(defarray) == UUID_LEN);
                                assert(defarray->declaration->elem->id == CTF_TYPE_INTEGER);
 
                                for (i = 0; i < UUID_LEN; i++) {
index d01b672437c5512017c09fa017b55c97dfd51ec3..232cc2038a123725a907945c609b1e7308b41232 100644 (file)
@@ -457,6 +457,7 @@ 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);
 
 /*
@@ -467,6 +468,7 @@ 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);
 
 /*
index d8ddd637c69bb804e5401e8276da9ba22a69969d..ae994301ae238dcf810a5f6d81ef9f88662a420c 100644 (file)
@@ -145,6 +145,11 @@ void _array_definition_free(struct definition *definition)
        g_free(array);
 }
 
+uint64_t array_len(struct definition_array *array)
+{
+       return array->elems->len;
+}
+
 struct definition *array_index(struct definition_array *array, uint64_t i)
 {
        if (i >= array->elems->len)
index 50763d7ad7ec7b7ed85ec2b70b523873791dd30a..e3586d384b5c715aba743ade348cc4248d5927d6 100644 (file)
@@ -167,6 +167,11 @@ void _sequence_definition_free(struct definition *definition)
        g_free(sequence);
 }
 
+uint64_t sequence_len(struct definition_sequence *sequence)
+{
+       return sequence->len->value._unsigned;
+}
+
 struct definition *sequence_index(struct definition_sequence *sequence, uint64_t i)
 {
        if (i >= sequence->len->value._unsigned)
This page took 0.036034 seconds and 4 git commands to generate.