ir: add bt_ctf_field_type_sequence/array_set_element_type()
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 31 Jul 2015 14:11:58 +0000 (10:11 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 31 Jul 2015 18:34:22 +0000 (14:34 -0400)
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
formats/ctf/ir/event-types.c
include/babeltrace/ctf-ir/event-types-internal.h

index 91104860483220924f34880caa195803d26ce2b8..61c0404d998d30f01f281a8e8c5d387a46eb97bd 100644 (file)
@@ -1545,6 +1545,32 @@ end:
        return ret;
 }
 
+BT_HIDDEN
+int bt_ctf_field_type_array_set_element_type(struct bt_ctf_field_type *type,
+               struct bt_ctf_field_type *element_type)
+{
+       int ret = 0;
+       struct bt_ctf_field_type_array *array;
+
+       if (!type || !element_type ||
+                       (type->declaration->id != CTF_TYPE_ARRAY)) {
+               ret = -1;
+               goto end;
+       }
+
+       array = container_of(type, struct bt_ctf_field_type_array, parent);
+
+       if (array->element_type) {
+               BT_PUT(array->element_type);
+       }
+
+       array->element_type = element_type;
+       bt_get(array->element_type);
+
+end:
+       return ret;
+}
+
 int64_t bt_ctf_field_type_array_get_length(struct bt_ctf_field_type *type)
 {
        int64_t ret;
@@ -1606,6 +1632,32 @@ end:
        return ret;
 }
 
+BT_HIDDEN
+int bt_ctf_field_type_sequence_set_element_type(struct bt_ctf_field_type *type,
+               struct bt_ctf_field_type *element_type)
+{
+       int ret = 0;
+       struct bt_ctf_field_type_sequence *sequence;
+
+       if (!type || !element_type ||
+                       (type->declaration->id != CTF_TYPE_SEQUENCE)) {
+               ret = -1;
+               goto end;
+       }
+
+       sequence = container_of(type, struct bt_ctf_field_type_sequence, parent);
+
+       if (sequence->element_type) {
+               BT_PUT(sequence->element_type);
+       }
+
+       sequence->element_type = element_type;
+       bt_get(sequence->element_type);
+
+end:
+       return ret;
+}
+
 const char *bt_ctf_field_type_sequence_get_length_field_name(
                struct bt_ctf_field_type *type)
 {
index ed085dabf27bce5bb3544f3e8160ee7108ad8a76..1dea88d0b0327ae392767793575ec8b6922ba682 100644 (file)
@@ -238,4 +238,12 @@ int bt_ctf_field_type_variant_set_field_index(
                struct bt_ctf_field_type *variant,
                struct bt_ctf_field_type *field, int index);
 
+BT_HIDDEN
+int bt_ctf_field_type_array_set_element_type(struct bt_ctf_field_type *array,
+               struct bt_ctf_field_type *element_type);
+
+BT_HIDDEN
+int bt_ctf_field_type_sequence_set_element_type(struct bt_ctf_field_type *array,
+               struct bt_ctf_field_type *element_type);
+
 #endif /* BABELTRACE_CTF_IR_EVENT_TYPES_INTERNAL_H */
This page took 0.026369 seconds and 4 git commands to generate.