ir: rename ctf_type_id -> bt_ctf_type_id
[babeltrace.git] / formats / ctf / ir / event-types.c
index 1c5e4765c1d0c99a9e3ca507683660e7a906dcd0..eab0ef4347512143ff79745d027da75b812f0583 100644 (file)
@@ -28,6 +28,7 @@
 
 #include <babeltrace/ctf-writer/event-types.h>
 #include <babeltrace/ctf-ir/event-types-internal.h>
+#include <babeltrace/ctf-ir/field-path-internal.h>
 #include <babeltrace/ctf-ir/utils.h>
 #include <babeltrace/ref.h>
 #include <babeltrace/ctf-ir/clock.h>
@@ -75,16 +76,16 @@ void bt_ctf_field_type_string_destroy(struct bt_ctf_field_type *);
 
 static
 void (* const type_destroy_funcs[])(struct bt_ctf_field_type *) = {
-       [CTF_TYPE_INTEGER] = bt_ctf_field_type_integer_destroy,
-       [CTF_TYPE_ENUM] =
+       [BT_CTF_TYPE_ID_INTEGER] = bt_ctf_field_type_integer_destroy,
+       [BT_CTF_TYPE_ID_ENUM] =
                bt_ctf_field_type_enumeration_destroy,
-       [CTF_TYPE_FLOAT] =
+       [BT_CTF_TYPE_ID_FLOAT] =
                bt_ctf_field_type_floating_point_destroy,
-       [CTF_TYPE_STRUCT] = bt_ctf_field_type_structure_destroy,
-       [CTF_TYPE_VARIANT] = bt_ctf_field_type_variant_destroy,
-       [CTF_TYPE_ARRAY] = bt_ctf_field_type_array_destroy,
-       [CTF_TYPE_SEQUENCE] = bt_ctf_field_type_sequence_destroy,
-       [CTF_TYPE_STRING] = bt_ctf_field_type_string_destroy,
+       [BT_CTF_TYPE_ID_STRUCT] = bt_ctf_field_type_structure_destroy,
+       [BT_CTF_TYPE_ID_VARIANT] = bt_ctf_field_type_variant_destroy,
+       [BT_CTF_TYPE_ID_ARRAY] = bt_ctf_field_type_array_destroy,
+       [BT_CTF_TYPE_ID_SEQUENCE] = bt_ctf_field_type_sequence_destroy,
+       [BT_CTF_TYPE_ID_STRING] = bt_ctf_field_type_string_destroy,
 };
 
 static
@@ -102,14 +103,14 @@ void bt_ctf_field_type_sequence_freeze(struct bt_ctf_field_type *);
 
 static
 type_freeze_func const type_freeze_funcs[] = {
-       [CTF_TYPE_INTEGER] = generic_field_type_freeze,
-       [CTF_TYPE_ENUM] = bt_ctf_field_type_enumeration_freeze,
-       [CTF_TYPE_FLOAT] = generic_field_type_freeze,
-       [CTF_TYPE_STRUCT] = bt_ctf_field_type_structure_freeze,
-       [CTF_TYPE_VARIANT] = bt_ctf_field_type_variant_freeze,
-       [CTF_TYPE_ARRAY] = bt_ctf_field_type_array_freeze,
-       [CTF_TYPE_SEQUENCE] = bt_ctf_field_type_sequence_freeze,
-       [CTF_TYPE_STRING] = generic_field_type_freeze,
+       [BT_CTF_TYPE_ID_INTEGER] = generic_field_type_freeze,
+       [BT_CTF_TYPE_ID_ENUM] = bt_ctf_field_type_enumeration_freeze,
+       [BT_CTF_TYPE_ID_FLOAT] = generic_field_type_freeze,
+       [BT_CTF_TYPE_ID_STRUCT] = bt_ctf_field_type_structure_freeze,
+       [BT_CTF_TYPE_ID_VARIANT] = bt_ctf_field_type_variant_freeze,
+       [BT_CTF_TYPE_ID_ARRAY] = bt_ctf_field_type_array_freeze,
+       [BT_CTF_TYPE_ID_SEQUENCE] = bt_ctf_field_type_sequence_freeze,
+       [BT_CTF_TYPE_ID_STRING] = generic_field_type_freeze,
 };
 
 static
