ir: add tag field path to variant field type
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 11 May 2015 21:29:53 +0000 (17:29 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 11 May 2015 21:39:24 +0000 (17:39 -0400)
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 9b6e7bbbfd8c0ac0b1d65ed3be343dc8a8d2ad2a..316efa78fa086b95915eec7c382a139801d17769 100644 (file)
@@ -2094,6 +2094,28 @@ int bt_ctf_field_type_sequence_set_length_field_path(
 end:
        return ret;
 }
+
+BT_HIDDEN
+int bt_ctf_field_type_variant_set_tag_field_path(struct bt_ctf_field_type *type,
+               struct bt_ctf_field_path *path)
+{
+       int ret = 0;
+       struct bt_ctf_field_type_variant *variant;
+
+       if (!type || bt_ctf_field_type_get_type_id(type) != CTF_TYPE_VARIANT) {
+               ret = -1;
+               goto end;
+       }
+
+       variant = container_of(type, struct bt_ctf_field_type_variant,
+               parent);
+       if (variant->tag_path) {
+               bt_ctf_field_path_destroy(variant->tag_path);
+       }
+       variant->tag_path = path;
+end:
+       return ret;
+}
 static
 void bt_ctf_field_type_integer_destroy(struct bt_ctf_ref *ref)
 {
@@ -2177,6 +2199,7 @@ void bt_ctf_field_type_variant_destroy(struct bt_ctf_ref *ref)
        g_hash_table_destroy(variant->field_name_to_index);
        g_string_free(variant->tag_name, TRUE);
        bt_ctf_field_type_put(&variant->tag->parent);
+       bt_ctf_field_path_destroy(variant->tag_path);
        g_free(variant);
 }
 
@@ -2994,6 +3017,13 @@ struct bt_ctf_field_type *bt_ctf_field_type_variant_copy(
        }
 
        copy_variant->declaration = variant->declaration;
+       if (variant->tag_path) {
+               copy_variant->tag_path = bt_ctf_field_path_copy(
+                       variant->tag_path);
+               if (!copy_variant->tag_path) {
+                       goto error;
+               }
+       }
 end:
        if (copy_tag) {
                bt_ctf_field_type_put(copy_tag);
index ca0cf0280c0393525923770077bc22b5744aebee..6078c345ec9bc0d4a62a45f7ee782f612c5c99ee 100644 (file)
@@ -123,6 +123,7 @@ struct bt_ctf_field_type_variant {
        struct bt_ctf_field_type parent;
        GString *tag_name;
        struct bt_ctf_field_type_enumeration *tag;
+       struct bt_ctf_field_path *tag_path;
        GHashTable *field_name_to_index;
        GPtrArray *fields; /* Array of pointers to struct structure_field */
        struct declaration_variant declaration;
@@ -208,4 +209,8 @@ BT_HIDDEN
 int bt_ctf_field_type_sequence_set_length_field_path(
                struct bt_ctf_field_type *type,
                struct bt_ctf_field_path *path);
+
+BT_HIDDEN
+int bt_ctf_field_type_variant_set_tag_field_path(struct bt_ctf_field_type *type,
+               struct bt_ctf_field_path *path);
 #endif /* BABELTRACE_CTF_IR_EVENT_TYPES_INTERNAL_H */
This page took 0.026764 seconds and 4 git commands to generate.