ir: add bt_ctf_field_type_variant_set_tag()
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 11 May 2015 21:31:06 +0000 (17:31 -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 316efa78fa086b95915eec7c382a139801d17769..78d0fa0daa6b4b6b14fd8a9445a7126445f94bf3 100644 (file)
@@ -2116,6 +2116,32 @@ int bt_ctf_field_type_variant_set_tag_field_path(struct bt_ctf_field_type *type,
 end:
        return ret;
 }
+
+BT_HIDDEN
+int bt_ctf_field_type_variant_set_tag(struct bt_ctf_field_type *type,
+               struct bt_ctf_field_type *tag)
+{
+       int ret = 0;
+       struct bt_ctf_field_type_variant *variant;
+
+       if (!type || !tag || type->frozen ||
+               bt_ctf_field_type_get_type_id(tag) != CTF_TYPE_ENUM) {
+               ret = -1;
+               goto end;
+       }
+
+       variant = container_of(type, struct bt_ctf_field_type_variant,
+               parent);
+       bt_ctf_field_type_get(tag);
+       if (variant->tag) {
+               bt_ctf_field_type_put(&variant->tag->parent);
+       }
+       variant->tag = container_of(tag, struct bt_ctf_field_type_enumeration,
+               parent);
+end:
+       return ret;
+}
+
 static
 void bt_ctf_field_type_integer_destroy(struct bt_ctf_ref *ref)
 {
index 6078c345ec9bc0d4a62a45f7ee782f612c5c99ee..48ead4858033f9d7543b7cc7e6e8d59d53b135cb 100644 (file)
@@ -213,4 +213,9 @@ int bt_ctf_field_type_sequence_set_length_field_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);
+
+BT_HIDDEN
+int bt_ctf_field_type_variant_set_tag(struct bt_ctf_field_type *type,
+               struct bt_ctf_field_type *tag);
+
 #endif /* BABELTRACE_CTF_IR_EVENT_TYPES_INTERNAL_H */
This page took 0.026471 seconds and 4 git commands to generate.