lib: merge common CTF IR part with the remaining implementation
[babeltrace.git] / lib / ctf-ir / field-types.c
index 084dc74d1f908a975bb1520fab598932cd318640..5de2978f814c9b93ad66672a2421c51d6572b38f 100644 (file)
@@ -79,76 +79,183 @@ struct bt_field_type *bt_field_type_sequence_copy_recursive(
 static
 struct bt_field_type *bt_field_type_string_copy(struct bt_field_type *ft);
 
-static struct bt_field_type_common_methods bt_field_type_integer_methods = {
-       .freeze = bt_field_type_common_generic_freeze,
-       .validate = bt_field_type_common_integer_validate,
-       .set_byte_order = bt_field_type_common_integer_set_byte_order,
-       .copy = (bt_field_type_common_method_copy)
+static
+int bt_field_type_integer_validate(struct bt_field_type *ft);
+
+static
+int bt_field_type_enumeration_validate_recursive(
+               struct bt_field_type *ft);
+static
+int bt_field_type_sequence_validate_recursive(
+               struct bt_field_type *ft);
+static
+int bt_field_type_array_validate_recursive(
+               struct bt_field_type *ft);
+static
+int bt_field_type_structure_validate_recursive(
+               struct bt_field_type *ft);
+static
+int bt_field_type_variant_validate_recursive(
+               struct bt_field_type *ft);
+
+static
+void bt_field_type_generic_freeze(struct bt_field_type *ft);
+
+static
+void bt_field_type_enumeration_freeze_recursive(
+               struct bt_field_type *ft);
+static
+void bt_field_type_structure_freeze_recursive(
+               struct bt_field_type *ft);
+static
+void bt_field_type_variant_freeze_recursive(
+               struct bt_field_type *ft);
+static
+void bt_field_type_array_freeze_recursive(
+               struct bt_field_type *ft);
+static
+void bt_field_type_sequence_freeze_recursive(
+               struct bt_field_type *ft);
+
+static
+void bt_field_type_integer_set_byte_order(
+               struct bt_field_type *ft, enum bt_byte_order byte_order);
+
+static
+void bt_field_type_enumeration_set_byte_order_recursive(
+               struct bt_field_type *ft, enum bt_byte_order byte_order);
+
+static
+void bt_field_type_floating_point_set_byte_order(
+               struct bt_field_type *ft, enum bt_byte_order byte_order);
+
+static
+void bt_field_type_structure_set_byte_order_recursive(
+               struct bt_field_type *ft,
+               enum bt_byte_order byte_order);
+static
+void bt_field_type_variant_set_byte_order_recursive(
+               struct bt_field_type *ft,
+               enum bt_byte_order byte_order);
+
+static
+void bt_field_type_array_set_byte_order_recursive(
+               struct bt_field_type *ft,
+               enum bt_byte_order byte_order);
+
+static
+void bt_field_type_sequence_set_byte_order_recursive(
+               struct bt_field_type *ft,
+               enum bt_byte_order byte_order);
+
+static
+int bt_field_type_integer_compare(struct bt_field_type *ft_a,
+               struct bt_field_type *ft_b);
+
+static
+int bt_field_type_floating_point_compare(
+               struct bt_field_type *ft_a,
+               struct bt_field_type *ft_b);
+
+static
+int bt_field_type_enumeration_compare_recursive(
+               struct bt_field_type *ft_a,
+               struct bt_field_type *ft_b);
+
+static
+int bt_field_type_string_compare(struct bt_field_type *ft_a,
+               struct bt_field_type *ft_b);
+
+static
+int bt_field_type_structure_compare_recursive(
+               struct bt_field_type *ft_a,
+               struct bt_field_type *ft_b);
+
+static
+int bt_field_type_variant_compare_recursive(
+               struct bt_field_type *ft_a,
+               struct bt_field_type *ft_b);
+
+static
+int bt_field_type_array_compare_recursive(
+               struct bt_field_type *ft_a,
+               struct bt_field_type *ft_b);
+
+static
+int bt_field_type_sequence_compare_recursive(
+               struct bt_field_type *ft_a,
+               struct bt_field_type *ft_b);
+
+static struct bt_field_type_methods bt_field_type_integer_methods = {
+       .freeze = bt_field_type_generic_freeze,
+       .validate = bt_field_type_integer_validate,
+       .set_byte_order = bt_field_type_integer_set_byte_order,
+       .copy = (bt_field_type_method_copy)
                bt_field_type_integer_copy,
-       .compare = bt_field_type_common_integer_compare,
+       .compare = bt_field_type_integer_compare,
 };
 
-static struct bt_field_type_common_methods bt_field_type_floating_point_methods = {
-       .freeze = bt_field_type_common_generic_freeze,
+static struct bt_field_type_methods bt_field_type_floating_point_methods = {
+       .freeze = bt_field_type_generic_freeze,
        .validate = NULL,
-       .set_byte_order = bt_field_type_common_floating_point_set_byte_order,
-       .copy = (bt_field_type_common_method_copy)
+       .set_byte_order = bt_field_type_floating_point_set_byte_order,
+       .copy = (bt_field_type_method_copy)
                bt_field_type_floating_point_copy,
-       .compare = bt_field_type_common_floating_point_compare,
+       .compare = bt_field_type_floating_point_compare,
 };
 
-static struct bt_field_type_common_methods bt_field_type_enumeration_methods = {
-       .freeze = bt_field_type_common_enumeration_freeze_recursive,
-       .validate = bt_field_type_common_enumeration_validate_recursive,
-       .set_byte_order = bt_field_type_common_enumeration_set_byte_order_recursive,
-       .copy = (bt_field_type_common_method_copy)
+static struct bt_field_type_methods bt_field_type_enumeration_methods = {
+       .freeze = bt_field_type_enumeration_freeze_recursive,
+       .validate = bt_field_type_enumeration_validate_recursive,
+       .set_byte_order = bt_field_type_enumeration_set_byte_order_recursive,
+       .copy = (bt_field_type_method_copy)
                bt_field_type_enumeration_copy_recursive,
-       .compare = bt_field_type_common_enumeration_compare_recursive,
+       .compare = bt_field_type_enumeration_compare_recursive,
 };
 
-static struct bt_field_type_common_methods bt_field_type_string_methods = {
-       .freeze = bt_field_type_common_generic_freeze,
+static struct bt_field_type_methods bt_field_type_string_methods = {
+       .freeze = bt_field_type_generic_freeze,
        .validate = NULL,
        .set_byte_order = NULL,
-       .copy = (bt_field_type_common_method_copy)
+       .copy = (bt_field_type_method_copy)
                bt_field_type_string_copy,
-       .compare = bt_field_type_common_string_compare,
+       .compare = bt_field_type_string_compare,
 };
 
-static struct bt_field_type_common_methods bt_field_type_array_methods = {
-       .freeze = bt_field_type_common_array_freeze_recursive,
-       .validate = bt_field_type_common_array_validate_recursive,
-       .set_byte_order = bt_field_type_common_array_set_byte_order_recursive,
-       .copy = (bt_field_type_common_method_copy)
+static struct bt_field_type_methods bt_field_type_array_methods = {
+       .freeze = bt_field_type_array_freeze_recursive,
+       .validate = bt_field_type_array_validate_recursive,
+       .set_byte_order = bt_field_type_array_set_byte_order_recursive,
+       .copy = (bt_field_type_method_copy)
                bt_field_type_array_copy_recursive,
-       .compare = bt_field_type_common_array_compare_recursive,
+       .compare = bt_field_type_array_compare_recursive,
 };
 
-static struct bt_field_type_common_methods bt_field_type_sequence_methods = {
-       .freeze = bt_field_type_common_sequence_freeze_recursive,
-       .validate = bt_field_type_common_sequence_validate_recursive,
-       .set_byte_order = bt_field_type_common_sequence_set_byte_order_recursive,
-       .copy = (bt_field_type_common_method_copy)
+static struct bt_field_type_methods bt_field_type_sequence_methods = {
+       .freeze = bt_field_type_sequence_freeze_recursive,
+       .validate = bt_field_type_sequence_validate_recursive,
+       .set_byte_order = bt_field_type_sequence_set_byte_order_recursive,
+       .copy = (bt_field_type_method_copy)
                bt_field_type_sequence_copy_recursive,
-       .compare = bt_field_type_common_sequence_compare_recursive,
+       .compare = bt_field_type_sequence_compare_recursive,
 };
 
-static struct bt_field_type_common_methods bt_field_type_structure_methods = {
-       .freeze = bt_field_type_common_structure_freeze_recursive,
-       .validate = bt_field_type_common_structure_validate_recursive,
-       .set_byte_order = bt_field_type_common_structure_set_byte_order_recursive,
-       .copy = (bt_field_type_common_method_copy)
+static struct bt_field_type_methods bt_field_type_structure_methods = {
+       .freeze = bt_field_type_structure_freeze_recursive,
+       .validate = bt_field_type_structure_validate_recursive,
+       .set_byte_order = bt_field_type_structure_set_byte_order_recursive,
+       .copy = (bt_field_type_method_copy)
                bt_field_type_structure_copy_recursive,
-       .compare = bt_field_type_common_structure_compare_recursive,
+       .compare = bt_field_type_structure_compare_recursive,
 };
 
-static struct bt_field_type_common_methods bt_field_type_variant_methods = {
-       .freeze = bt_field_type_common_variant_freeze_recursive,
-       .validate = bt_field_type_common_variant_validate_recursive,
-       .set_byte_order = bt_field_type_common_variant_set_byte_order_recursive,
-       .copy = (bt_field_type_common_method_copy)
+static struct bt_field_type_methods bt_field_type_variant_methods = {
+       .freeze = bt_field_type_variant_freeze_recursive,
+       .validate = bt_field_type_variant_validate_recursive,
+       .set_byte_order = bt_field_type_variant_set_byte_order_recursive,
+       .copy = (bt_field_type_method_copy)
                bt_field_type_variant_copy_recursive,
-       .compare = bt_field_type_common_variant_compare_recursive,
+       .compare = bt_field_type_variant_compare_recursive,
 };
 
 static
@@ -158,29 +265,14 @@ void destroy_enumeration_mapping(struct enumeration_mapping *mapping)
 }
 
 static
-void destroy_structure_field_common(struct structure_field_common *field)
-{
-       if (!field) {
-               return;
-       }
-
-       BT_LOGD("Destroying structure/variant field type's field object: "
-               "addr=%p, field-ft-addr=%p, field-name=\"%s\"",
-               field, field->type, g_quark_to_string(field->name));
-       BT_LOGD_STR("Putting field type.");
-       bt_put(field->type);
-       g_free(field);
-}
-
-BT_HIDDEN
-void bt_field_type_common_initialize(struct bt_field_type_common *ft,
+void bt_field_type_initialize(struct bt_field_type *ft,
                bool init_bo, bt_object_release_func release_func,
-               struct bt_field_type_common_methods *methods)
+               struct bt_field_type_methods *methods)
 {
        BT_ASSERT(ft && (ft->id > BT_FIELD_TYPE_ID_UNKNOWN) &&
                (ft->id < BT_FIELD_TYPE_ID_NR));
 
-       bt_object_init(ft, release_func);
+       bt_object_init_shared(&ft->base, release_func);
        ft->methods = methods;
 
        if (init_bo) {
@@ -189,186 +281,186 @@ void bt_field_type_common_initialize(struct bt_field_type_common *ft,
 
                BT_LOGD("Setting initial field type's byte order: bo=%s",
                        bt_common_byte_order_string(bo));
-               ret = bt_field_type_common_set_byte_order(ft, bo);
+               ret = bt_field_type_set_byte_order(ft, bo);
                BT_ASSERT(ret == 0);
        }
 
        ft->alignment = 1;
 }
 
-BT_HIDDEN
-void bt_field_type_common_integer_initialize(
-               struct bt_field_type_common *ft,
+static
+void bt_field_type_integer_initialize(
+               struct bt_field_type *ft,
                unsigned int size, bt_object_release_func release_func,
-               struct bt_field_type_common_methods *methods)
+               struct bt_field_type_methods *methods)
 {
-       struct bt_field_type_common_integer *int_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_integer *int_ft = (void *) ft;
 
        BT_ASSERT(size > 0);
-       BT_LOGD("Initializing common integer field type object: size=%u",
+       BT_LOGD("Initializing integer field type object: size=%u",
                size);
        ft->id = BT_FIELD_TYPE_ID_INTEGER;
        int_ft->size = size;
        int_ft->base = BT_INTEGER_BASE_DECIMAL;
        int_ft->encoding = BT_STRING_ENCODING_NONE;
-       bt_field_type_common_initialize(ft, true, release_func, methods);
-       BT_LOGD("Initialized common integer field type object: addr=%p, size=%u",
+       bt_field_type_initialize(ft, true, release_func, methods);
+       BT_LOGD("Initialized integer field type object: addr=%p, size=%u",
                ft, size);
 }
 
-BT_HIDDEN
-void bt_field_type_common_floating_point_initialize(
-               struct bt_field_type_common *ft,
+static
+void bt_field_type_floating_point_initialize(
+               struct bt_field_type *ft,
                bt_object_release_func release_func,
-               struct bt_field_type_common_methods *methods)
+               struct bt_field_type_methods *methods)
 {
-       struct bt_field_type_common_floating_point *flt_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_floating_point *flt_ft = (void *) ft;
 
-       BT_LOGD_STR("Initializing common floating point number field type object.");
+       BT_LOGD_STR("Initializing floating point number field type object.");
        ft->id = BT_FIELD_TYPE_ID_FLOAT;
        flt_ft->exp_dig = sizeof(float) * CHAR_BIT - FLT_MANT_DIG;
        flt_ft->mant_dig = FLT_MANT_DIG;
-       bt_field_type_common_initialize(ft, true, release_func, methods);
-       BT_LOGD("Initialized common floating point number field type object: addr=%p, "
+       bt_field_type_initialize(ft, true, release_func, methods);
+       BT_LOGD("Initialized floating point number field type object: addr=%p, "
                "exp-size=%u, mant-size=%u", ft, flt_ft->exp_dig,
                flt_ft->mant_dig);
 }
 
-BT_HIDDEN
-void bt_field_type_common_enumeration_initialize(
-               struct bt_field_type_common *ft,
-               struct bt_field_type_common *container_ft,
+static
+void bt_field_type_enumeration_initialize(
+               struct bt_field_type *ft,
+               struct bt_field_type *container_ft,
                bt_object_release_func release_func,
-               struct bt_field_type_common_methods *methods)
+               struct bt_field_type_methods *methods)
 {
-       struct bt_field_type_common_enumeration *enum_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_enumeration *enum_ft = (void *) ft;
 
        BT_ASSERT(container_ft);
-       BT_LOGD("Initializing common enumeration field type object: int-ft-addr=%p",
+       BT_LOGD("Initializing enumeration field type object: int-ft-addr=%p",
                container_ft);
        ft->id = BT_FIELD_TYPE_ID_ENUM;
        enum_ft->container_ft = bt_get(container_ft);
        enum_ft->entries = g_ptr_array_new_with_free_func(
                (GDestroyNotify) destroy_enumeration_mapping);
-       bt_field_type_common_initialize(ft, false, release_func, methods);
-       BT_LOGD("Initialized common enumeration field type object: addr=%p, "
+       bt_field_type_initialize(ft, false, release_func, methods);
+       BT_LOGD("Initialized enumeration field type object: addr=%p, "
                "int-ft-addr=%p, int-ft-size=%u", ft, container_ft,
-               bt_field_type_common_integer_get_size(container_ft));
+               bt_field_type_integer_get_size(container_ft));
 }
 
-BT_HIDDEN
-void bt_field_type_common_string_initialize(
-               struct bt_field_type_common *ft,
+static
+void bt_field_type_string_initialize(
+               struct bt_field_type *ft,
                bt_object_release_func release_func,
-               struct bt_field_type_common_methods *methods)
+               struct bt_field_type_methods *methods)
 {
-       struct bt_field_type_common_string *string_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_string *string_ft = (void *) ft;
 
-       BT_LOGD_STR("Initializing common string field type object.");
+       BT_LOGD_STR("Initializing string field type object.");
        ft->id = BT_FIELD_TYPE_ID_STRING;
-       bt_field_type_common_initialize(ft, true, release_func, methods);
+       bt_field_type_initialize(ft, true, release_func, methods);
        string_ft->encoding = BT_STRING_ENCODING_UTF8;
        ft->alignment = CHAR_BIT;
-       BT_LOGD("Initialized common string field type object: addr=%p", ft);
+       BT_LOGD("Initialized string field type object: addr=%p", ft);
 }
 
-BT_HIDDEN
-void bt_field_type_common_structure_initialize(
-               struct bt_field_type_common *ft,
+static
+void bt_field_type_structure_initialize(
+               struct bt_field_type *ft,
                bt_object_release_func release_func,
-               struct bt_field_type_common_methods *methods)
+               struct bt_field_type_methods *methods)
 {
-       struct bt_field_type_common_structure *struct_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_structure *struct_ft = (void *) ft;
 
-       BT_LOGD_STR("Initializing common structure field type object.");
+       BT_LOGD_STR("Initializing structure field type object.");
        ft->id = BT_FIELD_TYPE_ID_STRUCT;
-       struct_ft->fields = g_ptr_array_new_with_free_func(
-               (GDestroyNotify) destroy_structure_field_common);
+       struct_ft->fields = g_array_new(FALSE, TRUE,
+               sizeof(struct bt_field_type_structure_field));
        struct_ft->field_name_to_index = g_hash_table_new(NULL, NULL);
-       bt_field_type_common_initialize(ft, true, release_func, methods);
-       BT_LOGD("Initialized common structure field type object: addr=%p", ft);
+       bt_field_type_initialize(ft, true, release_func, methods);
+       BT_LOGD("Initialized structure field type object: addr=%p", ft);
 }
 
-BT_HIDDEN
-void bt_field_type_common_array_initialize(
-               struct bt_field_type_common *ft,
-               struct bt_field_type_common *element_ft,
+static
+void bt_field_type_array_initialize(
+               struct bt_field_type *ft,
+               struct bt_field_type *element_ft,
                unsigned int length, bt_object_release_func release_func,
-               struct bt_field_type_common_methods *methods)
+               struct bt_field_type_methods *methods)
 {
-       struct bt_field_type_common_array *array_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_array *array_ft = (void *) ft;
 
        BT_ASSERT(element_ft);
-       BT_LOGD("Initializing common array field type object: element-ft-addr=%p, "
+       BT_LOGD("Initializing array field type object: element-ft-addr=%p, "
                "length=%u", element_ft, length);
        ft->id = BT_FIELD_TYPE_ID_ARRAY;
        array_ft->element_ft = bt_get(element_ft);
        array_ft->length = length;
-       bt_field_type_common_initialize(ft, false, release_func, methods);
-       BT_LOGD("Initialized common array field type object: addr=%p, "
+       bt_field_type_initialize(ft, false, release_func, methods);
+       BT_LOGD("Initialized array field type object: addr=%p, "
                "element-ft-addr=%p, length=%u", ft, element_ft, length);
 }
 
-BT_HIDDEN
-void bt_field_type_common_sequence_initialize(
-               struct bt_field_type_common *ft,
-               struct bt_field_type_common *element_ft,
+static
+void bt_field_type_sequence_initialize(
+               struct bt_field_type *ft,
+               struct bt_field_type *element_ft,
                const char *length_field_name,
                bt_object_release_func release_func,
-               struct bt_field_type_common_methods *methods)
+               struct bt_field_type_methods *methods)
 {
-       struct bt_field_type_common_sequence *seq_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_sequence *seq_ft = (void *) ft;
 
        BT_ASSERT(element_ft);
        BT_ASSERT(length_field_name);
        BT_ASSERT(bt_identifier_is_valid(length_field_name));
-       BT_LOGD("Initializing common sequence field type object: element-ft-addr=%p, "
+       BT_LOGD("Initializing sequence field type object: element-ft-addr=%p, "
                "length-field-name=\"%s\"", element_ft, length_field_name);
        ft->id = BT_FIELD_TYPE_ID_SEQUENCE;
        seq_ft->element_ft = bt_get(element_ft);
        seq_ft->length_field_name = g_string_new(length_field_name);
-       bt_field_type_common_initialize(ft, false, release_func, methods);
-       BT_LOGD("Initialized common sequence field type object: addr=%p, "
+       bt_field_type_initialize(ft, false, release_func, methods);
+       BT_LOGD("Initialized sequence field type object: addr=%p, "
                "element-ft-addr=%p, length-field-name=\"%s\"",
                ft, element_ft, length_field_name);
 }
 
-BT_HIDDEN
-void bt_field_type_common_variant_initialize(
-               struct bt_field_type_common *ft,
-               struct bt_field_type_common *tag_ft,
+static
+void bt_field_type_variant_initialize(
+               struct bt_field_type *ft,
+               struct bt_field_type *tag_ft,
                const char *tag_name,
                bt_object_release_func release_func,
-               struct bt_field_type_common_methods *methods)
+               struct bt_field_type_methods *methods)
 {
-       struct bt_field_type_common_variant *var_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_variant *var_ft = (void *) ft;
 
        BT_ASSERT(!tag_name || bt_identifier_is_valid(tag_name));
-       BT_LOGD("Initializing common variant field type object: "
+       BT_LOGD("Initializing variant field type object: "
                "tag-ft-addr=%p, tag-field-name=\"%s\"",
                tag_ft, tag_name);
        ft->id = BT_FIELD_TYPE_ID_VARIANT;
        var_ft->tag_name = g_string_new(tag_name);
-       var_ft->field_name_to_index = g_hash_table_new(NULL, NULL);
-       var_ft->fields = g_ptr_array_new_with_free_func(
-               (GDestroyNotify) destroy_structure_field_common);
+       var_ft->choice_name_to_index = g_hash_table_new(NULL, NULL);
+       var_ft->choices = g_array_new(FALSE, TRUE,
+               sizeof(struct bt_field_type_variant_choice));
 
        if (tag_ft) {
                var_ft->tag_ft = bt_get(tag_ft);
        }
 
-       bt_field_type_common_initialize(ft, true, release_func, methods);
+       bt_field_type_initialize(ft, true, release_func, methods);
        /* A variant's alignment is undefined */
        ft->alignment = 0;
-       BT_LOGD("Initialized common variant field type object: addr=%p, "
+       BT_LOGD("Initialized variant field type object: addr=%p, "
                "tag-ft-addr=%p, tag-field-name=\"%s\"",
                ft, tag_ft, tag_name);
 }
 
-BT_HIDDEN
-void bt_field_type_common_integer_destroy(struct bt_object *obj)
+static
+void bt_field_type_integer_destroy(struct bt_object *obj)
 {
-       struct bt_field_type_common_integer *ft = (void *) obj;
+       struct bt_field_type_integer *ft = (void *) obj;
 
        if (!ft) {
                return;
@@ -380,10 +472,10 @@ void bt_field_type_common_integer_destroy(struct bt_object *obj)
        g_free(ft);
 }
 
-BT_HIDDEN
-void bt_field_type_common_floating_point_destroy(struct bt_object *obj)
+static
+void bt_field_type_floating_point_destroy(struct bt_object *obj)
 {
-       struct bt_field_type_common_floating_point *ft = (void *) obj;
+       struct bt_field_type_floating_point *ft = (void *) obj;
 
        if (!ft) {
                return;
@@ -393,10 +485,10 @@ void bt_field_type_common_floating_point_destroy(struct bt_object *obj)
        g_free(ft);
 }
 
-BT_HIDDEN
-void bt_field_type_common_enumeration_destroy_recursive(struct bt_object *obj)
+static
+void bt_field_type_enumeration_destroy_recursive(struct bt_object *obj)
 {
-       struct bt_field_type_common_enumeration *ft = (void *) obj;
+       struct bt_field_type_enumeration *ft = (void *) obj;
 
        if (!ft) {
                return;
@@ -409,10 +501,10 @@ void bt_field_type_common_enumeration_destroy_recursive(struct bt_object *obj)
        g_free(ft);
 }
 
-BT_HIDDEN
-void bt_field_type_common_string_destroy(struct bt_object *obj)
+static
+void bt_field_type_string_destroy(struct bt_object *obj)
 {
-       struct bt_field_type_common_string *ft = (void *) obj;
+       struct bt_field_type_string *ft = (void *) obj;
 
        if (!ft) {
                return;
@@ -422,26 +514,54 @@ void bt_field_type_common_string_destroy(struct bt_object *obj)
        g_free(ft);
 }
 
+static
+void bt_field_type_structure_field_finalize(
+               struct bt_field_type_structure_field *field)
+{
+       if (!field) {
+               return;
+       }
 
-BT_HIDDEN
-void bt_field_type_common_structure_destroy_recursive(struct bt_object *obj)
+       BT_LOGD("Finalizing structure field type's field: "
+               "addr=%p, field-ft-addr=%p, field-name=\"%s\"",
+               field, field->type, g_quark_to_string(field->name));
+       BT_LOGD_STR("Putting field type.");
+       bt_put(field->type);
+}
+
+static
+void bt_field_type_structure_destroy_recursive(struct bt_object *obj)
 {
-       struct bt_field_type_common_structure *ft = (void *) obj;
+       struct bt_field_type_structure *ft = (void *) obj;
+       uint64_t i;
 
        if (!ft) {
                return;
        }
 
        BT_LOGD("Destroying structure field type object: addr=%p", ft);
-       g_ptr_array_free(ft->fields, TRUE);
-       g_hash_table_destroy(ft->field_name_to_index);
+
+       if (ft->fields) {
+               for (i = 0; i < ft->fields->len; i++) {
+                       bt_field_type_structure_field_finalize(
+                               BT_FIELD_TYPE_STRUCTURE_FIELD_AT_INDEX(
+                                       ft, i));
+               }
+
+               g_array_free(ft->fields, TRUE);
+       }
+
+       if (ft->field_name_to_index) {
+               g_hash_table_destroy(ft->field_name_to_index);
+       }
+
        g_free(ft);
 }
 
-BT_HIDDEN
-void bt_field_type_common_array_destroy_recursive(struct bt_object *obj)
+static
+void bt_field_type_array_destroy_recursive(struct bt_object *obj)
 {
-       struct bt_field_type_common_array *ft = (void *) obj;
+       struct bt_field_type_array *ft = (void *) obj;
 
        if (!ft) {
                return;
@@ -453,10 +573,10 @@ void bt_field_type_common_array_destroy_recursive(struct bt_object *obj)
        g_free(ft);
 }
 
-BT_HIDDEN
-void bt_field_type_common_sequence_destroy_recursive(struct bt_object *obj)
+static
+void bt_field_type_sequence_destroy_recursive(struct bt_object *obj)
 {
-       struct bt_field_type_common_sequence *ft = (void *) obj;
+       struct bt_field_type_sequence *ft = (void *) obj;
 
        if (!ft) {
                return;
@@ -471,19 +591,55 @@ void bt_field_type_common_sequence_destroy_recursive(struct bt_object *obj)
        g_free(ft);
 }
 
-BT_HIDDEN
-void bt_field_type_common_variant_destroy_recursive(struct bt_object *obj)
+static
+void bt_field_type_variant_choice_finalize(
+               struct bt_field_type_variant_choice *choice)
+{
+       if (!choice) {
+               return;
+       }
+
+       BT_LOGD("Finalizing variant field type's choice: "
+               "addr=%p, field-ft-addr=%p, field-name=\"%s\"",
+               choice, choice->type, g_quark_to_string(choice->name));
+       BT_LOGD_STR("Putting field type.");
+       bt_put(choice->type);
+
+       if (choice->ranges) {
+               g_array_free(choice->ranges, TRUE);
+       }
+}
+
+static
+void bt_field_type_variant_destroy_recursive(struct bt_object *obj)
 {
-       struct bt_field_type_common_variant *ft = (void *) obj;
+       struct bt_field_type_variant *ft = (void *) obj;
+       uint64_t i;
 
        if (!ft) {
                return;
        }
 
        BT_LOGD("Destroying variant field type object: addr=%p", ft);
-       g_ptr_array_free(ft->fields, TRUE);
-       g_hash_table_destroy(ft->field_name_to_index);
-       g_string_free(ft->tag_name, TRUE);
+
+       if (ft->choices) {
+               for (i = 0; i < ft->choices->len; i++) {
+                       bt_field_type_variant_choice_finalize(
+                               BT_FIELD_TYPE_VARIANT_CHOICE_AT_INDEX(
+                                       ft, i));
+               }
+
+               g_array_free(ft->choices, TRUE);
+       }
+
+       if (ft->choice_name_to_index) {
+               g_hash_table_destroy(ft->choice_name_to_index);
+       }
+
+       if (ft->tag_name) {
+               g_string_free(ft->tag_name, TRUE);
+       }
+
        BT_LOGD_STR("Putting tag field type.");
        bt_put(ft->tag_ft);
        BT_LOGD_STR("Putting tag field path.");
@@ -505,68 +661,6 @@ struct range_overlap_query {
        GQuark mapping_name;
 };
 
-static
-void check_ranges_overlap(gpointer element, gpointer query)
-{
-       struct enumeration_mapping *mapping = element;
-       struct range_overlap_query *overlap_query = query;
-
-       if (mapping->range_start._signed <= overlap_query->range_end._signed
-                       && overlap_query->range_start._signed <=
-                       mapping->range_end._signed) {
-               overlap_query->overlaps = 1;
-               overlap_query->mapping_name = mapping->string;
-       }
-
-       overlap_query->overlaps |=
-               mapping->string == overlap_query->mapping_name;
-
-       if (overlap_query->overlaps) {
-               BT_LOGV("Overlapping enumeration field type mappings: "
-                       "mapping-name=\"%s\", "
-                       "mapping-a-range-start=%" PRId64 ", "
-                       "mapping-a-range-end=%" PRId64 ", "
-                       "mapping-b-range-start=%" PRId64 ", "
-                       "mapping-b-range-end=%" PRId64,
-                       g_quark_to_string(mapping->string),
-                       mapping->range_start._signed,
-                       mapping->range_end._signed,
-                       overlap_query->range_start._signed,
-                       overlap_query->range_end._signed);
-       }
-}
-
-static
-void check_ranges_overlap_unsigned(gpointer element, gpointer query)
-{
-       struct enumeration_mapping *mapping = element;
-       struct range_overlap_query *overlap_query = query;
-
-       if (mapping->range_start._unsigned <= overlap_query->range_end._unsigned
-                       && overlap_query->range_start._unsigned <=
-                       mapping->range_end._unsigned) {
-               overlap_query->overlaps = 1;
-               overlap_query->mapping_name = mapping->string;
-       }
-
-       overlap_query->overlaps |=
-               mapping->string == overlap_query->mapping_name;
-
-       if (overlap_query->overlaps) {
-               BT_LOGW("Overlapping enumeration field type mappings: "
-                       "mapping-name=\"%s\", "
-                       "mapping-a-range-start=%" PRIu64 ", "
-                       "mapping-a-range-end=%" PRIu64 ", "
-                       "mapping-b-range-start=%" PRIu64 ", "
-                       "mapping-b-range-end=%" PRIu64,
-                       g_quark_to_string(mapping->string),
-                       mapping->range_start._unsigned,
-                       mapping->range_end._unsigned,
-                       overlap_query->range_start._unsigned,
-                       overlap_query->range_end._unsigned);
-       }
-}
-
 static
 gint compare_enumeration_mappings_signed(struct enumeration_mapping **a,
                struct enumeration_mapping **b)
@@ -582,13 +676,15 @@ gint compare_enumeration_mappings_unsigned(struct enumeration_mapping **a,
 }
 
 static
-int add_structure_field(GPtrArray *fields,
+int add_structure_variant_member(GArray *members,
                GHashTable *field_name_to_index,
-               struct bt_field_type_common *field_type, const char *field_name)
+               struct bt_field_type *field_type, const char *field_name,
+               bool is_variant)
 {
        int ret = 0;
        GQuark name_quark = g_quark_from_string(field_name);
-       struct structure_field_common *field;
+       struct bt_field_type **member_ft;
+       GQuark *member_name;
 
        /* Make sure structure does not contain a field of the same name */
        if (g_hash_table_lookup_extended(field_name_to_index,
@@ -599,30 +695,47 @@ int add_structure_field(GPtrArray *fields,
                goto end;
        }
 
-       field = g_new0(struct structure_field_common, 1);
-       if (!field) {
-               BT_LOGE_STR("Failed to allocate one structure/variant field type field.");
-               ret = -1;
-               goto end;
+       g_array_set_size(members, members->len + 1);
+
+       if (is_variant) {
+               struct bt_field_type_variant_choice *choice =
+                       &g_array_index(members,
+                               struct bt_field_type_variant_choice,
+                               members->len - 1);
+
+               member_ft = &choice->type;
+               member_name = &choice->name;
+               BT_ASSERT(!choice->ranges);
+               choice->ranges = g_array_new(FALSE, TRUE,
+                       sizeof(struct bt_field_type_variant_choice_range));
+               BT_ASSERT(choice->ranges);
+       } else {
+               struct bt_field_type_structure_field *field =
+                       &g_array_index(members,
+                               struct bt_field_type_structure_field,
+                               members->len - 1);
+
+               member_ft = &field->type;
+               member_name = &field->name;
        }
 
-       bt_get(field_type);
-       field->name = name_quark;
-       field->type = field_type;
+       *member_name = name_quark;
+       *member_ft = bt_get(field_type);
        g_hash_table_insert(field_name_to_index,
-               GUINT_TO_POINTER(name_quark), GUINT_TO_POINTER(fields->len));
-       g_ptr_array_add(fields, field);
-       BT_LOGV("Added structure/variant field type field: field-ft-addr=%p, "
-               "field-name=\"%s\"", field_type, field_name);
+               GUINT_TO_POINTER(name_quark),
+               GUINT_TO_POINTER(members->len - 1));
+       BT_LOGV("Added structure/variant field type member: member-ft-addr=%p, "
+               "member-name=\"%s\"", field_type, field_name);
+
 end:
        return ret;
 }
 
-BT_HIDDEN
-int bt_field_type_common_integer_validate(struct bt_field_type_common *ft)
+static
+int bt_field_type_integer_validate(struct bt_field_type *ft)
 {
        int ret = 0;
-       struct bt_field_type_common_integer *int_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_integer *int_ft = (void *) ft;
 
        if (int_ft->mapped_clock_class && int_ft->is_signed) {
                BT_LOGW("Invalid integer field type: cannot be signed and have a mapped clock class: "
@@ -638,10 +751,10 @@ end:
 }
 
 static
-struct enumeration_mapping *bt_field_type_common_enumeration_get_mapping_by_index(
-               struct bt_field_type_common *ft, uint64_t index)
+struct enumeration_mapping *bt_field_type_enumeration_get_mapping_by_index(
+               struct bt_field_type *ft, uint64_t index)
 {
-       struct bt_field_type_common_enumeration *enum_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_enumeration *enum_ft = (void *) ft;
        struct enumeration_mapping *mapping = NULL;
 
        if (index >= enum_ft->entries->len) {
@@ -662,8 +775,8 @@ end:
  * Only used when freezing an enumeration.
  */
 static
-void bt_field_type_common_enumeration_set_range_overlap(
-               struct bt_field_type_common_enumeration *ft)
+void bt_field_type_enumeration_set_range_overlap(
+               struct bt_field_type_enumeration *ft)
 {
        int64_t i, j, len;
        int is_signed;
@@ -671,17 +784,16 @@ void bt_field_type_common_enumeration_set_range_overlap(
        BT_LOGV("Setting enumeration field type's overlap flag: addr=%p",
                ft);
        len = ft->entries->len;
-       is_signed = bt_field_type_common_integer_is_signed(
-               BT_TO_COMMON(ft->container_ft));
+       is_signed = bt_field_type_integer_is_signed((void *) ft->container_ft);
 
        for (i = 0; i < len; i++) {
                for (j = i + 1; j < len; j++) {
                        struct enumeration_mapping *mapping[2];
 
-                       mapping[0] = bt_field_type_common_enumeration_get_mapping_by_index(
-                               BT_TO_COMMON(ft), i);
-                       mapping[1] = bt_field_type_common_enumeration_get_mapping_by_index(
-                               BT_TO_COMMON(ft), j);
+                       mapping[0] = bt_field_type_enumeration_get_mapping_by_index(
+                               (void *) ft, i);
+                       mapping[1] = bt_field_type_enumeration_get_mapping_by_index(
+                               (void *) ft, j);
                        if (is_signed) {
                                if (mapping[0]->range_start._signed
                                                        <= mapping[1]->range_end._signed
@@ -710,15 +822,14 @@ end:
        }
 }
 
-BT_HIDDEN
-int bt_field_type_common_enumeration_validate_recursive(
-               struct bt_field_type_common *ft)
+static
+int bt_field_type_enumeration_validate_recursive(
+               struct bt_field_type *ft)
 {
        int ret = 0;
-       struct bt_field_type_common_enumeration *enum_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_enumeration *enum_ft = (void *) ft;
 
-       ret = bt_field_type_common_integer_validate(
-                       BT_TO_COMMON(enum_ft->container_ft));
+       ret = bt_field_type_integer_validate((void *) enum_ft->container_ft);
        if (ret) {
                BT_LOGW("Invalid enumeration field type: container type is invalid: "
                        "enum-ft-addr=%p, int-ft-addr=%p",
@@ -738,12 +849,12 @@ end:
        return ret;
 }
 
-BT_HIDDEN
-int bt_field_type_common_sequence_validate_recursive(
-               struct bt_field_type_common *ft)
+static
+int bt_field_type_sequence_validate_recursive(
+               struct bt_field_type *ft)
 {
        int ret = 0;
-       struct bt_field_type_common_sequence *seq_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_sequence *seq_ft = (void *) ft;
 
        /* Length field name should be set at this point */
        if (seq_ft->length_field_name->len == 0) {
@@ -753,7 +864,7 @@ int bt_field_type_common_sequence_validate_recursive(
                goto end;
        }
 
-       ret = bt_field_type_common_validate(seq_ft->element_ft);
+       ret = bt_field_type_validate(seq_ft->element_ft);
        if (ret) {
                BT_LOGW("Invalid sequence field type: invalid element field type: "
                        "seq-ft-addr=%p, element-ft-add=%p",
@@ -764,14 +875,14 @@ end:
        return ret;
 }
 
-BT_HIDDEN
-int bt_field_type_common_array_validate_recursive(
-               struct bt_field_type_common *ft)
+static
+int bt_field_type_array_validate_recursive(
+               struct bt_field_type *ft)
 {
        int ret = 0;
-       struct bt_field_type_common_array *array_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_array *array_ft = (void *) ft;
 
-       ret = bt_field_type_common_validate(array_ft->element_ft);
+       ret = bt_field_type_validate(array_ft->element_ft);
        if (ret) {
                BT_LOGW("Invalid array field type: invalid element field type: "
                        "array-ft-addr=%p, element-ft-add=%p",
@@ -781,14 +892,14 @@ int bt_field_type_common_array_validate_recursive(
        return ret;
 }
 
-BT_HIDDEN
-int bt_field_type_common_structure_validate_recursive(
-               struct bt_field_type_common *ft)
+static
+int bt_field_type_structure_validate_recursive(
+               struct bt_field_type *ft)
 {
        int ret = 0;
-       struct bt_field_type_common *child_ft = NULL;
+       struct bt_field_type *child_ft = NULL;
        int64_t field_count =
-               bt_field_type_common_structure_get_field_count(ft);
+               bt_field_type_structure_get_field_count(ft);
        int64_t i;
 
        BT_ASSERT(field_count >= 0);
@@ -796,10 +907,10 @@ int bt_field_type_common_structure_validate_recursive(
        for (i = 0; i < field_count; ++i) {
                const char *field_name;
 
-               ret = bt_field_type_common_structure_borrow_field_by_index(ft,
+               ret = bt_field_type_structure_borrow_field_by_index(ft,
                        &field_name, &child_ft, i);
                BT_ASSERT(ret == 0);
-               ret = bt_field_type_common_validate(child_ft);
+               ret = bt_field_type_validate(child_ft);
                if (ret) {
                        BT_LOGW("Invalid structure field type: "
                                "a contained field type is invalid: "
@@ -815,24 +926,24 @@ end:
 }
 
 static
-bt_bool bt_field_type_common_enumeration_has_overlapping_ranges(
-               struct bt_field_type_common_enumeration *enum_ft)
+bt_bool bt_field_type_enumeration_has_overlapping_ranges(
+               struct bt_field_type_enumeration *enum_ft)
 {
        if (!enum_ft->common.frozen) {
-               bt_field_type_common_enumeration_set_range_overlap(enum_ft);
+               bt_field_type_enumeration_set_range_overlap(enum_ft);
        }
 
        return enum_ft->has_overlapping_ranges;
 }
 
-BT_HIDDEN
-int bt_field_type_common_variant_validate_recursive(
-               struct bt_field_type_common *ft)
+static
+int bt_field_type_variant_validate_recursive(
+               struct bt_field_type *ft)
 {
        int ret = 0;
        int64_t field_count;
-       struct bt_field_type_common *child_ft = NULL;
-       struct bt_field_type_common_variant *var_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type *child_ft = NULL;
+       struct bt_field_type_variant *var_ft = (void *) ft;
        int64_t i;
 
        if (var_ft->tag_name->len == 0) {
@@ -850,7 +961,7 @@ int bt_field_type_common_variant_validate_recursive(
                goto end;
        }
 
-       if (bt_field_type_common_enumeration_has_overlapping_ranges(var_ft->tag_ft)) {
+       if (bt_field_type_enumeration_has_overlapping_ranges(var_ft->tag_ft)) {
                BT_LOGW("Invalid variant field type: enumeration tag field type has overlapping ranges: "
                        "variant-ft-addr=%p, tag-field-name=\"%s\", "
                        "enum-ft-addr=%p", ft, var_ft->tag_name->str,
@@ -873,7 +984,7 @@ int bt_field_type_common_variant_validate_recursive(
         * enumeration while reading a variant field, an error will be
         * generated at that point (while reading the stream).
         */
-       field_count = bt_field_type_common_variant_get_field_count(ft);
+       field_count = bt_field_type_variant_get_field_count(ft);
        if (field_count < 0) {
                BT_LOGW("Invalid variant field type: no fields: "
                        "addr=%p, tag-field-name=\"%s\"",
@@ -885,10 +996,10 @@ int bt_field_type_common_variant_validate_recursive(
        for (i = 0; i < field_count; ++i) {
                const char *field_name;
 
-               ret = bt_field_type_common_variant_borrow_field_by_index(ft,
+               ret = bt_field_type_variant_borrow_field_by_index(ft,
                        &field_name, &child_ft, i);
                BT_ASSERT(ret == 0);
-               ret = bt_field_type_common_validate(child_ft);
+               ret = bt_field_type_validate(child_ft);
                if (ret) {
                        BT_LOGW("Invalid variant field type: "
                                "a contained field type is invalid: "
@@ -912,7 +1023,7 @@ end:
  * applicable.
  */
 BT_HIDDEN
-int bt_field_type_common_validate(struct bt_field_type_common *ft)
+int bt_field_type_validate(struct bt_field_type *ft)
 {
        int ret = 0;
 
@@ -939,7 +1050,7 @@ end:
 
 struct bt_field_type *bt_field_type_integer_create(unsigned int size)
 {
-       struct bt_field_type_common_integer *integer = NULL;
+       struct bt_field_type_integer *integer = NULL;
 
        BT_LOGD("Creating integer field type object: size=%u", size);
 
@@ -949,14 +1060,14 @@ struct bt_field_type *bt_field_type_integer_create(unsigned int size)
                goto error;
        }
 
-       integer = g_new0(struct bt_field_type_common_integer, 1);
+       integer = g_new0(struct bt_field_type_integer, 1);
        if (!integer) {
                BT_LOGE_STR("Failed to allocate one integer field type.");
                goto error;
        }
 
-       bt_field_type_common_integer_initialize(BT_TO_COMMON(integer),
-               size, bt_field_type_common_integer_destroy,
+       bt_field_type_integer_initialize((void *) integer,
+               size, bt_field_type_integer_destroy,
                &bt_field_type_integer_methods);
        BT_LOGD("Created integer field type object: addr=%p, size=%u",
                integer, size);
@@ -969,44 +1080,32 @@ end:
        return (void *) integer;
 }
 
-BT_HIDDEN
-int bt_field_type_common_integer_get_size(struct bt_field_type_common *ft)
+
+int bt_field_type_integer_get_size(struct bt_field_type *ft)
 {
-       struct bt_field_type_common_integer *int_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_integer *int_ft = (void *) ft;
 
        BT_ASSERT_PRE_NON_NULL(ft, "Field type");
-       BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_INTEGER,
+       BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_INTEGER,
                "Field type");
        return (int) int_ft->size;
 }
 
-int bt_field_type_integer_get_size(struct bt_field_type *ft)
-{
-       return bt_field_type_common_integer_get_size((void *) ft);
-}
-
-BT_HIDDEN
-bt_bool bt_field_type_common_integer_is_signed(struct bt_field_type_common *ft)
+bt_bool bt_field_type_integer_is_signed(struct bt_field_type *ft)
 {
-       struct bt_field_type_common_integer *int_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_integer *int_ft = (void *) ft;
 
        BT_ASSERT_PRE_NON_NULL(ft, "Field type");
-       BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_INTEGER,
+       BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_INTEGER,
                "Field type");
        return int_ft->is_signed;
 }
 
-bt_bool bt_field_type_integer_is_signed(struct bt_field_type *ft)
-{
-       return bt_field_type_common_integer_is_signed((void *) ft);
-}
-
-BT_HIDDEN
-int bt_field_type_common_integer_set_is_signed(struct bt_field_type_common *ft,
+int bt_field_type_integer_set_is_signed(struct bt_field_type *ft,
                bt_bool is_signed)
 {
        int ret = 0;
-       struct bt_field_type_common_integer *int_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_integer *int_ft = (void *) ft;
 
        if (!ft) {
                BT_LOGW_STR("Invalid parameter: field type is NULL.");
@@ -1037,19 +1136,11 @@ end:
        return ret;
 }
 
-int bt_field_type_integer_set_is_signed(struct bt_field_type *ft,
-               bt_bool is_signed)
-{
-       return bt_field_type_common_integer_set_is_signed((void *) ft,
-               is_signed);
-}
-
-BT_HIDDEN
-int bt_field_type_common_integer_set_size(struct bt_field_type_common *ft,
+int bt_field_type_integer_set_size(struct bt_field_type *ft,
                unsigned int size)
 {
        int ret = 0;
-       struct bt_field_type_common_integer *int_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_integer *int_ft = (void *) ft;
 
        if (!ft) {
                BT_LOGW_STR("Invalid parameter: field type is NULL.");
@@ -1087,36 +1178,22 @@ end:
        return ret;
 }
 
-int bt_field_type_integer_set_size(struct bt_field_type *ft,
-               unsigned int size)
-{
-       return bt_field_type_common_integer_set_size((void *) ft, size);
-}
-
-BT_HIDDEN
-enum bt_integer_base bt_field_type_common_integer_get_base(
-               struct bt_field_type_common *ft)
+enum bt_integer_base bt_field_type_integer_get_base(
+               struct bt_field_type *ft)
 {
-       struct bt_field_type_common_integer *int_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_integer *int_ft = (void *) ft;
 
        BT_ASSERT_PRE_NON_NULL(ft, "Field type");
-       BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_INTEGER,
+       BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_INTEGER,
                "Field type");
        return int_ft->base;
 }
 
-enum bt_integer_base bt_field_type_integer_get_base(
-               struct bt_field_type *ft)
-{
-       return bt_field_type_common_integer_get_base((void *) ft);
-}
-
-BT_HIDDEN
-int bt_field_type_common_integer_set_base(struct bt_field_type_common *ft,
+int bt_field_type_integer_set_base(struct bt_field_type *ft,
                enum bt_integer_base base)
 {
        int ret = 0;
-       struct bt_field_type_common_integer *int_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_integer *int_ft = (void *) ft;
 
        if (!ft) {
                BT_LOGW_STR("Invalid parameter: field type is NULL.");
@@ -1162,36 +1239,22 @@ end:
        return ret;
 }
 
-int bt_field_type_integer_set_base(struct bt_field_type *ft,
-               enum bt_integer_base base)
-{
-       return bt_field_type_common_integer_set_base((void *) ft, base);
-}
-
-BT_HIDDEN
-enum bt_string_encoding bt_field_type_common_integer_get_encoding(
-               struct bt_field_type_common *ft)
+enum bt_string_encoding bt_field_type_integer_get_encoding(
+               struct bt_field_type *ft)
 {
-       struct bt_field_type_common_integer *int_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_integer *int_ft = (void *) ft;
 
        BT_ASSERT_PRE_NON_NULL(ft, "Field type");
-       BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_INTEGER,
+       BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_INTEGER,
                "Field type");
        return int_ft->encoding;
 }
 
-enum bt_string_encoding bt_field_type_integer_get_encoding(
-               struct bt_field_type *ft)
-{
-       return bt_field_type_common_integer_get_encoding((void *) ft);
-}
-
-BT_HIDDEN
-int bt_field_type_common_integer_set_encoding(struct bt_field_type_common *ft,
+int bt_field_type_integer_set_encoding(struct bt_field_type *ft,
                enum bt_string_encoding encoding)
 {
        int ret = 0;
-       struct bt_field_type_common_integer *int_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_integer *int_ft = (void *) ft;
 
        if (!ft) {
                BT_LOGW_STR("Invalid parameter: field type is NULL.");
@@ -1231,37 +1294,23 @@ end:
        return ret;
 }
 
-int bt_field_type_integer_set_encoding(struct bt_field_type *ft,
-               enum bt_string_encoding encoding)
-{
-       return bt_field_type_common_integer_set_encoding((void *) ft, encoding);
-}
-
-BT_HIDDEN
-struct bt_clock_class *bt_field_type_common_integer_borrow_mapped_clock_class(
-               struct bt_field_type_common *ft)
+struct bt_clock_class *bt_field_type_integer_borrow_mapped_clock_class(
+               struct bt_field_type *ft)
 {
-       struct bt_field_type_common_integer *int_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_integer *int_ft = (void *) ft;
 
        BT_ASSERT_PRE_NON_NULL(ft, "Field type");
-       BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_INTEGER,
+       BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_INTEGER,
                "Field type");
        return int_ft->mapped_clock_class;
 }
 
-struct bt_clock_class *bt_field_type_integer_borrow_mapped_clock_class(
-               struct bt_field_type *ft)
-{
-       return bt_field_type_common_integer_borrow_mapped_clock_class(
-               (void *) ft);
-}
-
-BT_HIDDEN
-int bt_field_type_common_integer_set_mapped_clock_class_no_check_frozen(
-               struct bt_field_type_common *ft,
+static
+int bt_field_type_integer_set_mapped_clock_class_no_check_frozen(
+               struct bt_field_type *ft,
                struct bt_clock_class *clock_class)
 {
-       struct bt_field_type_common_integer *int_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_integer *int_ft = (void *) ft;
        int ret = 0;
 
        if (!clock_class) {
@@ -1296,9 +1345,7 @@ end:
        return ret;
 }
 
-BT_HIDDEN
-int bt_field_type_common_integer_set_mapped_clock_class(
-               struct bt_field_type_common *ft,
+int bt_field_type_integer_set_mapped_clock_class(struct bt_field_type *ft,
                struct bt_clock_class *clock_class)
 {
        int ret = 0;
@@ -1316,20 +1363,13 @@ int bt_field_type_common_integer_set_mapped_clock_class(
                goto end;
        }
 
-       ret = bt_field_type_common_integer_set_mapped_clock_class_no_check_frozen(
+       ret = bt_field_type_integer_set_mapped_clock_class_no_check_frozen(
                ft, clock_class);
 
 end:
        return ret;
 }
 
-int bt_field_type_integer_set_mapped_clock_class(struct bt_field_type *ft,
-               struct bt_clock_class *clock_class)
-{
-       return bt_field_type_common_integer_set_mapped_clock_class((void *) ft,
-               clock_class);
-}
-
 static
 void bt_field_type_enum_iter_destroy(struct bt_object *obj)
 {
@@ -1347,14 +1387,14 @@ void bt_field_type_enum_iter_destroy(struct bt_object *obj)
 
 static
 struct bt_field_type_enumeration_mapping_iterator *
-bt_field_type_common_enumeration_find_mappings_type(
-               struct bt_field_type_common *ft,
+bt_field_type_enumeration_find_mappings_type(
+               struct bt_field_type *ft,
                enum bt_field_type_enumeration_mapping_iterator_type iterator_type)
 {
        struct bt_field_type_enumeration_mapping_iterator *iter = NULL;
 
        BT_ASSERT_PRE_NON_NULL(ft, "Field type");
-       BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_ENUM,
+       BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_ENUM,
                "Field type");
        iter = g_new0(struct bt_field_type_enumeration_mapping_iterator, 1);
        if (!iter) {
@@ -1362,7 +1402,7 @@ bt_field_type_common_enumeration_find_mappings_type(
                goto end;
        }
 
-       bt_object_init(&iter->base, bt_field_type_enum_iter_destroy);
+       bt_object_init_shared(&iter->base, bt_field_type_enum_iter_destroy);
        iter->enumeration_ft = bt_get(ft);
        iter->index = -1;
        iter->type = iterator_type;
@@ -1371,14 +1411,13 @@ end:
        return iter;
 }
 
-BT_HIDDEN
 struct bt_field_type_enumeration_mapping_iterator *
-bt_field_type_common_enumeration_find_mappings_by_name(
-               struct bt_field_type_common *ft, const char *name)
+bt_field_type_enumeration_find_mappings_by_name(
+               struct bt_field_type *ft, const char *name)
 {
        struct bt_field_type_enumeration_mapping_iterator *iter;
 
-       iter = bt_field_type_common_enumeration_find_mappings_type(
+       iter = bt_field_type_enumeration_find_mappings_type(
                        ft, ITERATOR_BY_NAME);
        if (!iter) {
                BT_LOGW("Cannot create enumeration field type mapping iterator: "
@@ -1402,26 +1441,18 @@ error:
        return NULL;
 }
 
-struct bt_field_type_enumeration_mapping_iterator *
-bt_field_type_enumeration_find_mappings_by_name(
-               struct bt_field_type *ft, const char *name)
-{
-       return bt_field_type_common_enumeration_find_mappings_by_name(
-               (void *) ft, name);
-}
-
 int bt_field_type_enumeration_mapping_iterator_next(
                struct bt_field_type_enumeration_mapping_iterator *iter)
 {
-       struct bt_field_type_common_enumeration *enum_ft = iter->enumeration_ft;
+       struct bt_field_type_enumeration *enum_ft = iter->enumeration_ft;
        int i, ret = 0, len;
 
        BT_ASSERT_PRE_NON_NULL(iter, "Enumeration field type mapping iterator");
        len = enum_ft->entries->len;
        for (i = iter->index + 1; i < len; i++) {
                struct enumeration_mapping *mapping =
-                       bt_field_type_common_enumeration_get_mapping_by_index(
-                               BT_TO_COMMON(enum_ft), i);
+                       bt_field_type_enumeration_get_mapping_by_index(
+                               (void *) enum_ft, i);
 
                switch (iter->type) {
                case ITERATOR_BY_NAME:
@@ -1465,14 +1496,13 @@ end:
        return ret;
 }
 
-BT_HIDDEN
 struct bt_field_type_enumeration_mapping_iterator *
-bt_field_type_common_enumeration_signed_find_mappings_by_value(
-               struct bt_field_type_common *ft, int64_t value)
+bt_field_type_enumeration_signed_find_mappings_by_value(
+               struct bt_field_type *ft, int64_t value)
 {
        struct bt_field_type_enumeration_mapping_iterator *iter;
 
-       iter = bt_field_type_common_enumeration_find_mappings_type(
+       iter = bt_field_type_enumeration_find_mappings_type(
                        ft, ITERATOR_BY_SIGNED_VALUE);
        if (!iter) {
                BT_LOGW("Cannot create enumeration field type mapping iterator: "
@@ -1480,8 +1510,8 @@ bt_field_type_common_enumeration_signed_find_mappings_by_value(
                goto error;
        }
 
-       if (bt_field_type_common_integer_is_signed(
-                       BT_TO_COMMON(iter->enumeration_ft->container_ft)) != 1) {
+       if (bt_field_type_integer_is_signed(
+                       (void *) iter->enumeration_ft->container_ft) != 1) {
                BT_LOGW("Invalid parameter: enumeration field type is unsigned: "
                        "enum-ft-addr=%p, int-ft-addr=%p",
                        ft, iter->enumeration_ft->container_ft);
@@ -1497,21 +1527,12 @@ error:
 }
 
 struct bt_field_type_enumeration_mapping_iterator *
-bt_field_type_enumeration_signed_find_mappings_by_value(
-               struct bt_field_type *ft, int64_t value)
-{
-       return bt_field_type_common_enumeration_signed_find_mappings_by_value(
-               (void *) ft, value);
-}
-
-BT_HIDDEN
-struct bt_field_type_enumeration_mapping_iterator *
-bt_field_type_common_enumeration_unsigned_find_mappings_by_value(
-               struct bt_field_type_common *ft, uint64_t value)
+bt_field_type_enumeration_unsigned_find_mappings_by_value(
+               struct bt_field_type *ft, uint64_t value)
 {
        struct bt_field_type_enumeration_mapping_iterator *iter;
 
-       iter = bt_field_type_common_enumeration_find_mappings_type(
+       iter = bt_field_type_enumeration_find_mappings_type(
                        ft, ITERATOR_BY_UNSIGNED_VALUE);
        if (!iter) {
                BT_LOGW("Cannot create enumeration field type mapping iterator: "
@@ -1519,8 +1540,8 @@ bt_field_type_common_enumeration_unsigned_find_mappings_by_value(
                goto error;
        }
 
-       if (bt_field_type_common_integer_is_signed(
-                       BT_TO_COMMON(iter->enumeration_ft->container_ft)) != 0) {
+       if (bt_field_type_integer_is_signed(
+                       (void *) iter->enumeration_ft->container_ft) != 0) {
                BT_LOGW("Invalid parameter: enumeration field type is signed: "
                        "enum-ft-addr=%p, int-ft-addr=%p",
                        ft, iter->enumeration_ft->container_ft);
@@ -1535,14 +1556,6 @@ error:
        return NULL;
 }
 
-struct bt_field_type_enumeration_mapping_iterator *
-bt_field_type_enumeration_unsigned_find_mappings_by_value(
-               struct bt_field_type *ft, uint64_t value)
-{
-       return bt_field_type_common_enumeration_unsigned_find_mappings_by_value(
-               (void *) ft, value);
-}
-
 int bt_field_type_enumeration_mapping_iterator_signed_get(
                struct bt_field_type_enumeration_mapping_iterator *iter,
                const char **mapping_name, int64_t *range_begin,
@@ -1552,7 +1565,7 @@ int bt_field_type_enumeration_mapping_iterator_signed_get(
        BT_ASSERT_PRE(iter->index != -1,
                "Invalid enumeration field type mapping iterator access: "
                "addr=%p, position=-1", iter);
-       return bt_field_type_common_enumeration_signed_get_mapping_by_index(
+       return bt_field_type_enumeration_signed_get_mapping_by_index(
                        (void *) iter->enumeration_ft, iter->index,
                        mapping_name, range_begin, range_end);
 }
@@ -1566,14 +1579,13 @@ int bt_field_type_enumeration_mapping_iterator_unsigned_get(
        BT_ASSERT_PRE(iter->index != -1,
                "Invalid enumeration field type mapping iterator access: "
                "addr=%p, position=-1", iter);
-       return bt_field_type_common_enumeration_unsigned_get_mapping_by_index(
+       return bt_field_type_enumeration_unsigned_get_mapping_by_index(
                        (void *) iter->enumeration_ft, iter->index,
                        mapping_name, range_begin, range_end);
 }
 
-BT_HIDDEN
-int bt_field_type_common_enumeration_signed_get_mapping_by_index(
-               struct bt_field_type_common *ft, uint64_t index,
+int bt_field_type_enumeration_signed_get_mapping_by_index(
+               struct bt_field_type *ft, uint64_t index,
                const char **mapping_name, int64_t *range_begin,
                int64_t *range_end)
 {
@@ -1581,12 +1593,12 @@ int bt_field_type_common_enumeration_signed_get_mapping_by_index(
        struct enumeration_mapping *mapping;
 
        BT_ASSERT_PRE_NON_NULL(ft, "Field type");
-       BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft,
+       BT_ASSERT_PRE_FT_HAS_ID(ft,
                BT_FIELD_TYPE_ID_ENUM, "Field type");
-       mapping = bt_field_type_common_enumeration_get_mapping_by_index(ft,
+       mapping = bt_field_type_enumeration_get_mapping_by_index(ft,
                index);
        if (!mapping) {
-               /* bt_field_type_common_enumeration_get_mapping_by_index() logs errors */
+               /* bt_field_type_enumeration_get_mapping_by_index() logs errors */
                ret = -1;
                goto end;
        }
@@ -1608,18 +1620,8 @@ end:
        return ret;
 }
 
-int bt_field_type_enumeration_signed_get_mapping_by_index(
+int bt_field_type_enumeration_unsigned_get_mapping_by_index(
                struct bt_field_type *ft, uint64_t index,
-               const char **mapping_name, int64_t *range_begin,
-               int64_t *range_end)
-{
-       return bt_field_type_common_enumeration_signed_get_mapping_by_index(
-               (void *) ft, index, mapping_name, range_begin, range_end);
-}
-
-BT_HIDDEN
-int bt_field_type_common_enumeration_unsigned_get_mapping_by_index(
-               struct bt_field_type_common *ft, uint64_t index,
                const char **mapping_name, uint64_t *range_begin,
                uint64_t *range_end)
 {
@@ -1627,11 +1629,11 @@ int bt_field_type_common_enumeration_unsigned_get_mapping_by_index(
        struct enumeration_mapping *mapping;
 
        BT_ASSERT_PRE_NON_NULL(ft, "Field type");
-       BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_ENUM, "Field type");
-       mapping = bt_field_type_common_enumeration_get_mapping_by_index(
+       BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_ENUM, "Field type");
+       mapping = bt_field_type_enumeration_get_mapping_by_index(
                ft, index);
        if (!mapping) {
-               /* bt_field_type_common_enumeration_get_mapping_by_index() reports any error */
+               /* bt_field_type_enumeration_get_mapping_by_index() reports any error */
                ret = -1;
                goto end;
        }
@@ -1653,20 +1655,11 @@ end:
        return ret;
 }
 
-int bt_field_type_enumeration_unsigned_get_mapping_by_index(
-               struct bt_field_type *ft, uint64_t index,
-               const char **mapping_name, uint64_t *range_begin,
-               uint64_t *range_end)
-{
-       return bt_field_type_common_enumeration_unsigned_get_mapping_by_index(
-               (void *) ft, index, mapping_name, range_begin, range_end);
-}
-
 struct bt_field_type *bt_field_type_enumeration_create(
                struct bt_field_type *container_ft)
 {
-       struct bt_field_type_common_enumeration *enumeration = NULL;
-       struct bt_field_type_common *int_ft = (void *) container_ft;
+       struct bt_field_type_enumeration *enumeration = NULL;
+       struct bt_field_type *int_ft = (void *) container_ft;
 
        BT_LOGD("Creating enumeration field type object: int-ft-addr=%p",
                container_ft);
@@ -1683,14 +1676,14 @@ struct bt_field_type *bt_field_type_enumeration_create(
                goto error;
        }
 
-       enumeration = g_new0(struct bt_field_type_common_enumeration, 1);
+       enumeration = g_new0(struct bt_field_type_enumeration, 1);
        if (!enumeration) {
                BT_LOGE_STR("Failed to allocate one enumeration field type.");
                goto error;
        }
 
-       bt_field_type_common_enumeration_initialize(BT_TO_COMMON(enumeration),
-               int_ft, bt_field_type_common_enumeration_destroy_recursive,
+       bt_field_type_enumeration_initialize((void *) enumeration,
+               int_ft, bt_field_type_enumeration_destroy_recursive,
                &bt_field_type_enumeration_methods);
        BT_LOGD("Created enumeration field type object: addr=%p, "
                "int-ft-addr=%p, int-ft-size=%u",
@@ -1705,34 +1698,24 @@ end:
        return (void *) enumeration;
 }
 
-BT_HIDDEN
-struct bt_field_type_common *
-bt_field_type_common_enumeration_borrow_container_field_type(
-               struct bt_field_type_common *ft)
-{
-       struct bt_field_type_common_enumeration *enum_ft = BT_FROM_COMMON(ft);
-
-       BT_ASSERT_PRE_NON_NULL(ft, "Field type");
-       BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_ENUM, "Field type");
-       return BT_TO_COMMON(enum_ft->container_ft);
-}
-
 struct bt_field_type *bt_field_type_enumeration_borrow_container_field_type(
                struct bt_field_type *ft)
 {
-       return (void *) bt_field_type_common_enumeration_borrow_container_field_type(
-               (void *) ft);
+       struct bt_field_type_enumeration *enum_ft = (void *) ft;
+
+       BT_ASSERT_PRE_NON_NULL(ft, "Field type");
+       BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_ENUM, "Field type");
+       return (void *) enum_ft->container_ft;
 }
 
-BT_HIDDEN
-int bt_field_type_common_enumeration_signed_add_mapping(
-               struct bt_field_type_common *ft, const char *string,
+int bt_field_type_enumeration_signed_add_mapping(
+               struct bt_field_type *ft, const char *string,
                int64_t range_start, int64_t range_end)
 {
        int ret = 0;
        GQuark mapping_name;
        struct enumeration_mapping *mapping;
-       struct bt_field_type_common_enumeration *enum_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_enumeration *enum_ft = (void *) ft;
        char *escaped_string;
 
        if (!ft) {
@@ -1814,23 +1797,14 @@ end:
        return ret;
 }
 
-int bt_field_type_enumeration_signed_add_mapping(
+int bt_field_type_enumeration_unsigned_add_mapping(
                struct bt_field_type *ft, const char *string,
-               int64_t range_start, int64_t range_end)
-{
-       return bt_field_type_common_enumeration_signed_add_mapping(
-               (void *) ft, string, range_start, range_end);
-}
-
-BT_HIDDEN
-int bt_field_type_common_enumeration_unsigned_add_mapping(
-               struct bt_field_type_common *ft, const char *string,
                uint64_t range_start, uint64_t range_end)
 {
        int ret = 0;
        GQuark mapping_name;
        struct enumeration_mapping *mapping;
-       struct bt_field_type_common_enumeration *enum_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_enumeration *enum_ft = (void *) ft;
        char *escaped_string;
 
        if (!ft) {
@@ -1912,35 +1886,20 @@ end:
        return ret;
 }
 
-int bt_field_type_enumeration_unsigned_add_mapping(
-               struct bt_field_type *ft, const char *string,
-               uint64_t range_start, uint64_t range_end)
-{
-       return bt_field_type_common_enumeration_unsigned_add_mapping(
-               (void *) ft, string, range_start, range_end);
-}
-
-BT_HIDDEN
-int64_t bt_field_type_common_enumeration_get_mapping_count(
-               struct bt_field_type_common *ft)
+int64_t bt_field_type_enumeration_get_mapping_count(
+               struct bt_field_type *ft)
 {
-       struct bt_field_type_common_enumeration *enum_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_enumeration *enum_ft = (void *) ft;
 
        BT_ASSERT_PRE_NON_NULL(ft, "Field type");
-       BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_ENUM, "Field type");
+       BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_ENUM, "Field type");
        return (int64_t) enum_ft->entries->len;
 }
 
-int64_t bt_field_type_enumeration_get_mapping_count(
-               struct bt_field_type *ft)
-{
-       return bt_field_type_common_enumeration_get_mapping_count((void *) ft);
-}
-
 struct bt_field_type *bt_field_type_floating_point_create(void)
 {
-       struct bt_field_type_common_floating_point *floating_point =
-               g_new0(struct bt_field_type_common_floating_point, 1);
+       struct bt_field_type_floating_point *floating_point =
+               g_new0(struct bt_field_type_floating_point, 1);
 
        BT_LOGD_STR("Creating floating point number field type object.");
 
@@ -1949,9 +1908,9 @@ struct bt_field_type *bt_field_type_floating_point_create(void)
                goto end;
        }
 
-       bt_field_type_common_floating_point_initialize(
-               BT_TO_COMMON(floating_point),
-               bt_field_type_common_floating_point_destroy,
+       bt_field_type_floating_point_initialize(
+               (void *) floating_point,
+               bt_field_type_floating_point_destroy,
                &bt_field_type_floating_point_methods);
        BT_LOGD("Created floating point number field type object: addr=%p, "
                "exp-size=%u, mant-size=%u", floating_point,
@@ -1961,32 +1920,22 @@ end:
        return (void *) floating_point;
 }
 
-BT_HIDDEN
-int bt_field_type_common_floating_point_get_exponent_digits(
-               struct bt_field_type_common *ft)
+int bt_field_type_floating_point_get_exponent_digits(
+               struct bt_field_type *ft)
 {
-       struct bt_field_type_common_floating_point *flt_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_floating_point *flt_ft = (void *) ft;
 
        BT_ASSERT_PRE_NON_NULL(ft, "Field type");
-       BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_FLOAT,
+       BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_FLOAT,
                "Field type");
        return (int) flt_ft->exp_dig;
 }
 
-int bt_field_type_floating_point_get_exponent_digits(
-               struct bt_field_type *ft)
-{
-       return bt_field_type_common_floating_point_get_exponent_digits(
-               (void *) ft);
-}
-
-BT_HIDDEN
-int bt_field_type_common_floating_point_set_exponent_digits(
-               struct bt_field_type_common *ft,
-               unsigned int exponent_digits)
+int bt_field_type_floating_point_set_exponent_digits(
+               struct bt_field_type *ft, unsigned int exponent_digits)
 {
        int ret = 0;
-       struct bt_field_type_common_floating_point *flt_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_floating_point *flt_ft = (void *) ft;
 
        if (!ft) {
                BT_LOGW_STR("Invalid parameter: field type is NULL.");
@@ -2027,38 +1976,22 @@ end:
        return ret;
 }
 
-int bt_field_type_floating_point_set_exponent_digits(
-               struct bt_field_type *ft, unsigned int exponent_digits)
-{
-       return bt_field_type_common_floating_point_set_exponent_digits(
-               (void *) ft, exponent_digits);
-}
-
-BT_HIDDEN
-int bt_field_type_common_floating_point_get_mantissa_digits(
-               struct bt_field_type_common *ft)
+int bt_field_type_floating_point_get_mantissa_digits(
+               struct bt_field_type *ft)
 {
-       struct bt_field_type_common_floating_point *flt_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_floating_point *flt_ft = (void *) ft;
 
        BT_ASSERT_PRE_NON_NULL(ft, "Field type");
-       BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_FLOAT,
+       BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_FLOAT,
                "Field type");
        return (int) flt_ft->mant_dig;
 }
 
-int bt_field_type_floating_point_get_mantissa_digits(
-               struct bt_field_type *ft)
-{
-       return bt_field_type_common_floating_point_get_mantissa_digits(
-               (void *) ft);
-}
-
-BT_HIDDEN
-int bt_field_type_common_floating_point_set_mantissa_digits(
-               struct bt_field_type_common *ft, unsigned int mantissa_digits)
+int bt_field_type_floating_point_set_mantissa_digits(
+               struct bt_field_type *ft, unsigned int mantissa_digits)
 {
        int ret = 0;
-       struct bt_field_type_common_floating_point *flt_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_floating_point *flt_ft = (void *) ft;
 
        if (!ft) {
                BT_LOGW_STR("Invalid parameter: field type is NULL.");
@@ -2098,17 +2031,10 @@ end:
        return ret;
 }
 
-int bt_field_type_floating_point_set_mantissa_digits(
-               struct bt_field_type *ft, unsigned int mantissa_digits)
-{
-       return bt_field_type_common_floating_point_set_mantissa_digits(
-               (void *) ft, mantissa_digits);
-}
-
 struct bt_field_type *bt_field_type_structure_create(void)
 {
-       struct bt_field_type_common_structure *structure =
-               g_new0(struct bt_field_type_common_structure, 1);
+       struct bt_field_type_structure *structure =
+               g_new0(struct bt_field_type_structure, 1);
 
        BT_LOGD_STR("Creating structure field type object.");
 
@@ -2117,8 +2043,8 @@ struct bt_field_type *bt_field_type_structure_create(void)
                goto error;
        }
 
-       bt_field_type_common_structure_initialize(BT_TO_COMMON(structure),
-               bt_field_type_common_structure_destroy_recursive,
+       bt_field_type_structure_initialize((void *) structure,
+               bt_field_type_structure_destroy_recursive,
                &bt_field_type_structure_methods);
        BT_LOGD("Created structure field type object: addr=%p",
                structure);
@@ -2131,43 +2057,12 @@ end:
        return (void *) structure;
 }
 
-BT_HIDDEN
-int bt_field_type_common_structure_replace_field(
-               struct bt_field_type_common *ft,
-               const char *field_name,
-               struct bt_field_type_common *field_type)
-{
-       int ret = 0;
-       struct bt_field_type_common_structure *struct_ft = BT_FROM_COMMON(ft);
-       GQuark name_quark;
-       uint64_t i;
-
-       BT_ASSERT(ft);
-       BT_ASSERT(field_name);
-       BT_ASSERT(field_type);
-       BT_ASSERT(ft->id == BT_FIELD_TYPE_ID_STRUCT);
-       name_quark = g_quark_from_string(field_name);
-
-       for (i = 0; i < struct_ft->fields->len; i++) {
-               struct structure_field_common *field = g_ptr_array_index(
-                       struct_ft->fields, i);
-
-               if (field->name == name_quark) {
-                       bt_put(field->type);
-                       field->type = bt_get(field_type);
-               }
-       }
-
-       return ret;
-}
-
-BT_HIDDEN
-int bt_field_type_common_structure_add_field(struct bt_field_type_common *ft,
-               struct bt_field_type_common *field_type,
+int bt_field_type_structure_add_field(struct bt_field_type *ft,
+               struct bt_field_type *field_type,
                const char *field_name)
 {
        int ret = 0;
-       struct bt_field_type_common_structure *struct_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_structure *struct_ft = (void *) ft;
 
        /*
         * TODO: check that `field_type` does not contain `type`,
@@ -2207,8 +2102,9 @@ int bt_field_type_common_structure_add_field(struct bt_field_type_common *ft,
                goto end;
        }
 
-       if (add_structure_field(struct_ft->fields,
-                       struct_ft->field_name_to_index, field_type, field_name)) {
+       if (add_structure_variant_member(struct_ft->fields,
+                       struct_ft->field_name_to_index, field_type, field_name,
+                       false)) {
                BT_LOGW("Cannot add field to structure field type: "
                        "struct-ft-addr=%p, field-ft-addr=%p, field-name=\"%s\"",
                        ft, field_type, field_name);
@@ -2224,48 +2120,32 @@ end:
        return ret;
 }
 
-int bt_field_type_structure_add_field(struct bt_field_type *ft,
-               struct bt_field_type *field_type,
-               const char *field_name)
-{
-       return bt_field_type_common_structure_add_field((void *) ft,
-               (void *) field_type, field_name);
-}
-
-BT_HIDDEN
-int64_t bt_field_type_common_structure_get_field_count(
-               struct bt_field_type_common *ft)
+int64_t bt_field_type_structure_get_field_count(struct bt_field_type *ft)
 {
-       struct bt_field_type_common_structure *struct_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_structure *struct_ft = (void *) ft;
 
        BT_ASSERT_PRE_NON_NULL(ft, "Field type");
-       BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_STRUCT,
+       BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_STRUCT,
                "Field type");
        return (int64_t) struct_ft->fields->len;
 }
 
-int64_t bt_field_type_structure_get_field_count(struct bt_field_type *ft)
-{
-       return bt_field_type_common_structure_get_field_count((void *) ft);
-}
-
-BT_HIDDEN
-int bt_field_type_common_structure_borrow_field_by_index(
-               struct bt_field_type_common *ft,
+int bt_field_type_structure_borrow_field_by_index(
+               struct bt_field_type *ft,
                const char **field_name,
-               struct bt_field_type_common **field_type, uint64_t index)
+               struct bt_field_type **field_type, uint64_t index)
 {
-       struct bt_field_type_common_structure *struct_ft = BT_FROM_COMMON(ft);
-       struct structure_field_common *field;
+       struct bt_field_type_structure *struct_ft = (void *) ft;
+       struct bt_field_type_structure_field *field;
 
        BT_ASSERT_PRE_NON_NULL(ft, "Field type");
-       BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_STRUCT,
+       BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_STRUCT,
                "Field type");
        BT_ASSERT_PRE(index < struct_ft->fields->len,
                "Index is out of bounds: index=%" PRIu64 ", "
-               "count=%u, %![ft-]+_F",
+               "count=%u, %![ft-]+F",
                index, struct_ft->fields->len, ft);
-       field = g_ptr_array_index(struct_ft->fields, index);
+       field = BT_FIELD_TYPE_STRUCTURE_FIELD_AT_INDEX(struct_ft, index);
 
        if (field_type) {
                *field_type = field->type;
@@ -2279,29 +2159,18 @@ int bt_field_type_common_structure_borrow_field_by_index(
        return 0;
 }
 
-int bt_field_type_structure_borrow_field_by_index(
-               struct bt_field_type *ft,
-               const char **field_name,
-               struct bt_field_type **field_type, uint64_t index)
-{
-       return bt_field_type_common_structure_borrow_field_by_index(
-               (void *) ft, field_name, (void *) field_type, index);
-}
-
-BT_HIDDEN
-struct bt_field_type_common *
-bt_field_type_common_structure_borrow_field_type_by_name(
-               struct bt_field_type_common *ft, const char *name)
+struct bt_field_type *bt_field_type_structure_borrow_field_type_by_name(
+               struct bt_field_type *ft, const char *name)
 {
        size_t index;
        GQuark name_quark;
-       struct structure_field_common *field;
-       struct bt_field_type_common_structure *struct_ft = BT_FROM_COMMON(ft);
-       struct bt_field_type_common *field_type = NULL;
+       struct bt_field_type_structure_field *field;
+       struct bt_field_type_structure *struct_ft = (void *) ft;
+       struct bt_field_type *field_type = NULL;
 
        BT_ASSERT_PRE_NON_NULL(ft, "Field type");
        BT_ASSERT_PRE_NON_NULL(name, "Name");
-       BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_STRUCT,
+       BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_STRUCT,
                "Field type");
        name_quark = g_quark_try_string(name);
        if (!name_quark) {
@@ -2319,24 +2188,17 @@ bt_field_type_common_structure_borrow_field_type_by_name(
                goto end;
        }
 
-       field = struct_ft->fields->pdata[index];
+       field = BT_FIELD_TYPE_STRUCTURE_FIELD_AT_INDEX(ft, index);
        field_type = field->type;
 
 end:
        return field_type;
 }
 
-struct bt_field_type *bt_field_type_structure_borrow_field_type_by_name(
-               struct bt_field_type *ft, const char *name)
-{
-       return (void *) bt_field_type_common_structure_borrow_field_type_by_name(
-               (void *) ft, name);
-}
-
 struct bt_field_type *bt_field_type_variant_create(
        struct bt_field_type *tag_ft, const char *tag_name)
 {
-       struct bt_field_type_common_variant *var_ft = NULL;
+       struct bt_field_type_variant *var_ft = NULL;
 
        BT_LOGD("Creating variant field type object: "
                "tag-ft-addr=%p, tag-field-name=\"%s\"",
@@ -2349,15 +2211,15 @@ struct bt_field_type *bt_field_type_variant_create(
                goto error;
        }
 
-       var_ft = g_new0(struct bt_field_type_common_variant, 1);
+       var_ft = g_new0(struct bt_field_type_variant, 1);
        if (!var_ft) {
                BT_LOGE_STR("Failed to allocate one variant field type.");
                goto error;
        }
 
-       bt_field_type_common_variant_initialize(BT_TO_COMMON(var_ft),
+       bt_field_type_variant_initialize((void *) var_ft,
                (void *) tag_ft, tag_name,
-               bt_field_type_common_variant_destroy_recursive,
+               bt_field_type_variant_destroy_recursive,
                &bt_field_type_variant_methods);
        BT_LOGD("Created variant field type object: addr=%p, "
                "tag-ft-addr=%p, tag-field-name=\"%s\"",
@@ -2371,16 +2233,14 @@ end:
        return (void *) var_ft;
 }
 
-BT_HIDDEN
-struct bt_field_type_common *
-bt_field_type_common_variant_borrow_tag_field_type(
-               struct bt_field_type_common *ft)
+struct bt_field_type *bt_field_type_variant_borrow_tag_field_type(
+               struct bt_field_type *ft)
 {
-       struct bt_field_type_common_variant *var_ft = BT_FROM_COMMON(ft);
-       struct bt_field_type_common *tag_ft = NULL;
+       struct bt_field_type_variant *var_ft = (void *) ft;
+       struct bt_field_type *tag_ft = NULL;
 
        BT_ASSERT_PRE_NON_NULL(ft, "Field type");
-       BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_VARIANT,
+       BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_VARIANT,
                "Field type");
 
        if (!var_ft->tag_ft) {
@@ -2389,28 +2249,19 @@ bt_field_type_common_variant_borrow_tag_field_type(
                goto end;
        }
 
-       tag_ft = BT_TO_COMMON(var_ft->tag_ft);
+       tag_ft = (void *) var_ft->tag_ft;
 
 end:
        return tag_ft;
 }
 
-struct bt_field_type *bt_field_type_variant_borrow_tag_field_type(
-               struct bt_field_type *ft)
-{
-       return (void *) bt_field_type_common_variant_borrow_tag_field_type(
-               (void *) ft);
-}
-
-BT_HIDDEN
-const char *bt_field_type_common_variant_get_tag_name(
-               struct bt_field_type_common *ft)
+const char *bt_field_type_variant_get_tag_name(struct bt_field_type *ft)
 {
-       struct bt_field_type_common_variant *var_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_variant *var_ft = (void *) ft;
        const char *tag_name = NULL;
 
        BT_ASSERT_PRE_NON_NULL(ft, "Field type");
-       BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_VARIANT,
+       BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_VARIANT,
                "Field type");
 
        if (var_ft->tag_name->len == 0) {
@@ -2425,17 +2276,11 @@ end:
        return tag_name;
 }
 
-const char *bt_field_type_variant_get_tag_name(struct bt_field_type *ft)
-{
-       return bt_field_type_common_variant_get_tag_name((void *) ft);
-}
-
-BT_HIDDEN
-int bt_field_type_common_variant_set_tag_name(
-               struct bt_field_type_common *ft, const char *name)
+int bt_field_type_variant_set_tag_name(
+               struct bt_field_type *ft, const char *name)
 {
        int ret = 0;
-       struct bt_field_type_common_variant *var_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_variant *var_ft = (void *) ft;
 
        if (!ft) {
                BT_LOGW_STR("Invalid parameter: field type is NULL.");
@@ -2473,20 +2318,13 @@ end:
        return ret;
 }
 
-int bt_field_type_variant_set_tag_name(
-               struct bt_field_type *ft, const char *name)
-{
-       return bt_field_type_common_variant_set_tag_name((void *) ft, name);
-}
-
-BT_HIDDEN
-int bt_field_type_common_variant_add_field(struct bt_field_type_common *ft,
-               struct bt_field_type_common *field_type,
+int bt_field_type_variant_add_field(struct bt_field_type *ft,
+               struct bt_field_type *field_type,
                const char *field_name)
 {
        size_t i;
        int ret = 0;
-       struct bt_field_type_common_variant *var_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_variant *var_ft = (void *) ft;
        GQuark field_name_quark = g_quark_from_string(field_name);
 
        /*
@@ -2549,8 +2387,9 @@ int bt_field_type_common_variant_add_field(struct bt_field_type_common *ft,
                }
        }
 
-       if (add_structure_field(var_ft->fields, var_ft->field_name_to_index,
-                       field_type, field_name)) {
+       if (add_structure_variant_member(var_ft->choices,
+                       var_ft->choice_name_to_index, field_type,
+                       field_name, true)) {
                BT_LOGW("Cannot add field to variant field type: "
                        "variant-ft-addr=%p, field-ft-addr=%p, field-name=\"%s\"",
                        ft, field_type, field_name);
@@ -2566,29 +2405,19 @@ end:
        return ret;
 }
 
-int bt_field_type_variant_add_field(struct bt_field_type *ft,
-               struct bt_field_type *field_type,
-               const char *field_name)
-{
-       return bt_field_type_common_variant_add_field((void *) ft,
-               (void *) field_type, field_name);
-}
-
-BT_HIDDEN
-struct bt_field_type_common *
-bt_field_type_common_variant_borrow_field_type_by_name(
-               struct bt_field_type_common *ft,
+struct bt_field_type *bt_field_type_variant_borrow_field_type_by_name(
+               struct bt_field_type *ft,
                const char *field_name)
 {
        size_t index;
        GQuark name_quark;
-       struct structure_field_common *field;
-       struct bt_field_type_common_variant *var_ft = BT_FROM_COMMON(ft);
-       struct bt_field_type_common *field_type = NULL;
+       struct bt_field_type_variant_choice *choice;
+       struct bt_field_type_variant *var_ft = (void *) ft;
+       struct bt_field_type *field_type = NULL;
 
        BT_ASSERT_PRE_NON_NULL(ft, "Field type");
        BT_ASSERT_PRE_NON_NULL(field_name, "Name");
-       BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_VARIANT,
+       BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_VARIANT,
                "Field type");
        name_quark = g_quark_try_string(field_name);
        if (!name_quark) {
@@ -2598,7 +2427,7 @@ bt_field_type_common_variant_borrow_field_type_by_name(
                goto end;
        }
 
-       if (!g_hash_table_lookup_extended(var_ft->field_name_to_index,
+       if (!g_hash_table_lookup_extended(var_ft->choice_name_to_index,
                        GUINT_TO_POINTER(name_quark), NULL, (gpointer *) &index)) {
                BT_LOGV("No such variant field type field name: "
                        "ft-addr=%p, field-name=\"%s\"",
@@ -2606,130 +2435,112 @@ bt_field_type_common_variant_borrow_field_type_by_name(
                goto end;
        }
 
-       field = g_ptr_array_index(var_ft->fields, index);
-       field_type = field->type;
+       choice = BT_FIELD_TYPE_VARIANT_CHOICE_AT_INDEX(ft, index);
+       field_type = choice->type;
 
 end:
        return field_type;
 }
 
-struct bt_field_type *bt_field_type_variant_borrow_field_type_by_name(
-               struct bt_field_type *ft,
-               const char *field_name)
-{
-       return (void *) bt_field_type_common_variant_borrow_field_type_by_name(
-               (void *) ft, field_name);
-}
-
-BT_HIDDEN
-struct bt_field_type_common *
-bt_field_type_common_variant_borrow_field_type_from_tag(
-               struct bt_field_type_common *ft,
-               struct bt_field_common *tag_field,
-               bt_field_common_create_func field_create_func)
-{
-       int ret;
-       const char *enum_value;
-       struct bt_field_type_common *field_type = NULL;
-       struct bt_field_type_enumeration_mapping_iterator *iter = NULL;
-
-       BT_ASSERT_PRE_NON_NULL(ft, "Variant field type");
-       BT_ASSERT_PRE_NON_NULL(tag_field, "Tag field");
-       BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_VARIANT,
-               "Field type");
-       iter = bt_field_common_enumeration_get_mappings(tag_field,
-               field_create_func);
-       ret = bt_field_type_enumeration_mapping_iterator_next(iter);
-       if (!iter || ret) {
-               BT_LOGW("Cannot get enumeration field type mapping iterator from enumeration field: "
-                       "enum-field-addr=%p", tag_field);
-               goto end;
-       }
-
-       ret = bt_field_type_enumeration_mapping_iterator_signed_get(iter,
-               &enum_value, NULL, NULL);
-       if (ret) {
-               BT_LOGW("Cannot get enumeration field type mapping iterator's current mapping: "
-                       "iter-addr=%p", iter);
-               goto end;
-       }
-
-       field_type = bt_field_type_common_variant_borrow_field_type_by_name(
-               ft, enum_value);
-
-end:
-       bt_put(iter);
-       return field_type;
-}
-
-struct bt_field_type *bt_field_type_variant_borrow_field_type_from_tag(
-               struct bt_field_type *ft,
-               struct bt_field *tag_field)
-{
-       return (void *) bt_field_type_common_variant_borrow_field_type_from_tag(
-               (void *) ft, (void *) tag_field,
-               (bt_field_common_create_func) bt_field_create);
-}
-
-BT_HIDDEN
-int64_t bt_field_type_common_variant_get_field_count(
-               struct bt_field_type_common *ft)
+int64_t bt_field_type_variant_get_field_count(struct bt_field_type *ft)
 {
-       struct bt_field_type_common_variant *var_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_variant *var_ft = (void *) ft;
 
        BT_ASSERT_PRE_NON_NULL(ft, "Variant field type");
-       BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_VARIANT,
+       BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_VARIANT,
                "Field type");
-       return (int64_t) var_ft->fields->len;
-}
-
-int64_t bt_field_type_variant_get_field_count(struct bt_field_type *ft)
-{
-       return bt_field_type_common_variant_get_field_count((void *) ft);
+       return (int64_t) var_ft->choices->len;
 }
 
-BT_HIDDEN
-int bt_field_type_common_variant_borrow_field_by_index(
-               struct bt_field_type_common *ft,
-               const char **field_name,
-               struct bt_field_type_common **field_type, uint64_t index)
+int bt_field_type_variant_borrow_field_by_index(struct bt_field_type *ft,
+               const char **field_name, struct bt_field_type **field_type,
+               uint64_t index)
 {
-       struct bt_field_type_common_variant *var_ft = BT_FROM_COMMON(ft);
-       struct structure_field_common *field;
+       struct bt_field_type_variant *var_ft = (void *) ft;
+       struct bt_field_type_variant_choice *choice;
 
        BT_ASSERT_PRE_NON_NULL(ft, "Field type");
-       BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_VARIANT,
+       BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_VARIANT,
                "Field type");
-       BT_ASSERT_PRE(index < var_ft->fields->len,
+       BT_ASSERT_PRE(index < var_ft->choices->len,
                "Index is out of bounds: index=%" PRIu64 ", "
-               "count=%u, %![ft-]+_F",
-               index, var_ft->fields->len, ft);
-       field = g_ptr_array_index(var_ft->fields, index);
+               "count=%u, %![ft-]+F",
+               index, var_ft->choices->len, ft);
+       choice = BT_FIELD_TYPE_VARIANT_CHOICE_AT_INDEX(ft, index);
 
        if (field_type) {
-               *field_type = field->type;
+               *field_type = choice->type;
        }
 
        if (field_name) {
-               *field_name = g_quark_to_string(field->name);
+               *field_name = g_quark_to_string(choice->name);
                BT_ASSERT(*field_name);
        }
 
        return 0;
 }
 
-int bt_field_type_variant_borrow_field_by_index(struct bt_field_type *ft,
-               const char **field_name, struct bt_field_type **field_type,
-               uint64_t index)
+BT_HIDDEN
+int64_t bt_field_type_variant_find_choice_index(
+               struct bt_field_type *ft, uint64_t uval,
+               bool is_signed)
 {
-       return bt_field_type_common_variant_borrow_field_by_index((void *) ft,
-               field_name, (void *) field_type, index);
+       int64_t ret;
+       uint64_t i;
+       struct bt_field_type_variant *var_ft = (void *) ft;
+
+       BT_ASSERT(ft);
+       BT_ASSERT(ft->id == BT_FIELD_TYPE_ID_VARIANT);
+
+       if (bt_field_type_variant_update_choices(ft)) {
+               ret = INT64_C(-1);
+               goto end;
+       }
+
+       for (i = 0; i < var_ft->choices->len; i++) {
+               uint64_t range_i;
+               struct bt_field_type_variant_choice *choice =
+                       BT_FIELD_TYPE_VARIANT_CHOICE_AT_INDEX(
+                               var_ft, i);
+
+               for (range_i = 0; range_i < choice->ranges->len; range_i++) {
+                       struct bt_field_type_variant_choice_range *range =
+                               &g_array_index(
+                                       choice->ranges,
+                                       struct bt_field_type_variant_choice_range,
+                                       range_i);
+
+                       if (is_signed) {
+                               int64_t tag_ival = (int64_t) uval;
+
+                               if (tag_ival >= range->lower.i &&
+                                               tag_ival <= range->upper.i) {
+                                       goto found;
+                               }
+                       } else {
+                               if (uval >= range->lower.u &&
+                                               uval <= range->upper.u) {
+                                       goto found;
+                               }
+                       }
+               }
+       }
+
+       /* Range not found */
+       ret = INT64_C(-1);
+       goto end;
+
+found:
+       ret = (int64_t) i;
+
+end:
+       return ret;
 }
 
 struct bt_field_type *bt_field_type_array_create(
                struct bt_field_type *element_ft, unsigned int length)
 {
-       struct bt_field_type_common_array *array = NULL;
+       struct bt_field_type_array *array = NULL;
 
        BT_LOGD("Creating array field type object: element-ft-addr=%p, "
                "length=%u", element_ft, length);
@@ -2744,15 +2555,15 @@ struct bt_field_type *bt_field_type_array_create(
                goto error;
        }
 
-       array = g_new0(struct bt_field_type_common_array, 1);
+       array = g_new0(struct bt_field_type_array, 1);
        if (!array) {
                BT_LOGE_STR("Failed to allocate one array field type.");
                goto error;
        }
 
-       bt_field_type_common_array_initialize(BT_TO_COMMON(array),
+       bt_field_type_array_initialize((void *) array,
                (void *) element_ft, length,
-               bt_field_type_common_array_destroy_recursive,
+               bt_field_type_array_destroy_recursive,
                &bt_field_type_array_methods);
        BT_LOGD("Created array field type object: addr=%p, "
                "element-ft-addr=%p, length=%u",
@@ -2766,88 +2577,33 @@ end:
        return (void *) array;
 }
 
-BT_HIDDEN
-struct bt_field_type_common *
-bt_field_type_common_array_borrow_element_field_type(
-               struct bt_field_type_common *ft)
+struct bt_field_type *bt_field_type_array_borrow_element_field_type(
+               struct bt_field_type *ft)
 {
-       struct bt_field_type_common_array *array_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_array *array_ft = (void *) ft;
 
        BT_ASSERT_PRE_NON_NULL(ft, "Field type");
-       BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_ARRAY,
+       BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_ARRAY,
                "Field type");
        BT_ASSERT(array_ft && array_ft->element_ft);
        return array_ft->element_ft;
 }
 
-struct bt_field_type *bt_field_type_array_borrow_element_field_type(
-               struct bt_field_type *ft)
-{
-       return (void *) bt_field_type_common_array_borrow_element_field_type(
-               (void *) ft);
-}
-
-BT_HIDDEN
-int bt_field_type_common_array_set_element_field_type(
-               struct bt_field_type_common *ft,
-               struct bt_field_type_common *element_ft)
-{
-       int ret = 0;
-       struct bt_field_type_common_array *array_ft = BT_FROM_COMMON(ft);
-
-       if (!ft) {
-               BT_LOGW_STR("Invalid parameter: array field type is NULL.");
-               ret = -1;
-               goto end;
-       }
-
-       if (!element_ft) {
-               BT_LOGW_STR("Invalid parameter: element field type is NULL.");
-               ret = -1;
-               goto end;
-       }
-
-       if (ft->id != BT_FIELD_TYPE_ID_ARRAY) {
-               BT_LOGW("Invalid parameter: field type is not an array field type: "
-                       "addr=%p, ft-id=%s", ft,
-                       bt_common_field_type_id_string(ft->id));
-               ret = -1;
-               goto end;
-       }
-
-       if (array_ft->element_ft) {
-               BT_PUT(array_ft->element_ft);
-       }
-
-       array_ft->element_ft = bt_get(element_ft);
-       BT_LOGV("Set array field type's element field type: array-ft-addr=%p, "
-               "element-ft-addr=%p", ft, element_ft);
-
-end:
-       return ret;
-}
-
-BT_HIDDEN
-int64_t bt_field_type_common_array_get_length(struct bt_field_type_common *ft)
+int64_t bt_field_type_array_get_length(struct bt_field_type *ft)
 {
-       struct bt_field_type_common_array *array_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_array *array_ft = (void *) ft;
 
        BT_ASSERT_PRE_NON_NULL(ft, "Field type");
-       BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_ARRAY,
+       BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_ARRAY,
                "Field type");
        return (int64_t) array_ft->length;
 }
 
-int64_t bt_field_type_array_get_length(struct bt_field_type *ft)
-{
-       return bt_field_type_common_array_get_length((void *) ft);
-}
-
 struct bt_field_type *bt_field_type_sequence_create(
                struct bt_field_type *element_ft,
                const char *length_field_name)
 {
-       struct bt_field_type_common_sequence *sequence = NULL;
+       struct bt_field_type_sequence *sequence = NULL;
 
        BT_LOGD("Creating sequence field type object: element-ft-addr=%p, "
                "length-field-name=\"%s\"", element_ft, length_field_name);
@@ -2863,15 +2619,15 @@ struct bt_field_type *bt_field_type_sequence_create(
                goto error;
        }
 
-       sequence = g_new0(struct bt_field_type_common_sequence, 1);
+       sequence = g_new0(struct bt_field_type_sequence, 1);
        if (!sequence) {
                BT_LOGE_STR("Failed to allocate one sequence field type.");
                goto error;
        }
 
-       bt_field_type_common_sequence_initialize(BT_TO_COMMON(sequence),
+       bt_field_type_sequence_initialize((void *) sequence,
                (void *) element_ft, length_field_name,
-               bt_field_type_common_sequence_destroy_recursive,
+               bt_field_type_sequence_destroy_recursive,
                &bt_field_type_sequence_methods);
        BT_LOGD("Created sequence field type object: addr=%p, "
                "element-ft-addr=%p, length-field-name=\"%s\"",
@@ -2885,89 +2641,33 @@ end:
        return (void *) sequence;
 }
 
-BT_HIDDEN
-struct bt_field_type_common *bt_field_type_common_sequence_borrow_element_field_type(
-               struct bt_field_type_common *ft)
-{
-       struct bt_field_type_common_sequence *seq_ft = BT_FROM_COMMON(ft);
-
-       BT_ASSERT_PRE_NON_NULL(ft, "Field type");
-       BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_SEQUENCE,
-               "Field type");
-       return seq_ft->element_ft;
-}
-
 struct bt_field_type *bt_field_type_sequence_borrow_element_field_type(
                struct bt_field_type *ft)
 {
-       return (void *) bt_field_type_common_sequence_borrow_element_field_type(
-               (void *) ft);
-}
-
-BT_HIDDEN
-int bt_field_type_common_sequence_set_element_field_type(
-               struct bt_field_type_common *ft,
-               struct bt_field_type_common *element_ft)
-{
-       int ret = 0;
-       struct bt_field_type_common_sequence *seq_ft = BT_FROM_COMMON(ft);
-
-       if (!ft) {
-               BT_LOGW_STR("Invalid parameter: sequence field type is NULL.");
-               ret = -1;
-               goto end;
-       }
-
-       if (!element_ft) {
-               BT_LOGW_STR("Invalid parameter: element field type is NULL.");
-               ret = -1;
-               goto end;
-       }
-
-       if (ft->id != BT_FIELD_TYPE_ID_SEQUENCE) {
-               BT_LOGW("Invalid parameter: field type is not a sequence field type: "
-                       "addr=%p, ft-id=%s", ft,
-                       bt_common_field_type_id_string(ft->id));
-               ret = -1;
-               goto end;
-       }
-
-       if (seq_ft->element_ft) {
-               BT_PUT(seq_ft->element_ft);
-       }
-
-       seq_ft->element_ft = element_ft;
-       bt_get(seq_ft->element_ft);
-       BT_LOGV("Set sequence field type's element field type: sequence-ft-addr=%p, "
-               "element-ft-addr=%p", ft, element_ft);
-
-end:
-       return ret;
-}
-
-BT_HIDDEN
-const char *bt_field_type_common_sequence_get_length_field_name(
-               struct bt_field_type_common *ft)
-{
-       struct bt_field_type_common_sequence *seq_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_sequence *seq_ft = (void *) ft;
 
        BT_ASSERT_PRE_NON_NULL(ft, "Field type");
-       BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_SEQUENCE,
+       BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_SEQUENCE,
                "Field type");
-       return seq_ft->length_field_name ?
-               seq_ft->length_field_name->str : NULL;
+       return seq_ft->element_ft;
 }
 
 const char *bt_field_type_sequence_get_length_field_name(
                struct bt_field_type *ft)
 {
-       return bt_field_type_common_sequence_get_length_field_name((void *) ft);
+       struct bt_field_type_sequence *seq_ft = (void *) ft;
+
+       BT_ASSERT_PRE_NON_NULL(ft, "Field type");
+       BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_SEQUENCE,
+               "Field type");
+       return seq_ft->length_field_name ?
+               seq_ft->length_field_name->str : NULL;
 }
 
 struct bt_field_type *bt_field_type_string_create(void)
 {
-       struct bt_field_type_common_string *string =
-               g_new0(struct bt_field_type_common_string, 1);
+       struct bt_field_type_string *string =
+               g_new0(struct bt_field_type_string, 1);
 
        BT_LOGD_STR("Creating string field type object.");
 
@@ -2976,37 +2676,29 @@ struct bt_field_type *bt_field_type_string_create(void)
                return NULL;
        }
 
-       bt_field_type_common_string_initialize(BT_TO_COMMON(string),
-               bt_field_type_common_string_destroy,
+       bt_field_type_string_initialize((void *) string,
+               bt_field_type_string_destroy,
                &bt_field_type_string_methods);
        BT_LOGD("Created string field type object: addr=%p", string);
        return (void *) string;
 }
 
-BT_HIDDEN
-enum bt_string_encoding bt_field_type_common_string_get_encoding(
-               struct bt_field_type_common *ft)
+enum bt_string_encoding bt_field_type_string_get_encoding(
+               struct bt_field_type *ft)
 {
-       struct bt_field_type_common_string *string_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_string *string_ft = (void *) ft;
 
        BT_ASSERT_PRE_NON_NULL(ft, "Field type");
-       BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_STRING,
+       BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_STRING,
                "Field type");
        return string_ft->encoding;
 }
 
-enum bt_string_encoding bt_field_type_string_get_encoding(
-               struct bt_field_type *ft)
-{
-       return bt_field_type_common_string_get_encoding((void *) ft);
-}
-
-BT_HIDDEN
-int bt_field_type_common_string_set_encoding(struct bt_field_type_common *ft,
+int bt_field_type_string_set_encoding(struct bt_field_type *ft,
                enum bt_string_encoding encoding)
 {
        int ret = 0;
-       struct bt_field_type_common_string *string_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_string *string_ft = (void *) ft;
 
        if (!ft) {
                BT_LOGW_STR("Invalid parameter: field type is NULL.");
@@ -3038,14 +2730,7 @@ end:
        return ret;
 }
 
-int bt_field_type_string_set_encoding(struct bt_field_type *ft,
-               enum bt_string_encoding encoding)
-{
-       return bt_field_type_common_string_set_encoding((void *) ft, encoding);
-}
-
-BT_HIDDEN
-int bt_field_type_common_get_alignment(struct bt_field_type_common *ft)
+int bt_field_type_get_alignment(struct bt_field_type *ft)
 {
        int ret;
        enum bt_field_type_id type_id;
@@ -3057,43 +2742,43 @@ int bt_field_type_common_get_alignment(struct bt_field_type_common *ft)
                goto end;
        }
 
-       type_id = bt_field_type_common_get_type_id(ft);
+       type_id = bt_field_type_get_type_id(ft);
        switch (type_id) {
        case BT_FIELD_TYPE_ID_SEQUENCE:
        {
-               struct bt_field_type_common *element_ft =
-                       bt_field_type_common_sequence_borrow_element_field_type(ft);
+               struct bt_field_type *element_ft =
+                       bt_field_type_sequence_borrow_element_field_type(ft);
 
                BT_ASSERT(element_ft);
-               ret = bt_field_type_common_get_alignment(element_ft);
+               ret = bt_field_type_get_alignment(element_ft);
                break;
        }
        case BT_FIELD_TYPE_ID_ARRAY:
        {
-               struct bt_field_type_common *element_ft =
-                       bt_field_type_common_array_borrow_element_field_type(ft);
+               struct bt_field_type *element_ft =
+                       bt_field_type_array_borrow_element_field_type(ft);
 
                BT_ASSERT(element_ft);
-               ret = bt_field_type_common_get_alignment(element_ft);
+               ret = bt_field_type_get_alignment(element_ft);
                break;
        }
        case BT_FIELD_TYPE_ID_STRUCT:
        {
                int64_t i, element_count;
 
-               element_count = bt_field_type_common_structure_get_field_count(
+               element_count = bt_field_type_structure_get_field_count(
                        ft);
                BT_ASSERT(element_count >= 0);
 
                for (i = 0; i < element_count; i++) {
-                       struct bt_field_type_common *field = NULL;
+                       struct bt_field_type *field = NULL;
                        int field_alignment;
 
-                       ret = bt_field_type_common_structure_borrow_field_by_index(
+                       ret = bt_field_type_structure_borrow_field_by_index(
                                ft, NULL, &field, i);
                        BT_ASSERT(ret == 0);
                        BT_ASSERT(field);
-                       field_alignment = bt_field_type_common_get_alignment(
+                       field_alignment = bt_field_type_get_alignment(
                                field);
                        if (field_alignment < 0) {
                                ret = field_alignment;
@@ -3119,19 +2804,13 @@ end:
        return ret;
 }
 
-int bt_field_type_get_alignment(struct bt_field_type *ft)
-{
-       return bt_field_type_common_get_alignment((void *) ft);
-}
-
 static inline
 int is_power_of_two(unsigned int value)
 {
        return ((value & (value - 1)) == 0) && value > 0;
 }
 
-BT_HIDDEN
-int bt_field_type_common_set_alignment(struct bt_field_type_common *ft,
+int bt_field_type_set_alignment(struct bt_field_type *ft,
                unsigned int alignment)
 {
        int ret = 0;
@@ -3158,7 +2837,7 @@ int bt_field_type_common_set_alignment(struct bt_field_type_common *ft,
                goto end;
        }
 
-       type_id = bt_field_type_common_get_type_id(ft);
+       type_id = bt_field_type_get_type_id(ft);
        if (type_id == BT_FIELD_TYPE_ID_UNKNOWN) {
                BT_LOGW("Invalid parameter: unknown field type ID: "
                        "addr=%p, ft-id=%d", ft, type_id);
@@ -3193,15 +2872,7 @@ end:
        return ret;
 }
 
-int bt_field_type_set_alignment(struct bt_field_type *ft,
-               unsigned int alignment)
-{
-       return bt_field_type_common_set_alignment((void *) ft, alignment);
-}
-
-BT_HIDDEN
-enum bt_byte_order bt_field_type_common_get_byte_order(
-               struct bt_field_type_common *ft)
+enum bt_byte_order bt_field_type_get_byte_order(struct bt_field_type *ft)
 {
        enum bt_byte_order ret = BT_BYTE_ORDER_UNKNOWN;
 
@@ -3210,25 +2881,22 @@ enum bt_byte_order bt_field_type_common_get_byte_order(
        switch (ft->id) {
        case BT_FIELD_TYPE_ID_INTEGER:
        {
-               struct bt_field_type_common_integer *integer =
-                       BT_FROM_COMMON(ft);
+               struct bt_field_type_integer *integer = (void *) ft;
 
                ret = integer->user_byte_order;
                break;
        }
        case BT_FIELD_TYPE_ID_ENUM:
        {
-               struct bt_field_type_common_enumeration *enum_ft =
-                       BT_FROM_COMMON(ft);
+               struct bt_field_type_enumeration *enum_ft = (void *) ft;
 
-               ret = bt_field_type_common_get_byte_order(
-                       BT_TO_COMMON(enum_ft->container_ft));
+               ret = bt_field_type_get_byte_order(
+                       (void *) enum_ft->container_ft);
                break;
        }
        case BT_FIELD_TYPE_ID_FLOAT:
        {
-               struct bt_field_type_common_floating_point *floating_point =
-                       BT_FROM_COMMON(ft);
+               struct bt_field_type_floating_point *floating_point = (void *) ft;
                ret = floating_point->user_byte_order;
                break;
        }
@@ -3248,13 +2916,7 @@ end:
        return ret;
 }
 
-enum bt_byte_order bt_field_type_get_byte_order(struct bt_field_type *ft)
-{
-       return bt_field_type_common_get_byte_order((void *) ft);
-}
-
-BT_HIDDEN
-int bt_field_type_common_set_byte_order(struct bt_field_type_common *ft,
+int bt_field_type_set_byte_order(struct bt_field_type *ft,
                enum bt_byte_order byte_order)
 {
        int ret = 0;
@@ -3294,67 +2956,14 @@ end:
        return ret;
 }
 
-int bt_field_type_set_byte_order(struct bt_field_type *ft,
-               enum bt_byte_order byte_order)
-{
-       return bt_field_type_common_set_byte_order((void *) ft, byte_order);
-}
-
-BT_HIDDEN
-enum bt_field_type_id bt_field_type_common_get_type_id(
-               struct bt_field_type_common *ft)
+enum bt_field_type_id bt_field_type_get_type_id(struct bt_field_type *ft)
 {
        BT_ASSERT_PRE_NON_NULL(ft, "Field type");
        return ft->id;
 }
 
-enum bt_field_type_id bt_field_type_get_type_id(struct bt_field_type *ft)
-{
-       return bt_field_type_common_get_type_id((void *) ft);
-}
-
-int bt_field_type_is_integer(struct bt_field_type *type)
-{
-       return bt_field_type_get_type_id(type) == BT_FIELD_TYPE_ID_INTEGER;
-}
-
-int bt_field_type_is_floating_point(struct bt_field_type *type)
-{
-       return bt_field_type_get_type_id(type) == BT_FIELD_TYPE_ID_FLOAT;
-}
-
-int bt_field_type_is_enumeration(struct bt_field_type *type)
-{
-       return bt_field_type_get_type_id(type) == BT_FIELD_TYPE_ID_ENUM;
-}
-
-int bt_field_type_is_string(struct bt_field_type *type)
-{
-       return bt_field_type_get_type_id(type) == BT_FIELD_TYPE_ID_STRING;
-}
-
-int bt_field_type_is_structure(struct bt_field_type *type)
-{
-       return bt_field_type_get_type_id(type) == BT_FIELD_TYPE_ID_STRUCT;
-}
-
-int bt_field_type_is_array(struct bt_field_type *type)
-{
-       return bt_field_type_get_type_id(type) == BT_FIELD_TYPE_ID_ARRAY;
-}
-
-int bt_field_type_is_sequence(struct bt_field_type *type)
-{
-       return bt_field_type_get_type_id(type) == BT_FIELD_TYPE_ID_SEQUENCE;
-}
-
-int bt_field_type_is_variant(struct bt_field_type *type)
-{
-       return bt_field_type_get_type_id(type) == BT_FIELD_TYPE_ID_VARIANT;
-}
-
 BT_HIDDEN
-void _bt_field_type_common_freeze(struct bt_field_type_common *ft)
+void bt_field_type_freeze(struct bt_field_type *ft)
 {
        if (!ft || ft->frozen) {
                return;
@@ -3364,88 +2973,9 @@ void _bt_field_type_common_freeze(struct bt_field_type_common *ft)
        ft->methods->freeze(ft);
 }
 
-BT_HIDDEN
-void _bt_field_type_freeze(struct bt_field_type *ft)
-{
-       _bt_field_type_common_freeze((void *) ft);
-}
-
-BT_HIDDEN
-struct bt_field_type_common *
-bt_field_type_common_variant_borrow_field_type_signed(
-               struct bt_field_type_common_variant *var_ft,
-               int64_t tag_value)
-{
-       struct bt_field_type_common *field_type = NULL;
-       GQuark field_name_quark;
-       gpointer index;
-       struct structure_field_common *field_entry;
-       struct range_overlap_query query = {
-               .range_start._signed = tag_value,
-               .range_end._signed = tag_value,
-               .mapping_name = 0,
-               .overlaps = 0,
-       };
-
-       g_ptr_array_foreach(var_ft->tag_ft->entries, check_ranges_overlap,
-               &query);
-       if (!query.overlaps) {
-               goto end;
-       }
-
-       field_name_quark = query.mapping_name;
-       if (!g_hash_table_lookup_extended(var_ft->field_name_to_index,
-                       GUINT_TO_POINTER(field_name_quark), NULL, &index)) {
-               goto end;
-       }
-
-       field_entry = g_ptr_array_index(var_ft->fields, (size_t) index);
-       field_type = field_entry->type;
-
-end:
-       return field_type;
-}
-
-BT_HIDDEN
-struct bt_field_type_common *
-bt_field_type_common_variant_borrow_field_type_unsigned(
-               struct bt_field_type_common_variant *var_ft,
-               uint64_t tag_value)
-{
-       struct bt_field_type_common *field_type = NULL;
-       GQuark field_name_quark;
-       gpointer index;
-       struct structure_field_common *field_entry;
-       struct range_overlap_query query = {
-               .range_start._unsigned = tag_value,
-               .range_end._unsigned = tag_value,
-               .mapping_name = 0,
-               .overlaps = 0,
-       };
-
-       g_ptr_array_foreach(var_ft->tag_ft->entries,
-               check_ranges_overlap_unsigned, &query);
-       if (!query.overlaps) {
-               goto end;
-       }
-
-       field_name_quark = query.mapping_name;
-       if (!g_hash_table_lookup_extended(var_ft->field_name_to_index,
-               GUINT_TO_POINTER(field_name_quark), NULL, &index)) {
-               goto end;
-       }
-
-       field_entry = g_ptr_array_index(var_ft->fields, (size_t) index);
-       field_type = field_entry->type;
-end:
-       return field_type;
-}
-
-BT_HIDDEN
-struct bt_field_type_common *bt_field_type_common_copy(
-               struct bt_field_type_common *ft)
+struct bt_field_type *bt_field_type_copy(struct bt_field_type *ft)
 {
-       struct bt_field_type_common *ft_copy = NULL;
+       struct bt_field_type *ft_copy = NULL;
 
        BT_ASSERT_PRE_NON_NULL(ft, "Field type");
        BT_ASSERT(ft->methods->copy);
@@ -3461,23 +2991,18 @@ end:
        return ft_copy;
 }
 
-struct bt_field_type *bt_field_type_copy(struct bt_field_type *ft)
-{
-       return (void *) bt_field_type_common_copy((void *) ft);
-}
-
-BT_HIDDEN
-int bt_field_type_common_structure_get_field_name_index(
-               struct bt_field_type_common *ft, const char *name)
+static inline
+int bt_field_type_structure_get_field_name_index(
+               struct bt_field_type *ft, const char *name)
 {
        int ret;
        size_t index;
        GQuark name_quark;
-       struct bt_field_type_common_structure *struct_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_structure *struct_ft = (void *) ft;
 
        BT_ASSERT_PRE_NON_NULL(ft, "Field type");
        BT_ASSERT_PRE_NON_NULL(name, "Name");
-       BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_STRUCT,
+       BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_STRUCT,
                "Field type");
 
        name_quark = g_quark_try_string(name);
@@ -3505,18 +3030,18 @@ end:
        return ret;
 }
 
-BT_HIDDEN
-int bt_field_type_common_variant_get_field_name_index(
-               struct bt_field_type_common *ft, const char *name)
+static inline
+int bt_field_type_variant_get_field_name_index(
+               struct bt_field_type *ft, const char *name)
 {
        int ret;
        size_t index;
        GQuark name_quark;
-       struct bt_field_type_common_variant *var_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_variant *var_ft = (void *) ft;
 
        BT_ASSERT_PRE_NON_NULL(ft, "Field type");
        BT_ASSERT_PRE_NON_NULL(name, "Name");
-       BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_VARIANT,
+       BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_VARIANT,
                "Field type");
        name_quark = g_quark_try_string(name);
        if (!name_quark) {
@@ -3527,7 +3052,7 @@ int bt_field_type_common_variant_get_field_name_index(
                goto end;
        }
 
-       if (!g_hash_table_lookup_extended(var_ft->field_name_to_index,
+       if (!g_hash_table_lookup_extended(var_ft->choice_name_to_index,
                        GUINT_TO_POINTER(name_quark),
                        NULL, (gpointer *) &index)) {
                BT_LOGV("No such variant field type field name: "
@@ -3544,11 +3069,11 @@ end:
 }
 
 BT_HIDDEN
-int bt_field_type_common_sequence_set_length_field_path(
-               struct bt_field_type_common *ft, struct bt_field_path *path)
+int bt_field_type_sequence_set_length_field_path(
+               struct bt_field_type *ft, struct bt_field_path *path)
 {
        int ret = 0;
-       struct bt_field_type_common_sequence *seq_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_sequence *seq_ft = (void *) ft;
 
        if (!ft) {
                BT_LOGW_STR("Invalid parameter: field type is NULL.");
@@ -3574,12 +3099,12 @@ end:
 }
 
 BT_HIDDEN
-int bt_field_type_common_variant_set_tag_field_path(
-               struct bt_field_type_common *ft,
+int bt_field_type_variant_set_tag_field_path(
+               struct bt_field_type *ft,
                struct bt_field_path *path)
 {
        int ret = 0;
-       struct bt_field_type_common_variant *var_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_variant *var_ft = (void *) ft;
 
        if (!ft) {
                BT_LOGW_STR("Invalid parameter: field type is NULL.");
@@ -3605,12 +3130,12 @@ end:
 }
 
 BT_HIDDEN
-int bt_field_type_common_variant_set_tag_field_type(
-               struct bt_field_type_common *ft,
-               struct bt_field_type_common *tag_ft)
+int bt_field_type_variant_set_tag_field_type(
+               struct bt_field_type *ft,
+               struct bt_field_type *tag_ft)
 {
        int ret = 0;
-       struct bt_field_type_common_variant *var_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_variant *var_ft = (void *) ft;
 
        if (!ft) {
                BT_LOGW_STR("Invalid parameter: variant field type is NULL.");
@@ -3641,181 +3166,249 @@ end:
        return ret;
 }
 
-BT_HIDDEN
-void bt_field_type_common_generic_freeze(struct bt_field_type_common *ft)
+static
+void bt_field_type_generic_freeze(struct bt_field_type *ft)
 {
        ft->frozen = 1;
 }
 
-BT_HIDDEN
-void bt_field_type_common_enumeration_freeze_recursive(
-               struct bt_field_type_common *ft)
+static
+void bt_field_type_enumeration_freeze_recursive(
+               struct bt_field_type *ft)
 {
-       struct bt_field_type_common_enumeration *enum_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_enumeration *enum_ft = (void *) ft;
 
        BT_LOGD("Freezing enumeration field type object: addr=%p", ft);
-       bt_field_type_common_enumeration_set_range_overlap(enum_ft);
-       bt_field_type_common_generic_freeze(ft);
+       bt_field_type_enumeration_set_range_overlap(enum_ft);
+       bt_field_type_generic_freeze(ft);
        BT_LOGD("Freezing enumeration field type object's container field type: int-ft-addr=%p",
                enum_ft->container_ft);
-       bt_field_type_common_freeze(BT_TO_COMMON(enum_ft->container_ft));
+       bt_field_type_freeze((void *) enum_ft->container_ft);
 }
 
 static
-void freeze_structure_field(struct structure_field_common *field)
+void bt_field_type_structure_freeze_recursive(
+               struct bt_field_type *ft)
 {
-       BT_LOGD("Freezing structure/variant field type field: field-addr=%p, "
-               "field-ft-addr=%p, field-name=\"%s\"", field,
-               field->type, g_quark_to_string(field->name));
-       bt_field_type_common_freeze(field->type);
+       struct bt_field_type_structure *struct_ft = (void *) ft;
+       uint64_t i;
+
+       /* Cache the alignment */
+       BT_LOGD("Freezing structure field type object: addr=%p", ft);
+       ft->alignment = bt_field_type_get_alignment(ft);
+       bt_field_type_generic_freeze(ft);
+
+       for (i = 0; i < struct_ft->fields->len; i++) {
+               struct bt_field_type_structure_field *field =
+                       BT_FIELD_TYPE_STRUCTURE_FIELD_AT_INDEX(ft, i);
+
+               BT_LOGD("Freezing structure field type field: "
+                       "ft-addr=%p, name=\"%s\"",
+                       field->type, g_quark_to_string(field->name));
+               bt_field_type_freeze(field->type);
+       }
 }
 
 BT_HIDDEN
-void bt_field_type_common_structure_freeze_recursive(
-               struct bt_field_type_common *ft)
+int bt_field_type_variant_update_choices(struct bt_field_type *ft)
 {
-       struct bt_field_type_common_structure *struct_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_variant *var_ft = (void *) ft;
+       uint64_t i;
+       int ret = 0;
+       bool is_signed;
 
-       /* Cache the alignment */
-       BT_LOGD("Freezing structure field type object: addr=%p", ft);
-       ft->alignment = bt_field_type_common_get_alignment(ft);
-       bt_field_type_common_generic_freeze(ft);
-       g_ptr_array_foreach(struct_ft->fields,
-               (GFunc) freeze_structure_field, NULL);
+       if (ft->frozen && var_ft->choices_up_to_date) {
+               goto end;
+       }
+
+       BT_ASSERT(var_ft->tag_ft);
+       is_signed = !!var_ft->tag_ft->container_ft->is_signed;
+
+       for (i = 0; i < var_ft->choices->len; i++) {
+               struct bt_field_type_variant_choice *choice =
+                       BT_FIELD_TYPE_VARIANT_CHOICE_AT_INDEX(ft, i);
+               const char *choice_name = g_quark_to_string(choice->name);
+               struct bt_field_type_enumeration_mapping_iterator *iter =
+                       bt_field_type_enumeration_find_mappings_by_name(
+                               (void *) var_ft->tag_ft, choice_name);
+
+               if (!iter) {
+                       ret = -1;
+                       goto end;
+               }
+
+               BT_ASSERT(choice->ranges);
+               g_array_set_size(choice->ranges, 0);
+
+               while (bt_field_type_enumeration_mapping_iterator_next(iter) == 0) {
+                       struct bt_field_type_variant_choice_range range;
+
+                       if (is_signed) {
+                               ret = bt_field_type_enumeration_mapping_iterator_signed_get(
+                                       iter, NULL,
+                                       &range.lower.i, &range.upper.i);
+                       } else {
+                               ret = bt_field_type_enumeration_mapping_iterator_unsigned_get(
+                                       iter, NULL,
+                                       &range.lower.u, &range.upper.u);
+                       }
+
+                       BT_ASSERT(ret == 0);
+                       g_array_append_val(choice->ranges, range);
+               }
+
+               bt_put(iter);
+       }
+
+       var_ft->choices_up_to_date = true;
+
+end:
+       return ret;
 }
 
-BT_HIDDEN
-void bt_field_type_common_variant_freeze_recursive(
-               struct bt_field_type_common *ft)
+static
+void bt_field_type_variant_freeze_recursive(
+               struct bt_field_type *ft)
 {
-       struct bt_field_type_common_variant *var_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_variant *var_ft = (void *) ft;
+       uint64_t i;
 
        BT_LOGD("Freezing variant field type object: addr=%p", ft);
-       bt_field_type_common_generic_freeze(ft);
-       g_ptr_array_foreach(var_ft->fields,
-               (GFunc) freeze_structure_field, NULL);
+       bt_field_type_generic_freeze(ft);
+
+       for (i = 0; i < var_ft->choices->len; i++) {
+               struct bt_field_type_variant_choice *choice =
+                       BT_FIELD_TYPE_VARIANT_CHOICE_AT_INDEX(ft, i);
+
+               BT_LOGD("Freezing variant field type member: "
+                       "ft-addr=%p, name=\"%s\"",
+                       choice->type, g_quark_to_string(choice->name));
+               bt_field_type_freeze(choice->type);
+       }
 }
 
-BT_HIDDEN
-void bt_field_type_common_array_freeze_recursive(
-               struct bt_field_type_common *ft)
+static
+void bt_field_type_array_freeze_recursive(
+               struct bt_field_type *ft)
 {
-       struct bt_field_type_common_array *array_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_array *array_ft = (void *) ft;
 
        /* Cache the alignment */
        BT_LOGD("Freezing array field type object: addr=%p", ft);
-       ft->alignment = bt_field_type_common_get_alignment(ft);
-       bt_field_type_common_generic_freeze(ft);
+       ft->alignment = bt_field_type_get_alignment(ft);
+       bt_field_type_generic_freeze(ft);
        BT_LOGD("Freezing array field type object's element field type: element-ft-addr=%p",
                array_ft->element_ft);
-       bt_field_type_common_freeze(array_ft->element_ft);
+       bt_field_type_freeze(array_ft->element_ft);
 }
 
-BT_HIDDEN
-void bt_field_type_common_sequence_freeze_recursive(
-               struct bt_field_type_common *ft)
+static
+void bt_field_type_sequence_freeze_recursive(
+               struct bt_field_type *ft)
 {
-       struct bt_field_type_common_sequence *seq_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_sequence *seq_ft = (void *) ft;
 
        /* Cache the alignment */
        BT_LOGD("Freezing sequence field type object: addr=%p", ft);
-       ft->alignment = bt_field_type_common_get_alignment(ft);
-       bt_field_type_common_generic_freeze(ft);
+       ft->alignment = bt_field_type_get_alignment(ft);
+       bt_field_type_generic_freeze(ft);
        BT_LOGD("Freezing sequence field type object's element field type: element-ft-addr=%p",
                seq_ft->element_ft);
-       bt_field_type_common_freeze(seq_ft->element_ft);
+       bt_field_type_freeze(seq_ft->element_ft);
 }
 
-BT_HIDDEN
-void bt_field_type_common_integer_set_byte_order(
-               struct bt_field_type_common *ft, enum bt_byte_order byte_order)
+static
+void bt_field_type_integer_set_byte_order(
+               struct bt_field_type *ft, enum bt_byte_order byte_order)
 {
-       struct bt_field_type_common_integer *int_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_integer *int_ft = (void *) ft;
 
        int_ft->user_byte_order = byte_order;
 }
 
-BT_HIDDEN
-void bt_field_type_common_enumeration_set_byte_order_recursive(
-               struct bt_field_type_common *ft, enum bt_byte_order byte_order)
+static
+void bt_field_type_enumeration_set_byte_order_recursive(
+               struct bt_field_type *ft, enum bt_byte_order byte_order)
 {
-       struct bt_field_type_common_enumeration *enum_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_enumeration *enum_ft = (void *) ft;
 
-       bt_field_type_common_set_byte_order(BT_TO_COMMON(enum_ft->container_ft),
+       bt_field_type_set_byte_order((void *) enum_ft->container_ft,
                byte_order);
 }
 
-BT_HIDDEN
-void bt_field_type_common_floating_point_set_byte_order(
-               struct bt_field_type_common *ft, enum bt_byte_order byte_order)
+static
+void bt_field_type_floating_point_set_byte_order(
+               struct bt_field_type *ft, enum bt_byte_order byte_order)
 {
-       struct bt_field_type_common_floating_point *flt_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_floating_point *flt_ft = (void *) ft;
 
        flt_ft->user_byte_order = byte_order;
 }
 
-BT_HIDDEN
-void bt_field_type_common_structure_set_byte_order_recursive(
-               struct bt_field_type_common *ft,
+static
+void bt_field_type_structure_set_byte_order_recursive(
+               struct bt_field_type *ft,
                enum bt_byte_order byte_order)
 {
        int i;
-       struct bt_field_type_common_structure *struct_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_structure *struct_ft = (void *) ft;
 
        for (i = 0; i < struct_ft->fields->len; i++) {
-               struct structure_field_common *field = g_ptr_array_index(
-                       struct_ft->fields, i);
-               struct bt_field_type_common *field_type = field->type;
+               struct bt_field_type_structure_field *field =
+                       BT_FIELD_TYPE_STRUCTURE_FIELD_AT_INDEX(
+                               struct_ft, i);
+               struct bt_field_type *field_type = field->type;
 
-               bt_field_type_common_set_byte_order(field_type, byte_order);
+               bt_field_type_set_byte_order(field_type, byte_order);
        }
 }
 
-BT_HIDDEN
-void bt_field_type_common_variant_set_byte_order_recursive(
-               struct bt_field_type_common *ft,
+static
+void bt_field_type_variant_set_byte_order_recursive(
+               struct bt_field_type *ft,
                enum bt_byte_order byte_order)
 {
        int i;
-       struct bt_field_type_common_variant *var_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_variant *var_ft = (void *) ft;
 
-       for (i = 0; i < var_ft->fields->len; i++) {
-               struct structure_field_common *field = g_ptr_array_index(
-                       var_ft->fields, i);
-               struct bt_field_type_common *field_type = field->type;
+       for (i = 0; i < var_ft->choices->len; i++) {
+               struct bt_field_type_variant_choice *choice =
+                       BT_FIELD_TYPE_VARIANT_CHOICE_AT_INDEX(
+                               var_ft, i);
+               struct bt_field_type *field_type = choice->type;
 
-               bt_field_type_common_set_byte_order(field_type, byte_order);
+               bt_field_type_set_byte_order(field_type, byte_order);
        }
 }
 
-BT_HIDDEN
-void bt_field_type_common_array_set_byte_order_recursive(
-               struct bt_field_type_common *ft,
+static
+void bt_field_type_array_set_byte_order_recursive(
+               struct bt_field_type *ft,
                enum bt_byte_order byte_order)
 {
-       struct bt_field_type_common_array *array_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_array *array_ft = (void *) ft;
 
-       bt_field_type_common_set_byte_order(array_ft->element_ft, byte_order);
+       bt_field_type_set_byte_order(array_ft->element_ft, byte_order);
 }
 
-BT_HIDDEN
-void bt_field_type_common_sequence_set_byte_order_recursive(
-               struct bt_field_type_common *ft,
+static
+void bt_field_type_sequence_set_byte_order_recursive(
+               struct bt_field_type *ft,
                enum bt_byte_order byte_order)
 {
-       struct bt_field_type_common_sequence *seq_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_sequence *seq_ft = (void *) ft;
 
-       bt_field_type_common_set_byte_order(seq_ft->element_ft, byte_order);
+       bt_field_type_set_byte_order(seq_ft->element_ft, byte_order);
 }
 
 
-BT_HIDDEN
-int bt_field_type_common_integer_compare(struct bt_field_type_common *ft_a,
-               struct bt_field_type_common *ft_b)
+static
+int bt_field_type_integer_compare(struct bt_field_type *ft_a,
+               struct bt_field_type *ft_b)
 {
        int ret = 1;
-       struct bt_field_type_common_integer *int_ft_a = BT_FROM_COMMON(ft_a);
-       struct bt_field_type_common_integer *int_ft_b = BT_FROM_COMMON(ft_b);
+       struct bt_field_type_integer *int_ft_a = (void *) ft_a;
+       struct bt_field_type_integer *int_ft_b = (void *) ft_b;
 
        /* Length */
        if (int_ft_a->size != int_ft_b->size) {
@@ -3890,16 +3483,14 @@ end:
        return ret;
 }
 
-BT_HIDDEN
-int bt_field_type_common_floating_point_compare(
-               struct bt_field_type_common *ft_a,
-               struct bt_field_type_common *ft_b)
+static
+int bt_field_type_floating_point_compare(
+               struct bt_field_type *ft_a,
+               struct bt_field_type *ft_b)
 {
        int ret = 1;
-       struct bt_field_type_common_floating_point *flt_ft_a =
-               BT_FROM_COMMON(ft_a);
-       struct bt_field_type_common_floating_point *flt_ft_b =
-               BT_FROM_COMMON(ft_b);
+       struct bt_field_type_floating_point *flt_ft_a = (void *) ft_a;
+       struct bt_field_type_floating_point *flt_ft_b = (void *) ft_b;
 
        /* Byte order */
        if (flt_ft_a->user_byte_order != flt_ft_b->user_byte_order) {
@@ -3977,22 +3568,19 @@ end:
        return ret;
 }
 
-BT_HIDDEN
-int bt_field_type_common_enumeration_compare_recursive(
-               struct bt_field_type_common *ft_a,
-               struct bt_field_type_common *ft_b)
+static
+int bt_field_type_enumeration_compare_recursive(
+               struct bt_field_type *ft_a,
+               struct bt_field_type *ft_b)
 {
        int ret = 1;
        int i;
-       struct bt_field_type_common_enumeration *enum_ft_a =
-               BT_FROM_COMMON(ft_a);
-       struct bt_field_type_common_enumeration *enum_ft_b =
-               BT_FROM_COMMON(ft_b);
+       struct bt_field_type_enumeration *enum_ft_a = (void *) ft_a;
+       struct bt_field_type_enumeration *enum_ft_b = (void *) ft_b;
 
        /* Container field type */
-       ret = bt_field_type_common_compare(
-               BT_TO_COMMON(enum_ft_a->container_ft),
-               BT_TO_COMMON(enum_ft_b->container_ft));
+       ret = bt_field_type_compare((void *) enum_ft_a->container_ft,
+               (void *) enum_ft_b->container_ft);
        if (ret) {
                BT_LOGV("Enumeration field types differ: different container field types: "
                        "ft-a-container-ft-addr=%p, ft-b-container-ft-addr=%p",
@@ -4031,13 +3619,13 @@ end:
        return ret;
 }
 
-BT_HIDDEN
-int bt_field_type_common_string_compare(struct bt_field_type_common *ft_a,
-               struct bt_field_type_common *ft_b)
+static
+int bt_field_type_string_compare(struct bt_field_type *ft_a,
+               struct bt_field_type *ft_b)
 {
        int ret = 1;
-       struct bt_field_type_common_string *string_ft_a = BT_FROM_COMMON(ft_a);
-       struct bt_field_type_common_string *string_ft_b = BT_FROM_COMMON(ft_b);
+       struct bt_field_type_string *string_ft_a = (void *) ft_a;
+       struct bt_field_type_string *string_ft_b = (void *) ft_b;
 
        /* Encoding */
        if (string_ft_a->encoding != string_ft_b->encoding) {
@@ -4056,52 +3644,52 @@ end:
 }
 
 static
-int compare_structure_fields(struct structure_field_common *field_a,
-               struct structure_field_common *field_b)
+int compare_structure_variant_members(
+               struct bt_field_type *member_a_ft,
+               struct bt_field_type *member_b_ft,
+               GQuark member_a_name, GQuark member_b_name)
 {
        int ret = 1;
 
        /* Label */
-       if (field_a->name != field_b->name) {
+       if (member_a_name != member_b_name) {
                BT_LOGV("Structure/variant field type fields differ: different names: "
                        "field-a-name=%s, field-b-name=%s",
-                       g_quark_to_string(field_a->name),
-                       g_quark_to_string(field_b->name));
+                       g_quark_to_string(member_a_name),
+                       g_quark_to_string(member_b_name));
                goto end;
        }
 
        /* Type */
-       ret = bt_field_type_common_compare(field_a->type, field_b->type);
+       ret = bt_field_type_compare(member_a_ft, member_b_ft);
        if (ret == 1) {
                BT_LOGV("Structure/variant field type fields differ: different field types: "
                        "field-name=\"%s\", field-a-ft-addr=%p, field-b-ft-addr=%p",
-                       g_quark_to_string(field_a->name),
-                       field_a->type, field_b->type);
+                       g_quark_to_string(member_a_name),
+                       member_a_ft, member_b_ft);
        }
 
 end:
        return ret;
 }
 
-BT_HIDDEN
-int bt_field_type_common_structure_compare_recursive(
-               struct bt_field_type_common *ft_a,
-               struct bt_field_type_common *ft_b)
+static
+int bt_field_type_structure_compare_recursive(
+               struct bt_field_type *ft_a,
+               struct bt_field_type *ft_b)
 {
        int ret = 1;
        int i;
-       struct bt_field_type_common_structure *struct_ft_a =
-               BT_FROM_COMMON(ft_a);
-       struct bt_field_type_common_structure *struct_ft_b =
-               BT_FROM_COMMON(ft_b);
+       struct bt_field_type_structure *struct_ft_a = (void *) ft_a;
+       struct bt_field_type_structure *struct_ft_b = (void *) ft_b;
 
        /* Alignment */
-       if (bt_field_type_common_get_alignment(ft_a) !=
-                       bt_field_type_common_get_alignment(ft_b)) {
+       if (bt_field_type_get_alignment(ft_a) !=
+                       bt_field_type_get_alignment(ft_b)) {
                BT_LOGV("Structure field types differ: different alignments: "
                        "ft-a-align=%u, ft-b-align=%u",
-                       bt_field_type_common_get_alignment(ft_a),
-                       bt_field_type_common_get_alignment(ft_b));
+                       bt_field_type_get_alignment(ft_a),
+                       bt_field_type_get_alignment(ft_b));
                goto end;
        }
 
@@ -4114,14 +3702,17 @@ int bt_field_type_common_structure_compare_recursive(
        }
 
        for (i = 0; i < struct_ft_a->fields->len; ++i) {
-               struct structure_field_common *field_a =
-                       g_ptr_array_index(struct_ft_a->fields, i);
-               struct structure_field_common *field_b =
-                       g_ptr_array_index(struct_ft_b->fields, i);
-
-               ret = compare_structure_fields(field_a, field_b);
+               struct bt_field_type_structure_field *field_a =
+                       BT_FIELD_TYPE_STRUCTURE_FIELD_AT_INDEX(
+                               struct_ft_a, i);
+               struct bt_field_type_structure_field *field_b =
+                       BT_FIELD_TYPE_STRUCTURE_FIELD_AT_INDEX(
+                               struct_ft_b, i);
+
+               ret = compare_structure_variant_members(field_a->type,
+                       field_b->type, field_a->name, field_b->name);
                if (ret) {
-                       /* compare_structure_fields() logs what differs */
+                       /* compare_structure_variant_members() logs what differs */
                        BT_LOGV_STR("Structure field types differ: different fields.");
                        goto end;
                }
@@ -4134,15 +3725,15 @@ end:
        return ret;
 }
 
-BT_HIDDEN
-int bt_field_type_common_variant_compare_recursive(
-               struct bt_field_type_common *ft_a,
-               struct bt_field_type_common *ft_b)
+static
+int bt_field_type_variant_compare_recursive(
+               struct bt_field_type *ft_a,
+               struct bt_field_type *ft_b)
 {
        int ret = 1;
        int i;
-       struct bt_field_type_common_variant *var_ft_a = BT_FROM_COMMON(ft_a);
-       struct bt_field_type_common_variant *var_ft_b = BT_FROM_COMMON(ft_b);
+       struct bt_field_type_variant *var_ft_a = (void *) ft_a;
+       struct bt_field_type_variant *var_ft_b = (void *) ft_b;
 
        /* Tag name */
        if (strcmp(var_ft_a->tag_name->str, var_ft_b->tag_name->str)) {
@@ -4153,8 +3744,8 @@ int bt_field_type_common_variant_compare_recursive(
        }
 
        /* Tag type */
-       ret = bt_field_type_common_compare(BT_TO_COMMON(var_ft_a->tag_ft),
-               BT_TO_COMMON(var_ft_b->tag_ft));
+       ret = bt_field_type_compare((void *) var_ft_a->tag_ft,
+               (void *) var_ft_b->tag_ft);
        if (ret) {
                BT_LOGV("Variant field types differ: different tag field types: "
                        "ft-a-tag-ft-addr=%p, ft-b-tag-ft-addr=%p",
@@ -4165,22 +3756,25 @@ int bt_field_type_common_variant_compare_recursive(
        ret = 1;
 
        /* Fields */
-       if (var_ft_a->fields->len != var_ft_b->fields->len) {
-               BT_LOGV("Structure field types differ: different field counts: "
+       if (var_ft_a->choices->len != var_ft_b->choices->len) {
+               BT_LOGV("Variant field types differ: different field counts: "
                        "ft-a-field-count=%u, ft-b-field-count=%u",
-                       var_ft_a->fields->len, var_ft_b->fields->len);
+                       var_ft_a->choices->len, var_ft_b->choices->len);
                goto end;
        }
 
-       for (i = 0; i < var_ft_a->fields->len; ++i) {
-               struct structure_field_common *field_a =
-                       g_ptr_array_index(var_ft_a->fields, i);
-               struct structure_field_common *field_b =
-                       g_ptr_array_index(var_ft_b->fields, i);
+       for (i = 0; i < var_ft_a->choices->len; ++i) {
+               struct bt_field_type_variant_choice *choice_a =
+                       BT_FIELD_TYPE_VARIANT_CHOICE_AT_INDEX(
+                               var_ft_a, i);
+               struct bt_field_type_variant_choice *choice_b =
+                       BT_FIELD_TYPE_VARIANT_CHOICE_AT_INDEX(
+                               var_ft_b, i);
 
-               ret = compare_structure_fields(field_a, field_b);
+               ret = compare_structure_variant_members(choice_a->type,
+                       choice_b->type, choice_a->name, choice_b->name);
                if (ret) {
-                       /* compare_structure_fields() logs what differs */
+                       /* compare_structure_variant_members() logs what differs */
                        BT_LOGV_STR("Variant field types differ: different fields.");
                        goto end;
                }
@@ -4193,14 +3787,14 @@ end:
        return ret;
 }
 
-BT_HIDDEN
-int bt_field_type_common_array_compare_recursive(
-               struct bt_field_type_common *ft_a,
-               struct bt_field_type_common *ft_b)
+static
+int bt_field_type_array_compare_recursive(
+               struct bt_field_type *ft_a,
+               struct bt_field_type *ft_b)
 {
        int ret = 1;
-       struct bt_field_type_common_array *array_ft_a = BT_FROM_COMMON(ft_a);
-       struct bt_field_type_common_array *array_ft_b = BT_FROM_COMMON(ft_b);
+       struct bt_field_type_array *array_ft_a = (void *) ft_a;
+       struct bt_field_type_array *array_ft_b = (void *) ft_b;
 
        /* Length */
        if (array_ft_a->length != array_ft_b->length) {
@@ -4211,7 +3805,7 @@ int bt_field_type_common_array_compare_recursive(
        }
 
        /* Element type */
-       ret = bt_field_type_common_compare(array_ft_a->element_ft,
+       ret = bt_field_type_compare(array_ft_a->element_ft,
                array_ft_b->element_ft);
        if (ret == 1) {
                BT_LOGV("Array field types differ: different element field types: "
@@ -4223,14 +3817,14 @@ end:
        return ret;
 }
 
-BT_HIDDEN
-int bt_field_type_common_sequence_compare_recursive(
-               struct bt_field_type_common *ft_a,
-               struct bt_field_type_common *ft_b)
+static
+int bt_field_type_sequence_compare_recursive(
+               struct bt_field_type *ft_a,
+               struct bt_field_type *ft_b)
 {
        int ret = -1;
-       struct bt_field_type_common_sequence *seq_ft_a = BT_FROM_COMMON(ft_a);
-       struct bt_field_type_common_sequence *seq_ft_b = BT_FROM_COMMON(ft_b);
+       struct bt_field_type_sequence *seq_ft_a = (void *) ft_a;
+       struct bt_field_type_sequence *seq_ft_b = (void *) ft_b;
 
        /* Length name */
        if (strcmp(seq_ft_a->length_field_name->str,
@@ -4244,7 +3838,7 @@ int bt_field_type_common_sequence_compare_recursive(
        }
 
        /* Element type */
-       ret = bt_field_type_common_compare(seq_ft_a->element_ft,
+       ret = bt_field_type_compare(seq_ft_a->element_ft,
                        seq_ft_b->element_ft);
        if (ret == 1) {
                BT_LOGV("Sequence field types differ: different element field types: "
@@ -4257,8 +3851,8 @@ end:
 }
 
 BT_HIDDEN
-int bt_field_type_common_compare(struct bt_field_type_common *ft_a,
-               struct bt_field_type_common *ft_b)
+int bt_field_type_compare(struct bt_field_type *ft_a,
+               struct bt_field_type *ft_b)
 {
        int ret = 1;
 
@@ -4311,25 +3905,19 @@ end:
        return ret;
 }
 
-int bt_field_type_compare(struct bt_field_type *ft_a,
-               struct bt_field_type *ft_b)
-{
-       return bt_field_type_common_compare((void *) ft_a, (void *) ft_b);
-}
-
 BT_HIDDEN
-int64_t bt_field_type_common_get_field_count(struct bt_field_type_common *ft)
+int64_t bt_field_type_get_field_count(struct bt_field_type *ft)
 {
        int64_t field_count = -1;
 
        switch (ft->id) {
        case BT_FIELD_TYPE_ID_STRUCT:
                field_count =
-                       bt_field_type_common_structure_get_field_count(ft);
+                       bt_field_type_structure_get_field_count(ft);
                break;
        case BT_FIELD_TYPE_ID_VARIANT:
                field_count =
-                       bt_field_type_common_variant_get_field_count(ft);
+                       bt_field_type_variant_get_field_count(ft);
                break;
        case BT_FIELD_TYPE_ID_ARRAY:
        case BT_FIELD_TYPE_ID_SEQUENCE:
@@ -4347,15 +3935,15 @@ int64_t bt_field_type_common_get_field_count(struct bt_field_type_common *ft)
 }
 
 BT_HIDDEN
-struct bt_field_type_common *bt_field_type_common_borrow_field_at_index(
-               struct bt_field_type_common *ft, int index)
+struct bt_field_type *bt_field_type_borrow_field_at_index(
+               struct bt_field_type *ft, int index)
 {
-       struct bt_field_type_common *field_type = NULL;
+       struct bt_field_type *field_type = NULL;
 
        switch (ft->id) {
        case BT_FIELD_TYPE_ID_STRUCT:
        {
-               int ret = bt_field_type_common_structure_borrow_field_by_index(
+               int ret = bt_field_type_structure_borrow_field_by_index(
                        ft, NULL, &field_type, index);
                if (ret) {
                        field_type = NULL;
@@ -4365,7 +3953,7 @@ struct bt_field_type_common *bt_field_type_common_borrow_field_at_index(
        }
        case BT_FIELD_TYPE_ID_VARIANT:
        {
-               int ret = bt_field_type_common_variant_borrow_field_by_index(
+               int ret = bt_field_type_variant_borrow_field_by_index(
                        ft, NULL, &field_type, index);
                if (ret) {
                        field_type = NULL;
@@ -4375,11 +3963,11 @@ struct bt_field_type_common *bt_field_type_common_borrow_field_at_index(
        }
        case BT_FIELD_TYPE_ID_ARRAY:
                field_type =
-                       bt_field_type_common_array_borrow_element_field_type(ft);
+                       bt_field_type_array_borrow_element_field_type(ft);
                break;
        case BT_FIELD_TYPE_ID_SEQUENCE:
                field_type =
-                       bt_field_type_common_sequence_borrow_element_field_type(ft);
+                       bt_field_type_sequence_borrow_element_field_type(ft);
                break;
        default:
                break;
@@ -4390,18 +3978,18 @@ end:
 }
 
 BT_HIDDEN
-int bt_field_type_common_get_field_index(struct bt_field_type_common *ft,
+int bt_field_type_get_field_index(struct bt_field_type *ft,
                const char *name)
 {
        int field_index = -1;
 
        switch (ft->id) {
        case BT_FIELD_TYPE_ID_STRUCT:
-               field_index = bt_field_type_common_structure_get_field_name_index(
+               field_index = bt_field_type_structure_get_field_name_index(
                        ft, name);
                break;
        case BT_FIELD_TYPE_ID_VARIANT:
-               field_index = bt_field_type_common_variant_get_field_name_index(
+               field_index = bt_field_type_variant_get_field_name_index(
                        ft, name);
                break;
        default:
@@ -4411,46 +3999,31 @@ int bt_field_type_common_get_field_index(struct bt_field_type_common *ft,
        return field_index;
 }
 
-BT_HIDDEN
-struct bt_field_path *bt_field_type_common_variant_borrow_tag_field_path(
-               struct bt_field_type_common *ft)
+struct bt_field_path *bt_field_type_variant_borrow_tag_field_path(
+               struct bt_field_type *ft)
 {
-       struct bt_field_type_common_variant *var_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_variant *var_ft = (void *) ft;
 
        BT_ASSERT_PRE_NON_NULL(ft, "Field type");
-       BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_VARIANT,
+       BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_VARIANT,
                "Field type");
        return var_ft->tag_field_path;
 }
 
-struct bt_field_path *bt_field_type_variant_borrow_tag_field_path(
+struct bt_field_path *bt_field_type_sequence_borrow_length_field_path(
                struct bt_field_type *ft)
 {
-       return bt_field_type_common_variant_borrow_tag_field_path((void *) ft);
-}
-
-BT_HIDDEN
-struct bt_field_path *bt_field_type_common_sequence_borrow_length_field_path(
-               struct bt_field_type_common *ft)
-{
-       struct bt_field_type_common_sequence *seq_ft = BT_FROM_COMMON(ft);
+       struct bt_field_type_sequence *seq_ft = (void *) ft;
 
        BT_ASSERT_PRE_NON_NULL(ft, "Field type");
-       BT_ASSERT_PRE_FT_COMMON_HAS_ID(ft, BT_FIELD_TYPE_ID_SEQUENCE,
+       BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_SEQUENCE,
                "Field type");
        return seq_ft->length_field_path;
 }
 
-struct bt_field_path *bt_field_type_sequence_borrow_length_field_path(
-               struct bt_field_type *ft)
-{
-       return bt_field_type_common_sequence_borrow_length_field_path(
-               (void *) ft);
-}
-
 BT_HIDDEN
-int bt_field_type_common_validate_single_clock_class(
-               struct bt_field_type_common *ft,
+int bt_field_type_validate_single_clock_class(
+               struct bt_field_type *ft,
                struct bt_clock_class **expected_clock_class)
 {
        int ret = 0;
@@ -4465,7 +4038,7 @@ int bt_field_type_common_validate_single_clock_class(
        case BT_FIELD_TYPE_ID_INTEGER:
        {
                struct bt_clock_class *mapped_clock_class =
-                       bt_field_type_common_integer_borrow_mapped_clock_class(ft);
+                       bt_field_type_integer_borrow_mapped_clock_class(ft);
 
                if (!mapped_clock_class) {
                        goto end;
@@ -4502,19 +4075,19 @@ int bt_field_type_common_validate_single_clock_class(
        case BT_FIELD_TYPE_ID_ARRAY:
        case BT_FIELD_TYPE_ID_SEQUENCE:
        {
-               struct bt_field_type_common *sub_ft = NULL;
+               struct bt_field_type *sub_ft = NULL;
 
                switch (ft->id) {
                case BT_FIELD_TYPE_ID_ENUM:
-                       sub_ft = bt_field_type_common_enumeration_borrow_container_field_type(
+                       sub_ft = bt_field_type_enumeration_borrow_container_field_type(
                                ft);
                        break;
                case BT_FIELD_TYPE_ID_ARRAY:
-                       sub_ft = bt_field_type_common_array_borrow_element_field_type(
+                       sub_ft = bt_field_type_array_borrow_element_field_type(
                                ft);
                        break;
                case BT_FIELD_TYPE_ID_SEQUENCE:
-                       sub_ft = bt_field_type_common_sequence_borrow_element_field_type(
+                       sub_ft = bt_field_type_sequence_borrow_element_field_type(
                                ft);
                        break;
                default:
@@ -4523,24 +4096,24 @@ int bt_field_type_common_validate_single_clock_class(
                }
 
                BT_ASSERT(sub_ft);
-               ret = bt_field_type_common_validate_single_clock_class(sub_ft,
+               ret = bt_field_type_validate_single_clock_class(sub_ft,
                        expected_clock_class);
                break;
        }
        case BT_FIELD_TYPE_ID_STRUCT:
        {
                uint64_t i;
-               int64_t count = bt_field_type_common_structure_get_field_count(
+               int64_t count = bt_field_type_structure_get_field_count(
                        ft);
 
                for (i = 0; i < count; i++) {
                        const char *name;
-                       struct bt_field_type_common *member_type;
+                       struct bt_field_type *member_type;
 
-                       ret = bt_field_type_common_structure_borrow_field_by_index(
+                       ret = bt_field_type_structure_borrow_field_by_index(
                                ft, &name, &member_type, i);
                        BT_ASSERT(ret == 0);
-                       ret = bt_field_type_common_validate_single_clock_class(
+                       ret = bt_field_type_validate_single_clock_class(
                                member_type, expected_clock_class);
                        if (ret) {
                                BT_LOGW("Structure field type's field's type "
@@ -4556,17 +4129,17 @@ int bt_field_type_common_validate_single_clock_class(
        case BT_FIELD_TYPE_ID_VARIANT:
        {
                uint64_t i;
-               int64_t count = bt_field_type_common_variant_get_field_count(
+               int64_t count = bt_field_type_variant_get_field_count(
                        ft);
 
                for (i = 0; i < count; i++) {
                        const char *name;
-                       struct bt_field_type_common *member_type;
+                       struct bt_field_type *member_type;
 
-                       ret = bt_field_type_common_variant_borrow_field_by_index(
+                       ret = bt_field_type_variant_borrow_field_by_index(
                                ft, &name, &member_type, i);
                        BT_ASSERT(ret == 0);
-                       ret = bt_field_type_common_validate_single_clock_class(
+                       ret = bt_field_type_validate_single_clock_class(
                                member_type, expected_clock_class);
                        if (ret) {
                                BT_LOGW("Variant field type's field's type "
@@ -4591,13 +4164,13 @@ static
 struct bt_field_type *bt_field_type_integer_copy(
                struct bt_field_type *ft)
 {
-       struct bt_field_type_common_integer *int_ft = (void *) ft;
-       struct bt_field_type_common_integer *copy_ft;
+       struct bt_field_type_integer *int_ft = (void *) ft;
+       struct bt_field_type_integer *copy_ft;
 
-       BT_LOGD("Copying CTF writer integer field type's: addr=%p", ft);
+       BT_LOGD("Copying integer field type's: addr=%p", ft);
        copy_ft = (void *) bt_field_type_integer_create(int_ft->size);
        if (!copy_ft) {
-               BT_LOGE_STR("Cannot create CTF writer integer field type.");
+               BT_LOGE_STR("Cannot create integer field type.");
                goto end;
        }
 
@@ -4607,7 +4180,7 @@ struct bt_field_type *bt_field_type_integer_copy(
        copy_ft->size = int_ft->size;
        copy_ft->base = int_ft->base;
        copy_ft->encoding = int_ft->encoding;
-       BT_LOGD("Copied CTF writer integer field type: original-ft-addr=%p, copy-ft-addr=%p",
+       BT_LOGD("Copied integer field type: original-ft-addr=%p, copy-ft-addr=%p",
                ft, copy_ft);
 
 end:
@@ -4619,25 +4192,25 @@ struct bt_field_type *bt_field_type_enumeration_copy_recursive(
                struct bt_field_type *ft)
 {
        size_t i;
-       struct bt_field_type_common_enumeration *enum_ft = (void *) ft;
-       struct bt_field_type_common_enumeration *copy_ft = NULL;
-       struct bt_field_type_common_enumeration *container_copy_ft;
+       struct bt_field_type_enumeration *enum_ft = (void *) ft;
+       struct bt_field_type_enumeration *copy_ft = NULL;
+       struct bt_field_type_enumeration *container_copy_ft;
 
-       BT_LOGD("Copying CTF writer enumeration field type's: addr=%p", ft);
+       BT_LOGD("Copying enumeration field type's: addr=%p", ft);
 
        /* Copy the source enumeration's container */
-       BT_LOGD_STR("Copying CTF writer enumeration field type's container field type.");
-       container_copy_ft = BT_FROM_COMMON(bt_field_type_common_copy(
-               BT_TO_COMMON(enum_ft->container_ft)));
+       BT_LOGD_STR("Copying enumeration field type's container field type.");
+       container_copy_ft =
+               (void *) bt_field_type_copy((void *) enum_ft->container_ft);
        if (!container_copy_ft) {
-               BT_LOGE_STR("Cannot copy CTF writer enumeration field type's container field type.");
+               BT_LOGE_STR("Cannot copy enumeration field type's container field type.");
                goto end;
        }
 
        copy_ft = (void *) bt_field_type_enumeration_create(
                (void *) container_copy_ft);
        if (!copy_ft) {
-               BT_LOGE_STR("Cannot create CTF writer enumeration field type.");
+               BT_LOGE_STR("Cannot create enumeration field type.");
                goto end;
        }
 
@@ -4657,7 +4230,7 @@ struct bt_field_type *bt_field_type_enumeration_copy_recursive(
                g_ptr_array_add(copy_ft->entries, copy_mapping);
        }
 
-       BT_LOGD("Copied CTF writer enumeration field type: original-ft-addr=%p, copy-ft-addr=%p",
+       BT_LOGD("Copied enumeration field type: original-ft-addr=%p, copy-ft-addr=%p",
                ft, copy_ft);
 
 end:
@@ -4674,20 +4247,20 @@ static
 struct bt_field_type *bt_field_type_floating_point_copy(
                struct bt_field_type *ft)
 {
-       struct bt_field_type_common_floating_point *flt_ft = BT_FROM_COMMON(ft);
-       struct bt_field_type_common_floating_point *copy_ft;
+       struct bt_field_type_floating_point *flt_ft = (void *) ft;
+       struct bt_field_type_floating_point *copy_ft;
 
-       BT_LOGD("Copying CTF writer floating point number field type's: addr=%p", ft);
+       BT_LOGD("Copying floating point number field type's: addr=%p", ft);
        copy_ft = (void *) bt_field_type_floating_point_create();
        if (!copy_ft) {
-               BT_LOGE_STR("Cannot create CTF writer floating point number field type.");
+               BT_LOGE_STR("Cannot create floating point number field type.");
                goto end;
        }
 
        copy_ft->user_byte_order = flt_ft->user_byte_order;
        copy_ft->exp_dig = flt_ft->exp_dig;
        copy_ft->mant_dig = flt_ft->mant_dig;
-       BT_LOGD("Copied CTF writer floating point number field type: original-ft-addr=%p, copy-ft-addr=%p",
+       BT_LOGD("Copied floating point number field type: original-ft-addr=%p, copy-ft-addr=%p",
                ft, copy_ft);
 
 end:
@@ -4701,13 +4274,13 @@ struct bt_field_type *bt_field_type_structure_copy_recursive(
        int64_t i;
        GHashTableIter iter;
        gpointer key, value;
-       struct bt_field_type_common_structure *struct_ft = (void *) ft;
-       struct bt_field_type_common_structure *copy_ft;
+       struct bt_field_type_structure *struct_ft = (void *) ft;
+       struct bt_field_type_structure *copy_ft;
 
-       BT_LOGD("Copying CTF writer structure field type's: addr=%p", ft);
+       BT_LOGD("Copying structure field type's: addr=%p", ft);
        copy_ft = (void *) bt_field_type_structure_create();
        if (!copy_ft) {
-               BT_LOGE_STR("Cannot create CTF writer structure field type.");
+               BT_LOGE_STR("Cannot create structure field type.");
                goto end;
        }
 
@@ -4718,38 +4291,36 @@ struct bt_field_type *bt_field_type_structure_copy_recursive(
                        key, value);
        }
 
-       for (i = 0; i < struct_ft->fields->len; i++) {
-               struct structure_field_common *entry, *copy_entry;
-               struct bt_field_type_common *field_ft_copy;
+       g_array_set_size(copy_ft->fields, struct_ft->fields->len);
 
-               entry = g_ptr_array_index(struct_ft->fields, i);
-               BT_LOGD("Copying CTF writer structure field type's field: "
+       for (i = 0; i < struct_ft->fields->len; i++) {
+               struct bt_field_type_structure_field *entry, *copy_entry;
+               struct bt_field_type *field_ft_copy;
+
+               entry = BT_FIELD_TYPE_STRUCTURE_FIELD_AT_INDEX(
+                       struct_ft, i);
+               copy_entry = BT_FIELD_TYPE_STRUCTURE_FIELD_AT_INDEX(
+                       copy_ft, i);
+               BT_LOGD("Copying structure field type's field: "
                        "index=%" PRId64 ", "
                        "field-ft-addr=%p, field-name=\"%s\"",
                        i, entry, g_quark_to_string(entry->name));
-               copy_entry = g_new0(struct structure_field_common, 1);
-               if (!copy_entry) {
-                       BT_LOGE_STR("Failed to allocate one structure field type field.");
-                       goto error;
-               }
 
                field_ft_copy = (void *) bt_field_type_copy(
                        (void *) entry->type);
                if (!field_ft_copy) {
-                       BT_LOGE("Cannot copy CTF writer structure field type's field: "
+                       BT_LOGE("Cannot copy structure field type's field: "
                                "index=%" PRId64 ", "
                                "field-ft-addr=%p, field-name=\"%s\"",
                                i, entry, g_quark_to_string(entry->name));
-                       g_free(copy_entry);
                        goto error;
                }
 
                copy_entry->name = entry->name;
                copy_entry->type = field_ft_copy;
-               g_ptr_array_add(copy_ft->fields, copy_entry);
        }
 
-       BT_LOGD("Copied CTF writer structure field type: original-ft-addr=%p, copy-ft-addr=%p",
+       BT_LOGD("Copied structure field type: original-ft-addr=%p, copy-ft-addr=%p",
                ft, copy_ft);
 
 end:
@@ -4767,17 +4338,16 @@ struct bt_field_type *bt_field_type_variant_copy_recursive(
        int64_t i;
        GHashTableIter iter;
        gpointer key, value;
-       struct bt_field_type_common *tag_ft_copy = NULL;
-       struct bt_field_type_common_variant *var_ft = (void *) ft;
-       struct bt_field_type_common_variant *copy_ft = NULL;
+       struct bt_field_type *tag_ft_copy = NULL;
+       struct bt_field_type_variant *var_ft = (void *) ft;
+       struct bt_field_type_variant *copy_ft = NULL;
 
-       BT_LOGD("Copying CTF writer variant field type's: addr=%p", ft);
+       BT_LOGD("Copying variant field type's: addr=%p", ft);
        if (var_ft->tag_ft) {
-               BT_LOGD_STR("Copying CTF writer variant field type's tag field type.");
-               tag_ft_copy = bt_field_type_common_copy(
-                       BT_TO_COMMON(var_ft->tag_ft));
+               BT_LOGD_STR("Copying variant field type's tag field type.");
+               tag_ft_copy = bt_field_type_copy((void *) var_ft->tag_ft);
                if (!tag_ft_copy) {
-                       BT_LOGE_STR("Cannot copy CTF writer variant field type's tag field type.");
+                       BT_LOGE_STR("Cannot copy variant field type's tag field type.");
                        goto end;
                }
        }
@@ -4786,36 +4356,36 @@ struct bt_field_type *bt_field_type_variant_copy_recursive(
                (void *) tag_ft_copy,
                var_ft->tag_name->len ? var_ft->tag_name->str : NULL);
        if (!copy_ft) {
-               BT_LOGE_STR("Cannot create CTF writer variant field type.");
+               BT_LOGE_STR("Cannot create variant field type.");
                goto end;
        }
 
        /* Copy field_name_to_index */
-       g_hash_table_iter_init(&iter, var_ft->field_name_to_index);
+       g_hash_table_iter_init(&iter, var_ft->choice_name_to_index);
        while (g_hash_table_iter_next(&iter, &key, &value)) {
-               g_hash_table_insert(copy_ft->field_name_to_index,
+               g_hash_table_insert(copy_ft->choice_name_to_index,
                        key, value);
        }
 
-       for (i = 0; i < var_ft->fields->len; i++) {
-               struct structure_field_common *entry, *copy_entry;
-               struct bt_field_type_common *field_ft_copy;
+       g_array_set_size(copy_ft->choices, var_ft->choices->len);
 
-               entry = g_ptr_array_index(var_ft->fields, i);
-               BT_LOGD("Copying CTF writer variant field type's field: "
+       for (i = 0; i < var_ft->choices->len; i++) {
+               struct bt_field_type_variant_choice *entry, *copy_entry;
+               struct bt_field_type *field_ft_copy;
+               uint64_t range_i;
+
+               entry = BT_FIELD_TYPE_VARIANT_CHOICE_AT_INDEX(var_ft, i);
+               copy_entry = BT_FIELD_TYPE_VARIANT_CHOICE_AT_INDEX(
+                       copy_ft, i);
+               BT_LOGD("Copying variant field type's field: "
                        "index=%" PRId64 ", "
                        "field-ft-addr=%p, field-name=\"%s\"",
                        i, entry, g_quark_to_string(entry->name));
-               copy_entry = g_new0(struct structure_field_common, 1);
-               if (!copy_entry) {
-                       BT_LOGE_STR("Failed to allocate one variant field type field.");
-                       goto error;
-               }
 
                field_ft_copy = (void *) bt_field_type_copy(
                        (void *) entry->type);
                if (!field_ft_copy) {
-                       BT_LOGE("Cannot copy CTF writer variant field type's field: "
+                       BT_LOGE("Cannot copy variant field type's field: "
                                "index=%" PRId64 ", "
                                "field-ft-addr=%p, field-name=\"%s\"",
                                i, entry, g_quark_to_string(entry->name));
@@ -4825,19 +4395,29 @@ struct bt_field_type *bt_field_type_variant_copy_recursive(
 
                copy_entry->name = entry->name;
                copy_entry->type = field_ft_copy;
-               g_ptr_array_add(copy_ft->fields, copy_entry);
+
+               /* Copy ranges */
+               copy_entry->ranges = g_array_new(FALSE, TRUE,
+                       sizeof(struct bt_field_type_variant_choice_range));
+               BT_ASSERT(copy_entry->ranges);
+               g_array_set_size(copy_entry->ranges, entry->ranges->len);
+
+               for (range_i = 0; range_i < entry->ranges->len; range_i++) {
+                       copy_entry->ranges[range_i] = entry->ranges[range_i];
+               }
        }
 
        if (var_ft->tag_field_path) {
-               BT_LOGD_STR("Copying CTF writer variant field type's tag field path.");
+               BT_LOGD_STR("Copying variant field type's tag field path.");
                copy_ft->tag_field_path = bt_field_path_copy(
                        var_ft->tag_field_path);
                if (!copy_ft->tag_field_path) {
-                       BT_LOGE_STR("Cannot copy CTF writer variant field type's tag field path.");
+                       BT_LOGE_STR("Cannot copy variant field type's tag field path.");
                        goto error;
                }
        }
 
+       copy_ft->choices_up_to_date = var_ft->choices_up_to_date;
        BT_LOGD("Copied variant field type: original-ft-addr=%p, copy-ft-addr=%p",
                ft, copy_ft);
 
@@ -4855,26 +4435,26 @@ static
 struct bt_field_type *bt_field_type_array_copy_recursive(
                struct bt_field_type *ft)
 {
-       struct bt_field_type_common *container_ft_copy = NULL;
-       struct bt_field_type_common_array *array_ft = (void *) ft;
-       struct bt_field_type_common_array *copy_ft = NULL;
+       struct bt_field_type *container_ft_copy = NULL;
+       struct bt_field_type_array *array_ft = (void *) ft;
+       struct bt_field_type_array *copy_ft = NULL;
 
-       BT_LOGD("Copying CTF writer array field type's: addr=%p", ft);
-       BT_LOGD_STR("Copying CTF writer array field type's element field type.");
-       container_ft_copy = bt_field_type_common_copy(array_ft->element_ft);
+       BT_LOGD("Copying array field type's: addr=%p", ft);
+       BT_LOGD_STR("Copying array field type's element field type.");
+       container_ft_copy = bt_field_type_copy(array_ft->element_ft);
        if (!container_ft_copy) {
-               BT_LOGE_STR("Cannot copy CTF writer array field type's element field type.");
+               BT_LOGE_STR("Cannot copy array field type's element field type.");
                goto end;
        }
 
        copy_ft = (void *) bt_field_type_array_create(
                (void *) container_ft_copy, array_ft->length);
        if (!copy_ft) {
-               BT_LOGE_STR("Cannot create CTF writer array field type.");
+               BT_LOGE_STR("Cannot create array field type.");
                goto end;
        }
 
-       BT_LOGD("Copied CTF writer array field type: original-ft-addr=%p, copy-ft-addr=%p",
+       BT_LOGD("Copied array field type: original-ft-addr=%p, copy-ft-addr=%p",
                ft, copy_ft);
 
 end:
@@ -4886,15 +4466,15 @@ static
 struct bt_field_type *bt_field_type_sequence_copy_recursive(
                struct bt_field_type *ft)
 {
-       struct bt_field_type_common *container_ft_copy = NULL;
-       struct bt_field_type_common_sequence *seq_ft = (void *) ft;
-       struct bt_field_type_common_sequence *copy_ft = NULL;
+       struct bt_field_type *container_ft_copy = NULL;
+       struct bt_field_type_sequence *seq_ft = (void *) ft;
+       struct bt_field_type_sequence *copy_ft = NULL;
 
-       BT_LOGD("Copying CTF writer sequence field type's: addr=%p", ft);
-       BT_LOGD_STR("Copying CTF writer sequence field type's element field type.");
-       container_ft_copy = bt_field_type_common_copy(seq_ft->element_ft);
+       BT_LOGD("Copying sequence field type's: addr=%p", ft);
+       BT_LOGD_STR("Copying sequence field type's element field type.");
+       container_ft_copy = bt_field_type_copy(seq_ft->element_ft);
        if (!container_ft_copy) {
-               BT_LOGE_STR("Cannot copy CTF writer sequence field type's element field type.");
+               BT_LOGE_STR("Cannot copy sequence field type's element field type.");
                goto end;
        }
 
@@ -4903,21 +4483,21 @@ struct bt_field_type *bt_field_type_sequence_copy_recursive(
                seq_ft->length_field_name->len ?
                        seq_ft->length_field_name->str : NULL);
        if (!copy_ft) {
-               BT_LOGE_STR("Cannot create CTF writer sequence field type.");
+               BT_LOGE_STR("Cannot create sequence field type.");
                goto end;
        }
 
        if (seq_ft->length_field_path) {
-               BT_LOGD_STR("Copying CTF writer sequence field type's length field path.");
+               BT_LOGD_STR("Copying sequence field type's length field path.");
                copy_ft->length_field_path = bt_field_path_copy(
                        seq_ft->length_field_path);
                if (!copy_ft->length_field_path) {
-                       BT_LOGE_STR("Cannot copy CTF writer sequence field type's length field path.");
+                       BT_LOGE_STR("Cannot copy sequence field type's length field path.");
                        goto error;
                }
        }
 
-       BT_LOGD("Copied CTF writer sequence field type: original-ft-addr=%p, copy-ft-addr=%p",
+       BT_LOGD("Copied sequence field type: original-ft-addr=%p, copy-ft-addr=%p",
                ft, copy_ft);
 
 end:
@@ -4932,18 +4512,18 @@ error:
 static
 struct bt_field_type *bt_field_type_string_copy(struct bt_field_type *ft)
 {
-       struct bt_field_type_common_string *string_ft = (void *) ft;
-       struct bt_field_type_common_string *copy_ft = NULL;
+       struct bt_field_type_string *string_ft = (void *) ft;
+       struct bt_field_type_string *copy_ft = NULL;
 
-       BT_LOGD("Copying CTF writer string field type's: addr=%p", ft);
+       BT_LOGD("Copying string field type's: addr=%p", ft);
        copy_ft = (void *) bt_field_type_string_create();
        if (!copy_ft) {
-               BT_LOGE_STR("Cannot create CTF writer string field type.");
+               BT_LOGE_STR("Cannot create string field type.");
                goto end;
        }
 
        copy_ft->encoding = string_ft->encoding;
-       BT_LOGD("Copied CTF writer string field type: original-ft-addr=%p, copy-ft-addr=%p",
+       BT_LOGD("Copied string field type: original-ft-addr=%p, copy-ft-addr=%p",
                ft, copy_ft);
 
 end:
This page took 0.100619 seconds and 4 git commands to generate.