From 4a1e8671a35f5881e7226c03c1ef2dbe1b2370f5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Mon, 11 May 2015 17:29:53 -0400 Subject: [PATCH] ir: add tag field path to variant field type MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérémie Galarneau --- formats/ctf/ir/event-types.c | 30 +++++++++++++++++++ .../babeltrace/ctf-ir/event-types-internal.h | 5 ++++ 2 files changed, 35 insertions(+) diff --git a/formats/ctf/ir/event-types.c b/formats/ctf/ir/event-types.c index 9b6e7bbb..316efa78 100644 --- a/formats/ctf/ir/event-types.c +++ b/formats/ctf/ir/event-types.c @@ -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); diff --git a/include/babeltrace/ctf-ir/event-types-internal.h b/include/babeltrace/ctf-ir/event-types-internal.h index ca0cf028..6078c345 100644 --- a/include/babeltrace/ctf-ir/event-types-internal.h +++ b/include/babeltrace/ctf-ir/event-types-internal.h @@ -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 */ -- 2.34.1