@@ -139,17 +140,17 @@ int bt_ctf_field_type_string_serialize(struct bt_ctf_field_type *,
 
 static
 type_serialize_func const type_serialize_funcs[] = {
-       [CTF_TYPE_INTEGER] = bt_ctf_field_type_integer_serialize,
-       [CTF_TYPE_ENUM] =
+       [BT_CTF_TYPE_ID_INTEGER] = bt_ctf_field_type_integer_serialize,
+       [BT_CTF_TYPE_ID_ENUM] =
                bt_ctf_field_type_enumeration_serialize,
-       [CTF_TYPE_FLOAT] =
+       [BT_CTF_TYPE_ID_FLOAT] =
                bt_ctf_field_type_floating_point_serialize,
-       [CTF_TYPE_STRUCT] =
+       [BT_CTF_TYPE_ID_STRUCT] =
                bt_ctf_field_type_structure_serialize,
-       [CTF_TYPE_VARIANT] = bt_ctf_field_type_variant_serialize,
-       [CTF_TYPE_ARRAY] = bt_ctf_field_type_array_serialize,
-       [CTF_TYPE_SEQUENCE] = bt_ctf_field_type_sequence_serialize,
-       [CTF_TYPE_STRING] = bt_ctf_field_type_string_serialize,
+       [BT_CTF_TYPE_ID_VARIANT] = bt_ctf_field_type_variant_serialize,
+       [BT_CTF_TYPE_ID_ARRAY] = bt_ctf_field_type_array_serialize,
+       [BT_CTF_TYPE_ID_SEQUENCE] = bt_ctf_field_type_sequence_serialize,
+       [BT_CTF_TYPE_ID_STRING] = bt_ctf_field_type_string_serialize,
 };
 
 static
@@ -178,17 +179,17 @@ void bt_ctf_field_type_sequence_set_byte_order(struct bt_ctf_field_type *,
 static
 void (* const set_byte_order_funcs[])(struct bt_ctf_field_type *,
                int byte_order, int set_native) = {
-       [CTF_TYPE_INTEGER] = bt_ctf_field_type_integer_set_byte_order,
-       [CTF_TYPE_ENUM] =
+       [BT_CTF_TYPE_ID_INTEGER] = bt_ctf_field_type_integer_set_byte_order,
+       [BT_CTF_TYPE_ID_ENUM] =
                bt_ctf_field_type_enumeration_set_byte_order,
-       [CTF_TYPE_FLOAT] =
+       [BT_CTF_TYPE_ID_FLOAT] =
                bt_ctf_field_type_floating_point_set_byte_order,
-       [CTF_TYPE_STRUCT] =
+       [BT_CTF_TYPE_ID_STRUCT] =
                bt_ctf_field_type_structure_set_byte_order,
-       [CTF_TYPE_VARIANT] = bt_ctf_field_type_variant_set_byte_order,
-       [CTF_TYPE_ARRAY] = bt_ctf_field_type_array_set_byte_order,
-       [CTF_TYPE_SEQUENCE] = bt_ctf_field_type_sequence_set_byte_order,
-       [CTF_TYPE_STRING] = NULL,
+       [BT_CTF_TYPE_ID_VARIANT] = bt_ctf_field_type_variant_set_byte_order,
+       [BT_CTF_TYPE_ID_ARRAY] = bt_ctf_field_type_array_set_byte_order,
+       [BT_CTF_TYPE_ID_SEQUENCE] = bt_ctf_field_type_sequence_set_byte_order,
+       [BT_CTF_TYPE_ID_STRING] = NULL,
 };
 
 static
@@ -219,14 +220,14 @@ struct bt_ctf_field_type *bt_ctf_field_type_string_copy(
 static
 struct bt_ctf_field_type *(* const type_copy_funcs[])(
                struct bt_ctf_field_type *) = {
-       [CTF_TYPE_INTEGER] = bt_ctf_field_type_integer_copy,
-       [CTF_TYPE_ENUM] = bt_ctf_field_type_enumeration_copy,
-       [CTF_TYPE_FLOAT] = bt_ctf_field_type_floating_point_copy,
-       [CTF_TYPE_STRUCT] = bt_ctf_field_type_structure_copy,
-       [CTF_TYPE_VARIANT] = bt_ctf_field_type_variant_copy,
-       [CTF_TYPE_ARRAY] = bt_ctf_field_type_array_copy,
-       [CTF_TYPE_SEQUENCE] = bt_ctf_field_type_sequence_copy,
-       [CTF_TYPE_STRING] = bt_ctf_field_type_string_copy,
+       [BT_CTF_TYPE_ID_INTEGER] = bt_ctf_field_type_integer_copy,
+       [BT_CTF_TYPE_ID_ENUM] = bt_ctf_field_type_enumeration_copy,
+       [BT_CTF_TYPE_ID_FLOAT] = bt_ctf_field_type_floating_point_copy,
+       [BT_CTF_TYPE_ID_STRUCT] = bt_ctf_field_type_structure_copy,
+       [BT_CTF_TYPE_ID_VARIANT] = bt_ctf_field_type_variant_copy,
+       [BT_CTF_TYPE_ID_ARRAY] = bt_ctf_field_type_array_copy,
+       [BT_CTF_TYPE_ID_SEQUENCE] = bt_ctf_field_type_sequence_copy,
+       [BT_CTF_TYPE_ID_STRING] = bt_ctf_field_type_string_copy,
 };
 
 static
@@ -257,14 +258,14 @@ int bt_ctf_field_type_sequence_compare(struct bt_ctf_field_type *,
 static
 int (* const type_compare_funcs[])(struct bt_ctf_field_type *,
                struct bt_ctf_field_type *) = {
-       [CTF_TYPE_INTEGER] = bt_ctf_field_type_integer_compare,
-       [CTF_TYPE_ENUM] = bt_ctf_field_type_enumeration_compare,
-       [CTF_TYPE_FLOAT] = bt_ctf_field_type_floating_point_compare,
-       [CTF_TYPE_STRUCT] = bt_ctf_field_type_structure_compare,
-       [CTF_TYPE_VARIANT] = bt_ctf_field_type_variant_compare,
-       [CTF_TYPE_ARRAY] = bt_ctf_field_type_array_compare,
-       [CTF_TYPE_SEQUENCE] = bt_ctf_field_type_sequence_compare,
-       [CTF_TYPE_STRING] = bt_ctf_field_type_string_compare,
+       [BT_CTF_TYPE_ID_INTEGER] = bt_ctf_field_type_integer_compare,
+       [BT_CTF_TYPE_ID_ENUM] = bt_ctf_field_type_enumeration_compare,
+       [BT_CTF_TYPE_ID_FLOAT] = bt_ctf_field_type_floating_point_compare,
+       [BT_CTF_TYPE_ID_STRUCT] = bt_ctf_field_type_structure_compare,
+       [BT_CTF_TYPE_ID_VARIANT] = bt_ctf_field_type_variant_compare,
+       [BT_CTF_TYPE_ID_ARRAY] = bt_ctf_field_type_array_compare,
+       [BT_CTF_TYPE_ID_SEQUENCE] = bt_ctf_field_type_sequence_compare,
+       [BT_CTF_TYPE_ID_STRING] = bt_ctf_field_type_string_compare,
 };
 
 static
@@ -280,14 +281,14 @@ int bt_ctf_field_type_sequence_validate(struct bt_ctf_field_type *);
 
 static
 int (* const type_validate_funcs[])(struct bt_ctf_field_type *) = {
-       [CTF_TYPE_INTEGER] = NULL,
-       [CTF_TYPE_FLOAT] = NULL,
-       [CTF_TYPE_STRING] = NULL,
-       [CTF_TYPE_ENUM] = bt_ctf_field_type_enumeration_validate,
-       [CTF_TYPE_STRUCT] = bt_ctf_field_type_structure_validate,
-       [CTF_TYPE_VARIANT] = bt_ctf_field_type_variant_validate,
-       [CTF_TYPE_ARRAY] = bt_ctf_field_type_array_validate,
-       [CTF_TYPE_SEQUENCE] = bt_ctf_field_type_sequence_validate,
+       [BT_CTF_TYPE_ID_INTEGER] = NULL,
+       [BT_CTF_TYPE_ID_FLOAT] = NULL,
+       [BT_CTF_TYPE_ID_STRING] = NULL,
+       [BT_CTF_TYPE_ID_ENUM] = bt_ctf_field_type_enumeration_validate,
+       [BT_CTF_TYPE_ID_STRUCT] = bt_ctf_field_type_structure_validate,
+       [BT_CTF_TYPE_ID_VARIANT] = bt_ctf_field_type_variant_validate,
+       [BT_CTF_TYPE_ID_ARRAY] = bt_ctf_field_type_array_validate,
+       [BT_CTF_TYPE_ID_SEQUENCE] = bt_ctf_field_type_sequence_validate,
 };
 
 static
@@ -354,10 +355,10 @@ gint compare_enumeration_mappings_unsigned(struct enumeration_mapping **a,
 static
 void bt_ctf_field_type_init(struct bt_ctf_field_type *type, int init_bo)
 {
-       enum ctf_type_id type_id = type->declaration->id;
+       enum bt_ctf_type_id type_id = type->declaration->id;
 
-       assert(type && (type_id > CTF_TYPE_UNKNOWN) &&
-               (type_id < NR_CTF_TYPES));
+       assert(type && (type_id > BT_CTF_TYPE_ID_UNKNOWN) &&
+               (type_id < BT_CTF_NR_TYPE_IDS));
 
        bt_object_init(type, bt_ctf_field_type_destroy);
        type->freeze = type_freeze_funcs[type_id];
@@ -410,12 +411,12 @@ static
 void bt_ctf_field_type_destroy(struct bt_object *obj)
 {
        struct bt_ctf_field_type *type;
-       enum ctf_type_id type_id;
+       enum bt_ctf_type_id type_id;
 
        type = container_of(obj, struct bt_ctf_field_type, base);
        type_id = type->declaration->id;
-       if (type_id <= CTF_TYPE_UNKNOWN ||
-               type_id >= NR_CTF_TYPES) {
+       if (type_id <= BT_CTF_TYPE_ID_UNKNOWN ||
+               type_id >= BT_CTF_NR_TYPE_IDS) {
                return;
        }
 
@@ -623,7 +624,7 @@ BT_HIDDEN
 int bt_ctf_field_type_validate(struct bt_ctf_field_type *type)
 {
        int ret = 0;
-       enum ctf_type_id id = bt_ctf_field_type_get_type_id(type);
+       enum bt_ctf_type_id id = bt_ctf_field_type_get_type_id(type);
 
        if (!type) {
                ret = -1;
@@ -658,10 +659,10 @@ struct bt_ctf_field_type *bt_ctf_field_type_integer_create(unsigned int size)
        }
 
        integer->parent.declaration = &integer->declaration.p;
-       integer->parent.declaration->id = CTF_TYPE_INTEGER;
+       integer->parent.declaration->id = BT_CTF_TYPE_ID_INTEGER;
        integer->declaration.len = size;
        integer->declaration.base = BT_CTF_INTEGER_BASE_DECIMAL;
-       integer->declaration.encoding = CTF_STRING_NONE;
+       integer->declaration.encoding = BT_CTF_STRING_ENCODING_NONE;
        bt_ctf_field_type_init(&integer->parent, TRUE);
        return &integer->parent;
 }
@@ -671,7 +672,7 @@ int bt_ctf_field_type_integer_get_size(struct bt_ctf_field_type *type)
        int ret = 0;
        struct bt_ctf_field_type_integer *integer;
 
-       if (!type || type->declaration->id != CTF_TYPE_INTEGER) {
+       if (!type || type->declaration->id != BT_CTF_TYPE_ID_INTEGER) {
                ret = -1;
                goto end;
        }
@@ -687,7 +688,7 @@ int bt_ctf_field_type_integer_get_signed(struct bt_ctf_field_type *type)
        int ret = 0;
        struct bt_ctf_field_type_integer *integer;
 
-       if (!type || type->declaration->id != CTF_TYPE_INTEGER) {
+       if (!type || type->declaration->id != BT_CTF_TYPE_ID_INTEGER) {
                ret = -1;
                goto end;
        }
@@ -705,7 +706,7 @@ int bt_ctf_field_type_integer_set_signed(struct bt_ctf_field_type *type,
        struct bt_ctf_field_type_integer *integer;
 
        if (!type || type->frozen ||
-               type->declaration->id != CTF_TYPE_INTEGER) {
+               type->declaration->id != BT_CTF_TYPE_ID_INTEGER) {
                ret = -1;
                goto end;
        }
@@ -722,7 +723,7 @@ enum bt_ctf_integer_base bt_ctf_field_type_integer_get_base(
        enum bt_ctf_integer_base ret = BT_CTF_INTEGER_BASE_UNKNOWN;
        struct bt_ctf_field_type_integer *integer;
 
-       if (!type || type->declaration->id != CTF_TYPE_INTEGER) {
+       if (!type || type->declaration->id != BT_CTF_TYPE_ID_INTEGER) {
                goto end;
        }
 
@@ -738,7 +739,7 @@ int bt_ctf_field_type_integer_set_base(struct bt_ctf_field_type *type,
        int ret = 0;
 
        if (!type || type->frozen ||
-               type->declaration->id != CTF_TYPE_INTEGER) {
+               type->declaration->id != BT_CTF_TYPE_ID_INTEGER) {
                ret = -1;
                goto end;
        }
@@ -761,13 +762,13 @@ end:
        return ret;
 }
 
-enum ctf_string_encoding bt_ctf_field_type_integer_get_encoding(
+enum bt_ctf_string_encoding bt_ctf_field_type_integer_get_encoding(
                struct bt_ctf_field_type *type)
 {
-       enum ctf_string_encoding ret = CTF_STRING_UNKNOWN;
+       enum bt_ctf_string_encoding ret = BT_CTF_STRING_ENCODING_UNKNOWN;
        struct bt_ctf_field_type_integer *integer;
 
-       if (!type || type->declaration->id != CTF_TYPE_INTEGER) {
+       if (!type || type->declaration->id != BT_CTF_TYPE_ID_INTEGER) {
                goto end;
        }
 
@@ -778,15 +779,15 @@ end:
 }
 
 int bt_ctf_field_type_integer_set_encoding(struct bt_ctf_field_type *type,
-               enum ctf_string_encoding encoding)
+               enum bt_ctf_string_encoding encoding)
 {
        int ret = 0;
        struct bt_ctf_field_type_integer *integer;
 
        if (!type || type->frozen ||
-               (type->declaration->id != CTF_TYPE_INTEGER) ||
-               (encoding < CTF_STRING_NONE) ||
-               (encoding >= CTF_STRING_UNKNOWN)) {
+               (type->declaration->id != BT_CTF_TYPE_ID_INTEGER) ||
+               (encoding < BT_CTF_STRING_ENCODING_NONE) ||
+               (encoding >= BT_CTF_STRING_ENCODING_UNKNOWN)) {
                ret = -1;
                goto end;
        }
@@ -843,7 +844,7 @@ struct bt_ctf_field_type *bt_ctf_field_type_enumeration_create(
                goto error;
        }
 
-       if (integer_container_type->declaration->id != CTF_TYPE_INTEGER) {
+       if (integer_container_type->declaration->id != BT_CTF_TYPE_ID_INTEGER) {
                goto error;
        }
 
@@ -853,7 +854,7 @@ struct bt_ctf_field_type *bt_ctf_field_type_enumeration_create(
        }
 
        enumeration->parent.declaration = &enumeration->declaration.p;
-       enumeration->parent.declaration->id = CTF_TYPE_ENUM;
+       enumeration->parent.declaration->id = BT_CTF_TYPE_ID_ENUM;
        bt_get(integer_container_type);
        enumeration->container = integer_container_type;
        enumeration->entries = g_ptr_array_new_with_free_func(
@@ -875,7 +876,7 @@ struct bt_ctf_field_type *bt_ctf_field_type_enumeration_get_container_type(
                goto end;
        }
 
-       if (type->declaration->id != CTF_TYPE_ENUM) {
+       if (type->declaration->id != BT_CTF_TYPE_ID_ENUM) {
                goto end;
        }
 
@@ -898,7 +899,7 @@ int bt_ctf_field_type_enumeration_add_mapping(
        struct range_overlap_query query;
        char *escaped_string;
 
-       if (!type || (type->declaration->id != CTF_TYPE_ENUM) ||
+       if (!type || (type->declaration->id != BT_CTF_TYPE_ID_ENUM) ||
                type->frozen ||
                (range_end < range_start)) {
                ret = -1;
@@ -961,7 +962,7 @@ int bt_ctf_field_type_enumeration_add_mapping_unsigned(
        struct range_overlap_query query;
        char *escaped_string;
 
-       if (!type || (type->declaration->id != CTF_TYPE_ENUM) ||
+       if (!type || (type->declaration->id != BT_CTF_TYPE_ID_ENUM) ||
                type->frozen ||
                (range_end < range_start)) {
                ret = -1;
@@ -1065,7 +1066,7 @@ int bt_ctf_field_type_enumeration_get_mapping_count(
        int ret = 0;
        struct bt_ctf_field_type_enumeration *enumeration;
 
-       if (!type || (type->declaration->id != CTF_TYPE_ENUM)) {
+       if (!type || (type->declaration->id != BT_CTF_TYPE_ID_ENUM)) {
                ret = -1;
                goto end;
        }
@@ -1103,7 +1104,7 @@ int bt_ctf_field_type_enumeration_get_mapping(
        int ret = 0;
 
        if (!type || index < 0 || !string || !range_start || !range_end ||
-               (type->declaration->id != CTF_TYPE_ENUM)) {
+               (type->declaration->id != BT_CTF_TYPE_ID_ENUM)) {
                ret = -1;
                goto end;
        }
@@ -1129,7 +1130,7 @@ int bt_ctf_field_type_enumeration_get_mapping_unsigned(
        int ret = 0;
 
        if (!type || index < 0 || !string || !range_start || !range_end ||
-               (type->declaration->id != CTF_TYPE_ENUM)) {
+               (type->declaration->id != BT_CTF_TYPE_ID_ENUM)) {
                ret = -1;
                goto end;
        }
@@ -1155,7 +1156,7 @@ int bt_ctf_field_type_enumeration_get_mapping_index_by_name(
        int i, ret = 0;
 
        if (!type || !name ||
-               (type->declaration->id != CTF_TYPE_ENUM)) {
+               (type->declaration->id != BT_CTF_TYPE_ID_ENUM)) {
                ret = -1;
                goto end;
        }
@@ -1189,7 +1190,7 @@ int bt_ctf_field_type_enumeration_get_mapping_index_by_value(
        struct bt_ctf_field_type_enumeration *enumeration;
        int i, ret = 0;
 
-       if (!type || (type->declaration->id != CTF_TYPE_ENUM)) {
+       if (!type || (type->declaration->id != BT_CTF_TYPE_ID_ENUM)) {
                ret = -1;
                goto end;
        }
@@ -1218,7 +1219,7 @@ int bt_ctf_field_type_enumeration_get_mapping_index_by_unsigned_value(
        struct bt_ctf_field_type_enumeration *enumeration;
        int i, ret = 0;
 
-       if (!type || (type->declaration->id != CTF_TYPE_ENUM)) {
+       if (!type || (type->declaration->id != BT_CTF_TYPE_ID_ENUM)) {
                ret = -1;
                goto end;
        }
@@ -1255,7 +1256,7 @@ struct bt_ctf_field_type *bt_ctf_field_type_floating_point_create(void)
        floating_point->declaration.exp = &floating_point->exp;
        floating_point->sign.len = 1;
        floating_point->parent.declaration = &floating_point->declaration.p;
-       floating_point->parent.declaration->id = CTF_TYPE_FLOAT;
+       floating_point->parent.declaration->id = BT_CTF_TYPE_ID_FLOAT;
        floating_point->declaration.exp->len =
                sizeof(float) * CHAR_BIT - FLT_MANT_DIG;
        floating_point->declaration.mantissa->len = FLT_MANT_DIG - 1;
@@ -1274,7 +1275,7 @@ int bt_ctf_field_type_floating_point_get_exponent_digits(
        int ret = 0;
        struct bt_ctf_field_type_floating_point *floating_point;
 
-       if (!type || (type->declaration->id != CTF_TYPE_FLOAT)) {
+       if (!type || (type->declaration->id != BT_CTF_TYPE_ID_FLOAT)) {
                ret = -1;
                goto end;
        }
@@ -1294,7 +1295,7 @@ int bt_ctf_field_type_floating_point_set_exponent_digits(
        struct bt_ctf_field_type_floating_point *floating_point;
 
        if (!type || type->frozen ||
-               (type->declaration->id != CTF_TYPE_FLOAT)) {
+               (type->declaration->id != BT_CTF_TYPE_ID_FLOAT)) {
                ret = -1;
                goto end;
        }
@@ -1320,7 +1321,7 @@ int bt_ctf_field_type_floating_point_get_mantissa_digits(
        int ret = 0;
        struct bt_ctf_field_type_floating_point *floating_point;
 
-       if (!type || (type->declaration->id != CTF_TYPE_FLOAT)) {
+       if (!type || (type->declaration->id != BT_CTF_TYPE_ID_FLOAT)) {
                ret = -1;
                goto end;
        }
@@ -1340,7 +1341,7 @@ int bt_ctf_field_type_floating_point_set_mantissa_digits(
        struct bt_ctf_field_type_floating_point *floating_point;
 
        if (!type || type->frozen ||
-               (type->declaration->id != CTF_TYPE_FLOAT)) {
+               (type->declaration->id != BT_CTF_TYPE_ID_FLOAT)) {
                ret = -1;
                goto end;
        }
@@ -1370,7 +1371,7 @@ struct bt_ctf_field_type *bt_ctf_field_type_structure_create(void)
        }
 
        structure->parent.declaration = &structure->declaration.p;
-       structure->parent.declaration->id = CTF_TYPE_STRUCT;
+       structure->parent.declaration->id = BT_CTF_TYPE_ID_STRUCT;
        structure->fields = g_ptr_array_new_with_free_func(
                (GDestroyNotify)destroy_structure_field);
        structure->field_name_to_index = g_hash_table_new(NULL, NULL);
@@ -1389,7 +1390,7 @@ int bt_ctf_field_type_structure_add_field(struct bt_ctf_field_type *type,
 
        if (!type || !field_type || type->frozen ||
                bt_ctf_validate_identifier(field_name) ||
-               (type->declaration->id != CTF_TYPE_STRUCT)) {
+               (type->declaration->id != BT_CTF_TYPE_ID_STRUCT)) {
                ret = -1;
                goto end;
        }
@@ -1411,7 +1412,7 @@ int bt_ctf_field_type_structure_get_field_count(
        int ret = 0;
        struct bt_ctf_field_type_structure *structure;
 
-       if (!type || (type->declaration->id != CTF_TYPE_STRUCT)) {
+       if (!type || (type->declaration->id != BT_CTF_TYPE_ID_STRUCT)) {
                ret = -1;
                goto end;
        }
@@ -1431,7 +1432,8 @@ int bt_ctf_field_type_structure_get_field(struct bt_ctf_field_type *type,
        struct structure_field *field;
        int ret = 0;
 
-       if (!type || index < 0 || (type->declaration->id != CTF_TYPE_STRUCT)) {
+       if (!type || index < 0 ||
+                       (type->declaration->id != BT_CTF_TYPE_ID_STRUCT)) {
                ret = -1;
                goto end;
        }
@@ -1503,7 +1505,7 @@ struct bt_ctf_field_type *bt_ctf_field_type_variant_create(
        }
 
        variant->parent.declaration = &variant->declaration.p;
-       variant->parent.declaration->id = CTF_TYPE_VARIANT;
+       variant->parent.declaration->id = BT_CTF_TYPE_ID_VARIANT;
        variant->tag_name = g_string_new(tag_name);
        variant->field_name_to_index = g_hash_table_new(NULL, NULL);
        variant->fields = g_ptr_array_new_with_free_func(
@@ -1528,7 +1530,7 @@ struct bt_ctf_field_type *bt_ctf_field_type_variant_get_tag_type(
        struct bt_ctf_field_type_variant *variant;
        struct bt_ctf_field_type *tag_type = NULL;
 
-       if (!type || (type->declaration->id != CTF_TYPE_VARIANT)) {
+       if (!type || (type->declaration->id != BT_CTF_TYPE_ID_VARIANT)) {
                goto end;
        }
 
@@ -1549,7 +1551,7 @@ const char *bt_ctf_field_type_variant_get_tag_name(
        struct bt_ctf_field_type_variant *variant;
        const char *tag_name = NULL;
 
-       if (!type || (type->declaration->id != CTF_TYPE_VARIANT)) {
+       if (!type || (type->declaration->id != BT_CTF_TYPE_ID_VARIANT)) {
                goto end;
        }
 
@@ -1570,7 +1572,7 @@ int bt_ctf_field_type_variant_set_tag_name(
        struct bt_ctf_field_type_variant *variant;
 
        if (!type || type->frozen ||
-               (type->declaration->id != CTF_TYPE_VARIANT) ||
+               (type->declaration->id != BT_CTF_TYPE_ID_VARIANT) ||
                bt_ctf_validate_identifier(name)) {
                ret = -1;
                goto end;
@@ -1593,7 +1595,7 @@ int bt_ctf_field_type_variant_add_field(struct bt_ctf_field_type *type,
 
        if (!type || !field_type || type->frozen ||
                bt_ctf_validate_identifier(field_name) ||
-               (type->declaration->id != CTF_TYPE_VARIANT)) {
+               (type->declaration->id != BT_CTF_TYPE_ID_VARIANT)) {
                ret = -1;
                goto end;
        }
@@ -1670,7 +1672,7 @@ struct bt_ctf_field_type *bt_ctf_field_type_variant_get_field_type_from_tag(
        const char *enum_value;
        struct bt_ctf_field_type *field_type = NULL;
 
-       if (!type || !tag || type->declaration->id != CTF_TYPE_VARIANT) {
+       if (!type || !tag || type->declaration->id != BT_CTF_TYPE_ID_VARIANT) {
                goto end;
        }
 
@@ -1691,7 +1693,7 @@ int bt_ctf_field_type_variant_get_field_count(struct bt_ctf_field_type *type)
        int ret = 0;
        struct bt_ctf_field_type_variant *variant;
 
-       if (!type || (type->declaration->id != CTF_TYPE_VARIANT)) {
+       if (!type || (type->declaration->id != BT_CTF_TYPE_ID_VARIANT)) {
                ret = -1;
                goto end;
        }
@@ -1712,7 +1714,8 @@ int bt_ctf_field_type_variant_get_field(struct bt_ctf_field_type *type,
        struct structure_field *field;
        int ret = 0;
 
-       if (!type || index < 0 || (type->declaration->id != CTF_TYPE_VARIANT)) {
+       if (!type || index < 0 ||
+                       (type->declaration->id != BT_CTF_TYPE_ID_VARIANT)) {
                ret = -1;
                goto end;
        }
@@ -1752,7 +1755,7 @@ struct bt_ctf_field_type *bt_ctf_field_type_array_create(
        }
 
        array->parent.declaration = &array->declaration.p;
-       array->parent.declaration->id = CTF_TYPE_ARRAY;
+       array->parent.declaration->id = BT_CTF_TYPE_ID_ARRAY;
 
        bt_get(element_type);
        array->element_type = element_type;
@@ -1769,7 +1772,7 @@ struct bt_ctf_field_type *bt_ctf_field_type_array_get_element_type(
        struct bt_ctf_field_type *ret = NULL;
        struct bt_ctf_field_type_array *array;
 
-       if (!type || (type->declaration->id != CTF_TYPE_ARRAY)) {
+       if (!type || (type->declaration->id != BT_CTF_TYPE_ID_ARRAY)) {
                goto end;
        }
 
@@ -1788,7 +1791,7 @@ int bt_ctf_field_type_array_set_element_type(struct bt_ctf_field_type *type,
        struct bt_ctf_field_type_array *array;
 
        if (!type || !element_type ||
-                       (type->declaration->id != CTF_TYPE_ARRAY)) {
+                       (type->declaration->id != BT_CTF_TYPE_ID_ARRAY)) {
                ret = -1;
                goto end;
        }
@@ -1811,7 +1814,7 @@ int64_t bt_ctf_field_type_array_get_length(struct bt_ctf_field_type *type)
        int64_t ret;
        struct bt_ctf_field_type_array *array;
 
-       if (!type || (type->declaration->id != CTF_TYPE_ARRAY)) {
+       if (!type || (type->declaration->id != BT_CTF_TYPE_ID_ARRAY)) {
                ret = -1;
                goto end;
        }
@@ -1838,7 +1841,7 @@ struct bt_ctf_field_type *bt_ctf_field_type_sequence_create(
        }
 
        sequence->parent.declaration = &sequence->declaration.p;
-       sequence->parent.declaration->id = CTF_TYPE_SEQUENCE;
+       sequence->parent.declaration->id = BT_CTF_TYPE_ID_SEQUENCE;
        bt_get(element_type);
        sequence->element_type = element_type;
        sequence->length_field_name = g_string_new(length_field_name);
@@ -1854,7 +1857,7 @@ struct bt_ctf_field_type *bt_ctf_field_type_sequence_get_element_type(
        struct bt_ctf_field_type *ret = NULL;
        struct bt_ctf_field_type_sequence *sequence;
 
-       if (!type || (type->declaration->id != CTF_TYPE_SEQUENCE)) {
+       if (!type || (type->declaration->id != BT_CTF_TYPE_ID_SEQUENCE)) {
                goto end;
        }
 
@@ -1874,7 +1877,7 @@ int bt_ctf_field_type_sequence_set_element_type(struct bt_ctf_field_type *type,
        struct bt_ctf_field_type_sequence *sequence;
 
        if (!type || !element_type ||
-                       (type->declaration->id != CTF_TYPE_SEQUENCE)) {
+                       (type->declaration->id != BT_CTF_TYPE_ID_SEQUENCE)) {
                ret = -1;
                goto end;
        }
@@ -1898,7 +1901,7 @@ const char *bt_ctf_field_type_sequence_get_length_field_name(
        const char *ret = NULL;
        struct bt_ctf_field_type_sequence *sequence;
 
-       if (!type || (type->declaration->id != CTF_TYPE_SEQUENCE)) {
+       if (!type || (type->declaration->id != BT_CTF_TYPE_ID_SEQUENCE)) {
                goto end;
        }
 
@@ -1919,20 +1922,20 @@ struct bt_ctf_field_type *bt_ctf_field_type_string_create(void)
        }
 
        string->parent.declaration = &string->declaration.p;
-       string->parent.declaration->id = CTF_TYPE_STRING;
+       string->parent.declaration->id = BT_CTF_TYPE_ID_STRING;
        bt_ctf_field_type_init(&string->parent, TRUE);
-       string->declaration.encoding = CTF_STRING_UTF8;
+       string->declaration.encoding = BT_CTF_STRING_ENCODING_UTF8;
        string->parent.declaration->alignment = CHAR_BIT;
        return &string->parent;
 }
 
-enum ctf_string_encoding bt_ctf_field_type_string_get_encoding(
+enum bt_ctf_string_encoding bt_ctf_field_type_string_get_encoding(
                struct bt_ctf_field_type *type)
 {
        struct bt_ctf_field_type_string *string;
-       enum ctf_string_encoding ret = CTF_STRING_UNKNOWN;
+       enum bt_ctf_string_encoding ret = BT_CTF_STRING_ENCODING_UNKNOWN;
 
-       if (!type || (type->declaration->id != CTF_TYPE_STRING)) {
+       if (!type || (type->declaration->id != BT_CTF_TYPE_ID_STRING)) {
                goto end;
        }
 
@@ -1944,14 +1947,14 @@ end:
 }
 
 int bt_ctf_field_type_string_set_encoding(struct bt_ctf_field_type *type,
-               enum ctf_string_encoding encoding)
+               enum bt_ctf_string_encoding encoding)
 {
        int ret = 0;
        struct bt_ctf_field_type_string *string;
 
-       if (!type || type->declaration->id != CTF_TYPE_STRING ||
-               (encoding != CTF_STRING_UTF8 &&
-               encoding != CTF_STRING_ASCII)) {
+       if (!type || type->declaration->id != BT_CTF_TYPE_ID_STRING ||
+               (encoding != BT_CTF_STRING_ENCODING_UTF8 &&
+               encoding != BT_CTF_STRING_ENCODING_ASCII)) {
                ret = -1;
                goto end;
        }
@@ -1965,7 +1968,7 @@ end:
 int bt_ctf_field_type_get_alignment(struct bt_ctf_field_type *type)
 {
        int ret;
-       enum ctf_type_id type_id;
+       enum bt_ctf_type_id type_id;
 
        if (!type) {
                ret = -1;
@@ -1979,7 +1982,7 @@ int bt_ctf_field_type_get_alignment(struct bt_ctf_field_type *type)
 
        type_id = bt_ctf_field_type_get_type_id(type);
        switch (type_id) {
-       case CTF_TYPE_SEQUENCE:
+       case BT_CTF_TYPE_ID_SEQUENCE:
        {
                struct bt_ctf_field_type *element =
                        bt_ctf_field_type_sequence_get_element_type(type);
@@ -1993,7 +1996,7 @@ int bt_ctf_field_type_get_alignment(struct bt_ctf_field_type *type)
                bt_put(element);
                break;
        }
-       case CTF_TYPE_ARRAY:
+       case BT_CTF_TYPE_ID_ARRAY:
        {
                struct bt_ctf_field_type *element =
                        bt_ctf_field_type_array_get_element_type(type);
@@ -2007,7 +2010,7 @@ int bt_ctf_field_type_get_alignment(struct bt_ctf_field_type *type)
                bt_put(element);
                break;
        }
-       case CTF_TYPE_STRUCT:
+       case BT_CTF_TYPE_ID_STRUCT:
        {
                int i, element_count;
 
@@ -2043,7 +2046,7 @@ int bt_ctf_field_type_get_alignment(struct bt_ctf_field_type *type)
                ret = (int) type->declaration->alignment;
                break;
        }
-       case CTF_TYPE_UNKNOWN:
+       case BT_CTF_TYPE_ID_UNKNOWN:
                ret = -1;
                break;
        default:
@@ -2064,7 +2067,7 @@ int bt_ctf_field_type_set_alignment(struct bt_ctf_field_type *type,
                unsigned int alignment)
 {
        int ret = 0;
-       enum ctf_type_id type_id;
+       enum bt_ctf_type_id type_id;
 
        /* Alignment must be a power of two */
        if (!type || type->frozen || !is_power_of_two(alignment)) {
@@ -2073,19 +2076,20 @@ int bt_ctf_field_type_set_alignment(struct bt_ctf_field_type *type,
        }
 
        type_id = bt_ctf_field_type_get_type_id(type);
-       if (type_id == CTF_TYPE_UNKNOWN) {
+       if (type_id == BT_CTF_TYPE_ID_UNKNOWN) {
                ret = -1;
                goto end;
        }
 
-       if (type->declaration->id == CTF_TYPE_STRING &&
+       if (type->declaration->id == BT_CTF_TYPE_ID_STRING &&
                alignment != CHAR_BIT) {
                ret = -1;
                goto end;
        }
 
-       if (type_id == CTF_TYPE_VARIANT || type_id == CTF_TYPE_SEQUENCE ||
-               type_id == CTF_TYPE_ARRAY) {
+       if (type_id == BT_CTF_TYPE_ID_VARIANT ||
+               type_id == BT_CTF_TYPE_ID_SEQUENCE ||
+               type_id == BT_CTF_TYPE_ID_ARRAY) {
                /* Setting an alignment on these types makes no sense */
                ret = -1;
                goto end;
@@ -2107,14 +2111,14 @@ enum bt_ctf_byte_order bt_ctf_field_type_get_byte_order(
        }
 
        switch (type->declaration->id) {
-       case CTF_TYPE_INTEGER:
+       case BT_CTF_TYPE_ID_INTEGER:
        {
                struct bt_ctf_field_type_integer *integer = container_of(
                        type, struct bt_ctf_field_type_integer, parent);
                ret = integer->user_byte_order;
                break;
        }
-       case CTF_TYPE_FLOAT:
+       case BT_CTF_TYPE_ID_FLOAT:
        {
                struct bt_ctf_field_type_floating_point *floating_point =
                        container_of(type,
@@ -2141,7 +2145,7 @@ int bt_ctf_field_type_set_byte_order(struct bt_ctf_field_type *type,
 {
        int ret = 0;
        int internal_byte_order;
-       enum ctf_type_id type_id;
+       enum bt_ctf_type_id type_id;
 
        if (!type || type->frozen) {
                ret = -1;
@@ -2173,11 +2177,11 @@ end:
        return ret;
 }
 
-enum ctf_type_id bt_ctf_field_type_get_type_id(
+enum bt_ctf_type_id bt_ctf_field_type_get_type_id(
                struct bt_ctf_field_type *type)
 {
        if (!type) {
-               return CTF_TYPE_UNKNOWN;
+               return BT_CTF_TYPE_ID_UNKNOWN;
        }
 
        return type->declaration->id;
@@ -2185,42 +2189,42 @@ enum ctf_type_id bt_ctf_field_type_get_type_id(
 
 int bt_ctf_field_type_is_integer(struct bt_ctf_field_type *type)
 {
-       return bt_ctf_field_type_get_type_id(type) == CTF_TYPE_INTEGER;
+       return bt_ctf_field_type_get_type_id(type) == BT_CTF_TYPE_ID_INTEGER;
 }
 
 int bt_ctf_field_type_is_floating_point(struct bt_ctf_field_type *type)
 {
-       return bt_ctf_field_type_get_type_id(type) == CTF_TYPE_FLOAT;
+       return bt_ctf_field_type_get_type_id(type) == BT_CTF_TYPE_ID_FLOAT;
 }
 
 int bt_ctf_field_type_is_enumeration(struct bt_ctf_field_type *type)
 {
-       return bt_ctf_field_type_get_type_id(type) == CTF_TYPE_ENUM;
+       return bt_ctf_field_type_get_type_id(type) == BT_CTF_TYPE_ID_ENUM;
 }
 
 int bt_ctf_field_type_is_string(struct bt_ctf_field_type *type)
 {
-       return bt_ctf_field_type_get_type_id(type) == CTF_TYPE_STRING;
+       return bt_ctf_field_type_get_type_id(type) == BT_CTF_TYPE_ID_STRING;
 }
 
 int bt_ctf_field_type_is_structure(struct bt_ctf_field_type *type)
 {
-       return bt_ctf_field_type_get_type_id(type) == CTF_TYPE_STRUCT;
+       return bt_ctf_field_type_get_type_id(type) == BT_CTF_TYPE_ID_STRUCT;
 }
 
 int bt_ctf_field_type_is_array(struct bt_ctf_field_type *type)
 {
-       return bt_ctf_field_type_get_type_id(type) == CTF_TYPE_ARRAY;
+       return bt_ctf_field_type_get_type_id(type) == BT_CTF_TYPE_ID_ARRAY;
 }
 
 int bt_ctf_field_type_is_sequence(struct bt_ctf_field_type *type)
 {
-       return bt_ctf_field_type_get_type_id(type) == CTF_TYPE_SEQUENCE;
+       return bt_ctf_field_type_get_type_id(type) == BT_CTF_TYPE_ID_SEQUENCE;
 }
 
 int bt_ctf_field_type_is_variant(struct bt_ctf_field_type *type)
 {
-       return bt_ctf_field_type_get_type_id(type) == CTF_TYPE_VARIANT;
+       return bt_ctf_field_type_get_type_id(type) == BT_CTF_TYPE_ID_VARIANT;
 }
 
 void bt_ctf_field_type_get(struct bt_ctf_field_type *type)
@@ -2360,65 +2364,6 @@ end:
        return copy;
 }
 
-BT_HIDDEN
-struct bt_ctf_field_path *bt_ctf_field_path_create(void)
-{
-       struct bt_ctf_field_path *field_path = NULL;
-
-       field_path = g_new0(struct bt_ctf_field_path, 1);
-       if (!field_path) {
-               goto end;
-       }
-
-       field_path->root = CTF_NODE_UNKNOWN;
-       field_path->path_indexes = g_array_new(TRUE, FALSE, sizeof(int));
-       if (!field_path->path_indexes) {
-               bt_ctf_field_path_destroy(field_path);
-               field_path = NULL;
-       }
-end:
-       return field_path;
-}
-
-BT_HIDDEN
-void bt_ctf_field_path_clear(struct bt_ctf_field_path *field_path)
-{
-       if (field_path->path_indexes->len > 0) {
-               g_array_remove_range(field_path->path_indexes, 0,
-                       field_path->path_indexes->len);
-       }
-}
-
-BT_HIDDEN
-struct bt_ctf_field_path *bt_ctf_field_path_copy(
-               struct bt_ctf_field_path *path)
-{
-       struct bt_ctf_field_path *new_path = bt_ctf_field_path_create();
-
-       if (!new_path) {
-               goto end;
-       }
-
-       new_path->root = path->root;
-       g_array_insert_vals(new_path->path_indexes, 0,
-               path->path_indexes->data, path->path_indexes->len);
-end:
-       return new_path;
-}
-
-BT_HIDDEN
-void bt_ctf_field_path_destroy(struct bt_ctf_field_path *path)
-{
-       if (!path) {
-               return;
-       }
-
-       if (path->path_indexes) {
-               g_array_free(path->path_indexes, TRUE);
-       }
-       g_free(path);
-}
-
 BT_HIDDEN
 int bt_ctf_field_type_structure_get_field_name_index(
                struct bt_ctf_field_type *type, const char *name)
@@ -2429,7 +2374,7 @@ int bt_ctf_field_type_structure_get_field_name_index(
        struct bt_ctf_field_type_structure *structure;
 
        if (!type || !name ||
-               bt_ctf_field_type_get_type_id(type) != CTF_TYPE_STRUCT) {
+               bt_ctf_field_type_get_type_id(type) != BT_CTF_TYPE_ID_STRUCT) {
                ret = -1;
                goto end;
        }
@@ -2460,7 +2405,7 @@ int bt_ctf_field_type_structure_set_field_index(struct bt_ctf_field_type *type,
        struct bt_ctf_field_type_structure *structure;
 
        if (!type || !field ||
-               bt_ctf_field_type_get_type_id(type) != CTF_TYPE_STRUCT) {
+               bt_ctf_field_type_get_type_id(type) != BT_CTF_TYPE_ID_STRUCT) {
                ret = -1;
                goto end;
        }
@@ -2491,7 +2436,7 @@ int bt_ctf_field_type_variant_get_field_name_index(
        struct bt_ctf_field_type_variant *variant;
 
        if (!type || !name ||
-               bt_ctf_field_type_get_type_id(type) != CTF_TYPE_VARIANT) {
+               bt_ctf_field_type_get_type_id(type) != BT_CTF_TYPE_ID_VARIANT) {
                ret = -1;
                goto end;
        }
@@ -2522,33 +2467,20 @@ int bt_ctf_field_type_sequence_set_length_field_path(
        int ret = 0;
        struct bt_ctf_field_type_sequence *sequence;
 
-       if (!type || bt_ctf_field_type_get_type_id(type) != CTF_TYPE_SEQUENCE) {
+       if (!type || bt_ctf_field_type_get_type_id(type) !=
+                       BT_CTF_TYPE_ID_SEQUENCE) {
                ret = -1;
                goto end;
        }
 
        sequence = container_of(type, struct bt_ctf_field_type_sequence,
                parent);
-       if (sequence->length_field_path) {
-               bt_ctf_field_path_destroy(sequence->length_field_path);
-       }
-       sequence->length_field_path = path;
+       bt_get(path);
+       BT_MOVE(sequence->length_field_path, path);
 end:
        return ret;
 }
 
-BT_HIDDEN
-struct bt_ctf_field_path *bt_ctf_field_type_sequence_get_length_field_path(
-               struct bt_ctf_field_type *type)
-{
-       struct bt_ctf_field_type_sequence *sequence;
-
-       sequence = container_of(type, struct bt_ctf_field_type_sequence,
-               parent);
-
-       return sequence->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)
@@ -2556,42 +2488,30 @@ int bt_ctf_field_type_variant_set_tag_field_path(struct bt_ctf_field_type *type,
        int ret = 0;
        struct bt_ctf_field_type_variant *variant;
 
-       if (!type || bt_ctf_field_type_get_type_id(type) != CTF_TYPE_VARIANT) {
+       if (!type || bt_ctf_field_type_get_type_id(type) !=
+                       BT_CTF_TYPE_ID_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;
+       bt_get(path);
+       BT_MOVE(variant->tag_field_path, path);
 end:
        return ret;
 }
 
 BT_HIDDEN
-struct bt_ctf_field_path *bt_ctf_field_type_variant_get_tag_field_path(
-               struct bt_ctf_field_type *type)
-{
-       struct bt_ctf_field_type_variant *variant;
-
-       variant = container_of(type, struct bt_ctf_field_type_variant,
-               parent);
-
-       return variant->tag_path;
-}
-
-BT_HIDDEN
-int bt_ctf_field_type_variant_set_tag(struct bt_ctf_field_type *type,
+int bt_ctf_field_type_variant_set_tag_field_type(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 ||
-                       bt_ctf_field_type_get_type_id(tag) != CTF_TYPE_ENUM) {
+                       bt_ctf_field_type_get_type_id(tag) !=
+                       BT_CTF_TYPE_ID_ENUM) {
                ret = -1;
                goto end;
        }
@@ -2616,7 +2536,7 @@ int bt_ctf_field_type_variant_set_field_index(struct bt_ctf_field_type *type,
        struct bt_ctf_field_type_variant *variant;
 
        if (!type || !field ||
-               bt_ctf_field_type_get_type_id(type) != CTF_TYPE_VARIANT) {
+               bt_ctf_field_type_get_type_id(type) != BT_CTF_TYPE_ID_VARIANT) {
                ret = -1;
                goto end;
        }
@@ -2708,7 +2628,7 @@ void bt_ctf_field_type_variant_destroy(struct bt_ctf_field_type *type)
        g_hash_table_destroy(variant->field_name_to_index);
        g_string_free(variant->tag_name, TRUE);
        bt_put(&variant->tag->parent);
-       bt_ctf_field_path_destroy(variant->tag_path);
+       BT_PUT(variant->tag_field_path);
        g_free(variant);
 }
 
@@ -2738,7 +2658,7 @@ void bt_ctf_field_type_sequence_destroy(struct bt_ctf_field_type *type)
 
        bt_put(sequence->element_type);
        g_string_free(sequence->length_field_name, TRUE);
-       bt_ctf_field_path_destroy(sequence->length_field_path);
+       BT_PUT(sequence->length_field_path);
        g_free(sequence);
 }
 
@@ -2826,18 +2746,18 @@ void bt_ctf_field_type_sequence_freeze(struct bt_ctf_field_type *type)
 }
 
 static
-const char *get_encoding_string(enum ctf_string_encoding encoding)
+const char *get_encoding_string(enum bt_ctf_string_encoding encoding)
 {
        const char *encoding_string;
 
        switch (encoding) {
-       case CTF_STRING_NONE:
+       case BT_CTF_STRING_ENCODING_NONE:
                encoding_string = "none";
                break;
-       case CTF_STRING_ASCII:
+       case BT_CTF_STRING_ENCODING_ASCII:
                encoding_string = "ASCII";
                break;
-       case CTF_STRING_UTF8:
+       case BT_CTF_STRING_ENCODING_UTF8:
                encoding_string = "UTF8";
                break;
        default:
@@ -3562,10 +3482,10 @@ 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) {
+       if (variant->tag_field_path) {
+               copy_variant->tag_field_path = bt_ctf_field_path_copy(
+                       variant->tag_field_path);
+               if (!copy_variant->tag_field_path) {
                        goto error;
                }
        }
@@ -3918,8 +3838,6 @@ int bt_ctf_field_type_structure_compare(struct bt_ctf_field_type *type_a,
                if (ret) {
                        goto end;
                }
-
-               ret = 1;
        }
 
        /* Equal */
@@ -3973,8 +3891,6 @@ int bt_ctf_field_type_variant_compare(struct bt_ctf_field_type *type_a,
                if (ret) {
                        goto end;
                }
-
-               ret = 1;
        }
 
        /* Equal */
@@ -4058,7 +3974,7 @@ int bt_ctf_field_type_compare(struct bt_ctf_field_type *type_a,
                goto end;
        }
 
-       if (type_a->declaration->id == CTF_TYPE_UNKNOWN) {
+       if (type_a->declaration->id == BT_CTF_TYPE_ID_UNKNOWN) {
                /* Both have unknown type IDs */
                goto end;
        }
@@ -4068,3 +3984,119 @@ int bt_ctf_field_type_compare(struct bt_ctf_field_type *type_a,
 end:
        return ret;
 }
+
+BT_HIDDEN
+int bt_ctf_field_type_get_field_count(struct bt_ctf_field_type *field_type)
+{
+       int field_count = -1;
+       enum ctf_type_id type_id = bt_ctf_field_type_get_type_id(field_type);
+
+       switch (type_id) {
+       case CTF_TYPE_STRUCT:
+               field_count =
+                       bt_ctf_field_type_structure_get_field_count(field_type);
+               break;
+       case CTF_TYPE_VARIANT:
+               field_count =
+                       bt_ctf_field_type_variant_get_field_count(field_type);
+               break;
+       case CTF_TYPE_ARRAY:
+       case CTF_TYPE_SEQUENCE:
+               /*
+                * Array and sequence types always contain a single member
+                * (the element type).
+                */
+               field_count = 1;
+               break;
+       default:
+               break;
+       }
+
+       return field_count;
+}
+
+BT_HIDDEN
+struct bt_ctf_field_type *bt_ctf_field_type_get_field_at_index(
+               struct bt_ctf_field_type *field_type, int index)
+{
+       struct bt_ctf_field_type *field = NULL;
+       enum ctf_type_id type_id = bt_ctf_field_type_get_type_id(field_type);
+
+       switch (type_id) {
+       case CTF_TYPE_STRUCT:
+               bt_ctf_field_type_structure_get_field(field_type, NULL, &field,
+                       index);
+               break;
+       case CTF_TYPE_VARIANT:
+               bt_ctf_field_type_variant_get_field(field_type, NULL,
+                       &field, index);
+               break;
+       case CTF_TYPE_ARRAY:
+               field = bt_ctf_field_type_array_get_element_type(field_type);
+               break;
+       case CTF_TYPE_SEQUENCE:
+               field = bt_ctf_field_type_sequence_get_element_type(field_type);
+               break;
+       default:
+               break;
+       }
+
+       return field;
+}
+
+BT_HIDDEN
+int bt_ctf_field_type_get_field_index(struct bt_ctf_field_type *field_type,
+               const char *name)
+{
+       int field_index = -1;
+       enum ctf_type_id type_id = bt_ctf_field_type_get_type_id(field_type);
+
+       switch (type_id) {
+       case CTF_TYPE_STRUCT:
+               field_index = bt_ctf_field_type_structure_get_field_name_index(
+                       field_type, name);
+               break;
+       case CTF_TYPE_VARIANT:
+               field_index = bt_ctf_field_type_variant_get_field_name_index(
+                       field_type, name);
+               break;
+       default:
+               break;
+       }
+
+       return field_index;
+}
+
+struct bt_ctf_field_path *bt_ctf_field_type_variant_get_tag_field_path(
+               struct bt_ctf_field_type *type)
+{
+       struct bt_ctf_field_path *field_path = NULL;
+       struct bt_ctf_field_type_variant *variant;
+
+       if (!type || !bt_ctf_field_type_is_variant(type)) {
+               goto end;
+       }
+
+       variant = container_of(type, struct bt_ctf_field_type_variant,
+                       parent);
+       field_path = bt_get(variant->tag_field_path);
+end:
+       return field_path;
+}
+
+struct bt_ctf_field_path *bt_ctf_field_type_sequence_get_length_field_path(
+               struct bt_ctf_field_type *type)
+{
+       struct bt_ctf_field_path *field_path = NULL;
+       struct bt_ctf_field_type_sequence *sequence;
+
+       if (!type || !bt_ctf_field_type_is_sequence(type)) {
+               goto end;
+       }
+
+       sequence = container_of(type, struct bt_ctf_field_type_sequence,
+                       parent);
+       field_path = bt_get(sequence->length_field_path);
+end:
+       return field_path;
+}
This page took 0.044718 seconds and 4 git commands to generate.