lib: merge common CTF IR part with the remaining implementation
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 16 Aug 2018 19:53:25 +0000 (15:53 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 2 May 2019 04:07:36 +0000 (00:07 -0400)
This patch merges the common part of the CTF IR implementation with the
rest of it, making it one. This will make it easier to modify this
implementation since it's not split in two.

Support for common CTF IR conversion specifiers is removed in
`lib-logging.c` (see updated `lib-logging-internal.h` documentation).

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
23 files changed:
include/babeltrace/ctf-ir/event-class-internal.h
include/babeltrace/ctf-ir/event-internal.h
include/babeltrace/ctf-ir/field-types-internal.h
include/babeltrace/ctf-ir/field-wrapper-internal.h
include/babeltrace/ctf-ir/fields-internal.h
include/babeltrace/ctf-ir/resolve-internal.h
include/babeltrace/ctf-ir/stream-class-internal.h
include/babeltrace/ctf-ir/stream-internal.h
include/babeltrace/ctf-ir/trace-internal.h
include/babeltrace/ctf-ir/utils-internal.h
include/babeltrace/ctf-ir/validation-internal.h
include/babeltrace/lib-logging-internal.h
lib/ctf-ir/event-class.c
lib/ctf-ir/event.c
lib/ctf-ir/field-types.c
lib/ctf-ir/fields.c
lib/ctf-ir/packet.c
lib/ctf-ir/resolve.c
lib/ctf-ir/stream-class.c
lib/ctf-ir/stream.c
lib/ctf-ir/trace.c
lib/ctf-ir/validation.c
lib/lib-logging.c

index 404bcd75fb1cab1034881e80019a2b8df5fb3a17..ec1a06930a45cd82a0392190ce22e18fe097797b 100644 (file)
 #include <babeltrace/object-pool-internal.h>
 #include <glib.h>
 
-struct bt_event_class_common {
+struct bt_event_class {
        struct bt_object base;
-       struct bt_field_type_common *context_field_type;
-       struct bt_field_type_common *payload_field_type;
+       struct bt_field_type *context_field_type;
+       struct bt_field_type *payload_field_type;
        int frozen;
 
        /*
@@ -60,10 +60,6 @@ struct bt_event_class_common {
        int64_t id;
        int log_level;
        GString *emf_uri;
-};
-
-struct bt_event_class {
-       struct bt_event_class_common common;
 
        /* Pool of `struct bt_event *` */
        struct bt_object_pool event_pool;
@@ -72,336 +68,11 @@ struct bt_event_class {
 BT_HIDDEN
 void bt_event_class_freeze(struct bt_event_class *event_class);
 
-BT_HIDDEN
-void bt_event_class_common_freeze(struct bt_event_class_common *event_class);
-
-BT_HIDDEN
-void bt_event_class_common_set_native_byte_order(
-               struct bt_event_class_common *event_class, int byte_order);
-
-static inline
-struct bt_stream_class_common *bt_event_class_common_borrow_stream_class(
-               struct bt_event_class_common *event_class)
-{
-       BT_ASSERT(event_class);
-       return (void *) bt_object_borrow_parent(&event_class->base);
-}
-
-typedef struct bt_field_type_common *(*bt_field_type_structure_create_func)();
-
-BT_HIDDEN
-int bt_event_class_common_initialize(struct bt_event_class_common *event_class,
-               const char *name, bt_object_release_func release_func,
-               bt_field_type_structure_create_func ft_struct_create_func);
+typedef struct bt_field_type *(*bt_field_type_structure_create_func)();
 
 BT_HIDDEN
-void bt_event_class_common_finalize(struct bt_object *obj);
-
-BT_HIDDEN
-int bt_event_class_common_validate_single_clock_class(
-               struct bt_event_class_common *event_class,
+int bt_event_class_validate_single_clock_class(
+               struct bt_event_class *event_class,
                struct bt_clock_class **expected_clock_class);
 
-static inline
-const char *bt_event_class_common_get_name(
-               struct bt_event_class_common *event_class)
-{
-       BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
-       BT_ASSERT(event_class->name);
-       return event_class->name->str;
-}
-
-static inline
-int64_t bt_event_class_common_get_id(
-               struct bt_event_class_common *event_class)
-{
-       BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
-       return event_class->id;
-}
-
-static inline
-int bt_event_class_common_set_id(
-               struct bt_event_class_common *event_class, uint64_t id_param)
-{
-       int ret = 0;
-       int64_t id = (int64_t) id_param;
-
-       if (!event_class) {
-               BT_LOGW_STR("Invalid parameter: event class is NULL.");
-               ret = -1;
-               goto end;
-       }
-
-       if (event_class->frozen) {
-               BT_LOGW("Invalid parameter: event class is frozen: "
-                       "addr=%p, name=\"%s\", id=%" PRId64,
-                       event_class,
-                       bt_event_class_common_get_name(event_class),
-                       bt_event_class_common_get_id(event_class));
-               ret = -1;
-               goto end;
-       }
-
-       if (id < 0) {
-               BT_LOGW("Invalid parameter: invalid event class's ID: "
-                       "addr=%p, name=\"%s\", id=%" PRIu64,
-                       event_class,
-                       bt_event_class_common_get_name(event_class),
-                       id_param);
-               ret = -1;
-               goto end;
-       }
-
-       event_class->id = id;
-       BT_LOGV("Set event class's ID: "
-               "addr=%p, name=\"%s\", id=%" PRId64,
-               event_class, bt_event_class_common_get_name(event_class), id);
-
-end:
-       return ret;
-}
-
-static inline
-int bt_event_class_common_get_log_level(
-               struct bt_event_class_common *event_class)
-{
-       BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
-       return event_class->log_level;
-}
-
-static inline
-int bt_event_class_common_set_log_level(
-               struct bt_event_class_common *event_class, int log_level)
-{
-       int ret = 0;
-
-       if (!event_class) {
-               BT_LOGW_STR("Invalid parameter: event class is NULL.");
-               ret = -1;
-               goto end;
-       }
-
-       if (event_class->frozen) {
-               BT_LOGW("Invalid parameter: event class is frozen: "
-                       "addr=%p, name=\"%s\", id=%" PRId64,
-                       event_class,
-                       bt_event_class_common_get_name(event_class),
-                       bt_event_class_common_get_id(event_class));
-               ret = -1;
-               goto end;
-       }
-
-       switch (log_level) {
-       case BT_EVENT_CLASS_LOG_LEVEL_UNSPECIFIED:
-       case BT_EVENT_CLASS_LOG_LEVEL_EMERGENCY:
-       case BT_EVENT_CLASS_LOG_LEVEL_ALERT:
-       case BT_EVENT_CLASS_LOG_LEVEL_CRITICAL:
-       case BT_EVENT_CLASS_LOG_LEVEL_ERROR:
-       case BT_EVENT_CLASS_LOG_LEVEL_WARNING:
-       case BT_EVENT_CLASS_LOG_LEVEL_NOTICE:
-       case BT_EVENT_CLASS_LOG_LEVEL_INFO:
-       case BT_EVENT_CLASS_LOG_LEVEL_DEBUG_SYSTEM:
-       case BT_EVENT_CLASS_LOG_LEVEL_DEBUG_PROGRAM:
-       case BT_EVENT_CLASS_LOG_LEVEL_DEBUG_PROCESS:
-       case BT_EVENT_CLASS_LOG_LEVEL_DEBUG_MODULE:
-       case BT_EVENT_CLASS_LOG_LEVEL_DEBUG_UNIT:
-       case BT_EVENT_CLASS_LOG_LEVEL_DEBUG_FUNCTION:
-       case BT_EVENT_CLASS_LOG_LEVEL_DEBUG_LINE:
-       case BT_EVENT_CLASS_LOG_LEVEL_DEBUG:
-               break;
-       default:
-               BT_LOGW("Invalid parameter: unknown event class log level: "
-                       "addr=%p, name=\"%s\", id=%" PRId64 ", log-level=%d",
-                       event_class, bt_event_class_common_get_name(event_class),
-                       bt_event_class_common_get_id(event_class), log_level);
-               ret = -1;
-               goto end;
-       }
-
-       event_class->log_level = log_level;
-       BT_LOGV("Set event class's log level: "
-               "addr=%p, name=\"%s\", id=%" PRId64 ", log-level=%s",
-               event_class, bt_event_class_common_get_name(event_class),
-               bt_event_class_common_get_id(event_class),
-               bt_common_event_class_log_level_string(log_level));
-
-end:
-       return ret;
-}
-
-static inline
-const char *bt_event_class_common_get_emf_uri(
-               struct bt_event_class_common *event_class)
-{
-       const char *emf_uri = NULL;
-
-       BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
-
-       if (event_class->emf_uri->len > 0) {
-               emf_uri = event_class->emf_uri->str;
-       }
-
-       return emf_uri;
-}
-
-static inline
-int bt_event_class_common_set_emf_uri(
-               struct bt_event_class_common *event_class,
-               const char *emf_uri)
-{
-       int ret = 0;
-
-       if (!event_class) {
-               BT_LOGW_STR("Invalid parameter: event class is NULL.");
-               ret = -1;
-               goto end;
-       }
-
-       if (emf_uri && strlen(emf_uri) == 0) {
-               BT_LOGW_STR("Invalid parameter: EMF URI is empty.");
-               ret = -1;
-               goto end;
-       }
-
-       if (event_class->frozen) {
-               BT_LOGW("Invalid parameter: event class is frozen: "
-                       "addr=%p, name=\"%s\", id=%" PRId64,
-                       event_class, bt_event_class_common_get_name(event_class),
-                       bt_event_class_common_get_id(event_class));
-               ret = -1;
-               goto end;
-       }
-
-       if (emf_uri) {
-               g_string_assign(event_class->emf_uri, emf_uri);
-               BT_LOGV("Set event class's EMF URI: "
-                       "addr=%p, name=\"%s\", id=%" PRId64 ", emf-uri=\"%s\"",
-                       event_class, bt_event_class_common_get_name(event_class),
-                       bt_event_class_common_get_id(event_class), emf_uri);
-       } else {
-               g_string_assign(event_class->emf_uri, "");
-               BT_LOGV("Reset event class's EMF URI: "
-                       "addr=%p, name=\"%s\", id=%" PRId64,
-                       event_class, bt_event_class_common_get_name(event_class),
-                       bt_event_class_common_get_id(event_class));
-       }
-
-end:
-       return ret;
-}
-
-static inline
-struct bt_field_type_common *bt_event_class_common_borrow_context_field_type(
-               struct bt_event_class_common *event_class)
-{
-       struct bt_field_type_common *context_ft = NULL;
-
-       BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
-
-       if (!event_class->context_field_type) {
-               BT_LOGV("Event class has no context field type: "
-                       "addr=%p, name=\"%s\", id=%" PRId64,
-                       event_class, bt_event_class_common_get_name(event_class),
-                       bt_event_class_common_get_id(event_class));
-               goto end;
-       }
-
-       context_ft = event_class->context_field_type;
-
-end:
-       return context_ft;
-}
-
-static inline
-int bt_event_class_common_set_context_field_type(
-               struct bt_event_class_common *event_class,
-               struct bt_field_type_common *context_ft)
-{
-       int ret = 0;
-
-       if (!event_class) {
-               BT_LOGW_STR("Invalid parameter: event class is NULL.");
-               ret = -1;
-               goto end;
-       }
-
-       if (event_class->frozen) {
-               BT_LOGW("Invalid parameter: event class is frozen: "
-                       "addr=%p, name=\"%s\", id=%" PRId64,
-                       event_class, bt_event_class_common_get_name(event_class),
-                       bt_event_class_common_get_id(event_class));
-               ret = -1;
-               goto end;
-       }
-
-       if (context_ft && bt_field_type_common_get_type_id(context_ft) !=
-                       BT_FIELD_TYPE_ID_STRUCT) {
-               BT_LOGW("Invalid parameter: event class's context field type must be a structure: "
-                       "addr=%p, name=\"%s\", id=%" PRId64 ", "
-                       "context-ft-id=%s",
-                       event_class, bt_event_class_common_get_name(event_class),
-                       bt_event_class_common_get_id(event_class),
-                       bt_common_field_type_id_string(
-                               bt_field_type_common_get_type_id(context_ft)));
-               ret = -1;
-               goto end;
-       }
-
-       bt_put(event_class->context_field_type);
-       event_class->context_field_type = bt_get(context_ft);
-       BT_LOGV("Set event class's context field type: "
-               "event-class-addr=%p, event-class-name=\"%s\", "
-               "event-class-id=%" PRId64 ", context-ft-addr=%p",
-               event_class, bt_event_class_common_get_name(event_class),
-               bt_event_class_common_get_id(event_class), context_ft);
-
-end:
-       return ret;
-}
-
-static inline
-struct bt_field_type_common *bt_event_class_common_borrow_payload_field_type(
-               struct bt_event_class_common *event_class)
-{
-       BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
-       return event_class->payload_field_type;
-}
-
-static inline
-int bt_event_class_common_set_payload_field_type(
-               struct bt_event_class_common *event_class,
-               struct bt_field_type_common *payload_ft)
-{
-       int ret = 0;
-
-       if (!event_class) {
-               BT_LOGW_STR("Invalid parameter: event class is NULL.");
-               ret = -1;
-               goto end;
-       }
-
-       if (payload_ft && bt_field_type_common_get_type_id(payload_ft) !=
-                       BT_FIELD_TYPE_ID_STRUCT) {
-               BT_LOGW("Invalid parameter: event class's payload field type must be a structure: "
-                       "addr=%p, name=\"%s\", id=%" PRId64 ", "
-                       "payload-ft-addr=%p, payload-ft-id=%s",
-                       event_class, bt_event_class_common_get_name(event_class),
-                       bt_event_class_common_get_id(event_class), payload_ft,
-                       bt_common_field_type_id_string(
-                               bt_field_type_common_get_type_id(payload_ft)));
-               ret = -1;
-               goto end;
-       }
-
-       bt_put(event_class->payload_field_type);
-       event_class->payload_field_type = bt_get(payload_ft);
-       BT_LOGV("Set event class's payload field type: "
-               "event-class-addr=%p, event-class-name=\"%s\", "
-               "event-class-id=%" PRId64 ", payload-ft-addr=%p",
-               event_class, bt_event_class_common_get_name(event_class),
-               bt_event_class_common_get_id(event_class), payload_ft);
-end:
-       return ret;
-}
-
 #endif /* BABELTRACE_CTF_IR_EVENT_CLASS_INTERNAL_H */
index f1d09205feee70669b9a2c9caab3a0c6bedf7511..7925cc4eed9e598dc750f18990d2acd19d228fe3 100644 (file)
 
 struct bt_stream_pos;
 
-struct bt_event_common {
+struct bt_event {
        struct bt_object base;
-       struct bt_event_class_common *class;
+       struct bt_event_class *class;
        struct bt_field_wrapper *header_field;
-       struct bt_field_common *stream_event_context_field;
-       struct bt_field_common *context_field;
-       struct bt_field_common *payload_field;
-       int frozen;
-};
-
-struct bt_event {
-       struct bt_event_common common;
+       struct bt_field *stream_event_context_field;
+       struct bt_field *context_field;
+       struct bt_field *payload_field;
        struct bt_clock_value_set cv_set;
        struct bt_packet *packet;
+       int frozen;
 };
 
 BT_HIDDEN
-int _bt_event_common_validate(struct bt_event_common *event);
+void bt_event_destroy(struct bt_event *event);
 
 BT_HIDDEN
-void _bt_event_common_set_is_frozen(struct bt_event_common *event,
-               bool is_frozen);
+struct bt_event *bt_event_new(struct bt_event_class *event_class);
 
 BT_HIDDEN
 void _bt_event_set_is_frozen(struct bt_event *event, bool is_frozen);
 
 #ifdef BT_DEV_MODE
-# define bt_event_common_validate      _bt_event_common_validate
-# define bt_event_common_set_is_frozen _bt_event_common_set_is_frozen
 # define bt_event_set_is_frozen                _bt_event_set_is_frozen
 #else
-# define bt_event_common_validate(_event)                      0
-# define bt_event_common_set_is_frozen(_event, _is_frozen)
 # define bt_event_set_is_frozen(_event, _is_frozen)
 #endif
 
-#define BT_ASSERT_PRE_EVENT_COMMON_HOT(_event, _name)                  \
-       BT_ASSERT_PRE_HOT((_event), (_name), ": %!+_e", (_event))
-
-static inline
-struct bt_event_class_common *bt_event_common_borrow_class(
-               struct bt_event_common *event)
-{
-       BT_ASSERT(event);
-       return event->class;
-}
+#define BT_ASSERT_PRE_EVENT_HOT(_event, _name)                 \
+       BT_ASSERT_PRE_HOT((_event), (_name), ": %!+e", (_event))
 
 typedef void *(*create_field_func)(void *);
 typedef void (*release_field_func)(void *);
 typedef void *(*create_header_field_func)(void *, void *);
 typedef void (*release_header_field_func)(void *, void *);
 
-BT_HIDDEN
-int bt_event_common_initialize(struct bt_event_common *event,
-               struct bt_event_class_common *event_class,
-               struct bt_clock_class *init_expected_clock_class,
-               bool is_shared_with_parent, bt_object_release_func release_func,
-               bt_validation_flag_copy_field_type_func field_type_copy_func,
-               bool must_be_in_trace,
-               int (*map_clock_classes_func)(struct bt_stream_class_common *stream_class,
-                       struct bt_field_type_common *packet_context_field_type,
-                       struct bt_field_type_common *event_header_field_type),
-               create_field_func create_field_func,
-               release_field_func release_field_func,
-               create_header_field_func create_header_field_func,
-               release_header_field_func release_header_field_func);
-
-static inline
-struct bt_field_common *bt_event_common_borrow_payload(
-               struct bt_event_common *event)
-{
-       struct bt_field_common *payload = NULL;
-
-       BT_ASSERT_PRE_NON_NULL(event, "Event");
-
-       if (!event->payload_field) {
-               BT_LOGV("Event has no current payload field: addr=%p, "
-                       "event-class-name=\"%s\", event-class-id=%" PRId64,
-                       event, bt_event_class_common_get_name(event->class),
-                       bt_event_class_common_get_id(event->class));
-               goto end;
-       }
-
-       payload = event->payload_field;
-
-end:
-       return payload;
-}
-
-static inline
-struct bt_field_common *bt_event_common_borrow_header(
-               struct bt_event_common *event)
-{
-       struct bt_field_common *header = NULL;
-
-       BT_ASSERT_PRE_NON_NULL(event, "Event");
-
-       if (!event->header_field) {
-               BT_LOGV("Event has no current header field: addr=%p, "
-                       "event-class-name=\"%s\", event-class-id=%" PRId64,
-                       event, bt_event_class_common_get_name(event->class),
-                       bt_event_class_common_get_id(event->class));
-               goto end;
-       }
-
-       header = event->header_field->field;
-
-end:
-       return header;
-}
-
-static inline
-struct bt_field_common *bt_event_common_borrow_context(
-               struct bt_event_common *event)
-{
-       struct bt_field_common *context = NULL;
-
-       BT_ASSERT_PRE_NON_NULL(event, "Event");
-
-       if (!event->context_field) {
-               BT_LOGV("Event has no current context field: addr=%p, "
-                       "event-class-name=\"%s\", event-class-id=%" PRId64,
-                       event, bt_event_class_common_get_name(event->class),
-                       bt_event_class_common_get_id(event->class));
-               goto end;
-       }
-
-       context = event->context_field;
-
-end:
-       return context;
-}
-
-static inline
-struct bt_field_common *bt_event_common_borrow_stream_event_context(
-               struct bt_event_common *event)
-{
-       struct bt_field_common *stream_event_context = NULL;
-
-       BT_ASSERT_PRE_NON_NULL(event, "Event");
-
-       if (!event->stream_event_context_field) {
-               BT_LOGV("Event has no current stream event context field: addr=%p, "
-                       "event-class-name=\"%s\", event-class-id=%" PRId64,
-                       event, bt_event_class_common_get_name(event->class),
-                       bt_event_class_common_get_id(event->class));
-               goto end;
-       }
-
-       stream_event_context = event->stream_event_context_field;
-
-end:
-       return stream_event_context;
-}
-
+BT_UNUSED
 static inline
-void bt_event_common_finalize(struct bt_object *obj,
-               void (*field_release_func)(void *),
-               void (*header_field_release_func)(void *, struct bt_event_common *))
+void _bt_event_reset_dev_mode(struct bt_event *event)
 {
-       struct bt_event_common *event = (void *) obj;
-
-       BT_LOGD("Destroying event: addr=%p, "
-               "event-class-name=\"%s\", event-class-id=%" PRId64,
-               event,
-               event->class ? bt_event_class_common_get_name(event->class) : NULL,
-               event->class ? bt_event_class_common_get_id(event->class) : INT64_C(-1));
+       BT_ASSERT(event);
 
        if (event->header_field) {
-               BT_LOGD_STR("Releasing event's header field.");
-               header_field_release_func(event->header_field, event);
+               bt_field_set_is_frozen_recursive(
+                       event->header_field->field, false);
+               bt_field_reset_recursive(
+                       event->header_field->field);
        }
 
        if (event->stream_event_context_field) {
-               BT_LOGD_STR("Releasing event's stream event context field.");
-               field_release_func(event->stream_event_context_field);
+               bt_field_set_is_frozen_recursive(
+                       event->stream_event_context_field, false);
+               bt_field_reset_recursive(
+                       event->stream_event_context_field);
        }
 
        if (event->context_field) {
-               BT_LOGD_STR("Releasing event's context field.");
-               field_release_func(event->context_field);
+               bt_field_set_is_frozen_recursive(
+                       event->context_field, false);
+               bt_field_reset_recursive(event->context_field);
        }
 
        if (event->payload_field) {
-               BT_LOGD_STR("Releasing event's payload field.");
-               field_release_func(event->payload_field);
-       }
-
-       /*
-        * Leave this after calling header_field_release_func() because
-        * this function receives the event object and could need its
-        * class to perform some cleanup.
-        */
-       if (!event->base.parent) {
-               /*
-                * Event was keeping a reference to its class since it shared no
-                * common ancestor with it to guarantee they would both have the
-                * same lifetime.
-                */
-               bt_put(event->class);
-       }
-}
-
-BT_UNUSED
-static inline
-void _bt_event_reset_dev_mode(struct bt_event *event)
-{
-       BT_ASSERT(event);
-
-       if (event->common.header_field) {
-               bt_field_common_set_is_frozen_recursive(
-                       event->common.header_field->field, false);
-               bt_field_common_reset_recursive(
-                       event->common.header_field->field);
-       }
-
-       if (event->common.stream_event_context_field) {
-               bt_field_common_set_is_frozen_recursive(
-                       event->common.stream_event_context_field, false);
-               bt_field_common_reset_recursive(
-                       event->common.stream_event_context_field);
-       }
-
-       if (event->common.context_field) {
-               bt_field_common_set_is_frozen_recursive(
-                       event->common.context_field, false);
-               bt_field_common_reset_recursive(event->common.context_field);
-       }
-
-       if (event->common.payload_field) {
-               bt_field_common_set_is_frozen_recursive(
-                       event->common.payload_field, false);
-               bt_field_common_reset_recursive(event->common.payload_field);
+               bt_field_set_is_frozen_recursive(
+                       event->payload_field, false);
+               bt_field_reset_recursive(event->payload_field);
        }
 }
 
@@ -289,9 +121,6 @@ void _bt_event_reset_dev_mode(struct bt_event *event)
 # define bt_event_reset_dev_mode(_x)
 #endif
 
-BT_HIDDEN
-void bt_event_destroy(struct bt_event *event);
-
 static inline
 void bt_event_reset(struct bt_event *event)
 {
@@ -333,11 +162,11 @@ void bt_event_recycle(struct bt_event *event)
         * 4. Put our event class reference.
         */
        bt_event_reset(event);
-       event_class = BT_FROM_COMMON(event->common.class);
+       event_class = event->class;
        BT_ASSERT(event_class);
-       event->common.class = NULL;
+       event->class = NULL;
        bt_object_pool_recycle_object(&event_class->event_pool, event);
-       bt_object_put_no_null_check(&event_class->common.base);
+       bt_object_put_no_null_check(&event_class->base);
 }
 
 static inline
@@ -345,10 +174,9 @@ void bt_event_set_packet(struct bt_event *event, struct bt_packet *packet)
 {
        BT_ASSERT_PRE_NON_NULL(event, "Event");
        BT_ASSERT_PRE_NON_NULL(packet, "Packet");
-       BT_ASSERT_PRE_EVENT_COMMON_HOT(BT_TO_COMMON(event), "Event");
+       BT_ASSERT_PRE_EVENT_HOT(event, "Event");
        BT_ASSERT_PRE(bt_event_class_borrow_stream_class(
-               BT_FROM_COMMON(event->common.class)) ==
-               BT_FROM_COMMON(packet->stream->common.stream_class),
+               event->class) == packet->stream->stream_class,
                "Packet's stream class and event's stream class differ: "
                "%![event-]+e, %![packet-]+a",
                event, packet);
@@ -359,8 +187,8 @@ void bt_event_set_packet(struct bt_event *event, struct bt_packet *packet)
        BT_LOGV("Set event's packet: event-addr=%p, "
                "event-class-name=\"%s\", event-class-id=%" PRId64 ", "
                "packet-addr=%p",
-               event, bt_event_class_common_get_name(event->common.class),
-               bt_event_class_common_get_id(event->common.class), packet);
+               event, bt_event_class_get_name(event->class),
+               bt_event_class_get_id(event->class), packet);
 }
 
 static inline
@@ -377,9 +205,9 @@ struct bt_event *bt_event_create(struct bt_event_class *event_class,
                goto end;
        }
 
-       if (unlikely(!event->common.class)) {
-               event->common.class = BT_TO_COMMON(event_class);
-               bt_object_get_no_null_check(&event_class->common.base);
+       if (unlikely(!event->class)) {
+               event->class = event_class;
+               bt_object_get_no_null_check(&event_class->base);
        }
 
        BT_ASSERT(packet);
@@ -390,7 +218,4 @@ end:
        return event;
 }
 
-BT_HIDDEN
-struct bt_event *bt_event_new(struct bt_event_class *event_class);
-
 #endif /* BABELTRACE_CTF_IR_EVENT_INTERNAL_H */
index 0b96007b8ad33d13dcd41605b3b7ee565ec15ffe..2acb5bbbe41193b6706579130d16cc5211bdd3f9 100644 (file)
 #include <stdint.h>
 #include <glib.h>
 
-#define BT_ASSERT_PRE_FT_COMMON_HAS_ID(_ft, _type_id, _name)           \
-       BT_ASSERT_PRE(((struct bt_field_type_common *) (_ft))->id == (_type_id), \
+#define BT_ASSERT_PRE_FT_HAS_ID(_ft, _type_id, _name)          \
+       BT_ASSERT_PRE(((struct bt_field_type *) (_ft))->id == (_type_id), \
                _name " has the wrong type ID: expected-type-id=%s, "   \
-               "%![ft-]+_F", bt_common_field_type_id_string(_type_id), (_ft))
+               "%![ft-]+F", bt_common_field_type_id_string(_type_id), (_ft))
 
 #define BT_ASSERT_PRE_FT_HOT(_ft, _name)                               \
-       BT_ASSERT_PRE_HOT((_ft), (_name), ": %!+_F", (_ft))
+       BT_ASSERT_PRE_HOT((_ft), (_name), ": %!+F", (_ft))
 
-#define BT_FIELD_TYPE_COMMON_STRUCTURE_FIELD_AT_INDEX(_ft, _index)     \
-       (&g_array_index(((struct bt_field_type_common_structure *) (_ft))->fields, \
-               struct bt_field_type_common_structure_field, (_index)))
+#define BT_FIELD_TYPE_STRUCTURE_FIELD_AT_INDEX(_ft, _index)    \
+       (&g_array_index(((struct bt_field_type_structure *) (_ft))->fields, \
+               struct bt_field_type_structure_field, (_index)))
 
-#define BT_FIELD_TYPE_COMMON_VARIANT_CHOICE_AT_INDEX(_ft, _index)      \
-       (&g_array_index(((struct bt_field_type_common_variant *) (_ft))->choices, \
-               struct bt_field_type_common_variant_choice, (_index)))
+#define BT_FIELD_TYPE_VARIANT_CHOICE_AT_INDEX(_ft, _index)     \
+       (&g_array_index(((struct bt_field_type_variant *) (_ft))->choices, \
+               struct bt_field_type_variant_choice, (_index)))
 
-struct bt_field_common;
-struct bt_field_type_common;
+struct bt_field;
 struct bt_field_type;
 
-typedef void (*bt_field_type_common_method_freeze)(
-               struct bt_field_type_common *);
-typedef int (*bt_field_type_common_method_validate)(
-               struct bt_field_type_common *);
-typedef void (*bt_field_type_common_method_set_byte_order)(
-               struct bt_field_type_common *, enum bt_byte_order);
-typedef struct bt_field_type_common *(*bt_field_type_common_method_copy)(
-               struct bt_field_type_common *);
-typedef int (*bt_field_type_common_method_compare)(
-               struct bt_field_type_common *,
-               struct bt_field_type_common *);
-
-struct bt_field_type_common_methods {
-       bt_field_type_common_method_freeze freeze;
-       bt_field_type_common_method_validate validate;
-       bt_field_type_common_method_set_byte_order set_byte_order;
-       bt_field_type_common_method_copy copy;
-       bt_field_type_common_method_compare compare;
+typedef void (*bt_field_type_method_freeze)(
+               struct bt_field_type *);
+typedef int (*bt_field_type_method_validate)(
+               struct bt_field_type *);
+typedef void (*bt_field_type_method_set_byte_order)(
+               struct bt_field_type *, enum bt_byte_order);
+typedef struct bt_field_type *(*bt_field_type_method_copy)(
+               struct bt_field_type *);
+typedef int (*bt_field_type_method_compare)(
+               struct bt_field_type *,
+               struct bt_field_type *);
+
+struct bt_field_type_methods {
+       bt_field_type_method_freeze freeze;
+       bt_field_type_method_validate validate;
+       bt_field_type_method_set_byte_order set_byte_order;
+       bt_field_type_method_copy copy;
+       bt_field_type_method_compare compare;
 };
 
-struct bt_field_type_common {
+struct bt_field_type {
        struct bt_object base;
        enum bt_field_type_id id;
        unsigned int alignment;
 
        /* Virtual table */
-       struct bt_field_type_common_methods *methods;
+       struct bt_field_type_methods *methods;
 
        /*
         * A type can't be modified once it is added to an event or after a
@@ -96,36 +95,10 @@ struct bt_field_type_common {
         * a valid field type are also valid (and thus frozen).
         */
        int valid;
-
-       /*
-        * Specialized data for either CTF IR or CTF writer APIs.
-        * Having this here ensures that:
-        *
-        * * The type-specific common data is always found at the same
-        *   offset when the common API has a `struct
-        *   bt_field_type_common *` so that you can cast it to `struct
-        *   bt_field_type_common_integer *` for example and access the
-        *   common integer field type fields.
-        *
-        * * The specific CTF IR and CTF writer APIs can access their
-        *   specific field type fields in this union at an offset known
-        *   at build time. This avoids a pointer to specific data so
-        *   that all the fields, common or specific, of a CTF IR
-        *   integer field type or of a CTF writer integer field type,
-        *   for example, are contained within the same contiguous block
-        *   of memory.
-        */
-       union {
-               struct {
-               } ir;
-               struct {
-                       void *serialize_func;
-               } writer;
-       } spec;
 };
 
-struct bt_field_type_common_integer {
-       struct bt_field_type_common common;
+struct bt_field_type_integer {
+       struct bt_field_type common;
 
        /* Owned by this */
        struct bt_clock_class *mapped_clock_class;
@@ -149,11 +122,11 @@ struct enumeration_mapping {
        GQuark string;
 };
 
-struct bt_field_type_common_enumeration {
-       struct bt_field_type_common common;
+struct bt_field_type_enumeration {
+       struct bt_field_type common;
 
        /* Owned by this */
-       struct bt_field_type_common_integer *container_ft;
+       struct bt_field_type_integer *container_ft;
 
        /* Array of `struct enumeration_mapping *`, owned by this */
        GPtrArray *entries;
@@ -172,7 +145,7 @@ struct bt_field_type_enumeration_mapping_iterator {
        struct bt_object base;
 
        /* Owned by this */
-       struct bt_field_type_common_enumeration *enumeration_ft;
+       struct bt_field_type_enumeration *enumeration_ft;
 
        enum bt_field_type_enumeration_mapping_iterator_type type;
        int index;
@@ -183,32 +156,32 @@ struct bt_field_type_enumeration_mapping_iterator {
        } u;
 };
 
-struct bt_field_type_common_floating_point {
-       struct bt_field_type_common common;
+struct bt_field_type_floating_point {
+       struct bt_field_type common;
        enum bt_byte_order user_byte_order;
        unsigned int exp_dig;
        unsigned int mant_dig;
 };
 
-struct bt_field_type_common_structure_field {
+struct bt_field_type_structure_field {
        GQuark name;
 
        /* Owned by this */
-       struct bt_field_type_common *type;
+       struct bt_field_type *type;
 };
 
-struct bt_field_type_common_structure {
-       struct bt_field_type_common common;
+struct bt_field_type_structure {
+       struct bt_field_type common;
        GHashTable *field_name_to_index;
 
        /*
-        * Array of `struct bt_field_type_common_structure_field`,
+        * Array of `struct bt_field_type_structure_field`,
         * owned by this
         */
        GArray *fields;
 };
 
-struct bt_field_type_common_variant_choice_range {
+struct bt_field_type_variant_choice_range {
        union {
                int64_t i;
                uint64_t u;
@@ -219,23 +192,23 @@ struct bt_field_type_common_variant_choice_range {
        } upper;
 };
 
-struct bt_field_type_common_variant_choice {
+struct bt_field_type_variant_choice {
        GQuark name;
 
        /* Owned by this */
-       struct bt_field_type_common *type;
+       struct bt_field_type *type;
 
-       /* Array of `struct bt_field_type_common_variant_choice_range` */
+       /* Array of `struct bt_field_type_variant_choice_range` */
        GArray *ranges;
 };
 
-struct bt_field_type_common_variant {
-       struct bt_field_type_common common;
+struct bt_field_type_variant {
+       struct bt_field_type common;
        GString *tag_name;
        bool choices_up_to_date;
 
        /* Owned by this */
-       struct bt_field_type_common_enumeration *tag_ft;
+       struct bt_field_type_enumeration *tag_ft;
 
        /* Owned by this */
        struct bt_field_path *tag_field_path;
@@ -243,25 +216,25 @@ struct bt_field_type_common_variant {
        GHashTable *choice_name_to_index;
 
        /*
-        * Array of `struct bt_field_type_common_variant_choice`,
+        * Array of `struct bt_field_type_variant_choice`,
         * owned by this */
        GArray *choices;
 };
 
-struct bt_field_type_common_array {
-       struct bt_field_type_common common;
+struct bt_field_type_array {
+       struct bt_field_type common;
 
        /* Owned by this */
-       struct bt_field_type_common *element_ft;
+       struct bt_field_type *element_ft;
 
        unsigned int length;
 };
 
-struct bt_field_type_common_sequence {
-       struct bt_field_type_common common;
+struct bt_field_type_sequence {
+       struct bt_field_type common;
 
        /* Owned by this */
-       struct bt_field_type_common *element_ft;
+       struct bt_field_type *element_ft;
 
        GString *length_field_name;
 
@@ -269,516 +242,65 @@ struct bt_field_type_common_sequence {
        struct bt_field_path *length_field_path;
 };
 
-struct bt_field_type_common_string {
-       struct bt_field_type_common common;
+struct bt_field_type_string {
+       struct bt_field_type common;
        enum bt_string_encoding encoding;
 };
 
-typedef struct bt_field_common *(* bt_field_common_create_func)(
-               struct bt_field_type_common *);
-
-BT_HIDDEN
-void bt_field_type_common_initialize(struct bt_field_type_common *ft,
-               bool init_bo, bt_object_release_func release_func,
-               struct bt_field_type_common_methods *methods);
-
-BT_HIDDEN
-void bt_field_type_common_integer_initialize(
-               struct bt_field_type_common *ft,
-               unsigned int size, bt_object_release_func release_func,
-               struct bt_field_type_common_methods *methods);
-
-BT_HIDDEN
-void bt_field_type_common_floating_point_initialize(
-               struct bt_field_type_common *ft,
-               bt_object_release_func release_func,
-               struct bt_field_type_common_methods *methods);
-
-BT_HIDDEN
-void bt_field_type_common_enumeration_initialize(
-               struct bt_field_type_common *ft,
-               struct bt_field_type_common *container_ft,
-               bt_object_release_func release_func,
-               struct bt_field_type_common_methods *methods);
-
-BT_HIDDEN
-void bt_field_type_common_string_initialize(
-               struct bt_field_type_common *ft,
-               bt_object_release_func release_func,
-               struct bt_field_type_common_methods *methods);
-
-BT_HIDDEN
-void bt_field_type_common_structure_initialize(
-               struct bt_field_type_common *ft,
-               bt_object_release_func release_func,
-               struct bt_field_type_common_methods *methods);
-
-BT_HIDDEN
-void bt_field_type_common_array_initialize(
-               struct bt_field_type_common *ft,
-               struct bt_field_type_common *element_ft,
-               unsigned int length, bt_object_release_func release_func,
-               struct bt_field_type_common_methods *methods);
-
-BT_HIDDEN
-void bt_field_type_common_sequence_initialize(
-               struct bt_field_type_common *ft,
-               struct bt_field_type_common *element_ft,
-               const char *length_field_name,
-               bt_object_release_func release_func,
-               struct bt_field_type_common_methods *methods);
-
-BT_HIDDEN
-void bt_field_type_common_variant_initialize(
-               struct bt_field_type_common *ft,
-               struct bt_field_type_common *tag_ft,
-               const char *tag_name,
-               bt_object_release_func release_func,
-               struct bt_field_type_common_methods *methods);
-
-BT_HIDDEN
-void bt_field_type_common_integer_destroy(struct bt_object *obj);
-
-BT_HIDDEN
-void bt_field_type_common_floating_point_destroy(struct bt_object *obj);
-
-BT_HIDDEN
-void bt_field_type_common_enumeration_destroy_recursive(struct bt_object *obj);
-
-BT_HIDDEN
-void bt_field_type_common_string_destroy(struct bt_object *obj);
-
-BT_HIDDEN
-void bt_field_type_common_structure_destroy_recursive(struct bt_object *obj);
-
-BT_HIDDEN
-void bt_field_type_common_array_destroy_recursive(struct bt_object *obj);
-
-BT_HIDDEN
-void bt_field_type_common_sequence_destroy_recursive(struct bt_object *obj);
-
-BT_HIDDEN
-void bt_field_type_common_variant_destroy_recursive(struct bt_object *obj);
-
-BT_HIDDEN
-int bt_field_type_common_integer_validate(struct bt_field_type_common *ft);
-
-BT_HIDDEN
-int bt_field_type_common_enumeration_validate_recursive(
-               struct bt_field_type_common *ft);
-
-BT_HIDDEN
-int bt_field_type_common_sequence_validate_recursive(
-               struct bt_field_type_common *ft);
-
-BT_HIDDEN
-int bt_field_type_common_array_validate_recursive(
-               struct bt_field_type_common *ft);
-
-BT_HIDDEN
-int bt_field_type_common_structure_validate_recursive(
-               struct bt_field_type_common *ft);
-
-BT_HIDDEN
-int bt_field_type_common_variant_validate_recursive(
-               struct bt_field_type_common *type);
-
-BT_HIDDEN
-int bt_field_type_common_validate(struct bt_field_type_common *ft);
-
-BT_HIDDEN
-int bt_field_type_common_integer_get_size(struct bt_field_type_common *ft);
-
-BT_HIDDEN
-bt_bool bt_field_type_common_integer_is_signed(struct bt_field_type_common *ft);
-
-BT_HIDDEN
-int bt_field_type_common_integer_set_is_signed(struct bt_field_type_common *ft,
-               bt_bool is_signed);
-
-BT_HIDDEN
-int bt_field_type_common_integer_set_size(struct bt_field_type_common *ft,
-               unsigned int size);
-
-BT_HIDDEN
-enum bt_integer_base bt_field_type_common_integer_get_base(
-               struct bt_field_type_common *ft);
-
-BT_HIDDEN
-int bt_field_type_common_integer_set_base(struct bt_field_type_common *ft,
-               enum bt_integer_base base);
-
-BT_HIDDEN
-enum bt_string_encoding bt_field_type_common_integer_get_encoding(
-               struct bt_field_type_common *ft);
-
-BT_HIDDEN
-int bt_field_type_common_integer_set_encoding(struct bt_field_type_common *ft,
-               enum bt_string_encoding encoding);
-
-BT_HIDDEN
-struct bt_clock_class *bt_field_type_common_integer_borrow_mapped_clock_class(
-               struct bt_field_type_common *ft);
-
-BT_HIDDEN
-int bt_field_type_common_integer_set_mapped_clock_class_no_check_frozen(
-               struct bt_field_type_common *ft,
-               struct bt_clock_class *clock_class);
-
-BT_HIDDEN
-int bt_field_type_common_integer_set_mapped_clock_class(
-               struct bt_field_type_common *ft,
-               struct bt_clock_class *clock_class);
-
-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_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_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_HIDDEN
-int bt_field_type_common_enumeration_signed_get_mapping_by_index(
-               struct bt_field_type_common *ft, uint64_t index,
-               const char **mapping_name, int64_t *range_begin,
-               int64_t *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);
-
-BT_HIDDEN
-struct bt_field_type_common *
-bt_field_type_common_enumeration_borrow_container_field_type(
-               struct bt_field_type_common *ft);
-
-BT_HIDDEN
-int bt_field_type_common_enumeration_signed_add_mapping(
-               struct bt_field_type_common *ft, const char *string,
-               int64_t range_start, int64_t 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);
-
-BT_HIDDEN
-int64_t bt_field_type_common_enumeration_get_mapping_count(
-               struct bt_field_type_common *ft);
-
-BT_HIDDEN
-int bt_field_type_common_floating_point_get_exponent_digits(
-               struct bt_field_type_common *ft);
+typedef struct bt_field *(* bt_field_create_func)(
+               struct bt_field_type *);
 
-BT_HIDDEN
-int bt_field_type_common_floating_point_set_exponent_digits(
-               struct bt_field_type_common *ft,
-               unsigned int exponent_digits);
+BT_ASSERT_FUNC
+static inline bool bt_field_type_has_known_id(
+               struct bt_field_type *ft)
+{
+       return (int) ft->id > BT_FIELD_TYPE_ID_UNKNOWN ||
+               (int) ft->id < BT_FIELD_TYPE_ID_NR;
+}
 
 BT_HIDDEN
-int bt_field_type_common_floating_point_get_mantissa_digits(
-               struct bt_field_type_common *type);
-
-BT_HIDDEN
-int bt_field_type_common_floating_point_set_mantissa_digits(
-               struct bt_field_type_common *ft, unsigned int mantissa_digits);
-
-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);
-
-BT_HIDDEN
-int bt_field_type_common_structure_add_field(struct bt_field_type_common *ft,
-               struct bt_field_type_common *field_type,
-               const char *field_name);
-
-BT_HIDDEN
-int64_t bt_field_type_common_structure_get_field_count(
-               struct bt_field_type_common *ft);
-
-BT_HIDDEN
-int bt_field_type_common_structure_borrow_field_by_index(
-               struct bt_field_type_common *ft,
-               const char **field_name,
-               struct bt_field_type_common **field_type, uint64_t 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);
-
-BT_HIDDEN
-struct bt_field_type_common *
-bt_field_type_common_variant_borrow_tag_field_type(
-               struct bt_field_type_common *ft);
-
-BT_HIDDEN
-const char *bt_field_type_common_variant_get_tag_name(
-               struct bt_field_type_common *ft);
-
-BT_HIDDEN
-int bt_field_type_common_variant_set_tag_name(
-               struct bt_field_type_common *ft, const char *name);
-
-BT_HIDDEN
-int bt_field_type_common_variant_add_field(struct bt_field_type_common *ft,
-               struct bt_field_type_common *field_type,
-               const char *field_name);
-
-BT_HIDDEN
-int bt_field_type_common_variant_update_choices(
-               struct bt_field_type_common *ft);
-
-BT_HIDDEN
-struct bt_field_type_common *
-bt_field_type_common_variant_borrow_field_type_by_name(
-               struct bt_field_type_common *ft,
-               const char *field_name);
-
-BT_HIDDEN
-int64_t bt_field_type_common_variant_get_field_count(
-               struct bt_field_type_common *ft);
-
-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);
-
-BT_HIDDEN
-struct bt_field_type_common *
-bt_field_type_common_array_borrow_element_field_type(
-               struct bt_field_type_common *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);
-
-BT_HIDDEN
-int64_t bt_field_type_common_array_get_length(struct bt_field_type_common *ft);
-
-BT_HIDDEN
-struct bt_field_type_common *
-bt_field_type_common_sequence_borrow_element_field_type(
-               struct bt_field_type_common *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);
-
-BT_HIDDEN
-const char *bt_field_type_common_sequence_get_length_field_name(
-               struct bt_field_type_common *ft);
-
-BT_HIDDEN
-enum bt_string_encoding bt_field_type_common_string_get_encoding(
-               struct bt_field_type_common *ft);
-
-BT_HIDDEN
-int bt_field_type_common_string_set_encoding(struct bt_field_type_common *ft,
-               enum bt_string_encoding encoding);
-
-BT_HIDDEN
-int bt_field_type_common_get_alignment(struct bt_field_type_common *type);
-
-BT_HIDDEN
-int bt_field_type_common_set_alignment(struct bt_field_type_common *ft,
-               unsigned int alignment);
-
-BT_HIDDEN
-enum bt_byte_order bt_field_type_common_get_byte_order(
-               struct bt_field_type_common *ft);
-
-BT_HIDDEN
-int bt_field_type_common_set_byte_order(struct bt_field_type_common *ft,
-               enum bt_byte_order byte_order);
-
-BT_HIDDEN
-enum bt_field_type_id bt_field_type_common_get_type_id(
-               struct bt_field_type_common *ft);
-
-BT_HIDDEN
-void bt_field_type_common_freeze(struct bt_field_type_common *ft);
+int bt_field_type_variant_update_choices(
+               struct bt_field_type *ft);
 
 BT_HIDDEN
 void bt_field_type_freeze(struct bt_field_type *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);
-
-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);
+int bt_field_type_validate(struct bt_field_type *ft);
 
 BT_HIDDEN
-struct bt_field_type_common *bt_field_type_common_copy(
-               struct bt_field_type_common *ft);
+int bt_field_type_sequence_set_length_field_path(
+               struct bt_field_type *ft, struct bt_field_path *path);
 
 BT_HIDDEN
-int bt_field_type_common_structure_get_field_name_index(
-               struct bt_field_type_common *ft, const char *name);
-
-BT_HIDDEN
-int bt_field_type_common_variant_get_field_name_index(
-               struct bt_field_type_common *ft, const char *name);
-
-BT_HIDDEN
-int bt_field_type_common_sequence_set_length_field_path(
-               struct bt_field_type_common *ft, struct bt_field_path *path);
-
-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);
 
 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);
-
-BT_HIDDEN
-void bt_field_type_common_generic_freeze(struct bt_field_type_common *ft);
-
-BT_HIDDEN
-void bt_field_type_common_enumeration_freeze_recursive(
-               struct bt_field_type_common *ft);
-
-BT_HIDDEN
-void bt_field_type_common_structure_freeze_recursive(
-               struct bt_field_type_common *ft);
-
-BT_HIDDEN
-void bt_field_type_common_variant_freeze_recursive(
-               struct bt_field_type_common *ft);
-
-BT_HIDDEN
-void bt_field_type_common_array_freeze_recursive(
-               struct bt_field_type_common *ft);
+int bt_field_type_variant_set_tag_field_type(
+               struct bt_field_type *ft,
+               struct bt_field_type *tag_ft);
 
 BT_HIDDEN
-void bt_field_type_common_sequence_freeze_recursive(
-               struct bt_field_type_common *type);
+int64_t bt_field_type_get_field_count(struct bt_field_type *ft);
 
 BT_HIDDEN
-void bt_field_type_common_integer_set_byte_order(
-               struct bt_field_type_common *ft, enum bt_byte_order byte_order);
+struct bt_field_type *bt_field_type_borrow_field_at_index(
+               struct bt_field_type *ft, int index);
 
 BT_HIDDEN
-void bt_field_type_common_enumeration_set_byte_order_recursive(
-               struct bt_field_type_common *ft, enum bt_byte_order 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);
-
-BT_HIDDEN
-void bt_field_type_common_structure_set_byte_order_recursive(
-               struct bt_field_type_common *ft,
-               enum bt_byte_order byte_order);
-
-BT_HIDDEN
-void bt_field_type_common_variant_set_byte_order_recursive(
-               struct bt_field_type_common *ft,
-               enum bt_byte_order byte_order);
-
-BT_HIDDEN
-void bt_field_type_common_array_set_byte_order_recursive(
-               struct bt_field_type_common *ft,
-               enum bt_byte_order byte_order);
-
-BT_HIDDEN
-void bt_field_type_common_sequence_set_byte_order_recursive(
-               struct bt_field_type_common *ft,
-               enum bt_byte_order 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);
-
-BT_HIDDEN
-int bt_field_type_common_floating_point_compare(
-               struct bt_field_type_common *ft_a,
-               struct bt_field_type_common *ft_b);
-
-BT_HIDDEN
-int bt_field_type_common_enumeration_compare_recursive(
-               struct bt_field_type_common *ft_a,
-               struct bt_field_type_common *ft_b);
-
-BT_HIDDEN
-int bt_field_type_common_string_compare(struct bt_field_type_common *ft_a,
-               struct bt_field_type_common *ft_b);
-
-BT_HIDDEN
-int bt_field_type_common_structure_compare_recursive(
-               struct bt_field_type_common *ft_a,
-               struct bt_field_type_common *ft_b);
-
-BT_HIDDEN
-int bt_field_type_common_variant_compare_recursive(
-               struct bt_field_type_common *ft_a,
-               struct bt_field_type_common *ft_b);
-
-BT_HIDDEN
-int bt_field_type_common_array_compare_recursive(
-               struct bt_field_type_common *ft_a,
-               struct bt_field_type_common *ft_b);
-
-BT_HIDDEN
-int bt_field_type_common_sequence_compare_recursive(
-               struct bt_field_type_common *ft_a,
-               struct bt_field_type_common *ft_b);
-
-BT_HIDDEN
-int bt_field_type_common_compare(struct bt_field_type_common *ft_a,
-               struct bt_field_type_common *ft_b);
-
-BT_HIDDEN
-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);
-
-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);
 
 BT_HIDDEN
-struct bt_field_path *bt_field_type_common_variant_borrow_tag_field_path(
-               struct bt_field_type_common *ft);
-
-BT_HIDDEN
-struct bt_field_path *bt_field_type_common_sequence_borrow_length_field_path(
-               struct bt_field_type_common *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);
 
 BT_HIDDEN
-int64_t bt_field_type_common_variant_find_choice_index(
-               struct bt_field_type_common *ft, uint64_t uval,
+int64_t bt_field_type_variant_find_choice_index(
+               struct bt_field_type *ft, uint64_t uval,
                bool is_signed);
 
 #endif /* BABELTRACE_CTF_IR_FIELD_TYPES_INTERNAL_H */
index cdbfabe93bd5eaf4180e25d351349325269f183e..cc164e0c3d54eea35427f57d27e51cf08e9ad034 100644 (file)
@@ -31,7 +31,7 @@ struct bt_field_wrapper {
        struct bt_object base;
 
        /* Owned by this */
-       struct bt_field_common *field;
+       struct bt_field *field;
 };
 
 BT_HIDDEN
index b7aff55eb43fff7d8e0a6da52453a6613b95e81d..765502c77eb6c838934217d4480c15821a3445b3 100644 (file)
 #include <stdbool.h>
 #include <glib.h>
 
-#define BT_ASSERT_PRE_FIELD_COMMON_HAS_TYPE_ID(_field, _type_id, _name)        \
+#define BT_ASSERT_PRE_FIELD_HAS_TYPE_ID(_field, _type_id, _name)       \
        BT_ASSERT_PRE((_field)->type->id == ((int) (_type_id)),         \
                _name " has the wrong type ID: expected-type-id=%s, "   \
-               "%![field-]+_f",                                        \
+               "%![field-]+f",                                 \
                bt_common_field_type_id_string((int) (_type_id)), (_field))
 
-#define BT_ASSERT_PRE_FIELD_COMMON_IS_SET(_field, _name)               \
-       BT_ASSERT_PRE(bt_field_common_is_set_recursive(_field),         \
-               _name " is not set: %!+_f", (_field))
+#define BT_ASSERT_PRE_FIELD_IS_SET(_field, _name)              \
+       BT_ASSERT_PRE(bt_field_is_set_recursive(_field),                \
+               _name " is not set: %!+f", (_field))
 
-#define BT_ASSERT_PRE_FIELD_COMMON_HOT(_field, _name)                  \
-       BT_ASSERT_PRE_HOT((_field), (_name), ": %!+_f", (_field))
+#define BT_ASSERT_PRE_FIELD_HOT(_field, _name)                 \
+       BT_ASSERT_PRE_HOT((_field), (_name), ": %!+f", (_field))
 
 struct bt_field;
-struct bt_field_common;
 
-typedef void (*bt_field_common_method_set_is_frozen)(struct bt_field_common *,
+typedef void (*bt_field_method_set_is_frozen)(struct bt_field *,
                bool);
-typedef int (*bt_field_common_method_validate)(struct bt_field_common *);
-typedef struct bt_field_common *(*bt_field_common_method_copy)(
-               struct bt_field_common *);
-typedef bt_bool (*bt_field_common_method_is_set)(struct bt_field_common *);
-typedef void (*bt_field_common_method_reset)(struct bt_field_common *);
-
-struct bt_field_common_methods {
-       bt_field_common_method_set_is_frozen set_is_frozen;
-       bt_field_common_method_validate validate;
-       bt_field_common_method_copy copy;
-       bt_field_common_method_is_set is_set;
-       bt_field_common_method_reset reset;
+typedef int (*bt_field_method_validate)(struct bt_field *);
+typedef bt_bool (*bt_field_method_is_set)(struct bt_field *);
+typedef void (*bt_field_method_reset)(struct bt_field *);
+
+struct bt_field_methods {
+       bt_field_method_set_is_frozen set_is_frozen;
+       bt_field_method_validate validate;
+       bt_field_method_is_set is_set;
+       bt_field_method_reset reset;
 };
 
-struct bt_field_common {
+struct bt_field {
        struct bt_object base;
-       struct bt_field_type_common *type;
-       struct bt_field_common_methods *methods;
+       struct bt_field_type *type;
+       struct bt_field_methods *methods;
        bool payload_set;
        bool frozen;
-
-       /*
-        * Specialized data for either CTF IR or CTF writer APIs.
-        * See comment in `field-types-internal.h` for more details.
-        */
-       union {
-               struct {
-               } ir;
-               struct {
-                       void *serialize_func;
-               } writer;
-       } spec;
 };
 
-struct bt_field_common_integer {
-       struct bt_field_common common;
+struct bt_field_integer {
+       struct bt_field common;
        union {
                int64_t signd;
                uint64_t unsignd;
        } payload;
 };
 
-struct bt_field_common_floating_point {
-       struct bt_field_common common;
+struct bt_field_enumeration {
+       struct bt_field_integer common;
+};
+
+struct bt_field_floating_point {
+       struct bt_field common;
        double payload;
 };
 
-struct bt_field_common_structure {
-       struct bt_field_common common;
+struct bt_field_structure {
+       struct bt_field common;
 
-       /* Array of `struct bt_field_common *`, owned by this */
+       /* Array of `struct bt_field *`, owned by this */
        GPtrArray *fields;
 };
 
-struct bt_field_common_variant {
-       struct bt_field_common common;
+struct bt_field_variant {
+       struct bt_field common;
 
        union {
                uint64_t u;
@@ -121,21 +109,21 @@ struct bt_field_common_variant {
        } tag_value;
 
        /* Weak: belongs to `choices` below */
-       struct bt_field_common *current_field;
+       struct bt_field *current_field;
 
-       /* Array of `struct bt_field_common *`, owned by this */
+       /* Array of `struct bt_field *`, owned by this */
        GPtrArray *fields;
 };
 
-struct bt_field_common_array {
-       struct bt_field_common common;
+struct bt_field_array {
+       struct bt_field common;
 
-       /* Array of `struct bt_field_common *`, owned by this */
+       /* Array of `struct bt_field *`, owned by this */
        GPtrArray *elements;
 };
 
-struct bt_field_common_sequence {
-       struct bt_field_common common;
+struct bt_field_sequence {
+       struct bt_field common;
 
        /*
         * This is the true sequence field's length: its value can be
@@ -144,147 +132,23 @@ struct bt_field_common_sequence {
         */
        uint64_t length;
 
-       /* Array of `struct bt_field_common *`, owned by this */
+       /* Array of `struct bt_field *`, owned by this */
        GPtrArray *elements;
 };
 
-struct bt_field_common_string {
-       struct bt_field_common common;
+struct bt_field_string {
+       struct bt_field common;
        GArray *buf;
        size_t size;
 };
 
-struct bt_field_enumeration {
-       struct bt_field_common_integer common;
-};
-
-BT_HIDDEN
-struct bt_field_common *bt_field_common_copy(struct bt_field_common *field);
-
-BT_HIDDEN
-int bt_field_common_structure_initialize(struct bt_field_common *field,
-               struct bt_field_type_common *type,
-               bool is_shared, bt_object_release_func release_func,
-               struct bt_field_common_methods *methods,
-               bt_field_common_create_func field_create_func,
-               GDestroyNotify field_release_func);
-
-BT_HIDDEN
-int bt_field_common_array_initialize(struct bt_field_common *field,
-               struct bt_field_type_common *type,
-               bool is_shared, bt_object_release_func release_func,
-               struct bt_field_common_methods *methods,
-               bt_field_common_create_func field_create_func,
-               GDestroyNotify field_destroy_func);
-
-BT_HIDDEN
-int bt_field_common_sequence_initialize(struct bt_field_common *field,
-               struct bt_field_type_common *type,
-               bool is_shared, bt_object_release_func release_func,
-               struct bt_field_common_methods *methods,
-               GDestroyNotify field_destroy_func);
-
-BT_HIDDEN
-int bt_field_common_variant_initialize(struct bt_field_common *field,
-               struct bt_field_type_common *type,
-               bool is_shared, bt_object_release_func release_func,
-               struct bt_field_common_methods *methods,
-               bt_field_common_create_func field_create_func,
-               GDestroyNotify field_release_func);
-
-BT_HIDDEN
-int bt_field_common_string_initialize(struct bt_field_common *field,
-               struct bt_field_type_common *type,
-               bool is_shared, bt_object_release_func release_func,
-               struct bt_field_common_methods *methods);
-
-BT_HIDDEN
-int bt_field_common_generic_validate(struct bt_field_common *field);
-
-BT_HIDDEN
-int bt_field_common_structure_validate_recursive(struct bt_field_common *field);
-
-BT_HIDDEN
-int bt_field_common_variant_validate_recursive(struct bt_field_common *field);
-
-BT_HIDDEN
-int bt_field_common_array_validate_recursive(struct bt_field_common *field);
-
-BT_HIDDEN
-int bt_field_common_sequence_validate_recursive(struct bt_field_common *field);
-
-BT_HIDDEN
-void bt_field_common_generic_reset(struct bt_field_common *field);
-
-BT_HIDDEN
-void bt_field_common_structure_reset_recursive(struct bt_field_common *field);
-
-BT_HIDDEN
-void bt_field_common_variant_reset_recursive(struct bt_field_common *field);
-
-BT_HIDDEN
-void bt_field_common_array_reset_recursive(struct bt_field_common *field);
-
-BT_HIDDEN
-void bt_field_common_sequence_reset_recursive(struct bt_field_common *field);
-
-BT_HIDDEN
-void bt_field_common_generic_set_is_frozen(struct bt_field_common *field,
-               bool is_frozen);
-
-BT_HIDDEN
-void bt_field_common_structure_set_is_frozen_recursive(
-               struct bt_field_common *field, bool is_frozen);
-
-BT_HIDDEN
-void bt_field_common_variant_set_is_frozen_recursive(
-               struct bt_field_common *field, bool is_frozen);
-
-BT_HIDDEN
-void bt_field_common_array_set_is_frozen_recursive(
-               struct bt_field_common *field, bool is_frozen);
-
-BT_HIDDEN
-void bt_field_common_sequence_set_is_frozen_recursive(
-               struct bt_field_common *field, bool is_frozen);
-
-BT_HIDDEN
-void _bt_field_common_set_is_frozen_recursive(struct bt_field_common *field,
-               bool is_frozen);
-
-BT_HIDDEN
-bt_bool bt_field_common_generic_is_set(struct bt_field_common *field);
-
-BT_HIDDEN
-bt_bool bt_field_common_structure_is_set_recursive(
-               struct bt_field_common *field);
-
-BT_HIDDEN
-bt_bool bt_field_common_variant_is_set_recursive(struct bt_field_common *field);
-
-BT_HIDDEN
-bt_bool bt_field_common_array_is_set_recursive(struct bt_field_common *field);
-
-BT_HIDDEN
-bt_bool bt_field_common_sequence_is_set_recursive(struct bt_field_common *field);
-
 #ifdef BT_DEV_MODE
-# define bt_field_common_validate_recursive            _bt_field_common_validate_recursive
-# define bt_field_common_set_is_frozen_recursive       _bt_field_common_set_is_frozen_recursive
-# define bt_field_common_is_set_recursive              _bt_field_common_is_set_recursive
-# define bt_field_common_reset_recursive               _bt_field_common_reset_recursive
-# define bt_field_common_set                           _bt_field_common_set
 # define bt_field_validate_recursive                   _bt_field_validate_recursive
 # define bt_field_set_is_frozen_recursive              _bt_field_set_is_frozen_recursive
 # define bt_field_is_set_recursive                     _bt_field_is_set_recursive
 # define bt_field_reset_recursive                      _bt_field_reset_recursive
 # define bt_field_set                                  _bt_field_set
 #else
-# define bt_field_common_validate_recursive(_field)    (-1)
-# define bt_field_common_set_is_frozen_recursive(_field, _is_frozen)
-# define bt_field_common_is_set_recursive(_field)      (BT_FALSE)
-# define bt_field_common_reset_recursive(_field)
-# define bt_field_common_set(_field, _val)
 # define bt_field_validate_recursive(_field)           (-1)
 # define bt_field_set_is_frozen_recursive(_field, _is_frozen)
 # define bt_field_is_set_recursive(_field)             (BT_FALSE)
@@ -292,16 +156,12 @@ bt_bool bt_field_common_sequence_is_set_recursive(struct bt_field_common *field)
 # define bt_field_set(_field, _val)
 #endif
 
-BT_ASSERT_FUNC
-static inline bool field_type_common_has_known_id(
-               struct bt_field_type_common *ft)
-{
-       return (int) ft->id > BT_FIELD_TYPE_ID_UNKNOWN ||
-               (int) ft->id < BT_FIELD_TYPE_ID_NR;
-}
+BT_HIDDEN
+void _bt_field_set_is_frozen_recursive(struct bt_field *field,
+               bool is_frozen);
 
 static inline
-int _bt_field_common_validate_recursive(struct bt_field_common *field)
+int _bt_field_validate_recursive(struct bt_field *field)
 {
        int ret = 0;
 
@@ -311,7 +171,7 @@ int _bt_field_common_validate_recursive(struct bt_field_common *field)
                goto end;
        }
 
-       BT_ASSERT(field_type_common_has_known_id(field->type));
+       BT_ASSERT(bt_field_type_has_known_id(field->type));
 
        if (field->methods->validate) {
                ret = field->methods->validate(field);
@@ -322,7 +182,7 @@ end:
 }
 
 static inline
-void _bt_field_common_reset_recursive(struct bt_field_common *field)
+void _bt_field_reset_recursive(struct bt_field *field)
 {
        BT_ASSERT(field);
        BT_ASSERT(field->methods->reset);
@@ -330,14 +190,14 @@ void _bt_field_common_reset_recursive(struct bt_field_common *field)
 }
 
 static inline
-void _bt_field_common_set(struct bt_field_common *field, bool value)
+void _bt_field_set(struct bt_field *field, bool value)
 {
        BT_ASSERT(field);
        field->payload_set = value;
 }
 
 static inline
-bt_bool _bt_field_common_is_set_recursive(struct bt_field_common *field)
+bt_bool _bt_field_is_set_recursive(struct bt_field *field)
 {
        bt_bool is_set = BT_FALSE;
 
@@ -345,7 +205,7 @@ bt_bool _bt_field_common_is_set_recursive(struct bt_field_common *field)
                goto end;
        }
 
-       BT_ASSERT(field_type_common_has_known_id(field->type));
+       BT_ASSERT(bt_field_type_has_known_id(field->type));
        BT_ASSERT(field->methods->is_set);
        is_set = field->methods->is_set(field);
 
@@ -353,539 +213,6 @@ end:
        return is_set;
 }
 
-static inline
-void bt_field_common_initialize(struct bt_field_common *field,
-               struct bt_field_type_common *ft, bool is_shared,
-               bt_object_release_func release_func,
-               struct bt_field_common_methods *methods)
-{
-       BT_ASSERT(field);
-       BT_ASSERT(ft);
-       bt_object_init(&field->base, is_shared, release_func);
-       field->methods = methods;
-       field->type = bt_get(ft);
-}
-
-static inline
-struct bt_field_type_common *bt_field_common_borrow_type(
-               struct bt_field_common *field)
-{
-       struct bt_field_type_common *ret = NULL;
-
-       BT_ASSERT_PRE_NON_NULL(field, "Field");
-       ret = field->type;
-       return ret;
-}
-
-static inline
-int64_t bt_field_common_sequence_get_length(struct bt_field_common *field)
-{
-       struct bt_field_common_sequence *sequence = BT_FROM_COMMON(field);
-
-       BT_ASSERT_PRE_NON_NULL(field, "Sequence field");
-       BT_ASSERT_PRE_FIELD_COMMON_HAS_TYPE_ID(field, BT_FIELD_TYPE_ID_SEQUENCE,
-               "Field");
-       return (int64_t) sequence->length;
-}
-
-static inline
-int bt_field_common_sequence_set_length(struct bt_field_common *field,
-               uint64_t length, bt_field_common_create_func field_create_func)
-{
-       int ret = 0;
-       struct bt_field_common_sequence *sequence = BT_FROM_COMMON(field);
-
-       BT_ASSERT_PRE_NON_NULL(field, "Sequence field");
-       BT_ASSERT_PRE(((int64_t) length) >= 0,
-               "Invalid sequence length (too large): length=%" PRId64,
-               length);
-       BT_ASSERT_PRE_FIELD_COMMON_HOT(field, "Sequence field");
-
-       if (unlikely(length > sequence->elements->len)) {
-               /* Make more room */
-               struct bt_field_type_common_sequence *sequence_ft;
-               uint64_t cur_len = sequence->elements->len;
-               uint64_t i;
-
-               g_ptr_array_set_size(sequence->elements, length);
-               sequence_ft = BT_FROM_COMMON(sequence->common.type);
-
-               for (i = cur_len; i < sequence->elements->len; i++) {
-                       struct bt_field_common *elem_field =
-                               field_create_func(sequence_ft->element_ft);
-
-                       if (!elem_field) {
-                               ret = -1;
-                               goto end;
-                       }
-
-                       BT_ASSERT(!sequence->elements->pdata[i]);
-                       sequence->elements->pdata[i] = elem_field;
-               }
-       }
-
-       sequence->length = length;
-
-end:
-       return ret;
-}
-
-static inline
-struct bt_field_common *bt_field_common_structure_borrow_field_by_name(
-               struct bt_field_common *field, const char *name)
-{
-       struct bt_field_common *ret = NULL;
-       GQuark field_quark;
-       struct bt_field_type_common_structure *structure_ft;
-       struct bt_field_common_structure *structure = BT_FROM_COMMON(field);
-       size_t index;
-       GHashTable *field_name_to_index;
-
-       BT_ASSERT_PRE_NON_NULL(field, "Structure field");
-       BT_ASSERT_PRE_NON_NULL(name, "Field name");
-       BT_ASSERT_PRE_FIELD_COMMON_HAS_TYPE_ID(field,
-               BT_FIELD_TYPE_ID_STRUCT, "Field");
-       structure_ft = BT_FROM_COMMON(field->type);
-       field_name_to_index = structure_ft->field_name_to_index;
-       field_quark = g_quark_from_string(name);
-       if (!g_hash_table_lookup_extended(field_name_to_index,
-                       GUINT_TO_POINTER(field_quark),
-                       NULL, (gpointer *) &index)) {
-               BT_LOGV("Invalid parameter: no such field in structure field's type: "
-                       "struct-field-addr=%p, struct-ft-addr=%p, name=\"%s\"",
-                       field, field->type, name);
-               goto error;
-       }
-
-       ret = structure->fields->pdata[index];
-       BT_ASSERT(ret);
-
-error:
-       return ret;
-}
-
-static inline
-struct bt_field_common *bt_field_common_structure_borrow_field_by_index(
-               struct bt_field_common *field, uint64_t index)
-{
-       struct bt_field_common_structure *structure = BT_FROM_COMMON(field);
-
-       BT_ASSERT_PRE_NON_NULL(field, "Structure field");
-       BT_ASSERT_PRE_FIELD_COMMON_HAS_TYPE_ID(field,
-               BT_FIELD_TYPE_ID_STRUCT, "Field");
-       BT_ASSERT_PRE(index < structure->fields->len,
-               "Index is out of bound: %![struct-field-]+_f, "
-               "index=%" PRIu64 ", count=%u", field, index,
-               structure->fields->len);
-       return structure->fields->pdata[index];
-}
-
-static inline
-struct bt_field_common *bt_field_common_array_borrow_field(
-               struct bt_field_common *field, uint64_t index)
-{
-       struct bt_field_common_array *array = BT_FROM_COMMON(field);
-
-       BT_ASSERT_PRE_NON_NULL(field, "Array field");
-       BT_ASSERT_PRE_FIELD_COMMON_HAS_TYPE_ID(field, BT_FIELD_TYPE_ID_ARRAY,
-               "Field");
-       BT_ASSERT_PRE(index < array->elements->len,
-               "Index is out of bound: %![array-field-]+_f, "
-               "index=%" PRIu64 ", count=%u", field,
-               index, array->elements->len);
-       return array->elements->pdata[(size_t) index];
-}
-
-static inline
-struct bt_field_common *bt_field_common_sequence_borrow_field(
-               struct bt_field_common *field, uint64_t index)
-{
-       struct bt_field_common_sequence *sequence = BT_FROM_COMMON(field);
-
-       BT_ASSERT_PRE_NON_NULL(field, "Sequence field");
-       BT_ASSERT_PRE_FIELD_COMMON_HAS_TYPE_ID(field, BT_FIELD_TYPE_ID_SEQUENCE,
-               "Field");
-       BT_ASSERT_PRE(index < sequence->length,
-               "Index is out of bound: %![seq-field-]+_f, "
-               "index=%" PRIu64 ", count=%u", field, index,
-               sequence->elements->len);
-       return sequence->elements->pdata[(size_t) index];
-}
-
-static inline
-int bt_field_variant_common_set_tag(struct bt_field_common *variant_field,
-               uint64_t tag_uval, bool is_signed)
-{
-       int ret = 0;
-       int64_t choice_index;
-       struct bt_field_common_variant *variant = BT_FROM_COMMON(variant_field);
-
-       BT_ASSERT_PRE_NON_NULL(variant_field, "Variant field");
-       BT_ASSERT_PRE_FIELD_COMMON_HAS_TYPE_ID(variant_field,
-               BT_FIELD_TYPE_ID_VARIANT, "Field");
-
-       /* Find matching index in variant field's type */
-       choice_index = bt_field_type_common_variant_find_choice_index(
-               variant_field->type, tag_uval, is_signed);
-       if (choice_index < 0) {
-               ret = -1;
-               goto end;
-       }
-
-       /* Select corresponding field */
-       BT_ASSERT(choice_index < variant->fields->len);
-       variant->current_field = variant->fields->pdata[choice_index];
-       variant->tag_value.u = tag_uval;
-
-end:
-       return ret;
-}
-
-static inline
-struct bt_field_common *bt_field_common_variant_borrow_current_field(
-               struct bt_field_common *variant_field)
-{
-       struct bt_field_common_variant *variant = BT_FROM_COMMON(variant_field);
-
-       BT_ASSERT_PRE_NON_NULL(variant_field, "Variant field");
-       BT_ASSERT_PRE_FIELD_COMMON_HAS_TYPE_ID(variant_field,
-               BT_FIELD_TYPE_ID_VARIANT, "Field");
-       BT_ASSERT_PRE(variant->current_field,
-               "Variant field has no current field: %!+_f", variant_field);
-       return variant->current_field;
-}
-
-static inline
-int bt_field_common_variant_get_tag_signed(struct bt_field_common *variant_field,
-       int64_t *tag)
-{
-       struct bt_field_common_variant *variant = BT_FROM_COMMON(variant_field);
-
-       BT_ASSERT_PRE_NON_NULL(variant_field, "Variant field");
-       BT_ASSERT_PRE_FIELD_COMMON_HAS_TYPE_ID(variant_field,
-               BT_FIELD_TYPE_ID_VARIANT, "Field");
-       BT_ASSERT_PRE(variant->current_field,
-               "Variant field has no current field: %!+_f", variant_field);
-       *tag = variant->tag_value.i;
-       return 0;
-}
-
-static inline
-int bt_field_common_variant_get_tag_unsigned(struct bt_field_common *variant_field,
-       uint64_t *tag)
-{
-       struct bt_field_common_variant *variant = BT_FROM_COMMON(variant_field);
-
-       BT_ASSERT_PRE_NON_NULL(variant_field, "Variant field");
-       BT_ASSERT_PRE_FIELD_COMMON_HAS_TYPE_ID(variant_field,
-               BT_FIELD_TYPE_ID_VARIANT, "Field");
-       BT_ASSERT_PRE(variant->current_field,
-               "Variant field has no current field: %!+_f", variant_field);
-       *tag = variant->tag_value.u;
-       return 0;
-}
-
-static inline
-struct bt_field_type_enumeration_mapping_iterator *
-bt_field_common_enumeration_get_mappings(struct bt_field_common *field,
-               bt_field_common_create_func field_create_func,
-               uint64_t uval)
-{
-       struct bt_field_type_common_enumeration *enum_type = NULL;
-       struct bt_field_type_common_integer *integer_type = NULL;
-       struct bt_field_type_enumeration_mapping_iterator *iter = NULL;
-
-       BT_ASSERT(field);
-       BT_ASSERT(field->type->id == BT_FIELD_TYPE_ID_ENUM);
-       BT_ASSERT(field->payload_set);
-       enum_type = BT_FROM_COMMON(field->type);
-       integer_type = enum_type->container_ft;
-
-       if (!integer_type->is_signed) {
-               iter = bt_field_type_common_enumeration_unsigned_find_mappings_by_value(
-                               field->type, uval);
-       } else {
-               iter = bt_field_type_common_enumeration_signed_find_mappings_by_value(
-                               field->type, (int64_t) uval);
-       }
-
-       return iter;
-}
-
-static inline
-int bt_field_common_floating_point_get_value(struct bt_field_common *field,
-               double *value)
-{
-       struct bt_field_common_floating_point *floating_point =
-               BT_FROM_COMMON(field);
-
-       BT_ASSERT_PRE_NON_NULL(field, "Floating point number field");
-       BT_ASSERT_PRE_NON_NULL(value, "Value");
-       BT_ASSERT_PRE_FIELD_COMMON_IS_SET(field, "Floating point number field");
-       BT_ASSERT_PRE_FIELD_COMMON_HAS_TYPE_ID(field,
-               BT_FIELD_TYPE_ID_FLOAT, "Field");
-       *value = floating_point->payload;
-       return 0;
-}
-
-static inline
-int bt_field_common_floating_point_set_value(struct bt_field_common *field,
-               double value)
-{
-       struct bt_field_common_floating_point *floating_point =
-               BT_FROM_COMMON(field);
-
-       BT_ASSERT_PRE_NON_NULL(field, "Floating point number field");
-       BT_ASSERT_PRE_FIELD_COMMON_HOT(field, "Floating point number field");
-       BT_ASSERT_PRE_FIELD_COMMON_HAS_TYPE_ID(field,
-               BT_FIELD_TYPE_ID_FLOAT, "Field");
-       floating_point->payload = value;
-       bt_field_common_set(field, true);
-       return 0;
-}
-
-static inline
-const char *bt_field_common_string_get_value(struct bt_field_common *field)
-{
-       struct bt_field_common_string *string = BT_FROM_COMMON(field);
-
-       BT_ASSERT_PRE_NON_NULL(field, "String field");
-       BT_ASSERT_PRE_FIELD_COMMON_IS_SET(field, "String field");
-       BT_ASSERT_PRE_FIELD_COMMON_HAS_TYPE_ID(field,
-               BT_FIELD_TYPE_ID_STRING, "Field");
-       return (const char *) string->buf->data;
-}
-
-static inline
-int bt_field_common_string_clear(struct bt_field_common *field)
-{
-       struct bt_field_common_string *string_field = BT_FROM_COMMON(field);
-
-       BT_ASSERT_PRE_NON_NULL(field, "String field");
-       BT_ASSERT_PRE_FIELD_COMMON_HOT(field, "String field");
-       BT_ASSERT_PRE_FIELD_COMMON_HAS_TYPE_ID(field,
-               BT_FIELD_TYPE_ID_STRING, "Field");
-       string_field->size = 0;
-       bt_field_common_set(field, true);
-       return 0;
-}
-
-static inline
-int bt_field_common_string_append_len(struct bt_field_common *field,
-               const char *value, unsigned int length)
-{
-       struct bt_field_common_string *string_field = BT_FROM_COMMON(field);
-       char *data;
-       size_t new_size;
-
-       BT_ASSERT_PRE_NON_NULL(field, "String field");
-       BT_ASSERT_PRE_NON_NULL(value, "Value");
-       BT_ASSERT_PRE_FIELD_COMMON_HOT(field, "String field");
-       BT_ASSERT_PRE_FIELD_COMMON_HAS_TYPE_ID(field,
-               BT_FIELD_TYPE_ID_STRING, "Field");
-
-       /* Make sure no null bytes are appended */
-       BT_ASSERT_PRE(memchr(value, '\0', length) == NULL,
-               "String value to append contains a null character: "
-               "partial-value=\"%.32s\", length=%u", value, length);
-
-       new_size = string_field->size + length;
-
-       if (unlikely(new_size + 1 > string_field->buf->len)) {
-               g_array_set_size(string_field->buf, new_size + 1);
-       }
-
-       data = string_field->buf->data;
-       memcpy(data + string_field->size, value, length);
-       ((char *) string_field->buf->data)[new_size] = '\0';
-       string_field->size = new_size;
-       bt_field_common_set(field, true);
-       return 0;
-}
-
-static inline
-int bt_field_common_string_append(struct bt_field_common *field,
-               const char *value)
-{
-       BT_ASSERT_PRE_NON_NULL(value, "Value");
-       return bt_field_common_string_append_len(field, value,
-               strlen(value));
-}
-
-static inline
-int bt_field_common_string_set_value(struct bt_field_common *field,
-               const char *value)
-{
-       BT_ASSERT_PRE_NON_NULL(field, "String field");
-       BT_ASSERT_PRE_NON_NULL(value, "Value");
-       BT_ASSERT_PRE_FIELD_COMMON_HOT(field, "String field");
-       BT_ASSERT_PRE_FIELD_COMMON_HAS_TYPE_ID(field,
-               BT_FIELD_TYPE_ID_STRING, "Field");
-       bt_field_common_string_clear(field);
-       return bt_field_common_string_append_len(field,
-               value, strlen(value));
-}
-
-static inline
-int _bt_field_validate_recursive(struct bt_field *field)
-{
-       return _bt_field_common_validate_recursive((void *) field);
-}
-
-static inline
-void _bt_field_set_is_frozen_recursive(struct bt_field *field, bool is_frozen)
-{
-       return _bt_field_common_set_is_frozen_recursive((void *) field,
-                       is_frozen);
-}
-
-static inline
-bt_bool _bt_field_is_set_recursive(struct bt_field *field)
-{
-       return _bt_field_common_is_set_recursive((void *) field);
-}
-
-static inline
-void _bt_field_reset_recursive(struct bt_field *field)
-{
-       _bt_field_common_reset_recursive((void *) field);
-}
-
-static inline
-void _bt_field_set(struct bt_field *field, bool value)
-{
-       _bt_field_common_set((void *) field, value);
-}
-
-static inline
-void bt_field_common_finalize(struct bt_field_common *field)
-{
-       BT_ASSERT(field);
-       BT_LOGD_STR("Putting field's type.");
-       bt_put(field->type);
-}
-
-static inline
-void bt_field_common_integer_finalize(struct bt_field_common *field)
-{
-       BT_ASSERT(field);
-       BT_LOGD("Finalizing common integer field object: addr=%p", field);
-       bt_field_common_finalize(field);
-}
-
-static inline
-void bt_field_common_floating_point_finalize(struct bt_field_common *field)
-{
-       BT_ASSERT(field);
-       BT_LOGD("Finalizing common floating point number field object: addr=%p", field);
-       bt_field_common_finalize(field);
-}
-
-static inline
-void bt_field_common_structure_finalize_recursive(struct bt_field_common *field)
-{
-       struct bt_field_common_structure *structure = BT_FROM_COMMON(field);
-
-       BT_ASSERT(field);
-       BT_LOGD("Finalizing common structure field object: addr=%p", field);
-       bt_field_common_finalize(field);
-
-       if (structure->fields) {
-               g_ptr_array_free(structure->fields, TRUE);
-       }
-}
-
-static inline
-void bt_field_common_variant_finalize_recursive(struct bt_field_common *field)
-{
-       struct bt_field_common_variant *variant = BT_FROM_COMMON(field);
-
-       BT_ASSERT(field);
-       BT_LOGD("Finalizing common variant field object: addr=%p", field);
-       bt_field_common_finalize(field);
-
-       if (variant->fields) {
-               g_ptr_array_free(variant->fields, TRUE);
-       }
-}
-
-static inline
-void bt_field_common_array_finalize_recursive(struct bt_field_common *field)
-{
-       struct bt_field_common_array *array = BT_FROM_COMMON(field);
-
-       BT_ASSERT(field);
-       BT_LOGD("Finalizing common array field object: addr=%p", field);
-       bt_field_common_finalize(field);
-
-       if (array->elements) {
-               g_ptr_array_free(array->elements, TRUE);
-       }
-}
-
-static inline
-void bt_field_common_sequence_finalize_recursive(struct bt_field_common *field)
-{
-       struct bt_field_common_sequence *sequence = BT_FROM_COMMON(field);
-
-       BT_ASSERT(field);
-       BT_LOGD("Finalizing common sequence field object: addr=%p", field);
-       bt_field_common_finalize(field);
-
-       if (sequence->elements) {
-               g_ptr_array_free(sequence->elements, TRUE);
-       }
-}
-
-static inline
-void bt_field_common_string_finalize(struct bt_field_common *field)
-{
-       struct bt_field_common_string *string = BT_FROM_COMMON(field);
-
-       BT_ASSERT(field);
-       BT_LOGD("Finalizing common string field object: addr=%p", field);
-       bt_field_common_finalize(field);
-
-       if (string->buf) {
-               g_array_free(string->buf, TRUE);
-       }
-}
-
-BT_ASSERT_PRE_FUNC
-static inline bool value_is_in_range_signed(unsigned int size, int64_t value)
-{
-       bool ret = true;
-       int64_t min_value, max_value;
-
-       min_value = -(1ULL << (size - 1));
-       max_value = (1ULL << (size - 1)) - 1;
-       if (value < min_value || value > max_value) {
-               BT_LOGF("Value is out of bounds: value=%" PRId64 ", "
-                       "min-value=%" PRId64 ", max-value=%" PRId64,
-                       value, min_value, max_value);
-               ret = false;
-       }
-
-       return ret;
-}
-
-BT_ASSERT_PRE_FUNC
-static inline bool value_is_in_range_unsigned(unsigned int size, uint64_t value)
-{
-       bool ret = true;
-       int64_t max_value;
-
-       max_value = (size == 64) ? UINT64_MAX : ((uint64_t) 1 << size) - 1;
-       if (value > max_value) {
-               BT_LOGF("Value is out of bounds: value=%" PRIu64 ", "
-                       "max-value=%" PRIu64,
-                       value, max_value);
-               ret = false;
-       }
-
-       return ret;
-}
-
 BT_HIDDEN
 struct bt_field *bt_field_create_recursive(struct bt_field_type *type);
 
index 619ae818fa036f4564bcb07a4e31f3ef82e099d0..dad97907b0614fec1f5f834590ffc760f9646d02 100644 (file)
@@ -61,12 +61,12 @@ enum bt_resolve_flag {
  */
 BT_HIDDEN
 int bt_resolve_types(struct bt_value *environment,
-               struct bt_field_type_common *packet_header_type,
-               struct bt_field_type_common *packet_context_type,
-               struct bt_field_type_common *event_header_type,
-               struct bt_field_type_common *stream_event_ctx_type,
-               struct bt_field_type_common *event_context_type,
-               struct bt_field_type_common *event_payload_type,
+               struct bt_field_type *packet_header_type,
+               struct bt_field_type *packet_context_type,
+               struct bt_field_type *event_header_type,
+               struct bt_field_type *stream_event_ctx_type,
+               struct bt_field_type *event_context_type,
+               struct bt_field_type *event_payload_type,
                enum bt_resolve_flag flags);
 
 #endif /* BABELTRACE_CTF_IR_RESOLVE_INTERNAL_H */
index 8dd7856782909916a3f1fc407227ac1bef64909c..6a167c9371267cf2302844cf46ca6de1f5b7ad3a 100644 (file)
 #include <babeltrace/ctf-ir/field-types-internal.h>
 #include <babeltrace/ctf-ir/utils-internal.h>
 #include <babeltrace/ctf-ir/visitor.h>
+#include <babeltrace/ctf-ir/stream-class.h>
 #include <babeltrace/object-internal.h>
 #include <babeltrace/object-pool-internal.h>
 #include <babeltrace/babeltrace-internal.h>
 #include <glib.h>
 #include <inttypes.h>
 
-struct bt_stream_class_common {
+struct bt_stream_class {
        struct bt_object base;
        GString *name;
 
@@ -51,9 +52,9 @@ struct bt_stream_class_common {
        int id_set;
        int64_t id;
        int64_t next_event_id;
-       struct bt_field_type_common *packet_context_field_type;
-       struct bt_field_type_common *event_header_field_type;
-       struct bt_field_type_common *event_context_field_type;
+       struct bt_field_type *packet_context_field_type;
+       struct bt_field_type *event_header_field_type;
+       struct bt_field_type *event_context_field_type;
        int frozen;
        int byte_order;
 
@@ -81,10 +82,6 @@ struct bt_stream_class_common {
         * backing clock class of the `clock` member above.
         */
        struct bt_clock_class *clock_class;
-};
-
-struct bt_stream_class {
-       struct bt_stream_class_common common;
 
        /* Pool of `struct bt_field_wrapper *` */
        struct bt_object_pool event_header_field_pool;
@@ -93,433 +90,39 @@ struct bt_stream_class {
        struct bt_object_pool packet_context_field_pool;
 };
 
-struct bt_event_class_common;
-
-BT_HIDDEN
-int bt_stream_class_common_initialize(struct bt_stream_class_common *stream_class,
-               const char *name, bt_object_release_func release_func);
-
-BT_HIDDEN
-void bt_stream_class_common_finalize(struct bt_stream_class_common *stream_class);
-
-BT_HIDDEN
-void bt_stream_class_common_freeze(struct bt_stream_class_common *stream_class);
+struct bt_event_class;
 
 BT_HIDDEN
 void bt_stream_class_freeze(struct bt_stream_class *stream_class);
 
-static inline
-const char *bt_stream_class_common_get_name(
-               struct bt_stream_class_common *stream_class)
-{
-       BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
-       return stream_class->name->len > 0 ? stream_class->name->str : NULL;
-}
-
-static inline
-int64_t bt_stream_class_common_get_id(
-               struct bt_stream_class_common *stream_class)
-{
-       int64_t ret;
-
-       BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
-
-       if (!stream_class->id_set) {
-               BT_LOGV("Stream class's ID is not set: addr=%p, name=\"%s\"",
-                       stream_class,
-                       bt_stream_class_common_get_name(stream_class));
-               ret = (int64_t) -1;
-               goto end;
-       }
-
-       ret = stream_class->id;
-
-end:
-       return ret;
-}
-
-BT_HIDDEN
-void bt_stream_class_common_set_byte_order(
-               struct bt_stream_class_common *stream_class, int byte_order);
-
 BT_HIDDEN
-int bt_stream_class_common_validate_single_clock_class(
-               struct bt_stream_class_common *stream_class,
+int bt_stream_class_validate_single_clock_class(
+               struct bt_stream_class *stream_class,
                struct bt_clock_class **expected_clock_class);
 
 BT_HIDDEN
-int bt_stream_class_common_add_event_class(
-               struct bt_stream_class_common *stream_class,
-               struct bt_event_class_common *event_class,
-               bt_validation_flag_copy_field_type_func copy_field_type_func);
-
-BT_HIDDEN
-int bt_stream_class_common_visit(struct bt_stream_class_common *stream_class,
+int bt_stream_class_visit(struct bt_stream_class *stream_class,
                bt_visitor visitor, void *data);
 
 static inline
-struct bt_trace_common *bt_stream_class_common_borrow_trace(
-               struct bt_stream_class_common *stream_class)
-{
-       BT_ASSERT(stream_class);
-       return (void *) bt_object_borrow_parent(&stream_class->base);
-}
-
-static inline
-int bt_stream_class_common_set_name(struct bt_stream_class_common *stream_class,
-               const char *name)
-{
-       int ret = 0;
-
-       if (!stream_class) {
-               BT_LOGW_STR("Invalid parameter: stream class is NULL.");
-               ret = -1;
-               goto end;
-       }
-
-       if (stream_class->frozen) {
-               BT_LOGW("Invalid parameter: stream class is frozen: "
-                       "addr=%p, name=\"%s\", id=%" PRId64,
-                       stream_class,
-                       bt_stream_class_common_get_name(stream_class),
-                       bt_stream_class_common_get_id(stream_class));
-               ret = -1;
-               goto end;
-       }
-
-       if (!name) {
-               g_string_assign(stream_class->name, "");
-       } else {
-               if (strlen(name) == 0) {
-                       BT_LOGW("Invalid parameter: name is empty.");
-                       ret = -1;
-                       goto end;
-               }
-
-               g_string_assign(stream_class->name, name);
-       }
-
-       BT_LOGV("Set stream class's name: "
-               "addr=%p, name=\"%s\", id=%" PRId64,
-               stream_class, bt_stream_class_common_get_name(stream_class),
-               bt_stream_class_common_get_id(stream_class));
-end:
-       return ret;
-}
-
-static inline
-void _bt_stream_class_common_set_id(
-               struct bt_stream_class_common *stream_class, int64_t id)
+void _bt_stream_class_set_id(
+               struct bt_stream_class *stream_class, int64_t id)
 {
        BT_ASSERT(stream_class);
        stream_class->id = id;
        stream_class->id_set = 1;
        BT_LOGV("Set stream class's ID (internal): "
                "addr=%p, name=\"%s\", id=%" PRId64,
-               stream_class, bt_stream_class_common_get_name(stream_class),
-               bt_stream_class_common_get_id(stream_class));
+               stream_class, bt_stream_class_get_name(stream_class),
+               bt_stream_class_get_id(stream_class));
 }
 
 static inline
-int bt_stream_class_common_set_id_no_check(
-               struct bt_stream_class_common *stream_class, int64_t id)
+int bt_stream_class_set_id_no_check(
+               struct bt_stream_class *stream_class, int64_t id)
 {
-       _bt_stream_class_common_set_id(stream_class, id);
+       _bt_stream_class_set_id(stream_class, id);
        return 0;
 }
 
-static inline
-int bt_stream_class_common_set_id(struct bt_stream_class_common *stream_class,
-               uint64_t id_param)
-{
-       int ret = 0;
-       int64_t id = (int64_t) id_param;
-
-       if (!stream_class) {
-               BT_LOGW_STR("Invalid parameter: stream class is NULL.");
-               ret = -1;
-               goto end;
-       }
-
-       if (stream_class->frozen) {
-               BT_LOGW("Invalid parameter: stream class is frozen: "
-                       "addr=%p, name=\"%s\", id=%" PRId64,
-                       stream_class,
-                       bt_stream_class_common_get_name(stream_class),
-                       bt_stream_class_common_get_id(stream_class));
-               ret = -1;
-               goto end;
-       }
-
-       if (id < 0) {
-               BT_LOGW("Invalid parameter: invalid stream class's ID: "
-                       "stream-class-addr=%p, stream-class-name=\"%s\", "
-                       "stream-class-id=%" PRId64 ", id=%" PRIu64,
-                       stream_class,
-                       bt_stream_class_common_get_name(stream_class),
-                       bt_stream_class_common_get_id(stream_class),
-                       id_param);
-               ret = -1;
-               goto end;
-       }
-
-       ret = bt_stream_class_common_set_id_no_check(stream_class, id);
-       if (ret == 0) {
-               BT_LOGV("Set stream class's ID: "
-                       "addr=%p, name=\"%s\", id=%" PRId64,
-                       stream_class,
-                       bt_stream_class_common_get_name(stream_class),
-                       bt_stream_class_common_get_id(stream_class));
-       }
-end:
-       return ret;
-}
-
-static inline
-int64_t bt_stream_class_common_get_event_class_count(
-               struct bt_stream_class_common *stream_class)
-{
-       int64_t ret;
-
-       if (!stream_class) {
-               BT_LOGW_STR("Invalid parameter: stream class is NULL.");
-               ret = (int64_t) -1;
-               goto end;
-       }
-
-       ret = (int64_t) stream_class->event_classes->len;
-end:
-       return ret;
-}
-
-static inline
-struct bt_event_class_common *bt_stream_class_common_borrow_event_class_by_index(
-               struct bt_stream_class_common *stream_class, uint64_t index)
-{
-       BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
-       BT_ASSERT_PRE(index < stream_class->event_classes->len,
-               "Index is out of bounds: index=%" PRIu64 ", "
-               "count=%u",
-               index, stream_class->event_classes->len);
-       return g_ptr_array_index(stream_class->event_classes, index);
-}
-
-static inline
-struct bt_event_class_common *bt_stream_class_common_borrow_event_class_by_id(
-               struct bt_stream_class_common *stream_class, uint64_t id)
-{
-       int64_t id_key = (int64_t) id;
-
-       BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
-       BT_ASSERT_PRE(id_key >= 0,
-               "Invalid event class ID: %" PRIu64, id);
-       return g_hash_table_lookup(stream_class->event_classes_ht,
-                       &id_key);
-}
-
-static inline
-struct bt_field_type_common *
-bt_stream_class_common_borrow_packet_context_field_type(
-               struct bt_stream_class_common *stream_class)
-{
-       BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
-       return stream_class->packet_context_field_type;
-}
-
-static inline
-int bt_stream_class_common_set_packet_context_field_type(
-               struct bt_stream_class_common *stream_class,
-               struct bt_field_type_common *packet_context_type)
-{
-       int ret = 0;
-
-       if (!stream_class) {
-               BT_LOGW_STR("Invalid parameter: stream class is NULL.");
-               ret = -1;
-               goto end;
-       }
-
-       if (stream_class->frozen) {
-               BT_LOGW("Invalid parameter: stream class is frozen: "
-                       "addr=%p, name=\"%s\", id=%" PRId64,
-                       stream_class, bt_stream_class_common_get_name(stream_class),
-                       bt_stream_class_common_get_id(stream_class));
-               ret = -1;
-               goto end;
-       }
-
-       if (packet_context_type &&
-                       bt_field_type_common_get_type_id(packet_context_type) !=
-                               BT_FIELD_TYPE_ID_STRUCT) {
-               /* A packet context must be a structure. */
-               BT_LOGW("Invalid parameter: stream class's packet context field type must be a structure: "
-                       "addr=%p, name=\"%s\", id=%" PRId64 ", "
-                       "packet-context-ft-addr=%p, packet-context-ft-id=%s",
-                       stream_class, bt_stream_class_common_get_name(stream_class),
-                       bt_stream_class_common_get_id(stream_class),
-                       packet_context_type,
-                       bt_common_field_type_id_string(
-                               bt_field_type_common_get_type_id(packet_context_type)));
-               ret = -1;
-               goto end;
-       }
-
-       bt_put(stream_class->packet_context_field_type);
-       bt_get(packet_context_type);
-       stream_class->packet_context_field_type = packet_context_type;
-       BT_LOGV("Set stream class's packet context field type: "
-               "addr=%p, name=\"%s\", id=%" PRId64 ", "
-               "packet-context-ft-addr=%p",
-               stream_class, bt_stream_class_common_get_name(stream_class),
-               bt_stream_class_common_get_id(stream_class),
-               packet_context_type);
-
-end:
-       return ret;
-}
-
-static inline
-struct bt_field_type_common *
-bt_stream_class_common_borrow_event_header_field_type(
-               struct bt_stream_class_common *stream_class)
-{
-       struct bt_field_type_common *ret = NULL;
-
-       BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
-
-       if (!stream_class->event_header_field_type) {
-               BT_LOGV("Stream class has no event header field type: "
-                       "addr=%p, name=\"%s\", id=%" PRId64,
-                       stream_class,
-                       bt_stream_class_common_get_name(stream_class),
-                       bt_stream_class_common_get_id(stream_class));
-               goto end;
-       }
-
-       ret = stream_class->event_header_field_type;
-
-end:
-       return ret;
-}
-
-static inline
-int bt_stream_class_common_set_event_header_field_type(
-               struct bt_stream_class_common *stream_class,
-               struct bt_field_type_common *event_header_type)
-{
-       int ret = 0;
-
-       if (!stream_class) {
-               BT_LOGW_STR("Invalid parameter: stream class is NULL.");
-               ret = -1;
-               goto end;
-       }
-
-       if (stream_class->frozen) {
-               BT_LOGW("Invalid parameter: stream class is frozen: "
-                       "addr=%p, name=\"%s\", id=%" PRId64,
-                       stream_class,
-                       bt_stream_class_common_get_name(stream_class),
-                       bt_stream_class_common_get_id(stream_class));
-               ret = -1;
-               goto end;
-       }
-
-       if (event_header_type &&
-                       bt_field_type_common_get_type_id(event_header_type) !=
-                               BT_FIELD_TYPE_ID_STRUCT) {
-               /* An event header must be a structure. */
-               BT_LOGW("Invalid parameter: stream class's event header field type must be a structure: "
-                       "addr=%p, name=\"%s\", id=%" PRId64 ", "
-                       "event-header-ft-addr=%p, event-header-ft-id=%s",
-                       stream_class, bt_stream_class_common_get_name(stream_class),
-                       bt_stream_class_common_get_id(stream_class),
-                       event_header_type,
-                       bt_common_field_type_id_string(
-                               bt_field_type_common_get_type_id(event_header_type)));
-               ret = -1;
-               goto end;
-       }
-
-       bt_put(stream_class->event_header_field_type);
-       stream_class->event_header_field_type = bt_get(event_header_type);
-       BT_LOGV("Set stream class's event header field type: "
-               "addr=%p, name=\"%s\", id=%" PRId64 ", "
-               "event-header-ft-addr=%p",
-               stream_class, bt_stream_class_common_get_name(stream_class),
-               bt_stream_class_common_get_id(stream_class),
-               event_header_type);
-end:
-       return ret;
-}
-
-static inline
-struct bt_field_type_common *
-bt_stream_class_common_borrow_event_context_field_type(
-               struct bt_stream_class_common *stream_class)
-{
-       struct bt_field_type_common *ret = NULL;
-
-       BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
-
-       if (!stream_class->event_context_field_type) {
-               goto end;
-       }
-
-       ret = stream_class->event_context_field_type;
-
-end:
-       return ret;
-}
-
-static inline
-int bt_stream_class_common_set_event_context_field_type(
-               struct bt_stream_class_common *stream_class,
-               struct bt_field_type_common *event_context_type)
-{
-       int ret = 0;
-
-       if (!stream_class) {
-               BT_LOGW_STR("Invalid parameter: stream class is NULL.");
-               ret = -1;
-               goto end;
-       }
-
-       if (stream_class->frozen) {
-               BT_LOGW("Invalid parameter: stream class is frozen: "
-                       "addr=%p, name=\"%s\", id=%" PRId64,
-                       stream_class, bt_stream_class_common_get_name(stream_class),
-                       bt_stream_class_common_get_id(stream_class));
-               ret = -1;
-               goto end;
-       }
-
-       if (event_context_type &&
-                       bt_field_type_common_get_type_id(event_context_type) !=
-                               BT_FIELD_TYPE_ID_STRUCT) {
-               /* A packet context must be a structure. */
-               BT_LOGW("Invalid parameter: stream class's event context field type must be a structure: "
-                       "addr=%p, name=\"%s\", id=%" PRId64 ", "
-                       "event-context-ft-addr=%p, event-context-ft-id=%s",
-                       stream_class, bt_stream_class_common_get_name(stream_class),
-                       bt_stream_class_common_get_id(stream_class),
-                       event_context_type,
-                       bt_common_field_type_id_string(
-                               bt_field_type_common_get_type_id(event_context_type)));
-               ret = -1;
-               goto end;
-       }
-
-       bt_put(stream_class->event_context_field_type);
-       stream_class->event_context_field_type = bt_get(event_context_type);
-       BT_LOGV("Set stream class's event context field type: "
-               "addr=%p, name=\"%s\", id=%" PRId64 ", "
-               "event-context-ft-addr=%p",
-               stream_class, bt_stream_class_common_get_name(stream_class),
-               bt_stream_class_common_get_id(stream_class),
-               event_context_type);
-end:
-       return ret;
-}
-
 #endif /* BABELTRACE_CTF_IR_STREAM_CLASS_INTERNAL_H */
index 87f3c848f7f1e7225dd5361071654ceaa895f308..19cd8c2f8658e92ae80d50577ec2bb6f57c8a99d 100644 (file)
 #include <glib.h>
 
 struct bt_stream_class;
-struct bt_stream_common;
+struct bt_stream;
 
-struct bt_stream_common {
+struct bt_stream {
        struct bt_object base;
        int64_t id;
-       struct bt_stream_class_common *stream_class;
+       struct bt_stream_class *stream_class;
        GString *name;
-};
-
-struct bt_stream {
-       struct bt_stream_common common;
 
        /* Pool of `struct bt_packet *` */
        struct bt_object_pool packet_pool;
 };
 
-BT_HIDDEN
-int bt_stream_common_initialize(
-               struct bt_stream_common *stream,
-               struct bt_stream_class_common *stream_class, const char *name,
-               uint64_t id, bt_object_release_func release_func);
-
-BT_HIDDEN
-void bt_stream_common_finalize(struct bt_stream_common *stream);
-
-static inline
-struct bt_stream_class_common *bt_stream_common_borrow_class(
-               struct bt_stream_common *stream)
-{
-       BT_ASSERT(stream);
-       return stream->stream_class;
-}
-
-static inline
-const char *bt_stream_common_get_name(struct bt_stream_common *stream)
-{
-       BT_ASSERT_PRE_NON_NULL(stream, "Stream");
-       return stream->name ? stream->name->str : NULL;
-}
-
-static inline
-int64_t bt_stream_common_get_id(struct bt_stream_common *stream)
-{
-       int64_t ret;
-
-       BT_ASSERT_PRE_NON_NULL(stream, "Stream");
-       ret = stream->id;
-       if (ret < 0) {
-               BT_LOGV("Stream's ID is not set: addr=%p, name=\"%s\"",
-                       stream, bt_stream_common_get_name(stream));
-       }
-
-       return ret;
-}
-
 #endif /* BABELTRACE_CTF_IR_STREAM_INTERNAL_H */
index 3d7a47f6e265b6d95ab658407914147ed557b046..8de7885281a5b91edca154005567795d0cddfc47 100644 (file)
@@ -44,7 +44,7 @@
 #include <sys/types.h>
 #include <babeltrace/compat/uuid-internal.h>
 
-struct bt_trace_common {
+struct bt_trace {
        struct bt_object base;
        GString *name;
        int frozen;
@@ -53,9 +53,9 @@ struct bt_trace_common {
        enum bt_byte_order native_byte_order;
        struct bt_value *environment;
        GPtrArray *clock_classes; /* Array of pointers to bt_clock_class */
-       GPtrArray *stream_classes; /* Array of ptrs to bt_stream_class_common */
-       GPtrArray *streams; /* Array of ptrs to bt_stream_common */
-       struct bt_field_type_common *packet_header_field_type;
+       GPtrArray *stream_classes; /* Array of ptrs to bt_stream_class */
+       GPtrArray *streams; /* Array of ptrs to bt_stream */
+       struct bt_field_type *packet_header_field_type;
        int64_t next_stream_id;
 
        /*
@@ -63,10 +63,7 @@ struct bt_trace_common {
         * trace is _always_ frozen.
         */
        int valid;
-};
 
-struct bt_trace {
-       struct bt_trace_common common;
        GPtrArray *listeners; /* Array of struct listener_wrapper */
        GArray *is_static_listeners;
        bt_bool is_static;
@@ -81,7 +78,7 @@ int bt_trace_object_modification(struct bt_visitor_object *object,
                void *trace_ptr);
 
 BT_HIDDEN
-bt_bool bt_trace_common_has_clock_class(struct bt_trace_common *trace,
+bt_bool bt_trace_has_clock_class(struct bt_trace *trace,
                struct bt_clock_class *clock_class);
 
 /**
@@ -116,230 +113,8 @@ BT_HIDDEN
 int bt_trace_add_listener(struct bt_trace *trace_class,
                bt_listener_cb listener, void *data);
 
-BT_HIDDEN
-int bt_trace_common_initialize(struct bt_trace_common *trace,
-               bt_object_release_func release_func);
-
-BT_HIDDEN
-void bt_trace_common_finalize(struct bt_trace_common *trace);
-
-static inline
-const char *bt_trace_common_get_name(struct bt_trace_common *trace)
-{
-       BT_ASSERT_PRE_NON_NULL(trace, "Trace");
-       return trace->name ? trace->name->str : NULL;
-}
-
-BT_HIDDEN
-int bt_trace_common_set_name(struct bt_trace_common *trace, const char *name);
-
-static inline
-const unsigned char *bt_trace_common_get_uuid(struct bt_trace_common *trace)
-{
-       BT_ASSERT_PRE_NON_NULL(trace, "Trace");
-       return trace->uuid_set ? trace->uuid : NULL;
-}
-
-BT_HIDDEN
-int bt_trace_common_set_uuid(struct bt_trace_common *trace, const unsigned char *uuid);
-
-BT_HIDDEN
-int bt_trace_common_set_environment_field(struct bt_trace_common *trace,
-               const char *name, struct bt_value *value);
-
-BT_HIDDEN
-int bt_trace_common_set_environment_field_string(struct bt_trace_common *trace,
-               const char *name, const char *value);
-
-BT_HIDDEN
-int bt_trace_common_set_environment_field_integer(struct bt_trace_common *trace,
-               const char *name, int64_t value);
-
-static inline
-int64_t bt_trace_common_get_environment_field_count(
-               struct bt_trace_common *trace)
-{
-       int64_t ret;
-
-       BT_ASSERT_PRE_NON_NULL(trace, "Trace");
-       ret = bt_attributes_get_count(trace->environment);
-       BT_ASSERT(ret >= 0);
-       return ret;
-}
-
-static inline
-const char *
-bt_trace_common_get_environment_field_name_by_index(
-               struct bt_trace_common *trace, uint64_t index)
-{
-       BT_ASSERT_PRE_NON_NULL(trace, "Trace");
-       return bt_attributes_get_field_name(trace->environment, index);
-}
-
-static inline
-struct bt_value *bt_trace_common_borrow_environment_field_value_by_index(
-               struct bt_trace_common *trace, uint64_t index)
-{
-       BT_ASSERT_PRE_NON_NULL(trace, "Trace");
-       return bt_attributes_borrow_field_value(trace->environment, index);
-}
-
-static inline
-struct bt_value *bt_trace_common_borrow_environment_field_value_by_name(
-               struct bt_trace_common *trace, const char *name)
-{
-       BT_ASSERT_PRE_NON_NULL(trace, "Trace");
-       BT_ASSERT_PRE_NON_NULL(name, "Name");
-       return bt_attributes_borrow_field_value_by_name(trace->environment,
-               name);
-}
-
-BT_HIDDEN
-int bt_trace_common_add_clock_class(struct bt_trace_common *trace,
-               struct bt_clock_class *clock_class);
-
-static inline
-int64_t bt_trace_common_get_clock_class_count(struct bt_trace_common *trace)
-{
-       BT_ASSERT_PRE_NON_NULL(trace, "Trace");
-       return trace->clock_classes->len;
-}
-
-static inline
-struct bt_clock_class *bt_trace_common_borrow_clock_class_by_index(
-               struct bt_trace_common *trace, uint64_t index)
-{
-       BT_ASSERT_PRE_NON_NULL(trace, "Trace");
-       BT_ASSERT_PRE(index < trace->clock_classes->len,
-               "Index is out of bounds: index=%" PRIu64 ", "
-               "count=%u",
-               index, trace->clock_classes->len);
-       return g_ptr_array_index(trace->clock_classes, index);
-}
-
 static inline
-int64_t bt_trace_common_get_stream_count(struct bt_trace_common *trace)
-{
-       BT_ASSERT_PRE_NON_NULL(trace, "Trace");
-       return (int64_t) trace->streams->len;
-}
-
-static inline
-struct bt_stream_common *bt_trace_common_borrow_stream_by_index(
-               struct bt_trace_common *trace,
-               uint64_t index)
-{
-       BT_ASSERT_PRE_NON_NULL(trace, "Trace");
-       BT_ASSERT_PRE(index < trace->streams->len,
-               "Index is out of bounds: index=%" PRIu64 ", "
-               "count=%u",
-               index, trace->streams->len);
-       return g_ptr_array_index(trace->streams, index);
-}
-
-static inline
-int64_t bt_trace_common_get_stream_class_count(struct bt_trace_common *trace)
-{
-       BT_ASSERT_PRE_NON_NULL(trace, "Trace");
-       return (int64_t) trace->stream_classes->len;
-}
-
-static inline
-struct bt_stream_class_common *bt_trace_common_borrow_stream_class_by_index(
-               struct bt_trace_common *trace, uint64_t index)
-{
-       BT_ASSERT_PRE_NON_NULL(trace, "Trace");
-       BT_ASSERT_PRE(index < trace->stream_classes->len,
-               "Index is out of bounds: index=%" PRIu64 ", "
-               "count=%u",
-               index, trace->stream_classes->len);
-       return g_ptr_array_index(trace->stream_classes, index);
-}
-
-static inline
-struct bt_stream_class_common *bt_trace_common_borrow_stream_class_by_id(
-               struct bt_trace_common *trace, uint64_t id_param)
-{
-       int i;
-       struct bt_stream_class_common *stream_class = NULL;
-       int64_t id = (int64_t) id_param;
-
-       BT_ASSERT_PRE_NON_NULL(trace, "Trace");
-       BT_ASSERT_PRE(id >= 0,
-               "Invalid stream class ID: %" PRIu64, id_param);
-
-       for (i = 0; i < trace->stream_classes->len; i++) {
-               struct bt_stream_class_common *stream_class_candidate;
-
-               stream_class_candidate =
-                       g_ptr_array_index(trace->stream_classes, i);
-
-               if (bt_stream_class_common_get_id(stream_class_candidate) ==
-                               (int64_t) id) {
-                       stream_class = stream_class_candidate;
-                       goto end;
-               }
-       }
-
-end:
-       return stream_class;
-}
-
-static inline
-struct bt_clock_class *bt_trace_common_borrow_clock_class_by_name(
-               struct bt_trace_common *trace, const char *name)
-{
-       size_t i;
-       struct bt_clock_class *clock_class = NULL;
-
-       BT_ASSERT_PRE_NON_NULL(trace, "Trace");
-       BT_ASSERT_PRE_NON_NULL(name, "Name");
-
-       for (i = 0; i < trace->clock_classes->len; i++) {
-               struct bt_clock_class *cur_clk =
-                       g_ptr_array_index(trace->clock_classes, i);
-               const char *cur_clk_name = bt_clock_class_get_name(cur_clk);
-
-               if (!cur_clk_name) {
-                       goto end;
-               }
-
-               if (!strcmp(cur_clk_name, name)) {
-                       clock_class = cur_clk;
-                       goto end;
-               }
-       }
-
-end:
-       return clock_class;
-}
-
-static inline
-enum bt_byte_order bt_trace_common_get_native_byte_order(
-               struct bt_trace_common *trace)
-{
-       BT_ASSERT_PRE_NON_NULL(trace, "Trace");
-       return trace->native_byte_order;
-}
-
-BT_HIDDEN
-int bt_trace_common_set_native_byte_order(struct bt_trace_common *trace,
-               enum bt_byte_order byte_order, bool allow_unspecified);
-
-static inline
-struct bt_field_type_common *bt_trace_common_borrow_packet_header_field_type(
-               struct bt_trace_common *trace)
-{
-       BT_ASSERT_PRE_NON_NULL(trace, "Trace");
-       return trace->packet_header_field_type;
-}
-
-BT_HIDDEN
-int bt_trace_common_set_packet_header_field_type(struct bt_trace_common *trace,
-               struct bt_field_type_common *packet_header_field_type);
-
-static inline
-void bt_trace_common_freeze(struct bt_trace_common *trace)
+void bt_trace_freeze(struct bt_trace *trace)
 {
        int i;
 
@@ -348,9 +123,9 @@ void bt_trace_common_freeze(struct bt_trace_common *trace)
        }
 
        BT_LOGD("Freezing trace: addr=%p, name=\"%s\"",
-               trace, bt_trace_common_get_name(trace));
+               trace, bt_trace_get_name(trace));
        BT_LOGD_STR("Freezing packet header field type.");
-       bt_field_type_common_freeze(trace->packet_header_field_type);
+       bt_field_type_freeze(trace->packet_header_field_type);
        BT_LOGD_STR("Freezing environment attributes.");
        bt_attributes_freeze(trace->environment);
 
@@ -368,14 +143,4 @@ void bt_trace_common_freeze(struct bt_trace_common *trace)
        trace->frozen = 1;
 }
 
-BT_HIDDEN
-int bt_trace_common_add_stream_class(struct bt_trace_common *trace,
-               struct bt_stream_class_common *stream_class,
-               bt_validation_flag_copy_field_type_func copy_field_type_func,
-               struct bt_clock_class *init_expected_clock_class,
-               int (*map_clock_classes_func)(struct bt_stream_class_common *stream_class,
-                       struct bt_field_type_common *packet_context_field_type,
-                       struct bt_field_type_common *event_header_field_type),
-               bool check_ts_begin_end_mapped);
-
 #endif /* BABELTRACE_CTF_IR_TRACE_INTERNAL_H */
index 12b2494028000f6bd431671e4df1ce3161e089a2..8aba362e9786663df9d875c4421540ea5bb9f56c 100644 (file)
@@ -27,9 +27,6 @@
 #include <babeltrace/ctf-ir/field-types.h>
 #include <stdint.h>
 
-#define BT_TO_COMMON(_obj)     (&(_obj)->common)
-#define BT_FROM_COMMON(_obj)   ((void *) _obj)
-
 struct search_query {
        gpointer value;
        int found;
index 81d48b8f78f362f3773ff85d208b1b6355d433f8..2eaa8d6e875e50c0deddcb6a6ce56e1df2d31eef 100644 (file)
 #include <babeltrace/values.h>
 #include <babeltrace/babeltrace-internal.h>
 
-struct bt_trace_common;
-struct bt_stream_class_common;
-struct bt_event_class_common;
-struct bt_field_type_common;
+struct bt_trace;
+struct bt_stream_class;
+struct bt_event_class;
+struct bt_field_type;
 
-typedef struct bt_field_type_common *(*bt_validation_flag_copy_field_type_func)(
-               struct bt_field_type_common *);
+typedef struct bt_field_type *(*bt_validation_flag_copy_field_type_func)(
+               struct bt_field_type *);
 
 enum bt_validation_flag {
        BT_VALIDATION_FLAG_TRACE        = 1,
@@ -52,12 +52,12 @@ enum bt_validation_flag {
  * `valid_flags` contains the results of the validation.
  */
 struct bt_validation_output {
-       struct bt_field_type_common *packet_header_type;
-       struct bt_field_type_common *packet_context_type;
-       struct bt_field_type_common *event_header_type;
-       struct bt_field_type_common *stream_event_ctx_type;
-       struct bt_field_type_common *event_context_type;
-       struct bt_field_type_common *event_payload_type;
+       struct bt_field_type *packet_header_type;
+       struct bt_field_type *packet_context_type;
+       struct bt_field_type *event_header_type;
+       struct bt_field_type *stream_event_ctx_type;
+       struct bt_field_type *event_context_type;
+       struct bt_field_type *event_payload_type;
        enum bt_validation_flag valid_flags;
 };
 
@@ -83,12 +83,12 @@ struct bt_validation_output {
  */
 BT_HIDDEN
 int bt_validate_class_types(struct bt_value *environment,
-               struct bt_field_type_common *packet_header_type,
-               struct bt_field_type_common *packet_context_type,
-               struct bt_field_type_common *event_header_type,
-               struct bt_field_type_common *stream_event_ctx_type,
-               struct bt_field_type_common *event_context_type,
-               struct bt_field_type_common *event_payload_type,
+               struct bt_field_type *packet_header_type,
+               struct bt_field_type *packet_context_type,
+               struct bt_field_type *event_header_type,
+               struct bt_field_type *stream_event_ctx_type,
+               struct bt_field_type *event_context_type,
+               struct bt_field_type *event_payload_type,
                int trace_valid, int stream_class_valid, int event_class_valid,
                struct bt_validation_output *output,
                enum bt_validation_flag validate_flags,
@@ -110,9 +110,9 @@ int bt_validate_class_types(struct bt_value *environment,
  * All parameters are owned by the caller.
  */
 BT_HIDDEN
-void bt_validation_replace_types(struct bt_trace_common *trace,
-               struct bt_stream_class_common *stream_class,
-               struct bt_event_class_common *event_class,
+void bt_validation_replace_types(struct bt_trace *trace,
+               struct bt_stream_class *stream_class,
+               struct bt_event_class *event_class,
                struct bt_validation_output *output,
                enum bt_validation_flag replace_flags);
 
index 9fcbec8ef41e5514a41c119b4205bc873f33429d..4373312787e89298b37a1daac096f6b89d4111cf 100644 (file)
@@ -70,14 +70,10 @@ int bt_lib_log_level;
  * 3. Optional: `+` to print extended fields. This depends on the
  *    provided format specifier.
  *
- * 4. Objet category: `_` for common objects, or nothing for default
- *    objects (includes CTF IR).
- *
- * 5. Format specifier (see below).
+ * 4. Format specifier (see below).
  *
  * The available format specifiers are:
  *
- * Default category:
  *   `r`:
  *       Reference count information. The parameter is any Babeltrace
  *       object.
@@ -146,36 +142,12 @@ int bt_lib_log_level;
  *   `o`:
  *       Object pool. The parameter type is `struct bt_object_pool *`.
  *
- * Common category:
- *   `F`:
- *       Common field type. The parameter type is `struct bt_field_type *`.
- *
- *   `f`:
- *       Common field. The parameter type is `struct bt_field *`.
- *
- *   `E`:
- *       Common event class. The parameter type is
- *       `struct bt_event_class *`.
- *
- *   `e`:
- *       Common event. The parameter type is `struct bt_event *`.
- *
- *   `S`:
- *       Common stream class. The parameter type is
- *       `struct bt_stream_class *`.
- *
- *   `s`:
- *       Common stream. The parameter type is `struct bt_stream *`.
- *
- *   `t`:
- *       Common trace. The parameter type is `struct bt_trace *`.
- *
  * Conversion specifier examples:
  *
  *     %!f
  *     %![my-event-]+e
- *     %!_t
- *     %!+_F
+ *     %!t
+ *     %!+F
  *
  * The string `, ` is printed between individual fields, but not after
  * the last one. Therefore you must put this separator in the format
index a6295cbe8c9276d69127753e6a2cde68e9596d49..61d49fbe08be487b14fa519d0ae8e23962783a50 100644 (file)
 #include <inttypes.h>
 #include <stdlib.h>
 
-BT_HIDDEN
-void bt_event_class_common_finalize(struct bt_object *obj)
+static inline
+void bt_event_class_finalize(struct bt_object *obj)
 {
-       struct bt_event_class_common *event_class;
+       struct bt_event_class *event_class;
 
-       event_class = container_of(obj, struct bt_event_class_common, base);
-       BT_LOGD("Finalizing common event class: addr=%p, name=\"%s\", id=%" PRId64,
-               event_class, bt_event_class_common_get_name(event_class),
-               bt_event_class_common_get_id(event_class));
+       event_class = container_of(obj, struct bt_event_class, base);
+       BT_LOGD("Finalizing event class: addr=%p, name=\"%s\", id=%" PRId64,
+               event_class, bt_event_class_get_name(event_class),
+               bt_event_class_get_id(event_class));
 
        if (event_class->name) {
                g_string_free(event_class->name, TRUE);
@@ -76,14 +76,14 @@ void bt_event_class_common_finalize(struct bt_object *obj)
        bt_put(event_class->payload_field_type);
 }
 
-BT_HIDDEN
-int bt_event_class_common_initialize(struct bt_event_class_common *event_class,
+static inline
+int bt_event_class_initialize(struct bt_event_class *event_class,
                const char *name, bt_object_release_func release_func,
                bt_field_type_structure_create_func ft_struct_create_func)
 {
        int ret = 0;
 
-       BT_LOGD("Initializing common event class object: name=\"%s\"",
+       BT_LOGD("Initializing event class object: name=\"%s\"",
                name);
        bt_object_init_shared_with_parent(&event_class->base, release_func);
        event_class->payload_field_type = ft_struct_create_func();
@@ -106,8 +106,8 @@ int bt_event_class_common_initialize(struct bt_event_class_common *event_class,
        }
 
        event_class->log_level = BT_EVENT_CLASS_LOG_LEVEL_UNSPECIFIED;
-       BT_LOGD("Initialized common event class object: addr=%p, name=\"%s\"",
-               event_class, bt_event_class_common_get_name(event_class));
+       BT_LOGD("Initialized event class object: addr=%p, name=\"%s\"",
+               event_class, bt_event_class_get_name(event_class));
        return ret;
 
 error:
@@ -121,7 +121,7 @@ void bt_event_class_destroy(struct bt_object *obj)
        struct bt_event_class *event_class = (void *) obj;
 
        BT_LOGD("Destroying event class: addr=%p", obj);
-       bt_event_class_common_finalize(obj);
+       bt_event_class_finalize(obj);
        bt_object_pool_finalize(&event_class->event_pool);
        g_free(obj);
 }
@@ -151,7 +151,7 @@ struct bt_event_class *bt_event_class_create(const char *name)
                goto error;
        }
 
-       ret = bt_event_class_common_initialize(BT_TO_COMMON(event_class),
+       ret = bt_event_class_initialize(event_class,
                name, bt_event_class_destroy,
                (bt_field_type_structure_create_func)
                        bt_field_type_structure_create);
@@ -182,84 +182,299 @@ end:
 
 const char *bt_event_class_get_name(struct bt_event_class *event_class)
 {
-       return bt_event_class_common_get_name(BT_TO_COMMON(event_class));
+       BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
+       BT_ASSERT(event_class->name);
+       return event_class->name->str;
 }
 
 int64_t bt_event_class_get_id(struct bt_event_class *event_class)
 {
-       return bt_event_class_common_get_id(BT_TO_COMMON(event_class));
+       BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
+       return event_class->id;
 }
 
-int bt_event_class_set_id(struct bt_event_class *event_class, uint64_t id)
+int bt_event_class_set_id(struct bt_event_class *event_class,
+               uint64_t id_param)
 {
-       return bt_event_class_common_set_id(BT_TO_COMMON(event_class), id);
+       int ret = 0;
+       int64_t id = (int64_t) id_param;
+
+       if (!event_class) {
+               BT_LOGW_STR("Invalid parameter: event class is NULL.");
+               ret = -1;
+               goto end;
+       }
+
+       if (event_class->frozen) {
+               BT_LOGW("Invalid parameter: event class is frozen: "
+                       "addr=%p, name=\"%s\", id=%" PRId64,
+                       event_class,
+                       bt_event_class_get_name(event_class),
+                       bt_event_class_get_id(event_class));
+               ret = -1;
+               goto end;
+       }
+
+       if (id < 0) {
+               BT_LOGW("Invalid parameter: invalid event class's ID: "
+                       "addr=%p, name=\"%s\", id=%" PRIu64,
+                       event_class,
+                       bt_event_class_get_name(event_class),
+                       id_param);
+               ret = -1;
+               goto end;
+       }
+
+       event_class->id = id;
+       BT_LOGV("Set event class's ID: "
+               "addr=%p, name=\"%s\", id=%" PRId64,
+               event_class, bt_event_class_get_name(event_class), id);
+
+end:
+       return ret;
 }
 
 enum bt_event_class_log_level bt_event_class_get_log_level(
                struct bt_event_class *event_class)
 {
-       return bt_event_class_common_get_log_level(BT_TO_COMMON(event_class));
+       BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
+       return event_class->log_level;
 }
 
 int bt_event_class_set_log_level(struct bt_event_class *event_class,
                enum bt_event_class_log_level log_level)
 {
-       return bt_event_class_common_set_log_level(BT_TO_COMMON(event_class),
-               log_level);
+       int ret = 0;
+
+       if (!event_class) {
+               BT_LOGW_STR("Invalid parameter: event class is NULL.");
+               ret = -1;
+               goto end;
+       }
+
+       if (event_class->frozen) {
+               BT_LOGW("Invalid parameter: event class is frozen: "
+                       "addr=%p, name=\"%s\", id=%" PRId64,
+                       event_class,
+                       bt_event_class_get_name(event_class),
+                       bt_event_class_get_id(event_class));
+               ret = -1;
+               goto end;
+       }
+
+       switch (log_level) {
+       case BT_EVENT_CLASS_LOG_LEVEL_UNSPECIFIED:
+       case BT_EVENT_CLASS_LOG_LEVEL_EMERGENCY:
+       case BT_EVENT_CLASS_LOG_LEVEL_ALERT:
+       case BT_EVENT_CLASS_LOG_LEVEL_CRITICAL:
+       case BT_EVENT_CLASS_LOG_LEVEL_ERROR:
+       case BT_EVENT_CLASS_LOG_LEVEL_WARNING:
+       case BT_EVENT_CLASS_LOG_LEVEL_NOTICE:
+       case BT_EVENT_CLASS_LOG_LEVEL_INFO:
+       case BT_EVENT_CLASS_LOG_LEVEL_DEBUG_SYSTEM:
+       case BT_EVENT_CLASS_LOG_LEVEL_DEBUG_PROGRAM:
+       case BT_EVENT_CLASS_LOG_LEVEL_DEBUG_PROCESS:
+       case BT_EVENT_CLASS_LOG_LEVEL_DEBUG_MODULE:
+       case BT_EVENT_CLASS_LOG_LEVEL_DEBUG_UNIT:
+       case BT_EVENT_CLASS_LOG_LEVEL_DEBUG_FUNCTION:
+       case BT_EVENT_CLASS_LOG_LEVEL_DEBUG_LINE:
+       case BT_EVENT_CLASS_LOG_LEVEL_DEBUG:
+               break;
+       default:
+               BT_LOGW("Invalid parameter: unknown event class log level: "
+                       "addr=%p, name=\"%s\", id=%" PRId64 ", log-level=%d",
+                       event_class, bt_event_class_get_name(event_class),
+                       bt_event_class_get_id(event_class), log_level);
+               ret = -1;
+               goto end;
+       }
+
+       event_class->log_level = log_level;
+       BT_LOGV("Set event class's log level: "
+               "addr=%p, name=\"%s\", id=%" PRId64 ", log-level=%s",
+               event_class, bt_event_class_get_name(event_class),
+               bt_event_class_get_id(event_class),
+               bt_common_event_class_log_level_string(log_level));
+
+end:
+       return ret;
 }
 
 const char *bt_event_class_get_emf_uri(struct bt_event_class *event_class)
 {
-       return bt_event_class_common_get_emf_uri(BT_TO_COMMON(event_class));
+       const char *emf_uri = NULL;
+
+       BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
+
+       if (event_class->emf_uri->len > 0) {
+               emf_uri = event_class->emf_uri->str;
+       }
+
+       return emf_uri;
 }
 
 int bt_event_class_set_emf_uri(struct bt_event_class *event_class,
                const char *emf_uri)
 {
-       return bt_event_class_common_set_emf_uri(BT_TO_COMMON(event_class),
-               emf_uri);
+       int ret = 0;
+
+       if (!event_class) {
+               BT_LOGW_STR("Invalid parameter: event class is NULL.");
+               ret = -1;
+               goto end;
+       }
+
+       if (emf_uri && strlen(emf_uri) == 0) {
+               BT_LOGW_STR("Invalid parameter: EMF URI is empty.");
+               ret = -1;
+               goto end;
+       }
+
+       if (event_class->frozen) {
+               BT_LOGW("Invalid parameter: event class is frozen: "
+                       "addr=%p, name=\"%s\", id=%" PRId64,
+                       event_class, bt_event_class_get_name(event_class),
+                       bt_event_class_get_id(event_class));
+               ret = -1;
+               goto end;
+       }
+
+       if (emf_uri) {
+               g_string_assign(event_class->emf_uri, emf_uri);
+               BT_LOGV("Set event class's EMF URI: "
+                       "addr=%p, name=\"%s\", id=%" PRId64 ", emf-uri=\"%s\"",
+                       event_class, bt_event_class_get_name(event_class),
+                       bt_event_class_get_id(event_class), emf_uri);
+       } else {
+               g_string_assign(event_class->emf_uri, "");
+               BT_LOGV("Reset event class's EMF URI: "
+                       "addr=%p, name=\"%s\", id=%" PRId64,
+                       event_class, bt_event_class_get_name(event_class),
+                       bt_event_class_get_id(event_class));
+       }
+
+end:
+       return ret;
 }
 
 struct bt_stream_class *bt_event_class_borrow_stream_class(
                struct bt_event_class *event_class)
 {
        BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
-       return BT_FROM_COMMON(
-               bt_event_class_common_borrow_stream_class(BT_TO_COMMON(
-                       event_class)));
+       return (void *) bt_object_borrow_parent(&event_class->base);
 }
 
 struct bt_field_type *bt_event_class_borrow_payload_field_type(
                struct bt_event_class *event_class)
 {
-       return BT_FROM_COMMON(bt_event_class_common_borrow_payload_field_type(
-               BT_TO_COMMON(event_class)));
+       BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
+       return event_class->payload_field_type;
 }
 
 int bt_event_class_set_payload_field_type(struct bt_event_class *event_class,
                struct bt_field_type *field_type)
 {
-       return bt_event_class_common_set_payload_field_type(
-               BT_TO_COMMON(event_class), (void *) field_type);
+       int ret = 0;
+
+       if (!event_class) {
+               BT_LOGW_STR("Invalid parameter: event class is NULL.");
+               ret = -1;
+               goto end;
+       }
+
+       if (field_type && bt_field_type_get_type_id(field_type) !=
+                       BT_FIELD_TYPE_ID_STRUCT) {
+               BT_LOGW("Invalid parameter: event class's payload field type must be a structure: "
+                       "addr=%p, name=\"%s\", id=%" PRId64 ", "
+                       "payload-ft-addr=%p, payload-ft-id=%s",
+                       event_class, bt_event_class_get_name(event_class),
+                       bt_event_class_get_id(event_class), field_type,
+                       bt_common_field_type_id_string(
+                               bt_field_type_get_type_id(field_type)));
+               ret = -1;
+               goto end;
+       }
+
+       bt_put(event_class->payload_field_type);
+       event_class->payload_field_type = bt_get(field_type);
+       BT_LOGV("Set event class's payload field type: "
+               "event-class-addr=%p, event-class-name=\"%s\", "
+               "event-class-id=%" PRId64 ", payload-ft-addr=%p",
+               event_class, bt_event_class_get_name(event_class),
+               bt_event_class_get_id(event_class), field_type);
+end:
+       return ret;
 }
 
 struct bt_field_type *bt_event_class_borrow_context_field_type(
                struct bt_event_class *event_class)
 {
-       return BT_FROM_COMMON(bt_event_class_common_borrow_context_field_type(
-               BT_TO_COMMON(event_class)));
+       struct bt_field_type *context_ft = NULL;
+
+       BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
+
+       if (!event_class->context_field_type) {
+               BT_LOGV("Event class has no context field type: "
+                       "addr=%p, name=\"%s\", id=%" PRId64,
+                       event_class, bt_event_class_get_name(event_class),
+                       bt_event_class_get_id(event_class));
+               goto end;
+       }
+
+       context_ft = event_class->context_field_type;
+
+end:
+       return context_ft;
 }
 
 int bt_event_class_set_context_field_type(
                struct bt_event_class *event_class,
                struct bt_field_type *field_type)
 {
-       return bt_event_class_common_set_context_field_type(
-               BT_TO_COMMON(event_class), (void *) field_type);
+       int ret = 0;
+
+       if (!event_class) {
+               BT_LOGW_STR("Invalid parameter: event class is NULL.");
+               ret = -1;
+               goto end;
+       }
+
+       if (event_class->frozen) {
+               BT_LOGW("Invalid parameter: event class is frozen: "
+                       "addr=%p, name=\"%s\", id=%" PRId64,
+                       event_class, bt_event_class_get_name(event_class),
+                       bt_event_class_get_id(event_class));
+               ret = -1;
+               goto end;
+       }
+
+       if (field_type && bt_field_type_get_type_id(field_type) !=
+                       BT_FIELD_TYPE_ID_STRUCT) {
+               BT_LOGW("Invalid parameter: event class's context field type must be a structure: "
+                       "addr=%p, name=\"%s\", id=%" PRId64 ", "
+                       "context-ft-id=%s",
+                       event_class, bt_event_class_get_name(event_class),
+                       bt_event_class_get_id(event_class),
+                       bt_common_field_type_id_string(
+                               bt_field_type_get_type_id(field_type)));
+               ret = -1;
+               goto end;
+       }
+
+       bt_put(event_class->context_field_type);
+       event_class->context_field_type = bt_get(field_type);
+       BT_LOGV("Set event class's context field type: "
+               "event-class-addr=%p, event-class-name=\"%s\", "
+               "event-class-id=%" PRId64 ", context-ft-addr=%p",
+               event_class, bt_event_class_get_name(event_class),
+               bt_event_class_get_id(event_class), field_type);
+
+end:
+       return ret;
 }
 
 BT_HIDDEN
-void bt_event_class_common_freeze(struct bt_event_class_common *event_class)
+void bt_event_class_freeze(struct bt_event_class *event_class)
 {
        BT_ASSERT(event_class);
 
@@ -268,25 +483,25 @@ void bt_event_class_common_freeze(struct bt_event_class_common *event_class)
        }
 
        BT_LOGD("Freezing event class: addr=%p, name=\"%s\", id=%" PRId64,
-               event_class, bt_event_class_common_get_name(event_class),
-               bt_event_class_common_get_id(event_class));
+               event_class, bt_event_class_get_name(event_class),
+               bt_event_class_get_id(event_class));
        event_class->frozen = 1;
        BT_LOGD_STR("Freezing event class's context field type.");
-       bt_field_type_common_freeze(event_class->context_field_type);
+       bt_field_type_freeze(event_class->context_field_type);
        BT_LOGD_STR("Freezing event class's payload field type.");
-       bt_field_type_common_freeze(event_class->payload_field_type);
+       bt_field_type_freeze(event_class->payload_field_type);
 }
 
 BT_HIDDEN
-int bt_event_class_common_validate_single_clock_class(
-               struct bt_event_class_common *event_class,
+int bt_event_class_validate_single_clock_class(
+               struct bt_event_class *event_class,
                struct bt_clock_class **expected_clock_class)
 {
        int ret = 0;
 
        BT_ASSERT(event_class);
        BT_ASSERT(expected_clock_class);
-       ret = bt_field_type_common_validate_single_clock_class(
+       ret = bt_field_type_validate_single_clock_class(
                event_class->context_field_type,
                expected_clock_class);
        if (ret) {
@@ -298,13 +513,13 @@ int bt_event_class_common_validate_single_clock_class(
                        "event-class-id=%" PRId64 ", "
                        "ft-addr=%p",
                        event_class,
-                       bt_event_class_common_get_name(event_class),
+                       bt_event_class_get_name(event_class),
                        event_class->id,
                        event_class->context_field_type);
                goto end;
        }
 
-       ret = bt_field_type_common_validate_single_clock_class(
+       ret = bt_field_type_validate_single_clock_class(
                event_class->payload_field_type,
                expected_clock_class);
        if (ret) {
@@ -316,7 +531,7 @@ int bt_event_class_common_validate_single_clock_class(
                        "event-class-id=%" PRId64 ", "
                        "ft-addr=%p",
                        event_class,
-                       bt_event_class_common_get_name(event_class),
+                       bt_event_class_get_name(event_class),
                        event_class->id,
                        event_class->payload_field_type);
                goto end;
index 115158c3e6a4e2289290b844b85cb7bec2026d1c..f8ef4e1d7f62201f78b15b978974c02f6a2e174f 100644 (file)
@@ -55,9 +55,9 @@
 #include <babeltrace/assert-internal.h>
 #include <inttypes.h>
 
-static
-int bt_event_common_validate_types_for_create(
-               struct bt_event_class_common *event_class,
+static inline
+int bt_event_validate_types_for_create(
+               struct bt_event_class *event_class,
                struct bt_validation_output *validation_output,
                bt_validation_flag_copy_field_type_func copy_field_type_func)
 {
@@ -65,42 +65,42 @@ int bt_event_common_validate_types_for_create(
        enum bt_validation_flag validation_flags =
                BT_VALIDATION_FLAG_STREAM |
                BT_VALIDATION_FLAG_EVENT;
-       struct bt_trace_common *trace = NULL;
-       struct bt_stream_class_common *stream_class = NULL;
-       struct bt_field_type_common *packet_header_type = NULL;
-       struct bt_field_type_common *packet_context_type = NULL;
-       struct bt_field_type_common *event_header_type = NULL;
-       struct bt_field_type_common *stream_event_ctx_type = NULL;
-       struct bt_field_type_common *event_context_type = NULL;
-       struct bt_field_type_common *event_payload_type = NULL;
+       struct bt_trace *trace = NULL;
+       struct bt_stream_class *stream_class = NULL;
+       struct bt_field_type *packet_header_type = NULL;
+       struct bt_field_type *packet_context_type = NULL;
+       struct bt_field_type *event_header_type = NULL;
+       struct bt_field_type *stream_event_ctx_type = NULL;
+       struct bt_field_type *event_context_type = NULL;
+       struct bt_field_type *event_payload_type = NULL;
        int trace_valid = 0;
        struct bt_value *environment = NULL;
 
-       stream_class = bt_event_class_common_borrow_stream_class(event_class);
+       stream_class = bt_event_class_borrow_stream_class(event_class);
        BT_ASSERT(stream_class);
-       trace = bt_stream_class_common_borrow_trace(stream_class);
+       trace = bt_stream_class_borrow_trace(stream_class);
        if (trace) {
                BT_LOGD_STR("Event class is part of a trace.");
                packet_header_type =
-                       bt_trace_common_borrow_packet_header_field_type(trace);
+                       bt_trace_borrow_packet_header_field_type(trace);
                trace_valid = trace->valid;
                BT_ASSERT(trace_valid);
                environment = trace->environment;
        }
 
        packet_context_type =
-               bt_stream_class_common_borrow_packet_context_field_type(
+               bt_stream_class_borrow_packet_context_field_type(
                        stream_class);
        event_header_type =
-               bt_stream_class_common_borrow_event_header_field_type(
+               bt_stream_class_borrow_event_header_field_type(
                        stream_class);
        stream_event_ctx_type =
-               bt_stream_class_common_borrow_event_context_field_type(
+               bt_stream_class_borrow_event_context_field_type(
                        stream_class);
        event_context_type =
-               bt_event_class_common_borrow_context_field_type(event_class);
+               bt_event_class_borrow_context_field_type(event_class);
        event_payload_type =
-               bt_event_class_common_borrow_payload_field_type(event_class);
+               bt_event_class_borrow_payload_field_type(event_class);
        ret = bt_validate_class_types(environment, packet_header_type,
                packet_context_type, event_header_type, stream_event_ctx_type,
                event_context_type, event_payload_type, trace_valid,
@@ -134,17 +134,17 @@ end:
 }
 
 static
-int bt_event_common_create_fields(
-               struct bt_stream_class_common *stream_class,
+int bt_event_create_fields(
+               struct bt_stream_class *stream_class,
                struct bt_validation_output *validation_output,
                create_field_func create_field_func,
                release_field_func release_field_func,
                create_header_field_func create_header_field_func,
                release_header_field_func release_header_field_func,
                struct bt_field_wrapper **header_field,
-               struct bt_field_common **stream_event_context_field,
-               struct bt_field_common **context_field,
-               struct bt_field_common **payload_field)
+               struct bt_field **stream_event_context_field,
+               struct bt_field **context_field,
+               struct bt_field **payload_field)
 {
        int ret = 0;
 
@@ -219,24 +219,24 @@ end:
 }
 
 BT_HIDDEN
-int _bt_event_common_validate(struct bt_event_common *event)
+int _bt_event_validate(struct bt_event *event)
 {
        int ret = 0;
-       struct bt_stream_class_common *stream_class;
+       struct bt_stream_class *stream_class;
 
        BT_ASSERT(event);
        if (event->header_field) {
-               ret = bt_field_common_validate_recursive(
+               ret = bt_field_validate_recursive(
                        event->header_field->field);
                if (ret) {
                        BT_ASSERT_PRE_MSG("Invalid event's header field: "
-                               "%![event-]+_e, %![field-]+_f",
+                               "%![event-]+e, %![field-]+f",
                                event, event->header_field->field);
                        goto end;
                }
        }
 
-       stream_class = bt_event_class_common_borrow_stream_class(event->class);
+       stream_class = bt_event_class_borrow_stream_class(event->class);
 
        /*
         * We should not have been able to create the event without associating
@@ -245,30 +245,30 @@ int _bt_event_common_validate(struct bt_event_common *event)
        BT_ASSERT(stream_class);
 
        if (stream_class->event_context_field_type) {
-               ret = bt_field_common_validate_recursive(
+               ret = bt_field_validate_recursive(
                        event->stream_event_context_field);
                if (ret) {
                        BT_ASSERT_PRE_MSG("Invalid event's stream event context field: "
-                               "%![event-]+_e, %![field-]+_f",
+                               "%![event-]+e, %![field-]+f",
                                event, event->stream_event_context_field);
                        goto end;
                }
        }
 
        if (event->class->context_field_type) {
-               ret = bt_field_common_validate_recursive(event->context_field);
+               ret = bt_field_validate_recursive(event->context_field);
                if (ret) {
                        BT_ASSERT_PRE_MSG("Invalid event's payload field: "
-                               "%![event-]+_e, %![field-]+_f",
+                               "%![event-]+e, %![field-]+f",
                                event, event->context_field);
                        goto end;
                }
        }
 
-       ret = bt_field_common_validate_recursive(event->payload_field);
+       ret = bt_field_validate_recursive(event->payload_field);
        if (ret) {
                BT_ASSERT_PRE_MSG("Invalid event's payload field: "
-                       "%![event-]+_e, %![field-]+_f",
+                       "%![event-]+e, %![field-]+f",
                        event, event->payload_field);
                goto end;
        }
@@ -278,99 +278,86 @@ end:
 }
 
 BT_HIDDEN
-void _bt_event_common_set_is_frozen(struct bt_event_common *event,
+void _bt_event_set_is_frozen(struct bt_event *event,
                bool is_frozen)
 {
        BT_ASSERT(event);
        BT_LOGD("Freezing event: addr=%p, "
                "event-class-name=\"%s\", event-class-id=%" PRId64,
-               event, bt_event_class_common_get_name(event->class),
-               bt_event_class_common_get_id(event->class));
+               event, bt_event_class_get_name(event->class),
+               bt_event_class_get_id(event->class));
 
        if (event->header_field) {
                BT_LOGD_STR("Freezing event's header field.");
-               bt_field_common_set_is_frozen_recursive(
+               bt_field_set_is_frozen_recursive(
                        event->header_field->field, is_frozen);
        }
 
        if (event->stream_event_context_field) {
                BT_LOGD_STR("Freezing event's stream event context field.");
-               bt_field_common_set_is_frozen_recursive(
+               bt_field_set_is_frozen_recursive(
                        event->stream_event_context_field, is_frozen);
        }
 
        if (event->context_field) {
                BT_LOGD_STR("Freezing event's context field.");
-               bt_field_common_set_is_frozen_recursive(event->context_field,
+               bt_field_set_is_frozen_recursive(event->context_field,
                        is_frozen);
        }
 
        if (event->payload_field) {
                BT_LOGD_STR("Freezing event's payload field.");
-               bt_field_common_set_is_frozen_recursive(event->payload_field,
+               bt_field_set_is_frozen_recursive(event->payload_field,
                        is_frozen);
        }
 
        event->frozen = is_frozen;
+       BT_LOGD_STR("Freezing event's packet.");
+       bt_packet_set_is_frozen(event->packet, is_frozen);
 }
 
-BT_HIDDEN
-int bt_event_common_initialize(struct bt_event_common *event,
-               struct bt_event_class_common *event_class,
-               struct bt_clock_class *init_expected_clock_class,
-               bool is_shared_with_parent, bt_object_release_func release_func,
+static inline
+int bt_event_initialize(struct bt_event *event,
+               struct bt_event_class *event_class,
                bt_validation_flag_copy_field_type_func field_type_copy_func,
-               bool must_be_in_trace,
-               int (*map_clock_classes_func)(struct bt_stream_class_common *stream_class,
-                       struct bt_field_type_common *packet_context_field_type,
-                       struct bt_field_type_common *event_header_field_type),
                create_field_func create_field_func,
                release_field_func release_field_func,
                create_header_field_func create_header_field_func,
                release_header_field_func release_header_field_func)
 {
        int ret;
-       struct bt_trace_common *trace = NULL;
-       struct bt_stream_class_common *stream_class = NULL;
+       struct bt_trace *trace = NULL;
+       struct bt_stream_class *stream_class = NULL;
        struct bt_field_wrapper *event_header = NULL;
-       struct bt_field_common *stream_event_context = NULL;
-       struct bt_field_common *event_context = NULL;
-       struct bt_field_common *event_payload = NULL;
+       struct bt_field *stream_event_context = NULL;
+       struct bt_field *event_context = NULL;
+       struct bt_field *event_payload = NULL;
        struct bt_validation_output validation_output = { 0 };
-       struct bt_clock_class *expected_clock_class =
-               init_expected_clock_class ? bt_get(init_expected_clock_class) :
-               NULL;
+       struct bt_clock_class *expected_clock_class = NULL;
 
        BT_ASSERT_PRE_NON_NULL(event_class, "Event class");
-       BT_LOGD("Initializing common event object: event-class-addr=%p, "
+       BT_LOGD("Initializing event object: event-class-addr=%p, "
                "event-class-name=\"%s\", event-class-id=%" PRId64,
-               event_class, bt_event_class_common_get_name(event_class),
-               bt_event_class_common_get_id(event_class));
+               event_class, bt_event_class_get_name(event_class),
+               bt_event_class_get_id(event_class));
 
-       stream_class = bt_event_class_common_borrow_stream_class(event_class);
+       stream_class = bt_event_class_borrow_stream_class(event_class);
        BT_ASSERT_PRE(stream_class,
-               "Event class is not part of a stream class: %!+_E", event_class);
+               "Event class is not part of a stream class: %!+E", event_class);
 
        /* The event class was frozen when added to its stream class */
        BT_ASSERT(event_class->frozen);
-       trace = bt_stream_class_common_borrow_trace(stream_class);
-
-       if (must_be_in_trace) {
-               BT_ASSERT_PRE(trace,
-                       "Event class's stream class is not part of a trace: "
-                       "%![ec-]+_E, %![ec-]+_S", event_class, stream_class);
-       }
+       trace = bt_stream_class_borrow_trace(stream_class);
+       BT_ASSERT_PRE(trace,
+               "Event class's stream class is not part of a trace: "
+               "%![ec-]+E, %![ec-]+S", event_class, stream_class);
 
        /*
         * This must be called before anything that can fail because on
         * failure, the caller releases the reference to `event` to
         * destroy it.
         */
-       if (is_shared_with_parent) {
-               bt_object_init_shared_with_parent(&event->base, release_func);
-       } else {
-               bt_object_init_unique(&event->base);
-       }
+       bt_object_init_unique(&event->base);
 
        if (!stream_class->frozen) {
                /*
@@ -379,7 +366,7 @@ int bt_event_common_initialize(struct bt_event_common *event,
                 * single clock class so that we set its expected clock
                 * class for future checks.
                 */
-               ret = bt_stream_class_common_validate_single_clock_class(
+               ret = bt_stream_class_validate_single_clock_class(
                        stream_class, &expected_clock_class);
                if (ret) {
                        BT_LOGW("Event class's stream class or one of its event "
@@ -392,8 +379,8 @@ int bt_event_common_initialize(struct bt_event_common *event,
                                "expected-clock-class-addr=%p, "
                                "expected-clock-class-name=\"%s\"",
                                stream_class,
-                               bt_stream_class_common_get_id(stream_class),
-                               bt_stream_class_common_get_name(stream_class),
+                               bt_stream_class_get_id(stream_class),
+                               bt_stream_class_get_name(stream_class),
                                expected_clock_class,
                                expected_clock_class ?
                                        bt_clock_class_get_name(expected_clock_class) :
@@ -403,45 +390,32 @@ int bt_event_common_initialize(struct bt_event_common *event,
        }
 
        /* Validate the trace, the stream class, and the event class */
-       ret = bt_event_common_validate_types_for_create(
+       ret = bt_event_validate_types_for_create(
                event_class, &validation_output, field_type_copy_func);
        if (ret) {
-               /* bt_event_common_validate_types_for_create() logs errors */
+               /* bt_event_validate_types_for_create() logs errors */
                goto error;
        }
 
-       if (map_clock_classes_func) {
-               /*
-                * Safe to automatically map selected fields to the
-                * stream's clock's class here because the stream class
-                * is about to be frozen.
-                */
-               if (map_clock_classes_func(stream_class,
-                               validation_output.packet_context_type,
-                               validation_output.event_header_type)) {
-                       BT_LOGW_STR("Cannot automatically map selected stream class's "
-                               "field types to stream class's clock's class.");
-                       goto error;
-               }
-       }
-
        /*
         * event does not share a common ancestor with the event class; it has
         * to guarantee its existence by holding a reference. This reference
         * shall be released once the event is associated to a stream since,
         * from that point, the event and its class will share the same
         * lifetime.
+        *
+        * TODO: Is this still true now that this API and CTF writer are
+        * two different implementations?
         */
        event->class = bt_get(event_class);
-
-       ret = bt_event_common_create_fields(stream_class,
+       ret = bt_event_create_fields(stream_class,
                &validation_output,
                create_field_func, release_field_func,
                create_header_field_func, release_header_field_func,
                &event_header, &stream_event_context, &event_context,
                &event_payload);
        if (ret) {
-               /* bt_event_common_create_fields() logs errors */
+               /* bt_event_create_fields() logs errors */
                goto error;
        }
 
@@ -472,7 +446,7 @@ int bt_event_common_initialize(struct bt_event_common *event,
         * Freeze the stream class since the event header must not be changed
         * anymore.
         */
-       bt_stream_class_common_freeze(stream_class);
+       bt_stream_class_freeze(stream_class);
 
        /*
         * It is safe to set the stream class's unique clock class
@@ -492,8 +466,8 @@ int bt_event_common_initialize(struct bt_event_common *event,
        /* Put stuff we borrowed from the event class */
        BT_LOGD("Initialized event object: addr=%p, event-class-name=\"%s\", "
                "event-class-id=%" PRId64,
-               event, bt_event_class_common_get_name(event->class),
-               bt_event_class_common_get_id(event->class));
+               event, bt_event_class_get_name(event->class),
+               bt_event_class_get_id(event->class));
        goto end;
 
 error:
@@ -538,7 +512,7 @@ void bt_event_header_field_recycle(struct bt_field_wrapper *field_wrapper,
 static
 struct bt_field_wrapper *create_event_header_field(
                struct bt_stream_class *stream_class,
-               struct bt_field_type_common *ft)
+               struct bt_field_type *ft)
 {
        struct bt_field_wrapper *field_wrapper = NULL;
 
@@ -573,16 +547,14 @@ struct bt_event *bt_event_new(struct bt_event_class *event_class)
                goto error;
        }
 
-       ret = bt_event_common_initialize(BT_TO_COMMON(event),
-               BT_TO_COMMON(event_class), NULL, false, NULL,
+       ret = bt_event_initialize(event, event_class,
                (bt_validation_flag_copy_field_type_func) bt_field_type_copy,
-               true, NULL,
                (create_field_func) bt_field_create_recursive,
                (release_field_func) bt_field_destroy_recursive,
                (create_header_field_func) create_event_header_field,
                (release_header_field_func) bt_event_header_field_recycle);
        if (ret) {
-               /* bt_event_common_initialize() logs errors */
+               /* bt_event_initialize() logs errors */
                goto error;
        }
 
@@ -608,8 +580,7 @@ end:
 struct bt_event_class *bt_event_borrow_class(struct bt_event *event)
 {
        BT_ASSERT_PRE_NON_NULL(event, "Event");
-       return BT_FROM_COMMON(
-               bt_event_common_borrow_class(BT_TO_COMMON(event)));
+       return event->class;
 }
 
 struct bt_stream *bt_event_borrow_stream(struct bt_event *event)
@@ -620,34 +591,89 @@ struct bt_stream *bt_event_borrow_stream(struct bt_event *event)
 
 struct bt_field *bt_event_borrow_payload(struct bt_event *event)
 {
-       return BT_FROM_COMMON(
-               bt_event_common_borrow_payload(BT_TO_COMMON(event)));
+       struct bt_field *payload = NULL;
+
+       BT_ASSERT_PRE_NON_NULL(event, "Event");
+
+       if (!event->payload_field) {
+               BT_LOGV("Event has no current payload field: addr=%p, "
+                       "event-class-name=\"%s\", event-class-id=%" PRId64,
+                       event, bt_event_class_get_name(event->class),
+                       bt_event_class_get_id(event->class));
+               goto end;
+       }
+
+       payload = event->payload_field;
+
+end:
+       return payload;
 }
 
 struct bt_field *bt_event_borrow_header(struct bt_event *event)
 {
-       return BT_FROM_COMMON(
-               bt_event_common_borrow_header(BT_TO_COMMON(event)));
+       struct bt_field *header = NULL;
+
+       BT_ASSERT_PRE_NON_NULL(event, "Event");
+
+       if (!event->header_field) {
+               BT_LOGV("Event has no current header field: addr=%p, "
+                       "event-class-name=\"%s\", event-class-id=%" PRId64,
+                       event, bt_event_class_get_name(event->class),
+                       bt_event_class_get_id(event->class));
+               goto end;
+       }
+
+       header = event->header_field->field;
+
+end:
+       return header;
 }
 
 struct bt_field *bt_event_borrow_context(struct bt_event *event)
 {
-       return BT_FROM_COMMON(
-               bt_event_common_borrow_context(BT_TO_COMMON(event)));
+       struct bt_field *context = NULL;
+
+       BT_ASSERT_PRE_NON_NULL(event, "Event");
+
+       if (!event->context_field) {
+               BT_LOGV("Event has no current context field: addr=%p, "
+                       "event-class-name=\"%s\", event-class-id=%" PRId64,
+                       event, bt_event_class_get_name(event->class),
+                       bt_event_class_get_id(event->class));
+               goto end;
+       }
+
+       context = event->context_field;
+
+end:
+       return context;
 }
 
 struct bt_field *bt_event_borrow_stream_event_context(
                struct bt_event *event)
 {
-       return BT_FROM_COMMON(bt_event_common_borrow_stream_event_context(
-               BT_TO_COMMON(event)));
+       struct bt_field *stream_event_context = NULL;
+
+       BT_ASSERT_PRE_NON_NULL(event, "Event");
+
+       if (!event->stream_event_context_field) {
+               BT_LOGV("Event has no current stream event context field: addr=%p, "
+                       "event-class-name=\"%s\", event-class-id=%" PRId64,
+                       event, bt_event_class_get_name(event->class),
+                       bt_event_class_get_id(event->class));
+               goto end;
+       }
+
+       stream_event_context = event->stream_event_context_field;
+
+end:
+       return stream_event_context;
 }
 
 static
 void release_event_header_field(struct bt_field_wrapper *field_wrapper,
-               struct bt_event_common *event_common)
+               struct bt_event *event)
 {
-       struct bt_event *event = BT_FROM_COMMON(event_common);
        struct bt_event_class *event_class = bt_event_borrow_class(event);
 
        if (!event_class) {
@@ -661,11 +687,59 @@ void release_event_header_field(struct bt_field_wrapper *field_wrapper,
        }
 }
 
+static inline
+void bt_event_finalize(struct bt_object *obj,
+               void (*field_release_func)(void *),
+               void (*header_field_release_func)(void *, struct bt_event *))
+{
+       struct bt_event *event = (void *) obj;
+
+       BT_LOGD("Destroying event: addr=%p, "
+               "event-class-name=\"%s\", event-class-id=%" PRId64,
+               event,
+               event->class ? bt_event_class_get_name(event->class) : NULL,
+               event->class ? bt_event_class_get_id(event->class) : INT64_C(-1));
+
+       if (event->header_field) {
+               BT_LOGD_STR("Releasing event's header field.");
+               header_field_release_func(event->header_field, event);
+       }
+
+       if (event->stream_event_context_field) {
+               BT_LOGD_STR("Releasing event's stream event context field.");
+               field_release_func(event->stream_event_context_field);
+       }
+
+       if (event->context_field) {
+               BT_LOGD_STR("Releasing event's context field.");
+               field_release_func(event->context_field);
+       }
+
+       if (event->payload_field) {
+               BT_LOGD_STR("Releasing event's payload field.");
+               field_release_func(event->payload_field);
+       }
+
+       /*
+        * Leave this after calling header_field_release_func() because
+        * this function receives the event object and could need its
+        * class to perform some cleanup.
+        */
+       if (!event->base.parent) {
+               /*
+                * Event was keeping a reference to its class since it shared no
+                * common ancestor with it to guarantee they would both have the
+                * same lifetime.
+                */
+               bt_put(event->class);
+       }
+}
+
 BT_HIDDEN
 void bt_event_destroy(struct bt_event *event)
 {
        BT_ASSERT(event);
-       bt_event_common_finalize((void *) event,
+       bt_event_finalize((void *) event,
                (void *) bt_field_destroy_recursive,
                (void *) release_event_header_field);
        bt_clock_value_set_finalize(&event->cv_set);
@@ -680,7 +754,7 @@ int bt_event_set_clock_value(struct bt_event *event,
 {
        BT_ASSERT_PRE_NON_NULL(event, "Event");
        BT_ASSERT_PRE_NON_NULL(clock_class, "Clock class");
-       BT_ASSERT_PRE_HOT(BT_TO_COMMON(event), "Event", ": %!+e", event);
+       BT_ASSERT_PRE_HOT(event, "Event", ": %!+e", event);
        BT_ASSERT_PRE(is_default,
                "You can only set a default clock value as of this version.");
        return bt_clock_value_set_set_clock_value(&event->cv_set, clock_class,
@@ -709,8 +783,8 @@ struct bt_packet *bt_event_borrow_packet(struct bt_event *event)
        if (!event->packet) {
                BT_LOGV("Event has no current packet: addr=%p, "
                        "event-class-name=\"%s\", event-class-id=%" PRId64,
-                       event, bt_event_class_common_get_name(event->common.class),
-                       bt_event_class_common_get_id(event->common.class));
+                       event, bt_event_class_get_name(event->class),
+                       bt_event_class_get_id(event->class));
                goto end;
        }
 
@@ -720,14 +794,6 @@ end:
        return packet;
 }
 
-BT_HIDDEN
-void _bt_event_set_is_frozen(struct bt_event *event, bool is_frozen)
-{
-       bt_event_common_set_is_frozen(BT_TO_COMMON(event), is_frozen);
-       BT_LOGD_STR("Freezing event's packet.");
-       bt_packet_set_is_frozen(event->packet, is_frozen);
-}
-
 int bt_event_move_header(struct bt_event *event,
                struct bt_event_header_field *header_field)
 {
@@ -736,19 +802,19 @@ int bt_event_move_header(struct bt_event *event,
 
        BT_ASSERT_PRE_NON_NULL(event, "Event");
        BT_ASSERT_PRE_NON_NULL(field_wrapper, "Header field");
-       BT_ASSERT_PRE_HOT(BT_TO_COMMON(event), "Event", ": %!+e", event);
+       BT_ASSERT_PRE_HOT(event, "Event", ": %!+e", event);
        stream_class = bt_event_class_borrow_stream_class(
                bt_event_borrow_class(event));
-       BT_ASSERT_PRE(stream_class->common.event_header_field_type,
+       BT_ASSERT_PRE(stream_class->event_header_field_type,
                "Stream class has no event header field type: %!+S",
                stream_class);
 
        /* Recycle current header field: always exists */
-       BT_ASSERT(event->common.header_field);
-       bt_event_header_field_recycle(event->common.header_field,
+       BT_ASSERT(event->header_field);
+       bt_event_header_field_recycle(event->header_field,
                stream_class);
 
        /* Move new field */
-       event->common.header_field = (void *) field_wrapper;
+       event->header_field = (void *) field_wrapper;
        return 0;
 }
index 4e808b938e5faa22072af00dbb7d2eea080d1b85..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
@@ -157,10 +264,10 @@ void destroy_enumeration_mapping(struct enumeration_mapping *mapping)
        g_free(mapping);
 }
 
-BT_HIDDEN
-void bt_field_type_common_initialize(struct bt_field_type_common *ft,
+static
+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));
@@ -174,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_array_new(FALSE, TRUE,
-               sizeof(struct bt_field_type_common_structure_field));
+               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->choice_name_to_index = g_hash_table_new(NULL, NULL);
        var_ft->choices = g_array_new(FALSE, TRUE,
-               sizeof(struct bt_field_type_common_variant_choice));
+               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;
@@ -365,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;
@@ -378,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;
@@ -394,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;
@@ -408,8 +515,8 @@ void bt_field_type_common_string_destroy(struct bt_object *obj)
 }
 
 static
-void bt_field_type_common_structure_field_finalize(
-               struct bt_field_type_common_structure_field *field)
+void bt_field_type_structure_field_finalize(
+               struct bt_field_type_structure_field *field)
 {
        if (!field) {
                return;
@@ -422,10 +529,10 @@ void bt_field_type_common_structure_field_finalize(
        bt_put(field->type);
 }
 
-BT_HIDDEN
-void bt_field_type_common_structure_destroy_recursive(struct bt_object *obj)
+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) {
@@ -436,8 +543,8 @@ void bt_field_type_common_structure_destroy_recursive(struct bt_object *obj)
 
        if (ft->fields) {
                for (i = 0; i < ft->fields->len; i++) {
-                       bt_field_type_common_structure_field_finalize(
-                               BT_FIELD_TYPE_COMMON_STRUCTURE_FIELD_AT_INDEX(
+                       bt_field_type_structure_field_finalize(
+                               BT_FIELD_TYPE_STRUCTURE_FIELD_AT_INDEX(
                                        ft, i));
                }
 
@@ -451,10 +558,10 @@ void bt_field_type_common_structure_destroy_recursive(struct bt_object *obj)
        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;
@@ -466,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;
@@ -485,8 +592,8 @@ void bt_field_type_common_sequence_destroy_recursive(struct bt_object *obj)
 }
 
 static
-void bt_field_type_common_variant_choice_finalize(
-               struct bt_field_type_common_variant_choice *choice)
+void bt_field_type_variant_choice_finalize(
+               struct bt_field_type_variant_choice *choice)
 {
        if (!choice) {
                return;
@@ -503,10 +610,10 @@ void bt_field_type_common_variant_choice_finalize(
        }
 }
 
-BT_HIDDEN
-void bt_field_type_common_variant_destroy_recursive(struct bt_object *obj)
+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) {
@@ -517,8 +624,8 @@ void bt_field_type_common_variant_destroy_recursive(struct bt_object *obj)
 
        if (ft->choices) {
                for (i = 0; i < ft->choices->len; i++) {
-                       bt_field_type_common_variant_choice_finalize(
-                               BT_FIELD_TYPE_COMMON_VARIANT_CHOICE_AT_INDEX(
+                       bt_field_type_variant_choice_finalize(
+                               BT_FIELD_TYPE_VARIANT_CHOICE_AT_INDEX(
                                        ft, i));
                }
 
@@ -554,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)
@@ -633,12 +678,12 @@ gint compare_enumeration_mappings_unsigned(struct enumeration_mapping **a,
 static
 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 bt_field_type_common **member_ft;
+       struct bt_field_type **member_ft;
        GQuark *member_name;
 
        /* Make sure structure does not contain a field of the same name */
@@ -653,21 +698,21 @@ int add_structure_variant_member(GArray *members,
        g_array_set_size(members, members->len + 1);
 
        if (is_variant) {
-               struct bt_field_type_common_variant_choice *choice =
+               struct bt_field_type_variant_choice *choice =
                        &g_array_index(members,
-                               struct bt_field_type_common_variant_choice,
+                               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_common_variant_choice_range));
+                       sizeof(struct bt_field_type_variant_choice_range));
                BT_ASSERT(choice->ranges);
        } else {
-               struct bt_field_type_common_structure_field *field =
+               struct bt_field_type_structure_field *field =
                        &g_array_index(members,
-                               struct bt_field_type_common_structure_field,
+                               struct bt_field_type_structure_field,
                                members->len - 1);
 
                member_ft = &field->type;
@@ -686,11 +731,11 @@ 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: "
@@ -706,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) {
@@ -730,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;
@@ -739,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
@@ -778,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",
@@ -806,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) {
@@ -821,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",
@@ -832,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",
@@ -849,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);
@@ -864,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: "
@@ -883,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) {
@@ -918,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,
@@ -941,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\"",
@@ -953,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: "
@@ -980,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;
 
@@ -1007,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);
 
@@ -1017,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);
@@ -1037,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.");
@@ -1105,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.");
@@ -1155,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.");
@@ -1230,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.");
@@ -1299,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) {
@@ -1364,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;
@@ -1384,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)
 {
@@ -1415,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) {
@@ -1439,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: "
@@ -1470,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:
@@ -1533,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: "
@@ -1548,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);
@@ -1565,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: "
@@ -1587,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);
@@ -1603,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,
@@ -1620,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);
 }
@@ -1634,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)
 {
@@ -1649,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;
        }
@@ -1676,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)
 {
@@ -1695,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;
        }
@@ -1721,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);
@@ -1751,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",
@@ -1773,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) {
@@ -1882,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) {
@@ -1980,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.");
 
@@ -2017,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,
@@ -2029,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.");
@@ -2095,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.");
@@ -2166,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.");
 
@@ -2185,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);
@@ -2199,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 bt_field_type_common_structure_field *field =
-                       BT_FIELD_TYPE_COMMON_STRUCTURE_FIELD_AT_INDEX(ft, 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`,
@@ -2293,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 bt_field_type_common_structure_field *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 = BT_FIELD_TYPE_COMMON_STRUCTURE_FIELD_AT_INDEX(struct_ft, index);
+       field = BT_FIELD_TYPE_STRUCTURE_FIELD_AT_INDEX(struct_ft, index);
 
        if (field_type) {
                *field_type = field->type;
@@ -2348,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 bt_field_type_common_structure_field *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) {
@@ -2388,24 +2188,17 @@ bt_field_type_common_structure_borrow_field_type_by_name(
                goto end;
        }
 
-       field = BT_FIELD_TYPE_COMMON_STRUCTURE_FIELD_AT_INDEX(ft, 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\"",
@@ -2418,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\"",
@@ -2440,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) {
@@ -2458,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) {
@@ -2494,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.");
@@ -2542,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);
 
        /*
@@ -2636,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 bt_field_type_common_variant_choice *choice;
-       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) {
@@ -2676,55 +2435,38 @@ bt_field_type_common_variant_borrow_field_type_by_name(
                goto end;
        }
 
-       choice = BT_FIELD_TYPE_COMMON_VARIANT_CHOICE_AT_INDEX(ft, index);
+       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
-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->choices->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);
-}
-
-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 bt_field_type_common_variant_choice *choice;
+       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->choices->len,
                "Index is out of bounds: index=%" PRIu64 ", "
-               "count=%u, %![ft-]+_F",
+               "count=%u, %![ft-]+F",
                index, var_ft->choices->len, ft);
-       choice = BT_FIELD_TYPE_COMMON_VARIANT_CHOICE_AT_INDEX(ft, index);
+       choice = BT_FIELD_TYPE_VARIANT_CHOICE_AT_INDEX(ft, index);
 
        if (field_type) {
                *field_type = choice->type;
@@ -2738,42 +2480,34 @@ int bt_field_type_common_variant_borrow_field_by_index(
        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)
-{
-       return bt_field_type_common_variant_borrow_field_by_index((void *) ft,
-               field_name, (void *) field_type, index);
-}
-
 BT_HIDDEN
-int64_t bt_field_type_common_variant_find_choice_index(
-               struct bt_field_type_common *ft, uint64_t uval,
+int64_t bt_field_type_variant_find_choice_index(
+               struct bt_field_type *ft, uint64_t uval,
                bool is_signed)
 {
        int64_t ret;
        uint64_t i;
-       struct bt_field_type_common_variant *var_ft = BT_FROM_COMMON(ft);
+       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_common_variant_update_choices(ft)) {
+       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_common_variant_choice *choice =
-                       BT_FIELD_TYPE_COMMON_VARIANT_CHOICE_AT_INDEX(
+               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_common_variant_choice_range *range =
+                       struct bt_field_type_variant_choice_range *range =
                                &g_array_index(
                                        choice->ranges,
-                                       struct bt_field_type_common_variant_choice_range,
+                                       struct bt_field_type_variant_choice_range,
                                        range_i);
 
                        if (is_signed) {
@@ -2806,7 +2540,7 @@ end:
 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);
@@ -2816,115 +2550,60 @@ struct bt_field_type *bt_field_type_array_create(
                goto error;
        }
 
-       if (length == 0) {
-               BT_LOGW_STR("Invalid parameter: length is zero.");
-               goto error;
-       }
-
-       array = g_new0(struct bt_field_type_common_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),
-               (void *) element_ft, length,
-               bt_field_type_common_array_destroy_recursive,
-               &bt_field_type_array_methods);
-       BT_LOGD("Created array field type object: addr=%p, "
-               "element-ft-addr=%p, length=%u",
-               array, element_ft, length);
-       goto end;
-
-error:
-       BT_PUT(array);
-
-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_common_array *array_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_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 (length == 0) {
+               BT_LOGW_STR("Invalid parameter: length is zero.");
+               goto error;
        }
 
-       if (array_ft->element_ft) {
-               BT_PUT(array_ft->element_ft);
+       array = g_new0(struct bt_field_type_array, 1);
+       if (!array) {
+               BT_LOGE_STR("Failed to allocate one array field type.");
+               goto error;
        }
 
-       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);
+       bt_field_type_array_initialize((void *) array,
+               (void *) element_ft, length,
+               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",
+               array, element_ft, length);
+       goto end;
+
+error:
+       BT_PUT(array);
 
 end:
-       return ret;
+       return (void *) array;
 }
 
-BT_HIDDEN
-int64_t bt_field_type_common_array_get_length(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");
-       return (int64_t) array_ft->length;
+       BT_ASSERT(array_ft && array_ft->element_ft);
+       return array_ft->element_ft;
 }
 
 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_array *array_ft = (void *) ft;
+
+       BT_ASSERT_PRE_NON_NULL(ft, "Field type");
+       BT_ASSERT_PRE_FT_HAS_ID(ft, BT_FIELD_TYPE_ID_ARRAY,
+               "Field type");
+       return (int64_t) array_ft->length;
 }
 
 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);
@@ -2940,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\"",
@@ -2962,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 *bt_field_type_sequence_borrow_element_field_type(
+               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;
 
        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->element_ft;
 }
 
-struct bt_field_type *bt_field_type_sequence_borrow_element_field_type(
+const char *bt_field_type_sequence_get_length_field_name(
                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;
 }
 
-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 *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.");
 
@@ -3053,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.");
@@ -3115,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;
@@ -3134,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;
@@ -3196,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;
@@ -3235,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);
@@ -3270,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;
 
@@ -3287,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;
        }
@@ -3325,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;
@@ -3371,27 +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);
-}
-
 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;
@@ -3401,91 +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 bt_field_type_common_variant_choice *choice;
-       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->choice_name_to_index,
-                       GUINT_TO_POINTER(field_name_quark), NULL, &index)) {
-               goto end;
-       }
-
-       choice = BT_FIELD_TYPE_COMMON_VARIANT_CHOICE_AT_INDEX(var_ft,
-               (size_t) index);
-       field_type = choice->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 bt_field_type_common_variant_choice *choice;
-       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->choice_name_to_index,
-               GUINT_TO_POINTER(field_name_quark), NULL, &index)) {
-               goto end;
-       }
-
-       choice = BT_FIELD_TYPE_COMMON_VARIANT_CHOICE_AT_INDEX(var_ft,
-               (size_t) index);
-       field_type = choice->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);
@@ -3501,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);
@@ -3545,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) {
@@ -3584,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.");
@@ -3614,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.");
@@ -3645,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.");
@@ -3681,53 +3166,53 @@ 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);
 }
 
-BT_HIDDEN
-void bt_field_type_common_structure_freeze_recursive(
-               struct bt_field_type_common *ft)
+static
+void bt_field_type_structure_freeze_recursive(
+               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;
        uint64_t i;
 
        /* 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);
+       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_common_structure_field *field =
-                       BT_FIELD_TYPE_COMMON_STRUCTURE_FIELD_AT_INDEX(ft, 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_common_freeze(field->type);
+               bt_field_type_freeze(field->type);
        }
 }
 
 BT_HIDDEN
-int bt_field_type_common_variant_update_choices(struct bt_field_type_common *ft)
+int bt_field_type_variant_update_choices(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;
        int ret = 0;
        bool is_signed;
@@ -3740,12 +3225,12 @@ int bt_field_type_common_variant_update_choices(struct bt_field_type_common *ft)
        is_signed = !!var_ft->tag_ft->container_ft->is_signed;
 
        for (i = 0; i < var_ft->choices->len; i++) {
-               struct bt_field_type_common_variant_choice *choice =
-                       BT_FIELD_TYPE_COMMON_VARIANT_CHOICE_AT_INDEX(ft, 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_common_enumeration_find_mappings_by_name(
-                               BT_TO_COMMON(var_ft->tag_ft), choice_name);
+                       bt_field_type_enumeration_find_mappings_by_name(
+                               (void *) var_ft->tag_ft, choice_name);
 
                if (!iter) {
                        ret = -1;
@@ -3756,7 +3241,7 @@ int bt_field_type_common_variant_update_choices(struct bt_field_type_common *ft)
                g_array_set_size(choice->ranges, 0);
 
                while (bt_field_type_enumeration_mapping_iterator_next(iter) == 0) {
-                       struct bt_field_type_common_variant_choice_range range;
+                       struct bt_field_type_variant_choice_range range;
 
                        if (is_signed) {
                                ret = bt_field_type_enumeration_mapping_iterator_signed_get(
@@ -3781,149 +3266,149 @@ 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);
+       bt_field_type_generic_freeze(ft);
 
        for (i = 0; i < var_ft->choices->len; i++) {
-               struct bt_field_type_common_variant_choice *choice =
-                       BT_FIELD_TYPE_COMMON_VARIANT_CHOICE_AT_INDEX(ft, 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_common_freeze(choice->type);
+               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 bt_field_type_common_structure_field *field =
-                       BT_FIELD_TYPE_COMMON_STRUCTURE_FIELD_AT_INDEX(
+               struct bt_field_type_structure_field *field =
+                       BT_FIELD_TYPE_STRUCTURE_FIELD_AT_INDEX(
                                struct_ft, i);
-               struct bt_field_type_common *field_type = field->type;
+               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->choices->len; i++) {
-               struct bt_field_type_common_variant_choice *choice =
-                       BT_FIELD_TYPE_COMMON_VARIANT_CHOICE_AT_INDEX(
+               struct bt_field_type_variant_choice *choice =
+                       BT_FIELD_TYPE_VARIANT_CHOICE_AT_INDEX(
                                var_ft, i);
-               struct bt_field_type_common *field_type = choice->type;
+               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) {
@@ -3998,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) {
@@ -4085,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",
@@ -4139,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) {
@@ -4165,8 +3645,8 @@ end:
 
 static
 int compare_structure_variant_members(
-               struct bt_field_type_common *member_a_ft,
-               struct bt_field_type_common *member_b_ft,
+               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;
@@ -4181,7 +3661,7 @@ int compare_structure_variant_members(
        }
 
        /* Type */
-       ret = bt_field_type_common_compare(member_a_ft, member_b_ft);
+       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",
@@ -4193,25 +3673,23 @@ 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;
        }
 
@@ -4224,11 +3702,11 @@ int bt_field_type_common_structure_compare_recursive(
        }
 
        for (i = 0; i < struct_ft_a->fields->len; ++i) {
-               struct bt_field_type_common_structure_field *field_a =
-                       BT_FIELD_TYPE_COMMON_STRUCTURE_FIELD_AT_INDEX(
+               struct bt_field_type_structure_field *field_a =
+                       BT_FIELD_TYPE_STRUCTURE_FIELD_AT_INDEX(
                                struct_ft_a, i);
-               struct bt_field_type_common_structure_field *field_b =
-                       BT_FIELD_TYPE_COMMON_STRUCTURE_FIELD_AT_INDEX(
+               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,
@@ -4247,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)) {
@@ -4266,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",
@@ -4286,11 +3764,11 @@ int bt_field_type_common_variant_compare_recursive(
        }
 
        for (i = 0; i < var_ft_a->choices->len; ++i) {
-               struct bt_field_type_common_variant_choice *choice_a =
-                       BT_FIELD_TYPE_COMMON_VARIANT_CHOICE_AT_INDEX(
+               struct bt_field_type_variant_choice *choice_a =
+                       BT_FIELD_TYPE_VARIANT_CHOICE_AT_INDEX(
                                var_ft_a, i);
-               struct bt_field_type_common_variant_choice *choice_b =
-                       BT_FIELD_TYPE_COMMON_VARIANT_CHOICE_AT_INDEX(
+               struct bt_field_type_variant_choice *choice_b =
+                       BT_FIELD_TYPE_VARIANT_CHOICE_AT_INDEX(
                                var_ft_b, i);
 
                ret = compare_structure_variant_members(choice_a->type,
@@ -4309,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) {
@@ -4327,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: "
@@ -4339,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,
@@ -4360,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: "
@@ -4373,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;
 
@@ -4427,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:
@@ -4463,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;
@@ -4481,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;
@@ -4491,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;
@@ -4506,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:
@@ -4527,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;
@@ -4581,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;
@@ -4618,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:
@@ -4639,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 "
@@ -4672,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 "
@@ -4707,8 +4164,8 @@ 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 integer field type's: addr=%p", ft);
        copy_ft = (void *) bt_field_type_integer_create(int_ft->size);
@@ -4735,16 +4192,16 @@ 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 enumeration field type's: addr=%p", ft);
 
        /* Copy the source enumeration's container */
        BT_LOGD_STR("Copying 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)));
+       container_copy_ft =
+               (void *) bt_field_type_copy((void *) enum_ft->container_ft);
        if (!container_copy_ft) {
                BT_LOGE_STR("Cannot copy enumeration field type's container field type.");
                goto end;
@@ -4790,8 +4247,8 @@ 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 floating point number field type's: addr=%p", ft);
        copy_ft = (void *) bt_field_type_floating_point_create();
@@ -4817,8 +4274,8 @@ 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 structure field type's: addr=%p", ft);
        copy_ft = (void *) bt_field_type_structure_create();
@@ -4837,12 +4294,12 @@ struct bt_field_type *bt_field_type_structure_copy_recursive(
        g_array_set_size(copy_ft->fields, struct_ft->fields->len);
 
        for (i = 0; i < struct_ft->fields->len; i++) {
-               struct bt_field_type_common_structure_field *entry, *copy_entry;
-               struct bt_field_type_common *field_ft_copy;
+               struct bt_field_type_structure_field *entry, *copy_entry;
+               struct bt_field_type *field_ft_copy;
 
-               entry = BT_FIELD_TYPE_COMMON_STRUCTURE_FIELD_AT_INDEX(
+               entry = BT_FIELD_TYPE_STRUCTURE_FIELD_AT_INDEX(
                        struct_ft, i);
-               copy_entry = BT_FIELD_TYPE_COMMON_STRUCTURE_FIELD_AT_INDEX(
+               copy_entry = BT_FIELD_TYPE_STRUCTURE_FIELD_AT_INDEX(
                        copy_ft, i);
                BT_LOGD("Copying structure field type's field: "
                        "index=%" PRId64 ", "
@@ -4881,15 +4338,14 @@ 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 variant field type's: addr=%p", ft);
        if (var_ft->tag_ft) {
                BT_LOGD_STR("Copying variant field type's tag field type.");
-               tag_ft_copy = bt_field_type_common_copy(
-                       BT_TO_COMMON(var_ft->tag_ft));
+               tag_ft_copy = bt_field_type_copy((void *) var_ft->tag_ft);
                if (!tag_ft_copy) {
                        BT_LOGE_STR("Cannot copy variant field type's tag field type.");
                        goto end;
@@ -4914,12 +4370,12 @@ struct bt_field_type *bt_field_type_variant_copy_recursive(
        g_array_set_size(copy_ft->choices, var_ft->choices->len);
 
        for (i = 0; i < var_ft->choices->len; i++) {
-               struct bt_field_type_common_variant_choice *entry, *copy_entry;
-               struct bt_field_type_common *field_ft_copy;
+               struct bt_field_type_variant_choice *entry, *copy_entry;
+               struct bt_field_type *field_ft_copy;
                uint64_t range_i;
 
-               entry = BT_FIELD_TYPE_COMMON_VARIANT_CHOICE_AT_INDEX(var_ft, i);
-               copy_entry = BT_FIELD_TYPE_COMMON_VARIANT_CHOICE_AT_INDEX(
+               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 ", "
@@ -4942,7 +4398,7 @@ struct bt_field_type *bt_field_type_variant_copy_recursive(
 
                /* Copy ranges */
                copy_entry->ranges = g_array_new(FALSE, TRUE,
-                       sizeof(struct bt_field_type_common_variant_choice_range));
+                       sizeof(struct bt_field_type_variant_choice_range));
                BT_ASSERT(copy_entry->ranges);
                g_array_set_size(copy_entry->ranges, entry->ranges->len);
 
@@ -4979,13 +4435,13 @@ 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 array field type's: addr=%p", ft);
        BT_LOGD_STR("Copying array field type's element field type.");
-       container_ft_copy = bt_field_type_common_copy(array_ft->element_ft);
+       container_ft_copy = bt_field_type_copy(array_ft->element_ft);
        if (!container_ft_copy) {
                BT_LOGE_STR("Cannot copy array field type's element field type.");
                goto end;
@@ -5010,13 +4466,13 @@ 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 sequence field type's: addr=%p", ft);
        BT_LOGD_STR("Copying sequence field type's element field type.");
-       container_ft_copy = bt_field_type_common_copy(seq_ft->element_ft);
+       container_ft_copy = bt_field_type_copy(seq_ft->element_ft);
        if (!container_ft_copy) {
                BT_LOGE_STR("Cannot copy sequence field type's element field type.");
                goto end;
@@ -5056,8 +4512,8 @@ 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 string field type's: addr=%p", ft);
        copy_ft = (void *) bt_field_type_string_create();
index d235f1b45f8aeb84d10b14f9deb260b630e783e0..3ebe6ebf18b25805bf9bf23393e63e599b8c5f00 100644 (file)
@@ -30,6 +30,7 @@
 #include <babeltrace/lib-logging-internal.h>
 
 #include <babeltrace/assert-pre-internal.h>
+#include <babeltrace/ctf-ir/fields.h>
 #include <babeltrace/ctf-ir/fields-internal.h>
 #include <babeltrace/ctf-ir/field-types-internal.h>
 #include <babeltrace/object-internal.h>
                _name " is not an integer or an enumeration field: "    \
                "%!+f", (_field))
 
-static struct bt_field_common_methods bt_field_integer_methods = {
-       .set_is_frozen = bt_field_common_generic_set_is_frozen,
-       .validate = bt_field_common_generic_validate,
-       .copy = NULL,
-       .is_set = bt_field_common_generic_is_set,
-       .reset = bt_field_common_generic_reset,
+static
+int bt_field_generic_validate(struct bt_field *field);
+
+static
+int bt_field_structure_validate_recursive(struct bt_field *field);
+
+static
+int bt_field_variant_validate_recursive(struct bt_field *field);
+
+static
+int bt_field_array_validate_recursive(struct bt_field *field);
+
+static
+int bt_field_sequence_validate_recursive(struct bt_field *field);
+
+static
+void bt_field_generic_reset(struct bt_field *field);
+
+static
+void bt_field_structure_reset_recursive(struct bt_field *field);
+
+static
+void bt_field_variant_reset_recursive(struct bt_field *field);
+
+static
+void bt_field_array_reset_recursive(struct bt_field *field);
+
+static
+void bt_field_sequence_reset_recursive(struct bt_field *field);
+
+static
+void bt_field_generic_set_is_frozen(struct bt_field *field,
+               bool is_frozen);
+
+static
+void bt_field_structure_set_is_frozen_recursive(
+               struct bt_field *field, bool is_frozen);
+
+static
+void bt_field_variant_set_is_frozen_recursive(
+               struct bt_field *field, bool is_frozen);
+
+static
+void bt_field_array_set_is_frozen_recursive(
+               struct bt_field *field, bool is_frozen);
+
+static
+void bt_field_sequence_set_is_frozen_recursive(
+               struct bt_field *field, bool is_frozen);
+
+static
+bt_bool bt_field_generic_is_set(struct bt_field *field);
+
+static
+bt_bool bt_field_structure_is_set_recursive(
+               struct bt_field *field);
+
+static
+bt_bool bt_field_variant_is_set_recursive(struct bt_field *field);
+
+static
+bt_bool bt_field_array_is_set_recursive(struct bt_field *field);
+
+static
+bt_bool bt_field_sequence_is_set_recursive(struct bt_field *field);
+
+static struct bt_field_methods bt_field_integer_methods = {
+       .set_is_frozen = bt_field_generic_set_is_frozen,
+       .validate = bt_field_generic_validate,
+       .is_set = bt_field_generic_is_set,
+       .reset = bt_field_generic_reset,
 };
 
-static struct bt_field_common_methods bt_field_floating_point_methods = {
-       .set_is_frozen = bt_field_common_generic_set_is_frozen,
-       .validate = bt_field_common_generic_validate,
-       .copy = NULL,
-       .is_set = bt_field_common_generic_is_set,
-       .reset = bt_field_common_generic_reset,
+static struct bt_field_methods bt_field_floating_point_methods = {
+       .set_is_frozen = bt_field_generic_set_is_frozen,
+       .validate = bt_field_generic_validate,
+       .is_set = bt_field_generic_is_set,
+       .reset = bt_field_generic_reset,
 };
 
-static struct bt_field_common_methods bt_field_enumeration_methods = {
-       .set_is_frozen = bt_field_common_generic_set_is_frozen,
-       .validate = bt_field_common_generic_validate,
-       .copy = NULL,
-       .is_set = bt_field_common_generic_is_set,
-       .reset = bt_field_common_generic_reset,
+static struct bt_field_methods bt_field_enumeration_methods = {
+       .set_is_frozen = bt_field_generic_set_is_frozen,
+       .validate = bt_field_generic_validate,
+       .is_set = bt_field_generic_is_set,
+       .reset = bt_field_generic_reset,
 };
 
-static struct bt_field_common_methods bt_field_string_methods = {
-       .set_is_frozen = bt_field_common_generic_set_is_frozen,
-       .validate = bt_field_common_generic_validate,
-       .copy = NULL,
-       .is_set = bt_field_common_generic_is_set,
-       .reset = bt_field_common_generic_reset,
+static struct bt_field_methods bt_field_string_methods = {
+       .set_is_frozen = bt_field_generic_set_is_frozen,
+       .validate = bt_field_generic_validate,
+       .is_set = bt_field_generic_is_set,
+       .reset = bt_field_generic_reset,
 };
 
-static struct bt_field_common_methods bt_field_structure_methods = {
-       .set_is_frozen = bt_field_common_structure_set_is_frozen_recursive,
-       .validate = bt_field_common_structure_validate_recursive,
-       .copy = NULL,
-       .is_set = bt_field_common_structure_is_set_recursive,
-       .reset = bt_field_common_structure_reset_recursive,
+static struct bt_field_methods bt_field_structure_methods = {
+       .set_is_frozen = bt_field_structure_set_is_frozen_recursive,
+       .validate = bt_field_structure_validate_recursive,
+       .is_set = bt_field_structure_is_set_recursive,
+       .reset = bt_field_structure_reset_recursive,
 };
 
-static struct bt_field_common_methods bt_field_sequence_methods = {
-       .set_is_frozen = bt_field_common_sequence_set_is_frozen_recursive,
-       .validate = bt_field_common_sequence_validate_recursive,
-       .copy = NULL,
-       .is_set = bt_field_common_sequence_is_set_recursive,
-       .reset = bt_field_common_sequence_reset_recursive,
+static struct bt_field_methods bt_field_sequence_methods = {
+       .set_is_frozen = bt_field_sequence_set_is_frozen_recursive,
+       .validate = bt_field_sequence_validate_recursive,
+       .is_set = bt_field_sequence_is_set_recursive,
+       .reset = bt_field_sequence_reset_recursive,
 };
 
-static struct bt_field_common_methods bt_field_array_methods = {
-       .set_is_frozen = bt_field_common_array_set_is_frozen_recursive,
-       .validate = bt_field_common_array_validate_recursive,
-       .copy = NULL,
-       .is_set = bt_field_common_array_is_set_recursive,
-       .reset = bt_field_common_array_reset_recursive,
+static struct bt_field_methods bt_field_array_methods = {
+       .set_is_frozen = bt_field_array_set_is_frozen_recursive,
+       .validate = bt_field_array_validate_recursive,
+       .is_set = bt_field_array_is_set_recursive,
+       .reset = bt_field_array_reset_recursive,
 };
 
-static struct bt_field_common_methods bt_field_variant_methods = {
-       .set_is_frozen = bt_field_common_variant_set_is_frozen_recursive,
-       .validate = bt_field_common_variant_validate_recursive,
-       .copy = NULL,
-       .is_set = bt_field_common_variant_is_set_recursive,
-       .reset = bt_field_common_variant_reset_recursive,
+static struct bt_field_methods bt_field_variant_methods = {
+       .set_is_frozen = bt_field_variant_set_is_frozen_recursive,
+       .validate = bt_field_variant_validate_recursive,
+       .is_set = bt_field_variant_is_set_recursive,
+       .reset = bt_field_variant_reset_recursive,
 };
 
 static
@@ -182,6 +241,41 @@ void (* const field_destroy_funcs[])(struct bt_field *) = {
        [BT_FIELD_TYPE_ID_STRING] =     bt_field_string_destroy,
 };
 
+BT_ASSERT_PRE_FUNC
+static inline bool value_is_in_range_signed(unsigned int size, int64_t value)
+{
+       bool ret = true;
+       int64_t min_value, max_value;
+
+       min_value = -(1ULL << (size - 1));
+       max_value = (1ULL << (size - 1)) - 1;
+       if (value < min_value || value > max_value) {
+               BT_LOGF("Value is out of bounds: value=%" PRId64 ", "
+                       "min-value=%" PRId64 ", max-value=%" PRId64,
+                       value, min_value, max_value);
+               ret = false;
+       }
+
+       return ret;
+}
+
+BT_ASSERT_PRE_FUNC
+static inline bool value_is_in_range_unsigned(unsigned int size, uint64_t value)
+{
+       bool ret = true;
+       int64_t max_value;
+
+       max_value = (size == 64) ? UINT64_MAX : ((uint64_t) 1 << size) - 1;
+       if (value > max_value) {
+               BT_LOGF("Value is out of bounds: value=%" PRIu64 ", "
+                       "max-value=%" PRIu64,
+                       value, max_value);
+               ret = false;
+       }
+
+       return ret;
+}
+
 BT_HIDDEN
 struct bt_field *bt_field_create_recursive(struct bt_field_type *type)
 {
@@ -189,8 +283,8 @@ struct bt_field *bt_field_create_recursive(struct bt_field_type *type)
        enum bt_field_type_id type_id;
 
        BT_ASSERT_PRE_NON_NULL(type, "Field type");
-       BT_ASSERT(field_type_common_has_known_id((void *) type));
-       BT_ASSERT_PRE(bt_field_type_common_validate((void *) type) == 0,
+       BT_ASSERT(bt_field_type_has_known_id((void *) type));
+       BT_ASSERT_PRE(bt_field_type_validate((void *) type) == 0,
                "Field type is invalid: %!+F", type);
        type_id = bt_field_type_get_type_id(type);
        field = field_create_funcs[type_id](type);
@@ -206,118 +300,280 @@ end:
 
 struct bt_field_type *bt_field_borrow_type(struct bt_field *field)
 {
-       return (void *) bt_field_common_borrow_type((void *) field);
+       struct bt_field_type *ret = NULL;
+
+       BT_ASSERT_PRE_NON_NULL(field, "Field");
+       ret = field->type;
+       return ret;
 }
 
 enum bt_field_type_id bt_field_get_type_id(struct bt_field *field)
 {
-       struct bt_field_common *field_common = (void *) field;
-
        BT_ASSERT_PRE_NON_NULL(field, "Field");
-       return field_common->type->id;
+       return field->type->id;
 }
 
 int64_t bt_field_sequence_get_length(struct bt_field *field)
 {
-       return bt_field_common_sequence_get_length((void *) field);
+       struct bt_field_sequence *sequence = (void *) field;
+
+       BT_ASSERT_PRE_NON_NULL(field, "Sequence field");
+       BT_ASSERT_PRE_FIELD_HAS_TYPE_ID(field, BT_FIELD_TYPE_ID_SEQUENCE,
+               "Field");
+       return (int64_t) sequence->length;
 }
 
 int bt_field_sequence_set_length(struct bt_field *field, uint64_t length)
 {
-       return bt_field_common_sequence_set_length((void *) field,
-               length, (bt_field_common_create_func) bt_field_create_recursive);
+       int ret = 0;
+       struct bt_field_sequence *sequence = (void *) field;
+
+       BT_ASSERT_PRE_NON_NULL(field, "Sequence field");
+       BT_ASSERT_PRE(((int64_t) length) >= 0,
+               "Invalid sequence length (too large): length=%" PRId64,
+               length);
+       BT_ASSERT_PRE_FIELD_HOT(field, "Sequence field");
+
+       if (unlikely(length > sequence->elements->len)) {
+               /* Make more room */
+               struct bt_field_type_sequence *sequence_ft;
+               uint64_t cur_len = sequence->elements->len;
+               uint64_t i;
+
+               g_ptr_array_set_size(sequence->elements, length);
+               sequence_ft = (void *) sequence->common.type;
+
+               for (i = cur_len; i < sequence->elements->len; i++) {
+                       struct bt_field *elem_field =
+                               bt_field_create_recursive(
+                                       sequence_ft->element_ft);
+
+                       if (!elem_field) {
+                               ret = -1;
+                               goto end;
+                       }
+
+                       BT_ASSERT(!sequence->elements->pdata[i]);
+                       sequence->elements->pdata[i] = elem_field;
+               }
+       }
+
+       sequence->length = length;
+
+end:
+       return ret;
 }
 
 struct bt_field *bt_field_structure_borrow_field_by_index(
                struct bt_field *field, uint64_t index)
 {
-       return (void *) bt_field_common_structure_borrow_field_by_index(
-               (void *) field, index);
+       struct bt_field_structure *structure = (void *) field;
+
+       BT_ASSERT_PRE_NON_NULL(field, "Structure field");
+       BT_ASSERT_PRE_FIELD_HAS_TYPE_ID(field,
+               BT_FIELD_TYPE_ID_STRUCT, "Field");
+       BT_ASSERT_PRE(index < structure->fields->len,
+               "Index is out of bound: %![struct-field-]+f, "
+               "index=%" PRIu64 ", count=%u", field, index,
+               structure->fields->len);
+       return structure->fields->pdata[index];
 }
 
 struct bt_field *bt_field_structure_borrow_field_by_name(
                struct bt_field *field, const char *name)
 {
-       return (void *) bt_field_common_structure_borrow_field_by_name(
-               (void *) field, name);
+       struct bt_field *ret = NULL;
+       GQuark field_quark;
+       struct bt_field_type_structure *structure_ft;
+       struct bt_field_structure *structure = (void *) field;
+       size_t index;
+       GHashTable *field_name_to_index;
+
+       BT_ASSERT_PRE_NON_NULL(field, "Structure field");
+       BT_ASSERT_PRE_NON_NULL(name, "Field name");
+       BT_ASSERT_PRE_FIELD_HAS_TYPE_ID(field,
+               BT_FIELD_TYPE_ID_STRUCT, "Field");
+       structure_ft = (void *) field->type;
+       field_name_to_index = structure_ft->field_name_to_index;
+       field_quark = g_quark_from_string(name);
+       if (!g_hash_table_lookup_extended(field_name_to_index,
+                       GUINT_TO_POINTER(field_quark),
+                       NULL, (gpointer *) &index)) {
+               BT_LOGV("Invalid parameter: no such field in structure field's type: "
+                       "struct-field-addr=%p, struct-ft-addr=%p, name=\"%s\"",
+                       field, field->type, name);
+               goto error;
+       }
+
+       ret = structure->fields->pdata[index];
+       BT_ASSERT(ret);
+
+error:
+       return ret;
 }
 
 struct bt_field *bt_field_array_borrow_field(
                struct bt_field *field, uint64_t index)
 {
-       return (void *) bt_field_common_array_borrow_field((void *) field,
-               index);
+       struct bt_field_array *array = (void *) field;
+
+       BT_ASSERT_PRE_NON_NULL(field, "Array field");
+       BT_ASSERT_PRE_FIELD_HAS_TYPE_ID(field, BT_FIELD_TYPE_ID_ARRAY,
+               "Field");
+       BT_ASSERT_PRE(index < array->elements->len,
+               "Index is out of bound: %![array-field-]+f, "
+               "index=%" PRIu64 ", count=%u", field,
+               index, array->elements->len);
+       return array->elements->pdata[(size_t) index];
 }
 
 struct bt_field *bt_field_sequence_borrow_field(
                struct bt_field *field, uint64_t index)
 {
-       return (void *) bt_field_common_sequence_borrow_field((void *) field,
-               index);
+       struct bt_field_sequence *sequence = (void *) field;
+
+       BT_ASSERT_PRE_NON_NULL(field, "Sequence field");
+       BT_ASSERT_PRE_FIELD_HAS_TYPE_ID(field, BT_FIELD_TYPE_ID_SEQUENCE,
+               "Field");
+       BT_ASSERT_PRE(index < sequence->length,
+               "Index is out of bound: %![seq-field-]+f, "
+               "index=%" PRIu64 ", count=%u", field, index,
+               sequence->elements->len);
+       return sequence->elements->pdata[(size_t) index];
 }
 
 struct bt_field *bt_field_variant_borrow_current_field(
-               struct bt_field *variant_field)
+               struct bt_field *field)
 {
-       return (void *) bt_field_common_variant_borrow_current_field(
-               (void *) variant_field);
+       struct bt_field_variant *variant = (void *) field;
+
+       BT_ASSERT_PRE_NON_NULL(field, "Variant field");
+       BT_ASSERT_PRE_FIELD_HAS_TYPE_ID(field,
+               BT_FIELD_TYPE_ID_VARIANT, "Field");
+       BT_ASSERT_PRE(variant->current_field,
+               "Variant field has no current field: %!+f", field);
+       return variant->current_field;
+}
+
+static inline
+int bt_field_variant_set_tag(struct bt_field *field,
+               uint64_t tag_uval, bool is_signed)
+{
+       int ret = 0;
+       int64_t choice_index;
+       struct bt_field_variant *variant = (void *) field;
+
+       BT_ASSERT_PRE_NON_NULL(field, "Variant field");
+       BT_ASSERT_PRE_FIELD_HAS_TYPE_ID(field,
+               BT_FIELD_TYPE_ID_VARIANT, "Field");
+
+       /* Find matching index in variant field's type */
+       choice_index = bt_field_type_variant_find_choice_index(
+               field->type, tag_uval, is_signed);
+       if (choice_index < 0) {
+               ret = -1;
+               goto end;
+       }
+
+       /* Select corresponding field */
+       BT_ASSERT(choice_index < variant->fields->len);
+       variant->current_field = variant->fields->pdata[choice_index];
+       variant->tag_value.u = tag_uval;
+
+end:
+       return ret;
 }
 
 int bt_field_variant_set_tag_signed(struct bt_field *variant_field,
                int64_t tag)
 {
-       return bt_field_variant_common_set_tag((void *) variant_field,
+       return bt_field_variant_set_tag((void *) variant_field,
                (uint64_t) tag, true);
 }
 
 int bt_field_variant_set_tag_unsigned(struct bt_field *variant_field,
                uint64_t tag)
 {
-       return bt_field_variant_common_set_tag((void *) variant_field,
+       return bt_field_variant_set_tag((void *) variant_field,
                (uint64_t) tag, false);
 }
 
-int bt_field_variant_get_tag_signed(struct bt_field *variant_field,
+int bt_field_variant_get_tag_signed(struct bt_field *field,
                int64_t *tag)
 {
-       return bt_field_common_variant_get_tag_signed((void *) variant_field, tag);
+       struct bt_field_variant *variant = (void *) field;
+
+       BT_ASSERT_PRE_NON_NULL(field, "Variant field");
+       BT_ASSERT_PRE_FIELD_HAS_TYPE_ID(field,
+               BT_FIELD_TYPE_ID_VARIANT, "Field");
+       BT_ASSERT_PRE(variant->current_field,
+               "Variant field has no current field: %!+f", field);
+       *tag = variant->tag_value.i;
+       return 0;
 }
 
-int bt_field_variant_get_tag_unsigned(struct bt_field *variant_field,
+int bt_field_variant_get_tag_unsigned(struct bt_field *field,
                uint64_t *tag)
 {
-       return bt_field_common_variant_get_tag_unsigned((void *) variant_field, tag);
+       struct bt_field_variant *variant = (void *) field;
+
+       BT_ASSERT_PRE_NON_NULL(field, "Variant field");
+       BT_ASSERT_PRE_FIELD_HAS_TYPE_ID(field,
+               BT_FIELD_TYPE_ID_VARIANT, "Field");
+       BT_ASSERT_PRE(variant->current_field,
+               "Variant field has no current field: %!+f", field);
+       *tag = variant->tag_value.u;
+       return 0;
 }
 
 struct bt_field_type_enumeration_mapping_iterator *
 bt_field_enumeration_get_mappings(struct bt_field *field)
 {
        struct bt_field_enumeration *enum_field = (void *) field;
+       struct bt_field_type_enumeration *enum_type = NULL;
+       struct bt_field_type_integer *integer_type = NULL;
+       struct bt_field_type_enumeration_mapping_iterator *iter = NULL;
 
+       BT_ASSERT(field);
+       BT_ASSERT(field->type->id == BT_FIELD_TYPE_ID_ENUM);
+       BT_ASSERT(field->payload_set);
        BT_ASSERT_PRE_NON_NULL(field, "Enumeration field");
-       BT_ASSERT_PRE_FIELD_COMMON_HAS_TYPE_ID((struct bt_field_common *) field,
+       BT_ASSERT_PRE_FIELD_HAS_TYPE_ID((struct bt_field *) field,
                BT_FIELD_TYPE_ID_ENUM, "Field");
-       BT_ASSERT_PRE_FIELD_COMMON_IS_SET((struct bt_field_common *) field,
+       BT_ASSERT_PRE_FIELD_IS_SET((struct bt_field *) field,
                "Enumeration field");
-       return bt_field_common_enumeration_get_mappings((void *) field,
-               (bt_field_common_create_func) bt_field_create_recursive,
-               enum_field->common.payload.unsignd);
+       enum_type = (void *) field->type;
+       integer_type = enum_type->container_ft;
+
+       if (!integer_type->is_signed) {
+               iter = bt_field_type_enumeration_unsigned_find_mappings_by_value(
+                               field->type,
+                               enum_field->common.payload.unsignd);
+       } else {
+               iter = bt_field_type_enumeration_signed_find_mappings_by_value(
+                               field->type,
+                               enum_field->common.payload.signd);
+       }
+
+       return iter;
 }
 
 BT_ASSERT_PRE_FUNC
 static inline
-struct bt_field_type_common_integer *get_int_enum_int_ft(
+struct bt_field_type_integer *get_int_enum_int_ft(
                struct bt_field *field)
 {
-       struct bt_field_common_integer *int_field = (void *) field;
-       struct bt_field_type_common_integer *int_ft = NULL;
+       struct bt_field_integer *int_field = (void *) field;
+       struct bt_field_type_integer *int_ft = NULL;
 
        if (int_field->common.type->id == BT_FIELD_TYPE_ID_INTEGER) {
-               int_ft = BT_FROM_COMMON(int_field->common.type);
+               int_ft = (void *) int_field->common.type;
        } else if (int_field->common.type->id == BT_FIELD_TYPE_ID_ENUM) {
-               struct bt_field_type_common_enumeration *enum_ft =
-                       BT_FROM_COMMON(int_field->common.type);
+               struct bt_field_type_enumeration *enum_ft =
+                       (void *) int_field->common.type;
                int_ft = enum_ft->container_ft;
+       } else {
+               abort();
        }
 
        BT_ASSERT(int_ft);
@@ -326,15 +582,15 @@ struct bt_field_type_common_integer *get_int_enum_int_ft(
 
 int bt_field_integer_signed_get_value(struct bt_field *field, int64_t *value)
 {
-       struct bt_field_common_integer *integer = (void *) field;
+       struct bt_field_integer *integer = (void *) field;
 
        BT_ASSERT_PRE_NON_NULL(field, "Integer/enumeration field");
        BT_ASSERT_PRE_NON_NULL(value, "Value");
-       BT_ASSERT_PRE_FIELD_COMMON_IS_SET(BT_TO_COMMON(integer),
+       BT_ASSERT_PRE_FIELD_IS_SET(field,
                "Integer/enumeration field");
-       BT_ASSERT_PRE_FIELD_IS_INT_OR_ENUM(BT_TO_COMMON(integer), "Field");
-       BT_ASSERT_PRE(bt_field_type_common_integer_is_signed(
-               BT_TO_COMMON(get_int_enum_int_ft(field))),
+       BT_ASSERT_PRE_FIELD_IS_INT_OR_ENUM(field, "Field");
+       BT_ASSERT_PRE(bt_field_type_integer_is_signed(
+               (void *) get_int_enum_int_ft(field)),
                "Field's type is unsigned: %!+f", field);
        *value = integer->payload.signd;
        return 0;
@@ -343,13 +599,13 @@ int bt_field_integer_signed_get_value(struct bt_field *field, int64_t *value)
 int bt_field_integer_signed_set_value(struct bt_field *field, int64_t value)
 {
        int ret = 0;
-       struct bt_field_common_integer *integer = (void *) field;
+       struct bt_field_integer *integer = (void *) field;
 
        BT_ASSERT_PRE_NON_NULL(field, "Integer field");
-       BT_ASSERT_PRE_FIELD_COMMON_HOT(BT_TO_COMMON(integer), "Integer field");
-       BT_ASSERT_PRE_FIELD_IS_INT_OR_ENUM(BT_TO_COMMON(integer), "Field");
-       BT_ASSERT_PRE(bt_field_type_common_integer_is_signed(
-               BT_FROM_COMMON(get_int_enum_int_ft(field))),
+       BT_ASSERT_PRE_FIELD_HOT(field, "Integer field");
+       BT_ASSERT_PRE_FIELD_IS_INT_OR_ENUM(field, "Field");
+       BT_ASSERT_PRE(bt_field_type_integer_is_signed(
+               (void *) get_int_enum_int_ft(field)),
                "Field's type is unsigned: %!+f", field);
        BT_ASSERT_PRE(value_is_in_range_signed(
                get_int_enum_int_ft(field)->size, value),
@@ -362,14 +618,14 @@ int bt_field_integer_signed_set_value(struct bt_field *field, int64_t value)
 
 int bt_field_integer_unsigned_get_value(struct bt_field *field, uint64_t *value)
 {
-       struct bt_field_common_integer *integer = (void *) field;
+       struct bt_field_integer *integer = (void *) field;
 
        BT_ASSERT_PRE_NON_NULL(field, "Integer field");
        BT_ASSERT_PRE_NON_NULL(value, "Value");
-       BT_ASSERT_PRE_FIELD_COMMON_IS_SET(BT_TO_COMMON(integer), "Integer field");
-       BT_ASSERT_PRE_FIELD_IS_INT_OR_ENUM(BT_TO_COMMON(integer), "Field");
-       BT_ASSERT_PRE(!bt_field_type_common_integer_is_signed(
-               BT_FROM_COMMON(get_int_enum_int_ft(field))),
+       BT_ASSERT_PRE_FIELD_IS_SET(field, "Integer field");
+       BT_ASSERT_PRE_FIELD_IS_INT_OR_ENUM(field, "Field");
+       BT_ASSERT_PRE(!bt_field_type_integer_is_signed(
+               (void *) get_int_enum_int_ft(field)),
                "Field's type is signed: %!+f", field);
        *value = integer->payload.unsignd;
        return 0;
@@ -378,13 +634,13 @@ int bt_field_integer_unsigned_get_value(struct bt_field *field, uint64_t *value)
 int bt_field_integer_unsigned_set_value(struct bt_field *field,
                uint64_t value)
 {
-       struct bt_field_common_integer *integer = (void *) field;
+       struct bt_field_integer *integer = (void *) field;
 
        BT_ASSERT_PRE_NON_NULL(field, "Integer field");
-       BT_ASSERT_PRE_FIELD_COMMON_HOT(BT_TO_COMMON(integer), "Integer field");
-       BT_ASSERT_PRE_FIELD_IS_INT_OR_ENUM(BT_TO_COMMON(integer), "Field");
-       BT_ASSERT_PRE(!bt_field_type_common_integer_is_signed(
-               BT_FROM_COMMON(get_int_enum_int_ft(field))),
+       BT_ASSERT_PRE_FIELD_HOT(field, "Integer field");
+       BT_ASSERT_PRE_FIELD_IS_INT_OR_ENUM(field, "Field");
+       BT_ASSERT_PRE(!bt_field_type_integer_is_signed(
+               (void *) get_int_enum_int_ft(field)),
                "Field's type is signed: %!+f", field);
        BT_ASSERT_PRE(value_is_in_range_unsigned(
                get_int_enum_int_ft(field)->size, value),
@@ -398,74 +654,129 @@ int bt_field_integer_unsigned_set_value(struct bt_field *field,
 int bt_field_floating_point_get_value(struct bt_field *field,
                double *value)
 {
-       return bt_field_common_floating_point_get_value((void *) field, value);
+       struct bt_field_floating_point *floating_point = (void *) field;
+
+       BT_ASSERT_PRE_NON_NULL(field, "Floating point number field");
+       BT_ASSERT_PRE_NON_NULL(value, "Value");
+       BT_ASSERT_PRE_FIELD_IS_SET(field, "Floating point number field");
+       BT_ASSERT_PRE_FIELD_HAS_TYPE_ID(field,
+               BT_FIELD_TYPE_ID_FLOAT, "Field");
+       *value = floating_point->payload;
+       return 0;
 }
 
 int bt_field_floating_point_set_value(struct bt_field *field,
                double value)
 {
-       return bt_field_common_floating_point_set_value((void *) field, value);
+       struct bt_field_floating_point *floating_point = (void *) field;
+
+       BT_ASSERT_PRE_NON_NULL(field, "Floating point number field");
+       BT_ASSERT_PRE_FIELD_HOT(field, "Floating point number field");
+       BT_ASSERT_PRE_FIELD_HAS_TYPE_ID(field,
+               BT_FIELD_TYPE_ID_FLOAT, "Field");
+       floating_point->payload = value;
+       bt_field_set(field, true);
+       return 0;
 }
 
 const char *bt_field_string_get_value(struct bt_field *field)
 {
-       return bt_field_common_string_get_value((void *) field);
+       struct bt_field_string *string = (void *) field;
+
+       BT_ASSERT_PRE_NON_NULL(field, "String field");
+       BT_ASSERT_PRE_FIELD_IS_SET(field, "String field");
+       BT_ASSERT_PRE_FIELD_HAS_TYPE_ID(field,
+               BT_FIELD_TYPE_ID_STRING, "Field");
+       return (const char *) string->buf->data;
 }
 
 int bt_field_string_set_value(struct bt_field *field, const char *value)
 {
-       return bt_field_common_string_set_value((void *) field, value);
+       BT_ASSERT_PRE_NON_NULL(field, "String field");
+       BT_ASSERT_PRE_NON_NULL(value, "Value");
+       BT_ASSERT_PRE_FIELD_HOT(field, "String field");
+       BT_ASSERT_PRE_FIELD_HAS_TYPE_ID(field,
+               BT_FIELD_TYPE_ID_STRING, "Field");
+       bt_field_string_clear(field);
+       return bt_field_string_append_len(field,
+               value, strlen(value));
 }
 
 int bt_field_string_append(struct bt_field *field, const char *value)
 {
-       return bt_field_common_string_append((void *) field, value);
+       BT_ASSERT_PRE_NON_NULL(value, "Value");
+       return bt_field_string_append_len(field, value,
+               strlen(value));
 }
 
 int bt_field_string_append_len(struct bt_field *field,
                const char *value, unsigned int length)
 {
-       return bt_field_common_string_append_len((void *) field, value, length);
-}
+       struct bt_field_string *string_field = (void *) field;
+       char *data;
+       size_t new_size;
 
-int bt_field_string_clear(struct bt_field *string_field)
-{
-       return bt_field_common_string_clear((void *) string_field);
-}
+       BT_ASSERT_PRE_NON_NULL(field, "String field");
+       BT_ASSERT_PRE_NON_NULL(value, "Value");
+       BT_ASSERT_PRE_FIELD_HOT(field, "String field");
+       BT_ASSERT_PRE_FIELD_HAS_TYPE_ID(field,
+               BT_FIELD_TYPE_ID_STRING, "Field");
 
-BT_HIDDEN
-struct bt_field_common *bt_field_common_copy(struct bt_field_common *field)
-{
-       struct bt_field_common *copy = NULL;
+       /* Make sure no null bytes are appended */
+       BT_ASSERT_PRE(memchr(value, '\0', length) == NULL,
+               "String value to append contains a null character: "
+               "partial-value=\"%.32s\", length=%u", value, length);
 
-       BT_ASSERT_PRE_NON_NULL(field, "Field");
-       BT_ASSERT(field_type_common_has_known_id(field->type));
-       BT_ASSERT(field->methods->copy);
-       copy = field->methods->copy(field);
-       if (!copy) {
-               BT_LOGW("Cannot create field: ft-addr=%p", field->type);
-               goto end;
+       new_size = string_field->size + length;
+
+       if (unlikely(new_size + 1 > string_field->buf->len)) {
+               g_array_set_size(string_field->buf, new_size + 1);
        }
 
-       bt_field_common_set(copy, field->payload_set);
+       data = string_field->buf->data;
+       memcpy(data + string_field->size, value, length);
+       ((char *) string_field->buf->data)[new_size] = '\0';
+       string_field->size = new_size;
+       bt_field_set(field, true);
+       return 0;
+}
 
-end:
-       return copy;
+int bt_field_string_clear(struct bt_field *field)
+{
+       struct bt_field_string *string_field = (void *) field;
+
+       BT_ASSERT_PRE_NON_NULL(field, "String field");
+       BT_ASSERT_PRE_FIELD_HOT(field, "String field");
+       BT_ASSERT_PRE_FIELD_HAS_TYPE_ID(field,
+               BT_FIELD_TYPE_ID_STRING, "Field");
+       string_field->size = 0;
+       bt_field_set(field, true);
+       return 0;
+}
+
+static inline
+void bt_field_finalize(struct bt_field *field)
+{
+       BT_ASSERT(field);
+       BT_LOGD_STR("Putting field's type.");
+       bt_put(field->type);
 }
 
 static
 void bt_field_integer_destroy(struct bt_field *field)
 {
+       BT_ASSERT(field);
        BT_LOGD("Destroying integer field object: addr=%p", field);
-       bt_field_common_integer_finalize((void *) field);
+       bt_field_finalize(field);
        g_free(field);
 }
 
 static
 void bt_field_floating_point_destroy(struct bt_field *field)
 {
+       BT_ASSERT(field);
        BT_LOGD("Destroying floating point field object: addr=%p", field);
-       bt_field_common_floating_point_finalize((void *) field);
+       bt_field_finalize(field);
        g_free(field);
 }
 
@@ -473,74 +784,123 @@ static
 void bt_field_enumeration_destroy(struct bt_field *field)
 {
        BT_LOGD("Destroying enumeration field object: addr=%p", field);
-       bt_field_common_finalize((void *) field);
+       bt_field_finalize((void *) field);
        g_free(field);
 }
 
 static
 void bt_field_structure_destroy_recursive(struct bt_field *field)
 {
+       struct bt_field_structure *structure = (void *) field;
+
+       BT_ASSERT(field);
        BT_LOGD("Destroying structure field object: addr=%p", field);
-       bt_field_common_structure_finalize_recursive((void *) field);
+       bt_field_finalize(field);
+
+       if (structure->fields) {
+               g_ptr_array_free(structure->fields, TRUE);
+       }
+
        g_free(field);
 }
 
 static
 void bt_field_variant_destroy_recursive(struct bt_field *field)
 {
+       struct bt_field_variant *variant = (void *) field;
+
+       BT_ASSERT(field);
        BT_LOGD("Destroying variant field object: addr=%p", field);
-       bt_field_common_variant_finalize_recursive((void *) field);
+       bt_field_finalize(field);
+
+       if (variant->fields) {
+               g_ptr_array_free(variant->fields, TRUE);
+       }
+
        g_free(field);
 }
 
 static
 void bt_field_array_destroy_recursive(struct bt_field *field)
 {
+       struct bt_field_array *array = (void *) field;
+
+       BT_ASSERT(field);
        BT_LOGD("Destroying array field object: addr=%p", field);
-       bt_field_common_array_finalize_recursive((void *) field);
+       bt_field_finalize(field);
+
+       if (array->elements) {
+               g_ptr_array_free(array->elements, TRUE);
+       }
+
        g_free(field);
 }
 
 static
 void bt_field_sequence_destroy_recursive(struct bt_field *field)
 {
+       struct bt_field_sequence *sequence = (void *) field;
+
+       BT_ASSERT(field);
        BT_LOGD("Destroying sequence field object: addr=%p", field);
-       bt_field_common_sequence_finalize_recursive((void *) field);
+       bt_field_finalize(field);
+
+       if (sequence->elements) {
+               g_ptr_array_free(sequence->elements, TRUE);
+       }
        g_free(field);
 }
 
 static
 void bt_field_string_destroy(struct bt_field *field)
 {
+       struct bt_field_string *string = (void *) field;
+
        BT_LOGD("Destroying string field object: addr=%p", field);
-       bt_field_common_string_finalize((void *) field);
+       BT_ASSERT(field);
+       bt_field_finalize(field);
+
+       if (string->buf) {
+               g_array_free(string->buf, TRUE);
+       }
+
        g_free(field);
 }
 
 BT_HIDDEN
 void bt_field_destroy_recursive(struct bt_field *field)
 {
-       struct bt_field_common *field_common = (void *) field;
-
        if (!field) {
                return;
        }
 
-       BT_ASSERT(field_type_common_has_known_id((void *) field_common->type));
-       field_destroy_funcs[field_common->type->id](field);
+       BT_ASSERT(bt_field_type_has_known_id((void *) field->type));
+       field_destroy_funcs[field->type->id](field);
+}
+
+static inline
+void bt_field_initialize(struct bt_field *field,
+               struct bt_field_type *ft,
+               struct bt_field_methods *methods)
+{
+       BT_ASSERT(field);
+       BT_ASSERT(ft);
+       bt_object_init_unique(&field->base);
+       field->methods = methods;
+       field->type = bt_get(ft);
 }
 
 static
 struct bt_field *bt_field_integer_create(struct bt_field_type *type)
 {
-       struct bt_field_common_integer *integer =
-               g_new0(struct bt_field_common_integer, 1);
+       struct bt_field_integer *integer =
+               g_new0(struct bt_field_integer, 1);
 
        BT_LOGD("Creating integer field object: ft-addr=%p", type);
 
        if (integer) {
-               bt_field_common_initialize(BT_TO_COMMON(integer), (void *) type,
-                       false, NULL, &bt_field_integer_methods);
+               bt_field_initialize((void *) integer, (void *) type,
+                       &bt_field_integer_methods);
                BT_LOGD("Created integer field object: addr=%p, ft-addr=%p",
                        integer, type);
        } else {
@@ -559,10 +919,8 @@ struct bt_field *bt_field_enumeration_create(struct bt_field_type *type)
        BT_LOGD("Creating enumeration field object: ft-addr=%p", type);
 
        if (enumeration) {
-               bt_field_common_initialize(
-                       BT_TO_COMMON(BT_TO_COMMON(enumeration)),
-                       (void *) type, false, NULL,
-                       &bt_field_enumeration_methods);
+               bt_field_initialize((void *) enumeration,
+                       (void *) type, &bt_field_enumeration_methods);
                BT_LOGD("Created enumeration field object: addr=%p, ft-addr=%p",
                        enumeration, type);
        } else {
@@ -575,15 +933,14 @@ struct bt_field *bt_field_enumeration_create(struct bt_field_type *type)
 static
 struct bt_field *bt_field_floating_point_create(struct bt_field_type *type)
 {
-       struct bt_field_common_floating_point *floating_point;
+       struct bt_field_floating_point *floating_point;
 
        BT_LOGD("Creating floating point number field object: ft-addr=%p", type);
-       floating_point = g_new0(struct bt_field_common_floating_point, 1);
+       floating_point = g_new0(struct bt_field_floating_point, 1);
 
        if (floating_point) {
-               bt_field_common_initialize(BT_TO_COMMON(floating_point),
-                       (void *) type, false, NULL,
-                       &bt_field_floating_point_methods);
+               bt_field_initialize((void *) floating_point,
+                       (void *) type, &bt_field_floating_point_methods);
                BT_LOGD("Created floating point number field object: addr=%p, ft-addr=%p",
                        floating_point, type);
        } else {
@@ -593,31 +950,28 @@ struct bt_field *bt_field_floating_point_create(struct bt_field_type *type)
        return (void *) floating_point;
 }
 
-BT_HIDDEN
-int bt_field_common_structure_initialize(struct bt_field_common *field,
-               struct bt_field_type_common *type,
-               bool is_shared, bt_object_release_func release_func,
-               struct bt_field_common_methods *methods,
-               bt_field_common_create_func field_create_func,
+static inline
+int bt_field_structure_initialize(struct bt_field *field,
+               struct bt_field_type *type,
+               struct bt_field_methods *methods,
+               bt_field_create_func field_create_func,
                GDestroyNotify field_release_func)
 {
        int ret = 0;
-       struct bt_field_type_common_structure *structure_type =
-               BT_FROM_COMMON(type);
-       struct bt_field_common_structure *structure = BT_FROM_COMMON(field);
+       struct bt_field_type_structure *structure_type = (void *) type;
+       struct bt_field_structure *structure = (void *) field;
        size_t i;
 
-       BT_LOGD("Initializing common structure field object: ft-addr=%p", type);
-       bt_field_common_initialize(field, type, is_shared,
-               release_func, methods);
+       BT_LOGD("Initializing structure field object: ft-addr=%p", type);
+       bt_field_initialize(field, type, methods);
        structure->fields = g_ptr_array_new_with_free_func(field_release_func);
        g_ptr_array_set_size(structure->fields, structure_type->fields->len);
 
        /* Create all fields contained in the structure field. */
        for (i = 0; i < structure_type->fields->len; i++) {
-               struct bt_field_common *field;
-               struct bt_field_type_common_structure_field *struct_field =
-                       BT_FIELD_TYPE_COMMON_STRUCTURE_FIELD_AT_INDEX(
+               struct bt_field *field;
+               struct bt_field_type_structure_field *struct_field =
+                       BT_FIELD_TYPE_STRUCTURE_FIELD_AT_INDEX(
                                structure_type, i);
                field = field_create_func(struct_field->type);
                if (!field) {
@@ -630,7 +984,7 @@ int bt_field_common_structure_initialize(struct bt_field_common *field,
                g_ptr_array_index(structure->fields, i) = field;
        }
 
-       BT_LOGD("Initialized common structure field object: addr=%p, ft-addr=%p",
+       BT_LOGD("Initialized structure field object: addr=%p, ft-addr=%p",
                field, type);
 
 end:
@@ -640,8 +994,8 @@ end:
 static
 struct bt_field *bt_field_structure_create(struct bt_field_type *type)
 {
-       struct bt_field_common_structure *structure = g_new0(
-               struct bt_field_common_structure, 1);
+       struct bt_field_structure *structure = g_new0(
+               struct bt_field_structure, 1);
        int iret;
 
        BT_LOGD("Creating structure field object: ft-addr=%p", type);
@@ -651,9 +1005,9 @@ struct bt_field *bt_field_structure_create(struct bt_field_type *type)
                goto end;
        }
 
-       iret = bt_field_common_structure_initialize(BT_TO_COMMON(structure),
-               (void *) type, false, NULL, &bt_field_structure_methods,
-               (bt_field_common_create_func) bt_field_create_recursive,
+       iret = bt_field_structure_initialize((void *) structure,
+               (void *) type, &bt_field_structure_methods,
+               (bt_field_create_func) bt_field_create_recursive,
                (GDestroyNotify) bt_field_destroy_recursive);
        if (iret) {
                BT_PUT(structure);
@@ -667,26 +1021,23 @@ end:
        return (void *) structure;
 }
 
-BT_HIDDEN
-int bt_field_common_variant_initialize(struct bt_field_common *field,
-               struct bt_field_type_common *type,
-               bool is_shared, bt_object_release_func release_func,
-               struct bt_field_common_methods *methods,
-               bt_field_common_create_func field_create_func,
+static inline
+int bt_field_variant_initialize(struct bt_field *field,
+               struct bt_field_type *type,
+               struct bt_field_methods *methods,
+               bt_field_create_func field_create_func,
                GDestroyNotify field_release_func)
 {
        int ret = 0;
-       struct bt_field_type_common_variant *variant_type =
-               BT_FROM_COMMON(type);
-       struct bt_field_common_variant *variant = BT_FROM_COMMON(field);
+       struct bt_field_type_variant *variant_type = (void *) type;
+       struct bt_field_variant *variant = (void *) field;
        size_t i;
 
-       BT_LOGD("Initializing common variant field object: ft-addr=%p", type);
-       bt_field_common_initialize(field, type, is_shared,
-               release_func, methods);
-       ret = bt_field_type_common_variant_update_choices(type);
+       BT_LOGD("Initializing variant field object: ft-addr=%p", type);
+       bt_field_initialize(field, type, methods);
+       ret = bt_field_type_variant_update_choices(type);
        if (ret) {
-               BT_LOGE("Cannot update common variant field type choices: "
+               BT_LOGE("Cannot update variant field type choices: "
                        "ret=%d", ret);
                goto end;
        }
@@ -696,9 +1047,9 @@ int bt_field_common_variant_initialize(struct bt_field_common *field,
 
        /* Create all fields contained in the variant field. */
        for (i = 0; i < variant_type->choices->len; i++) {
-               struct bt_field_common *field;
-               struct bt_field_type_common_variant_choice *var_choice =
-                       BT_FIELD_TYPE_COMMON_VARIANT_CHOICE_AT_INDEX(
+               struct bt_field *field;
+               struct bt_field_type_variant_choice *var_choice =
+                       BT_FIELD_TYPE_VARIANT_CHOICE_AT_INDEX(
                                variant_type, i);
 
                field = field_create_func(var_choice->type);
@@ -712,25 +1063,23 @@ int bt_field_common_variant_initialize(struct bt_field_common *field,
                g_ptr_array_index(variant->fields, i) = field;
        }
 
-       BT_LOGD("Initialized common variant field object: addr=%p, ft-addr=%p",
+       BT_LOGD("Initialized variant field object: addr=%p, ft-addr=%p",
                field, type);
 
 end:
        return ret;
 }
 
-BT_HIDDEN
-int bt_field_common_string_initialize(struct bt_field_common *field,
-               struct bt_field_type_common *type,
-               bool is_shared, bt_object_release_func release_func,
-               struct bt_field_common_methods *methods)
+static inline
+int bt_field_string_initialize(struct bt_field *field,
+               struct bt_field_type *type,
+               struct bt_field_methods *methods)
 {
        int ret = 0;
-       struct bt_field_common_string *string = BT_FROM_COMMON(field);
+       struct bt_field_string *string = (void *) field;
 
-       BT_LOGD("Initializing common string field object: ft-addr=%p", type);
-       bt_field_common_initialize(field, type, is_shared,
-               release_func, methods);
+       BT_LOGD("Initializing string field object: ft-addr=%p", type);
+       bt_field_initialize(field, type, methods);
        string->buf = g_array_sized_new(FALSE, FALSE, sizeof(char), 1);
        if (!string->buf) {
                ret = -1;
@@ -738,7 +1087,7 @@ int bt_field_common_string_initialize(struct bt_field_common *field,
        }
 
        g_array_index(string->buf, char, 0) = '\0';
-       BT_LOGD("Initialized common string field object: addr=%p, ft-addr=%p",
+       BT_LOGD("Initialized string field object: addr=%p, ft-addr=%p",
                field, type);
 
 end:
@@ -748,8 +1097,8 @@ end:
 static
 struct bt_field *bt_field_variant_create(struct bt_field_type *type)
 {
-       struct bt_field_common_variant *variant = g_new0(
-               struct bt_field_common_variant, 1);
+       struct bt_field_variant *variant = g_new0(
+               struct bt_field_variant, 1);
        int iret;
 
        BT_LOGD("Creating variant field object: ft-addr=%p", type);
@@ -759,9 +1108,9 @@ struct bt_field *bt_field_variant_create(struct bt_field_type *type)
                goto end;
        }
 
-       iret = bt_field_common_variant_initialize(BT_TO_COMMON(variant),
-               (void *) type, false, NULL, &bt_field_variant_methods,
-               (bt_field_common_create_func) bt_field_create_recursive,
+       iret = bt_field_variant_initialize((void *) variant,
+               (void *) type, &bt_field_variant_methods,
+               (bt_field_create_func) bt_field_create_recursive,
                (GDestroyNotify) bt_field_destroy_recursive);
        if (iret) {
                BT_PUT(variant);
@@ -775,24 +1124,22 @@ end:
        return (void *) variant;
 }
 
-BT_HIDDEN
-int bt_field_common_array_initialize(struct bt_field_common *field,
-               struct bt_field_type_common *type,
-               bool is_shared, bt_object_release_func release_func,
-               struct bt_field_common_methods *methods,
-               bt_field_common_create_func field_create_func,
+static inline
+int bt_field_array_initialize(struct bt_field *field,
+               struct bt_field_type *type,
+               struct bt_field_methods *methods,
+               bt_field_create_func field_create_func,
                GDestroyNotify field_destroy_func)
 {
-       struct bt_field_type_common_array *array_type = BT_FROM_COMMON(type);
-       struct bt_field_common_array *array = BT_FROM_COMMON(field);
+       struct bt_field_type_array *array_type = (void *) type;
+       struct bt_field_array *array = (void *) field;
        unsigned int array_length;
        int ret = 0;
        uint64_t i;
 
-       BT_LOGD("Initializing common array field object: ft-addr=%p", type);
+       BT_LOGD("Initializing array field object: ft-addr=%p", type);
        BT_ASSERT(type);
-       bt_field_common_initialize(field, type, is_shared,
-               release_func, methods);
+       bt_field_initialize(field, type, methods);
        array_length = array_type->length;
        array->elements = g_ptr_array_sized_new(array_length);
        if (!array->elements) {
@@ -812,7 +1159,7 @@ int bt_field_common_array_initialize(struct bt_field_common *field,
                }
        }
 
-       BT_LOGD("Initialized common array field object: addr=%p, ft-addr=%p",
+       BT_LOGD("Initialized array field object: addr=%p, ft-addr=%p",
                field, type);
 
 end:
@@ -822,8 +1169,8 @@ end:
 static
 struct bt_field *bt_field_array_create(struct bt_field_type *type)
 {
-       struct bt_field_common_array *array =
-               g_new0(struct bt_field_common_array, 1);
+       struct bt_field_array *array =
+               g_new0(struct bt_field_array, 1);
        int ret;
 
        BT_LOGD("Creating array field object: ft-addr=%p", type);
@@ -834,9 +1181,9 @@ struct bt_field *bt_field_array_create(struct bt_field_type *type)
                goto end;
        }
 
-       ret = bt_field_common_array_initialize(BT_TO_COMMON(array),
-               (void *) type, false, NULL, &bt_field_array_methods,
-               (bt_field_common_create_func) bt_field_create_recursive,
+       ret = bt_field_array_initialize((void *) array,
+               (void *) type, &bt_field_array_methods,
+               (bt_field_create_func) bt_field_create_recursive,
                (GDestroyNotify) bt_field_destroy_recursive);
        if (ret) {
                BT_PUT(array);
@@ -850,20 +1197,18 @@ end:
        return (void *) array;
 }
 
-BT_HIDDEN
-int bt_field_common_sequence_initialize(struct bt_field_common *field,
-               struct bt_field_type_common *type,
-               bool is_shared, bt_object_release_func release_func,
-               struct bt_field_common_methods *methods,
+static inline
+int bt_field_sequence_initialize(struct bt_field *field,
+               struct bt_field_type *type,
+               struct bt_field_methods *methods,
                GDestroyNotify field_destroy_func)
 {
-       struct bt_field_common_sequence *sequence = BT_FROM_COMMON(field);
+       struct bt_field_sequence *sequence = (void *) field;
        int ret = 0;
 
-       BT_LOGD("Initializing common sequence field object: ft-addr=%p", type);
+       BT_LOGD("Initializing sequence field object: ft-addr=%p", type);
        BT_ASSERT(type);
-       bt_field_common_initialize(field, type, is_shared,
-               release_func, methods);
+       bt_field_initialize(field, type, methods);
        sequence->elements = g_ptr_array_new();
        if (!sequence->elements) {
                ret = -1;
@@ -871,7 +1216,7 @@ int bt_field_common_sequence_initialize(struct bt_field_common *field,
        }
 
        g_ptr_array_set_free_func(sequence->elements, field_destroy_func);
-       BT_LOGD("Initialized common sequence field object: addr=%p, ft-addr=%p",
+       BT_LOGD("Initialized sequence field object: addr=%p, ft-addr=%p",
                field, type);
 
 end:
@@ -881,8 +1226,8 @@ end:
 static
 struct bt_field *bt_field_sequence_create(struct bt_field_type *type)
 {
-       struct bt_field_common_sequence *sequence =
-               g_new0(struct bt_field_common_sequence, 1);
+       struct bt_field_sequence *sequence =
+               g_new0(struct bt_field_sequence, 1);
        int ret;
 
        BT_LOGD("Creating sequence field object: ft-addr=%p", type);
@@ -893,8 +1238,8 @@ struct bt_field *bt_field_sequence_create(struct bt_field_type *type)
                goto end;
        }
 
-       ret = bt_field_common_sequence_initialize(BT_TO_COMMON(sequence),
-               (void *) type, false, NULL, &bt_field_sequence_methods,
+       ret = bt_field_sequence_initialize((void *) sequence,
+               (void *) type, &bt_field_sequence_methods,
                (GDestroyNotify) bt_field_destroy_recursive);
        if (ret) {
                BT_PUT(sequence);
@@ -911,14 +1256,14 @@ end:
 static
 struct bt_field *bt_field_string_create(struct bt_field_type *type)
 {
-       struct bt_field_common_string *string = g_new0(
-               struct bt_field_common_string, 1);
+       struct bt_field_string *string = g_new0(
+               struct bt_field_string, 1);
 
        BT_LOGD("Creating string field object: ft-addr=%p", type);
 
        if (string) {
-               bt_field_common_string_initialize(BT_TO_COMMON(string),
-                       (void *) type, false, NULL, &bt_field_string_methods);
+               bt_field_string_initialize((void *) string,
+                       (void *) type, &bt_field_string_methods);
                BT_LOGD("Created string field object: addr=%p, ft-addr=%p",
                        string, type);
        } else {
@@ -928,35 +1273,35 @@ struct bt_field *bt_field_string_create(struct bt_field_type *type)
        return (void *) string;
 }
 
-BT_HIDDEN
-int bt_field_common_generic_validate(struct bt_field_common *field)
+static
+int bt_field_generic_validate(struct bt_field *field)
 {
        return (field && field->payload_set) ? 0 : -1;
 }
 
-BT_HIDDEN
-int bt_field_common_structure_validate_recursive(struct bt_field_common *field)
+static
+int bt_field_structure_validate_recursive(struct bt_field *field)
 {
        int64_t i;
        int ret = 0;
-       struct bt_field_common_structure *structure = BT_FROM_COMMON(field);
+       struct bt_field_structure *structure = (void *) field;
 
        BT_ASSERT(field);
 
        for (i = 0; i < structure->fields->len; i++) {
-               ret = bt_field_common_validate_recursive(
+               ret = bt_field_validate_recursive(
                        (void *) structure->fields->pdata[i]);
 
                if (ret) {
                        int this_ret;
                        const char *name;
 
-                       this_ret = bt_field_type_common_structure_borrow_field_by_index(
+                       this_ret = bt_field_type_structure_borrow_field_by_index(
                                field->type, &name, NULL, i);
                        BT_ASSERT(this_ret == 0);
                        BT_ASSERT_PRE_MSG("Invalid structure field's field: "
-                               "%![struct-field-]+_f, field-name=\"%s\", "
-                               "index=%" PRId64 ", %![field-]+_f",
+                               "%![struct-field-]+f, field-name=\"%s\", "
+                               "index=%" PRId64 ", %![field-]+f",
                                field, name, i, structure->fields->pdata[i]);
                        goto end;
                }
@@ -966,11 +1311,11 @@ end:
        return ret;
 }
 
-BT_HIDDEN
-int bt_field_common_variant_validate_recursive(struct bt_field_common *field)
+static
+int bt_field_variant_validate_recursive(struct bt_field *field)
 {
        int ret = 0;
-       struct bt_field_common_variant *variant = BT_FROM_COMMON(field);
+       struct bt_field_variant *variant = (void *) field;
 
        BT_ASSERT(field);
 
@@ -979,27 +1324,27 @@ int bt_field_common_variant_validate_recursive(struct bt_field_common *field)
                goto end;
        }
 
-       ret = bt_field_common_validate_recursive(variant->current_field);
+       ret = bt_field_validate_recursive(variant->current_field);
 
 end:
        return ret;
 }
 
-BT_HIDDEN
-int bt_field_common_array_validate_recursive(struct bt_field_common *field)
+static
+int bt_field_array_validate_recursive(struct bt_field *field)
 {
        int64_t i;
        int ret = 0;
-       struct bt_field_common_array *array = BT_FROM_COMMON(field);
+       struct bt_field_array *array = (void *) field;
 
        BT_ASSERT(field);
 
        for (i = 0; i < array->elements->len; i++) {
-               ret = bt_field_common_validate_recursive((void *) array->elements->pdata[i]);
+               ret = bt_field_validate_recursive((void *) array->elements->pdata[i]);
                if (ret) {
                        BT_ASSERT_PRE_MSG("Invalid array field's element field: "
-                               "%![array-field-]+_f, " PRId64 ", "
-                               "%![elem-field-]+_f",
+                               "%![array-field-]+f, " PRId64 ", "
+                               "%![elem-field-]+f",
                                field, i, array->elements->pdata[i]);
                        goto end;
                }
@@ -1009,22 +1354,22 @@ end:
        return ret;
 }
 
-BT_HIDDEN
-int bt_field_common_sequence_validate_recursive(struct bt_field_common *field)
+static
+int bt_field_sequence_validate_recursive(struct bt_field *field)
 {
        size_t i;
        int ret = 0;
-       struct bt_field_common_sequence *sequence = BT_FROM_COMMON(field);
+       struct bt_field_sequence *sequence = (void *) field;
 
        BT_ASSERT(field);
 
        for (i = 0; i < sequence->elements->len; i++) {
-               ret = bt_field_common_validate_recursive(
+               ret = bt_field_validate_recursive(
                        (void *) sequence->elements->pdata[i]);
                if (ret) {
                        BT_ASSERT_PRE_MSG("Invalid sequence field's element field: "
-                               "%![seq-field-]+_f, " PRId64 ", "
-                               "%![elem-field-]+_f",
+                               "%![seq-field-]+f, " PRId64 ", "
+                               "%![elem-field-]+f",
                                field, i, sequence->elements->pdata[i]);
                        goto end;
                }
@@ -1033,23 +1378,23 @@ end:
        return ret;
 }
 
-BT_HIDDEN
-void bt_field_common_generic_reset(struct bt_field_common *field)
+static
+void bt_field_generic_reset(struct bt_field *field)
 {
        BT_ASSERT(field);
        field->payload_set = false;
 }
 
-BT_HIDDEN
-void bt_field_common_structure_reset_recursive(struct bt_field_common *field)
+static
+void bt_field_structure_reset_recursive(struct bt_field *field)
 {
        int64_t i;
-       struct bt_field_common_structure *structure = BT_FROM_COMMON(field);
+       struct bt_field_structure *structure = (void *) field;
 
        BT_ASSERT(field);
 
        for (i = 0; i < structure->fields->len; i++) {
-               struct bt_field_common *member = structure->fields->pdata[i];
+               struct bt_field *member = structure->fields->pdata[i];
 
                if (!member) {
                        /*
@@ -1060,29 +1405,29 @@ void bt_field_common_structure_reset_recursive(struct bt_field_common *field)
                        continue;
                }
 
-               bt_field_common_reset_recursive(member);
+               bt_field_reset_recursive(member);
        }
 }
 
-BT_HIDDEN
-void bt_field_common_variant_reset_recursive(struct bt_field_common *field)
+static
+void bt_field_variant_reset_recursive(struct bt_field *field)
 {
-       struct bt_field_common_variant *variant = BT_FROM_COMMON(field);
+       struct bt_field_variant *variant = (void *) field;
 
        BT_ASSERT(field);
        variant->current_field = NULL;
 }
 
-BT_HIDDEN
-void bt_field_common_array_reset_recursive(struct bt_field_common *field)
+static
+void bt_field_array_reset_recursive(struct bt_field *field)
 {
        size_t i;
-       struct bt_field_common_array *array = BT_FROM_COMMON(field);
+       struct bt_field_array *array = (void *) field;
 
        BT_ASSERT(field);
 
        for (i = 0; i < array->elements->len; i++) {
-               struct bt_field_common *member = array->elements->pdata[i];
+               struct bt_field *member = array->elements->pdata[i];
 
                if (!member) {
                        /*
@@ -1092,21 +1437,21 @@ void bt_field_common_array_reset_recursive(struct bt_field_common *field)
                        continue;
                }
 
-               bt_field_common_reset_recursive(member);
+               bt_field_reset_recursive(member);
        }
 }
 
-BT_HIDDEN
-void bt_field_common_sequence_reset_recursive(struct bt_field_common *field)
+static
+void bt_field_sequence_reset_recursive(struct bt_field *field)
 {
-       struct bt_field_common_sequence *sequence = BT_FROM_COMMON(field);
+       struct bt_field_sequence *sequence = (void *) field;
        uint64_t i;
 
        BT_ASSERT(field);
 
        for (i = 0; i < sequence->elements->len; i++) {
                if (sequence->elements->pdata[i]) {
-                       bt_field_common_reset_recursive(
+                       bt_field_reset_recursive(
                                sequence->elements->pdata[i]);
                }
        }
@@ -1114,104 +1459,102 @@ void bt_field_common_sequence_reset_recursive(struct bt_field_common *field)
        sequence->length = 0;
 }
 
-BT_HIDDEN
-void bt_field_common_generic_set_is_frozen(struct bt_field_common *field,
+static
+void bt_field_generic_set_is_frozen(struct bt_field *field,
                bool is_frozen)
 {
        field->frozen = is_frozen;
 }
 
-BT_HIDDEN
-void bt_field_common_structure_set_is_frozen_recursive(
-               struct bt_field_common *field, bool is_frozen)
+static
+void bt_field_structure_set_is_frozen_recursive(
+               struct bt_field *field, bool is_frozen)
 {
        uint64_t i;
-       struct bt_field_common_structure *structure_field =
-               BT_FROM_COMMON(field);
+       struct bt_field_structure *structure_field = (void *) field;
 
        BT_LOGD("Freezing structure field object: addr=%p", field);
 
        for (i = 0; i < structure_field->fields->len; i++) {
-               struct bt_field_common *struct_field =
+               struct bt_field *struct_field =
                        g_ptr_array_index(structure_field->fields, i);
 
                BT_LOGD("Freezing structure field's field: field-addr=%p, index=%" PRId64,
                        struct_field, i);
-               bt_field_common_set_is_frozen_recursive(struct_field,
+               bt_field_set_is_frozen_recursive(struct_field,
                        is_frozen);
        }
 
-       bt_field_common_generic_set_is_frozen(field, is_frozen);
+       bt_field_generic_set_is_frozen(field, is_frozen);
 }
 
-BT_HIDDEN
-void bt_field_common_variant_set_is_frozen_recursive(
-               struct bt_field_common *field, bool is_frozen)
+static
+void bt_field_variant_set_is_frozen_recursive(
+               struct bt_field *field, bool is_frozen)
 {
        uint64_t i;
-       struct bt_field_common_variant *variant_field = BT_FROM_COMMON(field);
+       struct bt_field_variant *variant_field = (void *) field;
 
        BT_LOGD("Freezing variant field object: addr=%p", field);
 
        for (i = 0; i < variant_field->fields->len; i++) {
-               struct bt_field_common *var_field =
+               struct bt_field *var_field =
                        g_ptr_array_index(variant_field->fields, i);
 
                BT_LOGD("Freezing variant field's field: field-addr=%p, index=%" PRId64,
                        var_field, i);
-               bt_field_common_set_is_frozen_recursive(var_field, is_frozen);
+               bt_field_set_is_frozen_recursive(var_field, is_frozen);
        }
 
-       bt_field_common_generic_set_is_frozen(field, is_frozen);
+       bt_field_generic_set_is_frozen(field, is_frozen);
 }
 
-BT_HIDDEN
-void bt_field_common_array_set_is_frozen_recursive(
-               struct bt_field_common *field, bool is_frozen)
+static
+void bt_field_array_set_is_frozen_recursive(
+               struct bt_field *field, bool is_frozen)
 {
        int64_t i;
-       struct bt_field_common_array *array_field = BT_FROM_COMMON(field);
+       struct bt_field_array *array_field = (void *) field;
 
        BT_LOGD("Freezing array field object: addr=%p", field);
 
        for (i = 0; i < array_field->elements->len; i++) {
-               struct bt_field_common *elem_field =
+               struct bt_field *elem_field =
                        g_ptr_array_index(array_field->elements, i);
 
                BT_LOGD("Freezing array field object's element field: "
                        "element-field-addr=%p, index=%" PRId64,
                        elem_field, i);
-               bt_field_common_set_is_frozen_recursive(elem_field, is_frozen);
+               bt_field_set_is_frozen_recursive(elem_field, is_frozen);
        }
 
-       bt_field_common_generic_set_is_frozen(field, is_frozen);
+       bt_field_generic_set_is_frozen(field, is_frozen);
 }
 
-BT_HIDDEN
-void bt_field_common_sequence_set_is_frozen_recursive(
-               struct bt_field_common *field, bool is_frozen)
+static
+void bt_field_sequence_set_is_frozen_recursive(
+               struct bt_field *field, bool is_frozen)
 {
        int64_t i;
-       struct bt_field_common_sequence *sequence_field =
-               BT_FROM_COMMON(field);
+       struct bt_field_sequence *sequence_field = (void *) field;
 
        BT_LOGD("Freezing sequence field object: addr=%p", field);
 
        for (i = 0; i < sequence_field->length; i++) {
-               struct bt_field_common *elem_field =
+               struct bt_field *elem_field =
                        g_ptr_array_index(sequence_field->elements, i);
 
                BT_LOGD("Freezing sequence field object's element field: "
                        "element-field-addr=%p, index=%" PRId64,
                        elem_field, i);
-               bt_field_common_set_is_frozen_recursive(elem_field, is_frozen);
+               bt_field_set_is_frozen_recursive(elem_field, is_frozen);
        }
 
-       bt_field_common_generic_set_is_frozen(field, is_frozen);
+       bt_field_generic_set_is_frozen(field, is_frozen);
 }
 
 BT_HIDDEN
-void _bt_field_common_set_is_frozen_recursive(struct bt_field_common *field,
+void _bt_field_set_is_frozen_recursive(struct bt_field *field,
                bool is_frozen)
 {
        if (!field) {
@@ -1220,7 +1563,7 @@ void _bt_field_common_set_is_frozen_recursive(struct bt_field_common *field,
 
        BT_LOGD("Setting field object's frozen state: addr=%p, is-frozen=%d",
                field, is_frozen);
-       BT_ASSERT(field_type_common_has_known_id(field->type));
+       BT_ASSERT(bt_field_type_has_known_id(field->type));
        BT_ASSERT(field->methods->set_is_frozen);
        field->methods->set_is_frozen(field, is_frozen);
 
@@ -1228,24 +1571,24 @@ end:
        return;
 }
 
-BT_HIDDEN
-bt_bool bt_field_common_generic_is_set(struct bt_field_common *field)
+static
+bt_bool bt_field_generic_is_set(struct bt_field *field)
 {
        return field && field->payload_set;
 }
 
-BT_HIDDEN
-bt_bool bt_field_common_structure_is_set_recursive(
-               struct bt_field_common *field)
+static
+bt_bool bt_field_structure_is_set_recursive(
+               struct bt_field *field)
 {
        bt_bool is_set = BT_FALSE;
        size_t i;
-       struct bt_field_common_structure *structure = BT_FROM_COMMON(field);
+       struct bt_field_structure *structure = (void *) field;
 
        BT_ASSERT(field);
 
        for (i = 0; i < structure->fields->len; i++) {
-               is_set = bt_field_common_is_set_recursive(
+               is_set = bt_field_is_set_recursive(
                        structure->fields->pdata[i]);
                if (!is_set) {
                        goto end;
@@ -1256,33 +1599,33 @@ end:
        return is_set;
 }
 
-BT_HIDDEN
-bt_bool bt_field_common_variant_is_set_recursive(struct bt_field_common *field)
+static
+bt_bool bt_field_variant_is_set_recursive(struct bt_field *field)
 {
-       struct bt_field_common_variant *variant = BT_FROM_COMMON(field);
+       struct bt_field_variant *variant = (void *) field;
        bt_bool is_set = BT_FALSE;
 
        BT_ASSERT(field);
 
        if (variant->current_field) {
-               is_set = bt_field_common_is_set_recursive(
+               is_set = bt_field_is_set_recursive(
                        variant->current_field);
        }
 
        return is_set;
 }
 
-BT_HIDDEN
-bt_bool bt_field_common_array_is_set_recursive(struct bt_field_common *field)
+static
+bt_bool bt_field_array_is_set_recursive(struct bt_field *field)
 {
        size_t i;
        bt_bool is_set = BT_FALSE;
-       struct bt_field_common_array *array = BT_FROM_COMMON(field);
+       struct bt_field_array *array = (void *) field;
 
        BT_ASSERT(field);
 
        for (i = 0; i < array->elements->len; i++) {
-               is_set = bt_field_common_is_set_recursive(array->elements->pdata[i]);
+               is_set = bt_field_is_set_recursive(array->elements->pdata[i]);
                if (!is_set) {
                        goto end;
                }
@@ -1292,12 +1635,12 @@ end:
        return is_set;
 }
 
-BT_HIDDEN
-bt_bool bt_field_common_sequence_is_set_recursive(struct bt_field_common *field)
+static
+bt_bool bt_field_sequence_is_set_recursive(struct bt_field *field)
 {
        size_t i;
        bt_bool is_set = BT_FALSE;
-       struct bt_field_common_sequence *sequence = BT_FROM_COMMON(field);
+       struct bt_field_sequence *sequence = (void *) field;
 
        BT_ASSERT(field);
 
@@ -1306,7 +1649,7 @@ bt_bool bt_field_common_sequence_is_set_recursive(struct bt_field_common *field)
        }
 
        for (i = 0; i < sequence->elements->len; i++) {
-               is_set = bt_field_common_is_set_recursive(
+               is_set = bt_field_is_set_recursive(
                        sequence->elements->pdata[i]);
                if (!is_set) {
                        goto end;
index 939efa610867709e55a987cae66987ff4c851ae3..43506ef8c1bc54404c5e67e178ed611b2771cfeb 100644 (file)
@@ -202,7 +202,7 @@ void bt_packet_recycle(struct bt_packet *packet)
        BT_ASSERT(stream);
        packet->stream = NULL;
        bt_object_pool_recycle_object(&stream->packet_pool, packet);
-       bt_object_put_no_null_check(&stream->common.base);
+       bt_object_put_no_null_check(&stream->base);
 }
 
 BT_HIDDEN
@@ -251,9 +251,9 @@ struct bt_packet *bt_packet_new(struct bt_stream *stream)
                "stream-name=\"%s\", stream-class-addr=%p, "
                "stream-class-name=\"%s\", stream-class-id=%" PRId64,
                stream, bt_stream_get_name(stream),
-               stream->common.stream_class,
-               bt_stream_class_common_get_name(stream->common.stream_class),
-               bt_stream_class_common_get_id(stream->common.stream_class));
+               stream->stream_class,
+               bt_stream_class_get_name(stream->stream_class),
+               bt_stream_class_get_id(stream->stream_class));
        stream_class = bt_stream_borrow_class(stream);
        BT_ASSERT(stream_class);
        trace = bt_stream_class_borrow_trace(stream_class);
@@ -268,12 +268,12 @@ struct bt_packet *bt_packet_new(struct bt_stream *stream)
                (bt_object_release_func) bt_packet_recycle);
        packet->stream = bt_get(stream);
 
-       if (trace->common.packet_header_field_type) {
+       if (trace->packet_header_field_type) {
                BT_LOGD("Creating initial packet header field: ft-addr=%p",
-                       trace->common.packet_header_field_type);
+                       trace->packet_header_field_type);
                packet->header = bt_field_wrapper_create(
                        &trace->packet_header_field_pool,
-                       (void *) trace->common.packet_header_field_type);
+                       (void *) trace->packet_header_field_type);
                if (!packet->header) {
                        BT_LOGE("Cannot create packet header field wrapper.");
                        BT_PUT(packet);
@@ -281,12 +281,12 @@ struct bt_packet *bt_packet_new(struct bt_stream *stream)
                }
        }
 
-       if (stream->common.stream_class->packet_context_field_type) {
+       if (stream->stream_class->packet_context_field_type) {
                BT_LOGD("Creating initial packet context field: ft-addr=%p",
-                       stream->common.stream_class->packet_context_field_type);
+                       stream->stream_class->packet_context_field_type);
                packet->context = bt_field_wrapper_create(
                        &stream_class->packet_context_field_pool,
-                       (void *) stream->common.stream_class->packet_context_field_type);
+                       (void *) stream->stream_class->packet_context_field_type);
                if (!packet->context) {
                        BT_LOGE("Cannot create packet context field wrapper.");
                        BT_PUT(packet);
@@ -528,7 +528,7 @@ struct bt_packet *bt_packet_create(struct bt_stream *stream,
        if (unlikely(!packet->stream)) {
                packet->stream = stream;
                bt_object_get_no_null_check_no_parent_check(
-                       &packet->stream->common.base);
+                       &packet->stream->base);
        }
 
        ret = snapshot_prev_packet_properties(packet, prev_packet_avail,
@@ -561,7 +561,7 @@ int bt_packet_move_header(struct bt_packet *packet,
        BT_ASSERT_PRE_HOT(packet, "Packet", ": %!+a", packet);
        trace = bt_stream_class_borrow_trace(
                bt_stream_borrow_class(packet->stream));
-       BT_ASSERT_PRE(trace->common.packet_header_field_type,
+       BT_ASSERT_PRE(trace->packet_header_field_type,
                "Trace has no packet header field type: %!+t",
                trace);
 
@@ -586,7 +586,7 @@ int bt_packet_move_context(struct bt_packet *packet,
        BT_ASSERT_PRE_NON_NULL(field_wrapper, "Context field");
        BT_ASSERT_PRE_HOT(packet, "Packet", ": %!+a", packet);
        stream_class = bt_stream_borrow_class(packet->stream);
-       BT_ASSERT_PRE(stream_class->common.packet_context_field_type,
+       BT_ASSERT_PRE(stream_class->packet_context_field_type,
                "Stream class has no packet context field type: %!+S",
                stream_class);
 
index 3f16495324dba0bcea1cfc7aaed168f4fd79b65d..c4bf310d0369bf05309fdc60cc60bbbfee5ab40f 100644 (file)
@@ -58,7 +58,7 @@ typedef GPtrArray type_stack;
  * `type` is owned by the stack frame.
  */
 struct type_stack_frame {
-       struct bt_field_type_common *type;
+       struct bt_field_type *type;
        int index;
 };
 
@@ -77,12 +77,12 @@ struct type_stack_frame {
  */
 struct resolve_context {
        struct bt_value *environment;
-       struct bt_field_type_common *scopes[6];
+       struct bt_field_type *scopes[6];
 
        /* Root scope being visited */
        enum bt_scope root_scope;
        type_stack *type_stack;
-       struct bt_field_type_common *cur_field_type;
+       struct bt_field_type *cur_field_type;
 };
 
 /* TSDL dynamic scope prefixes as defined in CTF Section 7.3.2 */
@@ -145,7 +145,7 @@ void type_stack_destroy(type_stack *stack)
  * `type` is owned by the caller (stack frame gets a new reference).
  */
 static
-int type_stack_push(type_stack *stack, struct bt_field_type_common *type)
+int type_stack_push(type_stack *stack, struct bt_field_type *type)
 {
        int ret = 0;
        struct type_stack_frame *frame = NULL;
@@ -253,7 +253,7 @@ void type_stack_pop(type_stack *stack)
  * Return value is owned by `ctx` on success.
  */
 static
-struct bt_field_type_common *get_type_from_ctx(struct resolve_context *ctx,
+struct bt_field_type *get_type_from_ctx(struct resolve_context *ctx,
                enum bt_scope scope)
 {
        BT_ASSERT(scope >= BT_SCOPE_TRACE_PACKET_HEADER &&
@@ -395,7 +395,7 @@ error:
  */
 static
 int ptokens_to_field_path(GList *ptokens, struct bt_field_path *field_path,
-               struct bt_field_type_common *type, int src_index)
+               struct bt_field_type *type, int src_index)
 {
        int ret = 0;
        GList *cur_ptoken = ptokens;
@@ -407,10 +407,10 @@ int ptokens_to_field_path(GList *ptokens, struct bt_field_path *field_path,
        /* Locate target */
        while (cur_ptoken) {
                int child_index;
-               struct bt_field_type_common *child_type;
+               struct bt_field_type *child_type;
                const char *field_name = ptoken_get_string(cur_ptoken);
                enum bt_field_type_id type_id =
-                       bt_field_type_common_get_type_id(type);
+                       bt_field_type_get_type_id(type);
 
                BT_LOGV("Current path token: token=\"%s\"", field_name);
 
@@ -419,7 +419,7 @@ int ptokens_to_field_path(GList *ptokens, struct bt_field_path *field_path,
                                type_id == BT_FIELD_TYPE_ID_SEQUENCE) {
                        child_index = -1;
                } else {
-                       child_index = bt_field_type_common_get_field_index(type,
+                       child_index = bt_field_type_get_field_index(type,
                                field_name);
                        if (child_index < 0) {
                                /*
@@ -449,7 +449,7 @@ int ptokens_to_field_path(GList *ptokens, struct bt_field_path *field_path,
                g_array_append_val(field_path->indexes, child_index);
 
                /* Get child field type */
-               child_type = bt_field_type_common_borrow_field_at_index(type,
+               child_type = bt_field_type_borrow_field_at_index(type,
                        child_index);
                if (!child_type) {
                        BT_LOGW("Cannot get child field type: "
@@ -483,7 +483,7 @@ int absolute_ptokens_to_field_path(GList *ptokens,
 {
        int ret = 0;
        GList *cur_ptoken;
-       struct bt_field_type_common *type;
+       struct bt_field_type *type;
 
        /* Skip absolute path tokens */
        cur_ptoken = g_list_nth(ptokens,
@@ -532,7 +532,7 @@ int relative_ptokens_to_field_path(GList *ptokens,
        parent_pos_in_stack = type_stack_size(ctx->type_stack) - 1;
 
        while (parent_pos_in_stack >= 0) {
-               struct bt_field_type_common *parent_type =
+               struct bt_field_type *parent_type =
                        type_stack_at(ctx->type_stack,
                                parent_pos_in_stack)->type;
                int cur_index = type_stack_at(ctx->type_stack,
@@ -556,7 +556,7 @@ int relative_ptokens_to_field_path(GList *ptokens,
                                tail_field_path->indexes->len;
 
                        while (BT_TRUE) {
-                               struct bt_field_type_common *cur_type =
+                               struct bt_field_type *cur_type =
                                        type_stack_at(ctx->type_stack, i)->type;
                                int index = type_stack_at(
                                        ctx->type_stack, i)->index;
@@ -589,7 +589,7 @@ int relative_ptokens_to_field_path(GList *ptokens,
                field_path->root--;
 
                while (field_path->root >= BT_SCOPE_TRACE_PACKET_HEADER) {
-                       struct bt_field_type_common *root_type;
+                       struct bt_field_type *root_type;
                        bt_field_path_clear(field_path);
 
                        BT_LOGV("Looking into potential root scope: scope=%s",
@@ -718,12 +718,12 @@ end:
  * Return value is owned by the caller on success.
  */
 static
-struct bt_field_type_common *field_path_to_field_type(
+struct bt_field_type *field_path_to_field_type(
                struct bt_field_path *field_path,
                struct resolve_context *ctx)
 {
        int i;
-       struct bt_field_type_common *type;
+       struct bt_field_type *type;
 
        /* Start with root type */
        type = get_type_from_ctx(ctx, field_path->root);
@@ -737,12 +737,12 @@ struct bt_field_type_common *field_path_to_field_type(
 
        /* Locate target */
        for (i = 0; i < field_path->indexes->len; i++) {
-               struct bt_field_type_common *child_type;
+               struct bt_field_type *child_type;
                int child_index =
                        g_array_index(field_path->indexes, int, i);
 
                /* Get child field type */
-               child_type = bt_field_type_common_borrow_field_at_index(type,
+               child_type = bt_field_type_borrow_field_at_index(type,
                        child_index);
                if (!child_type) {
                        BT_LOGW("Cannot get field type: "
@@ -880,7 +880,7 @@ int get_field_paths_lca_index(struct bt_field_path *field_path1,
  */
 static
 int validate_target_field_path(struct bt_field_path *target_field_path,
-               struct bt_field_type_common *target_type,
+               struct bt_field_type *target_type,
                struct resolve_context *ctx)
 {
        int ret = 0;
@@ -956,9 +956,9 @@ int validate_target_field_path(struct bt_field_path *target_field_path,
        /*
         * Make sure the target type has the right type and properties.
         */
-       ctx_cur_field_type_id = bt_field_type_common_get_type_id(
+       ctx_cur_field_type_id = bt_field_type_get_type_id(
                ctx->cur_field_type);
-       target_type_id = bt_field_type_common_get_type_id(target_type);
+       target_type_id = bt_field_type_get_type_id(target_type);
 
        switch (ctx_cur_field_type_id) {
        case BT_FIELD_TYPE_ID_VARIANT:
@@ -973,7 +973,7 @@ int validate_target_field_path(struct bt_field_path *target_field_path,
                break;
        case BT_FIELD_TYPE_ID_SEQUENCE:
                if (target_type_id != BT_FIELD_TYPE_ID_INTEGER ||
-                               bt_field_type_common_integer_is_signed(target_type)) {
+                               bt_field_type_integer_is_signed(target_type)) {
                        BT_LOGW("Sequence field type's length field type is not an unsigned integer field type: "
                                "length-ft-addr=%p, length-ft-id=%s",
                                target_type,
@@ -997,14 +997,14 @@ end:
  * `type` is owned by the caller.
  */
 static
-int resolve_sequence_or_variant_type(struct bt_field_type_common *type,
+int resolve_sequence_or_variant_type(struct bt_field_type *type,
                struct resolve_context *ctx)
 {
        int ret = 0;
        const char *pathstr;
-       enum bt_field_type_id type_id = bt_field_type_common_get_type_id(type);
+       enum bt_field_type_id type_id = bt_field_type_get_type_id(type);
        struct bt_field_path *target_field_path = NULL;
-       struct bt_field_type_common *target_type = NULL;
+       struct bt_field_type *target_type = NULL;
        GString *target_field_path_pretty = NULL;
        const char *target_field_path_pretty_str;
 
@@ -1013,11 +1013,11 @@ int resolve_sequence_or_variant_type(struct bt_field_type_common *type,
        switch (type_id) {
        case BT_FIELD_TYPE_ID_SEQUENCE:
                pathstr =
-                       bt_field_type_common_sequence_get_length_field_name(type);
+                       bt_field_type_sequence_get_length_field_name(type);
                break;
        case BT_FIELD_TYPE_ID_VARIANT:
                pathstr =
-                       bt_field_type_common_variant_get_tag_name(type);
+                       bt_field_type_variant_get_tag_name(type);
                break;
        default:
                abort();
@@ -1063,7 +1063,7 @@ int resolve_sequence_or_variant_type(struct bt_field_type_common *type,
        /* Set target field path and target field type */
        switch (type_id) {
        case BT_FIELD_TYPE_ID_SEQUENCE:
-               ret = bt_field_type_common_sequence_set_length_field_path(
+               ret = bt_field_type_sequence_set_length_field_path(
                        type, target_field_path);
                if (ret) {
                        BT_LOGW("Cannot set sequence field type's length field path: "
@@ -1074,7 +1074,7 @@ int resolve_sequence_or_variant_type(struct bt_field_type_common *type,
                }
                break;
        case BT_FIELD_TYPE_ID_VARIANT:
-               ret = bt_field_type_common_variant_set_tag_field_path(
+               ret = bt_field_type_variant_set_tag_field_path(
                        type, target_field_path);
                if (ret) {
                        BT_LOGW("Cannot set varaint field type's tag field path: "
@@ -1084,7 +1084,7 @@ int resolve_sequence_or_variant_type(struct bt_field_type_common *type,
                        goto end;
                }
 
-               ret = bt_field_type_common_variant_set_tag_field_type(
+               ret = bt_field_type_variant_set_tag_field_type(
                        type, target_type);
                if (ret) {
                        BT_LOGW("Cannot set varaint field type's tag field type: "
@@ -1114,7 +1114,7 @@ end:
  * `type` is owned by the caller.
  */
 static
-int resolve_type(struct bt_field_type_common *type, struct resolve_context *ctx)
+int resolve_type(struct bt_field_type *type, struct resolve_context *ctx)
 {
        int ret = 0;
        enum bt_field_type_id type_id;
@@ -1124,7 +1124,7 @@ int resolve_type(struct bt_field_type_common *type, struct resolve_context *ctx)
                goto end;
        }
 
-       type_id = bt_field_type_common_get_type_id(type);
+       type_id = bt_field_type_get_type_id(type);
        ctx->cur_field_type = type;
 
        /* Resolve sequence/variant field type */
@@ -1158,7 +1158,7 @@ int resolve_type(struct bt_field_type_common *type, struct resolve_context *ctx)
                        goto end;
                }
 
-               field_count = bt_field_type_common_get_field_count(type);
+               field_count = bt_field_type_get_field_count(type);
                if (field_count < 0) {
                        BT_LOGW("Cannot get field type's field count: "
                                "ret=%" PRId64 ", ft-addr=%p",
@@ -1168,8 +1168,8 @@ int resolve_type(struct bt_field_type_common *type, struct resolve_context *ctx)
                }
 
                for (f_index = 0; f_index < field_count; f_index++) {
-                       struct bt_field_type_common *child_type =
-                               bt_field_type_common_borrow_field_at_index(type,
+                       struct bt_field_type *child_type =
+                               bt_field_type_borrow_field_at_index(type,
                                        f_index);
 
                        if (!child_type) {
@@ -1229,12 +1229,12 @@ int resolve_root_type(enum bt_scope root_scope, struct resolve_context *ctx)
 BT_HIDDEN
 int bt_resolve_types(
                struct bt_value *environment,
-               struct bt_field_type_common *packet_header_type,
-               struct bt_field_type_common *packet_context_type,
-               struct bt_field_type_common *event_header_type,
-               struct bt_field_type_common *stream_event_ctx_type,
-               struct bt_field_type_common *event_context_type,
-               struct bt_field_type_common *event_payload_type,
+               struct bt_field_type *packet_header_type,
+               struct bt_field_type *packet_context_type,
+               struct bt_field_type *event_header_type,
+               struct bt_field_type *stream_event_ctx_type,
+               struct bt_field_type *event_context_type,
+               struct bt_field_type *event_payload_type,
                enum bt_resolve_flag flags)
 {
        int ret = 0;
index 03d8ce8f15f700d4530f0ca1aae7034941f51e47..24cb870b36461596f179cdc08e683997bac023bb 100644 (file)
 #include <stdint.h>
 #include <stdbool.h>
 
-BT_HIDDEN
-int bt_stream_class_common_initialize(struct bt_stream_class_common *stream_class,
+static inline
+int bt_stream_class_initialize(struct bt_stream_class *stream_class,
                const char *name, bt_object_release_func release_func)
 {
-       BT_LOGD("Initializing common stream class object: name=\"%s\"", name);
+       BT_LOGD("Initializing stream class object: name=\"%s\"", name);
 
        bt_object_init_shared_with_parent(&stream_class->base, release_func);
        stream_class->name = g_string_new(name);
@@ -71,7 +71,7 @@ int bt_stream_class_common_initialize(struct bt_stream_class_common *stream_clas
                goto error;
        }
 
-       BT_LOGD("Initialized common stream class object: addr=%p, name=\"%s\"",
+       BT_LOGD("Initialized stream class object: addr=%p, name=\"%s\"",
                stream_class, name);
        return 0;
 
@@ -79,12 +79,14 @@ error:
        return -1;
 }
 
-BT_HIDDEN
-void bt_stream_class_common_finalize(struct bt_stream_class_common *stream_class)
+static
+void bt_stream_class_destroy(struct bt_object *obj)
 {
-       BT_LOGD("Finalizing common stream class: addr=%p, name=\"%s\", id=%" PRId64,
-               stream_class, bt_stream_class_common_get_name(stream_class),
-               bt_stream_class_common_get_id(stream_class));
+       struct bt_stream_class *stream_class = (void *) obj;
+
+       BT_LOGD("Destroying stream class: addr=%p, name=\"%s\", id=%" PRId64,
+               stream_class, bt_stream_class_get_name(stream_class),
+               bt_stream_class_get_id(stream_class));
        bt_put(stream_class->clock_class);
 
        if (stream_class->event_classes_ht) {
@@ -105,35 +107,6 @@ void bt_stream_class_common_finalize(struct bt_stream_class_common *stream_class
        bt_put(stream_class->packet_context_field_type);
        BT_LOGD_STR("Putting event context field type.");
        bt_put(stream_class->event_context_field_type);
-}
-
-static
-void bt_stream_class_destroy(struct bt_object *obj)
-{
-       struct bt_stream_class *stream_class;
-
-       stream_class = (void *) obj;
-       BT_LOGD("Destroying stream class: addr=%p, name=\"%s\", id=%" PRId64,
-               stream_class, bt_stream_class_get_name(stream_class),
-               bt_stream_class_get_id(stream_class));
-
-       /*
-        * IMPORTANT: Finalize the common stream class BEFORE finalizing
-        * the pools because otherwise this scenario is possible:
-        *
-        * 1. Event header field object pool is finalized, thus
-        *    destroying its internal array and state.
-        *
-        * 2. Stream class is finalized: each event class is destroyed.
-        *
-        * 3. Destroying an event class finalizes its event pool,
-        *    destroying each contained event.
-        *
-        * 4. Destroying an event makes it recycle its event header
-        *    field to its stream class's event header field pool. But
-        *    said pool is already finalized.
-        */
-       bt_stream_class_common_finalize(BT_TO_COMMON(stream_class));
        bt_object_pool_finalize(&stream_class->event_header_field_pool);
        bt_object_pool_finalize(&stream_class->packet_context_field_pool);
        g_free(stream_class);
@@ -158,10 +131,10 @@ struct bt_stream_class *bt_stream_class_create(const char *name)
                goto error;
        }
 
-       ret = bt_stream_class_common_initialize(BT_TO_COMMON(stream_class),
-               name, bt_stream_class_destroy);
+       ret = bt_stream_class_initialize(stream_class, name,
+               bt_stream_class_destroy);
        if (ret) {
-               /* bt_stream_class_common_initialize() logs errors */
+               /* bt_stream_class_initialize() logs errors */
                goto error;
        }
 
@@ -200,14 +173,14 @@ struct bt_event_header_field *bt_stream_class_create_event_header_field(
        struct bt_field_wrapper *field_wrapper;
 
        BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
-       BT_ASSERT_PRE(stream_class->common.frozen,
+       BT_ASSERT_PRE(stream_class->frozen,
                "Stream class is not part of a trace: %!+S", stream_class);
-       BT_ASSERT_PRE(stream_class->common.event_header_field_type,
+       BT_ASSERT_PRE(stream_class->event_header_field_type,
                "Stream class has no event header field type: %!+S",
                stream_class);
        field_wrapper = bt_field_wrapper_create(
                &stream_class->event_header_field_pool,
-               (void *) stream_class->common.event_header_field_type);
+               (void *) stream_class->event_header_field_type);
        if (!field_wrapper) {
                BT_LIB_LOGE("Cannot allocate one event header field from stream class: "
                        "%![sc-]+S", stream_class);
@@ -233,14 +206,14 @@ struct bt_packet_context_field *bt_stream_class_create_packet_context_field(
        struct bt_field_wrapper *field_wrapper;
 
        BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
-       BT_ASSERT_PRE(stream_class->common.frozen,
+       BT_ASSERT_PRE(stream_class->frozen,
                "Stream class is not part of a trace: %!+S", stream_class);
-       BT_ASSERT_PRE(stream_class->common.packet_context_field_type,
+       BT_ASSERT_PRE(stream_class->packet_context_field_type,
                "Stream class has no packet context field type: %!+S",
                stream_class);
        field_wrapper = bt_field_wrapper_create(
                &stream_class->packet_context_field_pool,
-               (void *) stream_class->common.packet_context_field_type);
+               (void *) stream_class->packet_context_field_type);
        if (!field_wrapper) {
                BT_LIB_LOGE("Cannot allocate one packet context field from stream class: "
                        "%![sc-]+S", stream_class);
@@ -262,38 +235,129 @@ end:
 
 struct bt_trace *bt_stream_class_borrow_trace(struct bt_stream_class *stream_class)
 {
-       return BT_FROM_COMMON(bt_stream_class_common_borrow_trace(
-               BT_TO_COMMON(stream_class)));
+       BT_ASSERT(stream_class);
+       return (void *) bt_object_borrow_parent(&stream_class->base);
 }
 
 const char *bt_stream_class_get_name(struct bt_stream_class *stream_class)
 {
-       return bt_stream_class_common_get_name(BT_TO_COMMON(stream_class));
+       BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
+       return stream_class->name->len > 0 ? stream_class->name->str : NULL;
 }
 
 int bt_stream_class_set_name(struct bt_stream_class *stream_class,
                const char *name)
 {
-       return bt_stream_class_common_set_name(BT_TO_COMMON(stream_class),
-               name);
+       int ret = 0;
+
+       if (!stream_class) {
+               BT_LOGW_STR("Invalid parameter: stream class is NULL.");
+               ret = -1;
+               goto end;
+       }
+
+       if (stream_class->frozen) {
+               BT_LOGW("Invalid parameter: stream class is frozen: "
+                       "addr=%p, name=\"%s\", id=%" PRId64,
+                       stream_class,
+                       bt_stream_class_get_name(stream_class),
+                       bt_stream_class_get_id(stream_class));
+               ret = -1;
+               goto end;
+       }
+
+       if (!name) {
+               g_string_assign(stream_class->name, "");
+       } else {
+               if (strlen(name) == 0) {
+                       BT_LOGW("Invalid parameter: name is empty.");
+                       ret = -1;
+                       goto end;
+               }
+
+               g_string_assign(stream_class->name, name);
+       }
+
+       BT_LOGV("Set stream class's name: "
+               "addr=%p, name=\"%s\", id=%" PRId64,
+               stream_class, bt_stream_class_get_name(stream_class),
+               bt_stream_class_get_id(stream_class));
+end:
+       return ret;
 }
 
 int64_t bt_stream_class_get_id(struct bt_stream_class *stream_class)
 {
-       return bt_stream_class_common_get_id(BT_TO_COMMON(stream_class));
+       int64_t ret;
+
+       BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
+
+       if (!stream_class->id_set) {
+               BT_LOGV("Stream class's ID is not set: addr=%p, name=\"%s\"",
+                       stream_class,
+                       bt_stream_class_get_name(stream_class));
+               ret = (int64_t) -1;
+               goto end;
+       }
+
+       ret = stream_class->id;
+
+end:
+       return ret;
 }
 
-int bt_stream_class_set_id(struct bt_stream_class *stream_class, uint64_t id)
+int bt_stream_class_set_id(struct bt_stream_class *stream_class,
+               uint64_t id_param)
 {
-       return bt_stream_class_common_set_id(BT_TO_COMMON(stream_class), id);
+       int ret = 0;
+       int64_t id = (int64_t) id_param;
+
+       if (!stream_class) {
+               BT_LOGW_STR("Invalid parameter: stream class is NULL.");
+               ret = -1;
+               goto end;
+       }
+
+       if (stream_class->frozen) {
+               BT_LOGW("Invalid parameter: stream class is frozen: "
+                       "addr=%p, name=\"%s\", id=%" PRId64,
+                       stream_class,
+                       bt_stream_class_get_name(stream_class),
+                       bt_stream_class_get_id(stream_class));
+               ret = -1;
+               goto end;
+       }
+
+       if (id < 0) {
+               BT_LOGW("Invalid parameter: invalid stream class's ID: "
+                       "stream-class-addr=%p, stream-class-name=\"%s\", "
+                       "stream-class-id=%" PRId64 ", id=%" PRIu64,
+                       stream_class,
+                       bt_stream_class_get_name(stream_class),
+                       bt_stream_class_get_id(stream_class),
+                       id_param);
+               ret = -1;
+               goto end;
+       }
+
+       ret = bt_stream_class_set_id_no_check(stream_class, id);
+       if (ret == 0) {
+               BT_LOGV("Set stream class's ID: "
+                       "addr=%p, name=\"%s\", id=%" PRId64,
+                       stream_class,
+                       bt_stream_class_get_name(stream_class),
+                       bt_stream_class_get_id(stream_class));
+       }
+end:
+       return ret;
 }
 
 static
 void event_class_exists(gpointer element, gpointer query)
 {
-       struct bt_event_class_common *event_class_a = element;
+       struct bt_event_class *event_class_a = element;
        struct search_query *search_query = query;
-       struct bt_event_class_common *event_class_b = search_query->value;
+       struct bt_event_class *event_class_b = search_query->value;
        int64_t id_a, id_b;
 
        if (search_query->value == element) {
@@ -305,8 +369,8 @@ void event_class_exists(gpointer element, gpointer query)
         * Two event classes cannot share the same ID in a given
         * stream class.
         */
-       id_a = bt_event_class_common_get_id(event_class_a);
-       id_b = bt_event_class_common_get_id(event_class_b);
+       id_a = bt_event_class_get_id(event_class_a);
+       id_b = bt_event_class_get_id(event_class_b);
 
        if (id_a < 0 || id_b < 0) {
                /* at least one ID is not set: will be automatically set later */
@@ -316,7 +380,7 @@ void event_class_exists(gpointer element, gpointer query)
        if (id_a == id_b) {
                BT_LOGW("Event class with this ID already exists in the stream class: "
                        "id=%" PRId64 ", name=\"%s\"",
-                       id_a, bt_event_class_common_get_name(event_class_a));
+                       id_a, bt_event_class_get_name(event_class_a));
                search_query->found = 1;
                goto end;
        }
@@ -325,28 +389,39 @@ end:
        return;
 }
 
-BT_HIDDEN
-int bt_stream_class_common_add_event_class(
-               struct bt_stream_class_common *stream_class,
-               struct bt_event_class_common *event_class,
-               bt_validation_flag_copy_field_type_func copy_field_type_func)
+int bt_stream_class_add_event_class(struct bt_stream_class *stream_class,
+               struct bt_event_class *event_class)
 {
        int ret = 0;
        int64_t *event_id = NULL;
-       struct bt_trace_common *trace = NULL;
-       struct bt_stream_class_common *old_stream_class = NULL;
+       struct bt_trace *trace = NULL;
+       struct bt_stream_class *old_stream_class = NULL;
        struct bt_validation_output validation_output = { 0 };
-       struct bt_field_type_common *packet_header_type = NULL;
-       struct bt_field_type_common *packet_context_type = NULL;
-       struct bt_field_type_common *event_header_type = NULL;
-       struct bt_field_type_common *stream_event_ctx_type = NULL;
-       struct bt_field_type_common *event_context_type = NULL;
-       struct bt_field_type_common *event_payload_type = NULL;
+       struct bt_field_type *packet_header_type = NULL;
+       struct bt_field_type *packet_context_type = NULL;
+       struct bt_field_type *event_header_type = NULL;
+       struct bt_field_type *stream_event_ctx_type = NULL;
+       struct bt_field_type *event_context_type = NULL;
+       struct bt_field_type *event_payload_type = NULL;
        const enum bt_validation_flag validation_flags =
                BT_VALIDATION_FLAG_EVENT;
        struct bt_clock_class *expected_clock_class = NULL;
 
-       BT_ASSERT(copy_field_type_func);
+       if (!stream_class) {
+               BT_LOGW("Invalid parameter: stream class is NULL: "
+                       "stream-class-addr=%p", stream_class);
+               ret = -1;
+               goto end;
+       }
+
+       trace = bt_stream_class_borrow_trace(stream_class);
+       if (trace && trace->is_static) {
+               BT_LOGW("Invalid parameter: stream class's trace is static: "
+                       "trace-addr=%p, trace-name=\"%s\"",
+                       trace, bt_trace_get_name(trace));
+               ret = -1;
+               goto end;
+       }
 
        if (!stream_class || !event_class) {
                BT_LOGW("Invalid parameter: stream class or event class is NULL: "
@@ -360,12 +435,12 @@ int bt_stream_class_common_add_event_class(
                "stream-class-addr=%p, stream-class-name=\"%s\", "
                "stream-class-id=%" PRId64 ", event-class-addr=%p, "
                "event-class-name=\"%s\", event-class-id=%" PRId64,
-               stream_class, bt_stream_class_common_get_name(stream_class),
-               bt_stream_class_common_get_id(stream_class),
+               stream_class, bt_stream_class_get_name(stream_class),
+               bt_stream_class_get_id(stream_class),
                event_class,
-               bt_event_class_common_get_name(event_class),
-               bt_event_class_common_get_id(event_class));
-       trace = bt_stream_class_common_borrow_trace(stream_class);
+               bt_event_class_get_name(event_class),
+               bt_event_class_get_id(event_class));
+       trace = bt_stream_class_borrow_trace(stream_class);
 
        if (stream_class->frozen) {
                /*
@@ -387,7 +462,7 @@ int bt_stream_class_common_add_event_class(
                 * and bt_event_class_validate_single_clock_class()
                 * below can set it.
                 */
-               ret = bt_event_class_common_validate_single_clock_class(
+               ret = bt_event_class_validate_single_clock_class(
                        event_class, &expected_clock_class);
                if (ret) {
                        BT_LOGW("Event class contains a field type which is not "
@@ -399,8 +474,8 @@ int bt_stream_class_common_add_event_class(
                                "expected-clock-class-addr=%p, "
                                "expected-clock-class-name=\"%s\"",
                                stream_class,
-                               bt_stream_class_common_get_id(stream_class),
-                               bt_stream_class_common_get_name(stream_class),
+                               bt_stream_class_get_id(stream_class),
+                               bt_stream_class_get_name(stream_class),
                                expected_clock_class,
                                expected_clock_class ?
                                        bt_clock_class_get_name(expected_clock_class) :
@@ -426,7 +501,7 @@ int bt_stream_class_common_add_event_class(
                goto end;
        }
 
-       old_stream_class = bt_event_class_common_borrow_stream_class(event_class);
+       old_stream_class = bt_event_class_borrow_stream_class(event_class);
        if (old_stream_class) {
                /* Event class is already associated to a stream class. */
                BT_LOGW("Event class is already part of another stream class: "
@@ -434,8 +509,8 @@ int bt_stream_class_common_add_event_class(
                        "event-class-stream-class-name=\"%s\", "
                        "event-class-stream-class-id=%" PRId64,
                        old_stream_class,
-                       bt_stream_class_common_get_name(old_stream_class),
-                       bt_stream_class_common_get_id(old_stream_class));
+                       bt_stream_class_get_name(old_stream_class),
+                       bt_stream_class_get_id(old_stream_class));
                ret = -1;
                goto end;
        }
@@ -453,21 +528,21 @@ int bt_stream_class_common_add_event_class(
                BT_ASSERT(trace->valid);
                BT_ASSERT(stream_class->valid);
                packet_header_type =
-                       bt_trace_common_borrow_packet_header_field_type(trace);
+                       bt_trace_borrow_packet_header_field_type(trace);
                packet_context_type =
-                       bt_stream_class_common_borrow_packet_context_field_type(
+                       bt_stream_class_borrow_packet_context_field_type(
                                stream_class);
                event_header_type =
-                       bt_stream_class_common_borrow_event_header_field_type(
+                       bt_stream_class_borrow_event_header_field_type(
                                stream_class);
                stream_event_ctx_type =
-                       bt_stream_class_common_borrow_event_context_field_type(
+                       bt_stream_class_borrow_event_context_field_type(
                                stream_class);
                event_context_type =
-                       bt_event_class_common_borrow_context_field_type(
+                       bt_event_class_borrow_context_field_type(
                                event_class);
                event_payload_type =
-                       bt_event_class_common_borrow_payload_field_type(
+                       bt_event_class_borrow_payload_field_type(
                                event_class);
                ret = bt_validate_class_types(
                        trace->environment, packet_header_type,
@@ -476,7 +551,7 @@ int bt_stream_class_common_add_event_class(
                        event_payload_type, trace->valid,
                        stream_class->valid, event_class->valid,
                        &validation_output, validation_flags,
-                       copy_field_type_func);
+                       bt_field_type_copy);
 
                if (ret) {
                        /*
@@ -500,12 +575,12 @@ int bt_stream_class_common_add_event_class(
        }
 
        /* Only set an event ID if none was explicitly set before */
-       *event_id = bt_event_class_common_get_id(event_class);
+       *event_id = bt_event_class_get_id(event_class);
        if (*event_id < 0) {
                BT_LOGV("Event class has no ID: automatically setting it: "
                        "id=%" PRId64, stream_class->next_event_id);
 
-               if (bt_event_class_common_set_id(event_class,
+               if (bt_event_class_set_id(event_class,
                                stream_class->next_event_id)) {
                        BT_LOGE("Cannot set event class's ID: id=%" PRId64,
                                stream_class->next_event_id);
@@ -543,7 +618,7 @@ int bt_stream_class_common_add_event_class(
        event_id = NULL;
 
        /* Freeze the event class */
-       bt_event_class_common_freeze(event_class);
+       bt_event_class_freeze(event_class);
 
        /*
         * It is safe to set the stream class's unique clock class
@@ -555,15 +630,23 @@ int bt_stream_class_common_add_event_class(
                BT_MOVE(stream_class->clock_class, expected_clock_class);
        }
 
+       /* Notifiy listeners of the trace's schema modification. */
+       if (trace) {
+               struct bt_visitor_object obj = { .object = event_class,
+                               .type = BT_VISITOR_OBJECT_TYPE_EVENT_CLASS };
+
+               (void) bt_trace_object_modification(&obj, trace);
+       }
+
        BT_LOGD("Added event class to stream class: "
                "stream-class-addr=%p, stream-class-name=\"%s\", "
                "stream-class-id=%" PRId64 ", event-class-addr=%p, "
                "event-class-name=\"%s\", event-class-id=%" PRId64,
-               stream_class, bt_stream_class_common_get_name(stream_class),
-               bt_stream_class_common_get_id(stream_class),
+               stream_class, bt_stream_class_get_name(stream_class),
+               bt_stream_class_get_id(stream_class),
                event_class,
-               bt_event_class_common_get_name(event_class),
-               bt_event_class_common_get_id(event_class));
+               bt_event_class_get_name(event_class),
+               bt_event_class_get_id(event_class));
 
 end:
        bt_validation_output_put_types(&validation_output);
@@ -572,112 +655,239 @@ end:
        return ret;
 }
 
-int bt_stream_class_add_event_class(struct bt_stream_class *stream_class,
-               struct bt_event_class *event_class)
+int64_t bt_stream_class_get_event_class_count(
+               struct bt_stream_class *stream_class)
 {
-       struct bt_trace *trace;
-       int ret = 0;
+       int64_t ret;
 
        if (!stream_class) {
-               BT_LOGW("Invalid parameter: stream class is NULL: "
-                       "stream-class-addr=%p", stream_class);
-               ret = -1;
-               goto end;
-       }
-
-       trace = BT_FROM_COMMON(bt_stream_class_common_borrow_trace(
-               BT_TO_COMMON(stream_class)));
-       if (trace && trace->is_static) {
-               BT_LOGW("Invalid parameter: stream class's trace is static: "
-                       "trace-addr=%p, trace-name=\"%s\"",
-                       trace, bt_trace_get_name(trace));
-               ret = -1;
-               goto end;
-       }
-
-       ret = bt_stream_class_common_add_event_class(
-               BT_TO_COMMON(stream_class), BT_TO_COMMON(event_class),
-               (bt_validation_flag_copy_field_type_func) bt_field_type_copy);
-       if (ret) {
+               BT_LOGW_STR("Invalid parameter: stream class is NULL.");
+               ret = (int64_t) -1;
                goto end;
        }
 
-       /* Notifiy listeners of the trace's schema modification. */
-       if (trace) {
-               struct bt_visitor_object obj = { .object = event_class,
-                               .type = BT_VISITOR_OBJECT_TYPE_EVENT_CLASS };
-
-               (void) bt_trace_object_modification(&obj, trace);
-       }
-
+       ret = (int64_t) stream_class->event_classes->len;
 end:
        return ret;
 }
 
-int64_t bt_stream_class_get_event_class_count(
-               struct bt_stream_class *stream_class)
-{
-       return bt_stream_class_common_get_event_class_count(
-               BT_TO_COMMON(stream_class));
-}
-
 struct bt_event_class *bt_stream_class_borrow_event_class_by_index(
                struct bt_stream_class *stream_class, uint64_t index)
 {
-       return BT_FROM_COMMON(bt_stream_class_common_borrow_event_class_by_index(
-               BT_TO_COMMON(stream_class), index));
+       BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
+       BT_ASSERT_PRE(index < stream_class->event_classes->len,
+               "Index is out of bounds: index=%" PRIu64 ", "
+               "count=%u",
+               index, stream_class->event_classes->len);
+       return g_ptr_array_index(stream_class->event_classes, index);
 }
 
 struct bt_event_class *bt_stream_class_borrow_event_class_by_id(
                struct bt_stream_class *stream_class, uint64_t id)
 {
-       return BT_FROM_COMMON(bt_stream_class_common_borrow_event_class_by_id(
-               BT_TO_COMMON(stream_class), id));
+       int64_t id_key = (int64_t) id;
+
+       BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
+       BT_ASSERT_PRE(id_key >= 0,
+               "Invalid event class ID: %" PRIu64, id);
+       return g_hash_table_lookup(stream_class->event_classes_ht,
+                       &id_key);
 }
 
 struct bt_field_type *bt_stream_class_borrow_packet_context_field_type(
                struct bt_stream_class *stream_class)
 {
-       return BT_FROM_COMMON(bt_stream_class_common_borrow_packet_context_field_type(
-               BT_TO_COMMON(stream_class)));
+       BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
+       return stream_class->packet_context_field_type;
 }
 
 int bt_stream_class_set_packet_context_field_type(
                struct bt_stream_class *stream_class,
                struct bt_field_type *packet_context_type)
 {
-       return bt_stream_class_common_set_packet_context_field_type(
-               BT_TO_COMMON(stream_class), (void *) packet_context_type);
+       int ret = 0;
+
+       if (!stream_class) {
+               BT_LOGW_STR("Invalid parameter: stream class is NULL.");
+               ret = -1;
+               goto end;
+       }
+
+       if (stream_class->frozen) {
+               BT_LOGW("Invalid parameter: stream class is frozen: "
+                       "addr=%p, name=\"%s\", id=%" PRId64,
+                       stream_class, bt_stream_class_get_name(stream_class),
+                       bt_stream_class_get_id(stream_class));
+               ret = -1;
+               goto end;
+       }
+
+       if (packet_context_type &&
+                       bt_field_type_get_type_id(packet_context_type) !=
+                               BT_FIELD_TYPE_ID_STRUCT) {
+               /* A packet context must be a structure. */
+               BT_LOGW("Invalid parameter: stream class's packet context field type must be a structure: "
+                       "addr=%p, name=\"%s\", id=%" PRId64 ", "
+                       "packet-context-ft-addr=%p, packet-context-ft-id=%s",
+                       stream_class, bt_stream_class_get_name(stream_class),
+                       bt_stream_class_get_id(stream_class),
+                       packet_context_type,
+                       bt_common_field_type_id_string(
+                               bt_field_type_get_type_id(packet_context_type)));
+               ret = -1;
+               goto end;
+       }
+
+       bt_put(stream_class->packet_context_field_type);
+       bt_get(packet_context_type);
+       stream_class->packet_context_field_type = packet_context_type;
+       BT_LOGV("Set stream class's packet context field type: "
+               "addr=%p, name=\"%s\", id=%" PRId64 ", "
+               "packet-context-ft-addr=%p",
+               stream_class, bt_stream_class_get_name(stream_class),
+               bt_stream_class_get_id(stream_class),
+               packet_context_type);
+
+end:
+       return ret;
 }
 
 struct bt_field_type *bt_stream_class_borrow_event_header_field_type(
                struct bt_stream_class *stream_class)
 {
-       return BT_FROM_COMMON(bt_stream_class_common_borrow_event_header_field_type(
-               BT_TO_COMMON(stream_class)));
+       struct bt_field_type *ret = NULL;
+
+       BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
+
+       if (!stream_class->event_header_field_type) {
+               BT_LOGV("Stream class has no event header field type: "
+                       "addr=%p, name=\"%s\", id=%" PRId64,
+                       stream_class,
+                       bt_stream_class_get_name(stream_class),
+                       bt_stream_class_get_id(stream_class));
+               goto end;
+       }
+
+       ret = stream_class->event_header_field_type;
+
+end:
+       return ret;
 }
 
 int bt_stream_class_set_event_header_field_type(
                struct bt_stream_class *stream_class,
                struct bt_field_type *event_header_type)
 {
-       return bt_stream_class_common_set_event_header_field_type(
-               BT_TO_COMMON(stream_class), (void *) event_header_type);
+       int ret = 0;
+
+       if (!stream_class) {
+               BT_LOGW_STR("Invalid parameter: stream class is NULL.");
+               ret = -1;
+               goto end;
+       }
+
+       if (stream_class->frozen) {
+               BT_LOGW("Invalid parameter: stream class is frozen: "
+                       "addr=%p, name=\"%s\", id=%" PRId64,
+                       stream_class,
+                       bt_stream_class_get_name(stream_class),
+                       bt_stream_class_get_id(stream_class));
+               ret = -1;
+               goto end;
+       }
+
+       if (event_header_type &&
+                       bt_field_type_get_type_id(event_header_type) !=
+                               BT_FIELD_TYPE_ID_STRUCT) {
+               /* An event header must be a structure. */
+               BT_LOGW("Invalid parameter: stream class's event header field type must be a structure: "
+                       "addr=%p, name=\"%s\", id=%" PRId64 ", "
+                       "event-header-ft-addr=%p, event-header-ft-id=%s",
+                       stream_class, bt_stream_class_get_name(stream_class),
+                       bt_stream_class_get_id(stream_class),
+                       event_header_type,
+                       bt_common_field_type_id_string(
+                               bt_field_type_get_type_id(event_header_type)));
+               ret = -1;
+               goto end;
+       }
+
+       bt_put(stream_class->event_header_field_type);
+       stream_class->event_header_field_type = bt_get(event_header_type);
+       BT_LOGV("Set stream class's event header field type: "
+               "addr=%p, name=\"%s\", id=%" PRId64 ", "
+               "event-header-ft-addr=%p",
+               stream_class, bt_stream_class_get_name(stream_class),
+               bt_stream_class_get_id(stream_class),
+               event_header_type);
+end:
+       return ret;
 }
 
 struct bt_field_type *bt_stream_class_borrow_event_context_field_type(
                struct bt_stream_class *stream_class)
 {
-       return BT_FROM_COMMON(bt_stream_class_common_borrow_event_context_field_type(
-               BT_TO_COMMON(stream_class)));
+       struct bt_field_type *ret = NULL;
+
+       BT_ASSERT_PRE_NON_NULL(stream_class, "Stream class");
+
+       if (!stream_class->event_context_field_type) {
+               goto end;
+       }
+
+       ret = stream_class->event_context_field_type;
+
+end:
+       return ret;
 }
 
 int bt_stream_class_set_event_context_field_type(
                struct bt_stream_class *stream_class,
                struct bt_field_type *event_context_type)
 {
-       return bt_stream_class_common_set_event_context_field_type(
-               BT_TO_COMMON(stream_class), (void *) event_context_type);
+       int ret = 0;
+
+       if (!stream_class) {
+               BT_LOGW_STR("Invalid parameter: stream class is NULL.");
+               ret = -1;
+               goto end;
+       }
+
+       if (stream_class->frozen) {
+               BT_LOGW("Invalid parameter: stream class is frozen: "
+                       "addr=%p, name=\"%s\", id=%" PRId64,
+                       stream_class, bt_stream_class_get_name(stream_class),
+                       bt_stream_class_get_id(stream_class));
+               ret = -1;
+               goto end;
+       }
+
+       if (event_context_type &&
+                       bt_field_type_get_type_id(event_context_type) !=
+                               BT_FIELD_TYPE_ID_STRUCT) {
+               /* A packet context must be a structure. */
+               BT_LOGW("Invalid parameter: stream class's event context field type must be a structure: "
+                       "addr=%p, name=\"%s\", id=%" PRId64 ", "
+                       "event-context-ft-addr=%p, event-context-ft-id=%s",
+                       stream_class, bt_stream_class_get_name(stream_class),
+                       bt_stream_class_get_id(stream_class),
+                       event_context_type,
+                       bt_common_field_type_id_string(
+                               bt_field_type_get_type_id(event_context_type)));
+               ret = -1;
+               goto end;
+       }
+
+       bt_put(stream_class->event_context_field_type);
+       stream_class->event_context_field_type = bt_get(event_context_type);
+       BT_LOGV("Set stream class's event context field type: "
+               "addr=%p, name=\"%s\", id=%" PRId64 ", "
+               "event-context-ft-addr=%p",
+               stream_class, bt_stream_class_get_name(stream_class),
+               bt_stream_class_get_id(stream_class),
+               event_context_type);
+end:
+       return ret;
 }
 
 static
@@ -706,7 +916,7 @@ int visit_event_class(void *object, bt_visitor visitor,void *data)
 }
 
 BT_HIDDEN
-int bt_stream_class_common_visit(struct bt_stream_class_common *stream_class,
+int bt_stream_class_visit(struct bt_stream_class *stream_class,
                bt_visitor visitor, void *data)
 {
        int ret;
@@ -732,38 +942,26 @@ end:
        return ret;
 }
 
-int bt_stream_class_visit(struct bt_stream_class *stream_class,
-               bt_visitor visitor, void *data)
-{
-       return bt_stream_class_common_visit(BT_FROM_COMMON(stream_class),
-               visitor, data);
-}
-
 BT_HIDDEN
-void bt_stream_class_common_freeze(struct bt_stream_class_common *stream_class)
+void bt_stream_class_freeze(struct bt_stream_class *stream_class)
 {
        if (!stream_class || stream_class->frozen) {
                return;
        }
 
        BT_LOGD("Freezing stream class: addr=%p, name=\"%s\", id=%" PRId64,
-               stream_class, bt_stream_class_common_get_name(stream_class),
-               bt_stream_class_common_get_id(stream_class));
+               stream_class, bt_stream_class_get_name(stream_class),
+               bt_stream_class_get_id(stream_class));
        stream_class->frozen = 1;
-       bt_field_type_common_freeze(stream_class->event_header_field_type);
-       bt_field_type_common_freeze(stream_class->packet_context_field_type);
-       bt_field_type_common_freeze(stream_class->event_context_field_type);
+       bt_field_type_freeze(stream_class->event_header_field_type);
+       bt_field_type_freeze(stream_class->packet_context_field_type);
+       bt_field_type_freeze(stream_class->event_context_field_type);
        bt_clock_class_freeze(stream_class->clock_class);
 }
 
-void bt_stream_class_freeze(struct bt_stream_class *stream_class)
-{
-       bt_stream_class_common_freeze(BT_TO_COMMON(stream_class));
-}
-
 BT_HIDDEN
-int bt_stream_class_common_validate_single_clock_class(
-               struct bt_stream_class_common *stream_class,
+int bt_stream_class_validate_single_clock_class(
+               struct bt_stream_class *stream_class,
                struct bt_clock_class **expected_clock_class)
 {
        int ret;
@@ -771,7 +969,7 @@ int bt_stream_class_common_validate_single_clock_class(
 
        BT_ASSERT(stream_class);
        BT_ASSERT(expected_clock_class);
-       ret = bt_field_type_common_validate_single_clock_class(
+       ret = bt_field_type_validate_single_clock_class(
                stream_class->packet_context_field_type,
                expected_clock_class);
        if (ret) {
@@ -783,13 +981,13 @@ int bt_stream_class_common_validate_single_clock_class(
                        "stream-class-id=%" PRId64 ", "
                        "ft-addr=%p",
                        stream_class,
-                       bt_stream_class_common_get_name(stream_class),
+                       bt_stream_class_get_name(stream_class),
                        stream_class->id,
                        stream_class->packet_context_field_type);
                goto end;
        }
 
-       ret = bt_field_type_common_validate_single_clock_class(
+       ret = bt_field_type_validate_single_clock_class(
                stream_class->event_header_field_type,
                expected_clock_class);
        if (ret) {
@@ -801,13 +999,13 @@ int bt_stream_class_common_validate_single_clock_class(
                        "stream-class-id=%" PRId64 ", "
                        "ft-addr=%p",
                        stream_class,
-                       bt_stream_class_common_get_name(stream_class),
+                       bt_stream_class_get_name(stream_class),
                        stream_class->id,
                        stream_class->event_header_field_type);
                goto end;
        }
 
-       ret = bt_field_type_common_validate_single_clock_class(
+       ret = bt_field_type_validate_single_clock_class(
                stream_class->event_context_field_type,
                expected_clock_class);
        if (ret) {
@@ -819,18 +1017,18 @@ int bt_stream_class_common_validate_single_clock_class(
                        "stream-class-id=%" PRId64 ", "
                        "ft-addr=%p",
                        stream_class,
-                       bt_stream_class_common_get_name(stream_class),
+                       bt_stream_class_get_name(stream_class),
                        stream_class->id,
                        stream_class->event_context_field_type);
                goto end;
        }
 
        for (i = 0; i < stream_class->event_classes->len; i++) {
-               struct bt_event_class_common *event_class =
+               struct bt_event_class *event_class =
                        g_ptr_array_index(stream_class->event_classes, i);
 
                BT_ASSERT(event_class);
-               ret = bt_event_class_common_validate_single_clock_class(
+               ret = bt_event_class_validate_single_clock_class(
                        event_class, expected_clock_class);
                if (ret) {
                        BT_LOGW("Stream class's event class contains a "
@@ -840,7 +1038,7 @@ int bt_stream_class_common_validate_single_clock_class(
                                "stream-class-name=\"%s\", "
                                "stream-class-id=%" PRId64,
                                stream_class,
-                               bt_stream_class_common_get_name(stream_class),
+                               bt_stream_class_get_name(stream_class),
                                stream_class->id);
                        goto end;
                }
index 2e7c2b4ed309b94634aa854c895f48b7726279f8..61636206015624ab6b53ecc0d5e6901cf2d1d752 100644 (file)
 #include <inttypes.h>
 #include <unistd.h>
 
-BT_HIDDEN
-void bt_stream_common_finalize(struct bt_stream_common *stream)
+static inline
+void bt_stream_finalize(struct bt_stream *stream)
 {
-       BT_LOGD("Finalizing common stream object: addr=%p, name=\"%s\"",
-               stream, bt_stream_common_get_name(stream));
+       BT_LOGD("Finalizing stream object: addr=%p, name=\"%s\"",
+               stream, bt_stream_get_name(stream));
 
        if (stream->name) {
                g_string_free(stream->name, TRUE);
@@ -63,18 +63,18 @@ void bt_stream_destroy(struct bt_object *obj)
        BT_LOGD("Destroying stream object: addr=%p, name=\"%s\"",
                stream, bt_stream_get_name(stream));
        bt_object_pool_finalize(&stream->packet_pool);
-       bt_stream_common_finalize((void *) obj);
+       bt_stream_finalize((void *) obj);
        g_free(stream);
 }
 
-BT_HIDDEN
-int bt_stream_common_initialize(
-               struct bt_stream_common *stream,
-               struct bt_stream_class_common *stream_class, const char *name,
+static inline
+int bt_stream_initialize(
+               struct bt_stream *stream,
+               struct bt_stream_class *stream_class, const char *name,
                uint64_t id, bt_object_release_func release_func)
 {
        int ret = 0;
-       struct bt_trace_common *trace = NULL;
+       struct bt_trace *trace = NULL;
 
        bt_object_init_shared_with_parent(&stream->base, release_func);
 
@@ -83,18 +83,18 @@ int bt_stream_common_initialize(
                goto error;
        }
 
-       BT_LOGD("Initializing common stream object: stream-class-addr=%p, "
+       BT_LOGD("Initializing stream object: stream-class-addr=%p, "
                "stream-class-name=\"%s\", stream-name=\"%s\", "
                "stream-id=%" PRIu64,
-               stream_class, bt_stream_class_common_get_name(stream_class),
+               stream_class, bt_stream_class_get_name(stream_class),
                name, id);
-       trace = bt_stream_class_common_borrow_trace(stream_class);
+       trace = bt_stream_class_borrow_trace(stream_class);
        if (!trace) {
                BT_LOGW("Invalid parameter: cannot create stream from a stream class which is not part of trace: "
                        "stream-class-addr=%p, stream-class-name=\"%s\", "
                        "stream-name=\"%s\"",
                        stream_class,
-                       bt_stream_class_common_get_name(stream_class), name);
+                       bt_stream_class_get_name(stream_class), name);
                goto error;
        }
 
@@ -107,7 +107,7 @@ int bt_stream_common_initialize(
                size_t i;
 
                for (i = 0; i < trace->streams->len; i++) {
-                       struct bt_stream_common *trace_stream =
+                       struct bt_stream *trace_stream =
                                g_ptr_array_index(trace->streams, i);
 
                        if (trace_stream->stream_class != (void *) stream_class) {
@@ -137,10 +137,10 @@ int bt_stream_common_initialize(
                }
        }
 
-       BT_LOGD("Set common stream's trace parent: trace-addr=%p", trace);
+       BT_LOGD("Set stream's trace parent: trace-addr=%p", trace);
 
        /* Add this stream to the trace's streams */
-       BT_LOGD("Created common stream object: addr=%p", stream);
+       BT_LOGD("Created stream object: addr=%p", stream);
        goto end;
 
 error:
@@ -171,8 +171,7 @@ struct bt_stream *bt_stream_create_with_id_no_check(
                stream_class, bt_stream_class_get_name(stream_class),
                name, id);
 
-       trace = BT_FROM_COMMON(bt_stream_class_common_borrow_trace(
-               BT_TO_COMMON(stream_class)));
+       trace = bt_stream_class_borrow_trace(stream_class);
        if (!trace) {
                BT_LOGW("Invalid parameter: cannot create stream from a stream class which is not part of trace: "
                        "stream-class-addr=%p, stream-class-name=\"%s\", "
@@ -202,10 +201,10 @@ struct bt_stream *bt_stream_create_with_id_no_check(
                goto error;
        }
 
-       ret = bt_stream_common_initialize(BT_TO_COMMON(stream),
-               BT_TO_COMMON(stream_class), name, id, bt_stream_destroy);
+       ret = bt_stream_initialize(stream, stream_class, name,
+               id, bt_stream_destroy);
        if (ret) {
-               /* bt_stream_common_initialize() logs errors */
+               /* bt_stream_initialize() logs errors */
                goto error;
        }
 
@@ -218,7 +217,7 @@ struct bt_stream *bt_stream_create_with_id_no_check(
                goto error;
        }
 
-       g_ptr_array_add(trace->common.streams, stream);
+       g_ptr_array_add(trace->streams, stream);
        BT_LOGD("Created stream object: addr=%p", stream);
        goto end;
 
@@ -256,15 +255,26 @@ end:
 
 struct bt_stream_class *bt_stream_borrow_class(struct bt_stream *stream)
 {
-       return BT_FROM_COMMON(bt_stream_common_borrow_class(BT_TO_COMMON(stream)));
+       BT_ASSERT(stream);
+       return stream->stream_class;
 }
 
 const char *bt_stream_get_name(struct bt_stream *stream)
 {
-       return bt_stream_common_get_name(BT_TO_COMMON(stream));
+       BT_ASSERT_PRE_NON_NULL(stream, "Stream");
+       return stream->name ? stream->name->str : NULL;
 }
 
 int64_t bt_stream_get_id(struct bt_stream *stream)
 {
-       return bt_stream_common_get_id(BT_TO_COMMON(stream));
+       int64_t ret;
+
+       BT_ASSERT_PRE_NON_NULL(stream, "Stream");
+       ret = stream->id;
+       if (ret < 0) {
+               BT_LOGV("Stream's ID is not set: addr=%p, name=\"%s\"",
+                       stream, bt_stream_get_name(stream));
+       }
+
+       return ret;
 }
index c9a588fbe063fb6170064a84801479a035e87cb0..57a3769bc4c4b6ea33eaebf88aac04fe5d36aefe 100644 (file)
@@ -72,6 +72,40 @@ struct bt_trace_is_static_listener_elem {
        void *data;
 };
 
+static inline
+void bt_trace_finalize(struct bt_trace *trace)
+{
+       BT_LOGD("Finalizing trace object: addr=%p, name=\"%s\"",
+               trace, bt_trace_get_name(trace));
+
+       if (trace->environment) {
+               BT_LOGD_STR("Destroying environment attributes.");
+               bt_attributes_destroy(trace->environment);
+       }
+
+       if (trace->name) {
+               g_string_free(trace->name, TRUE);
+       }
+
+       if (trace->clock_classes) {
+               BT_LOGD_STR("Putting clock classes.");
+               g_ptr_array_free(trace->clock_classes, TRUE);
+       }
+
+       if (trace->streams) {
+               BT_LOGD_STR("Destroying streams.");
+               g_ptr_array_free(trace->streams, TRUE);
+       }
+
+       if (trace->stream_classes) {
+               BT_LOGD_STR("Destroying stream classes.");
+               g_ptr_array_free(trace->stream_classes, TRUE);
+       }
+
+       BT_LOGD_STR("Putting packet header field type.");
+       bt_put(trace->packet_header_field_type);
+}
+
 static
 void bt_trace_destroy(struct bt_object *obj)
 {
@@ -105,17 +139,17 @@ void bt_trace_destroy(struct bt_object *obj)
        }
 
        bt_object_pool_finalize(&trace->packet_header_field_pool);
-       bt_trace_common_finalize(BT_TO_COMMON(trace));
+       bt_trace_finalize(trace);
        g_free(trace);
 }
 
-BT_HIDDEN
-int bt_trace_common_initialize(struct bt_trace_common *trace,
+static inline
+int bt_trace_initialize(struct bt_trace *trace,
                bt_object_release_func release_func)
 {
        int ret = 0;
 
-       BT_LOGD_STR("Initializing common trace object.");
+       BT_LOGD_STR("Initializing trace object.");
        trace->native_byte_order = BT_BYTE_ORDER_UNSPECIFIED;
        bt_object_init_shared_with_parent(&trace->base, release_func);
        trace->clock_classes = g_ptr_array_new_with_free_func(
@@ -146,7 +180,7 @@ int bt_trace_common_initialize(struct bt_trace_common *trace,
                goto error;
        }
 
-       BT_LOGD("Initialized common trace object: addr=%p", trace);
+       BT_LOGD("Initialized trace object: addr=%p", trace);
        goto end;
 
 error:
@@ -156,40 +190,6 @@ end:
        return ret;
 }
 
-BT_HIDDEN
-void bt_trace_common_finalize(struct bt_trace_common *trace)
-{
-       BT_LOGD("Finalizing common trace object: addr=%p, name=\"%s\"",
-               trace, bt_trace_common_get_name(trace));
-
-       if (trace->environment) {
-               BT_LOGD_STR("Destroying environment attributes.");
-               bt_attributes_destroy(trace->environment);
-       }
-
-       if (trace->name) {
-               g_string_free(trace->name, TRUE);
-       }
-
-       if (trace->clock_classes) {
-               BT_LOGD_STR("Putting clock classes.");
-               g_ptr_array_free(trace->clock_classes, TRUE);
-       }
-
-       if (trace->streams) {
-               BT_LOGD_STR("Destroying streams.");
-               g_ptr_array_free(trace->streams, TRUE);
-       }
-
-       if (trace->stream_classes) {
-               BT_LOGD_STR("Destroying stream classes.");
-               g_ptr_array_free(trace->stream_classes, TRUE);
-       }
-
-       BT_LOGD_STR("Putting packet header field type.");
-       bt_put(trace->packet_header_field_type);
-}
-
 static
 void free_packet_header_field(struct bt_field_wrapper *field_wrapper,
                struct bt_trace *trace)
@@ -209,9 +209,9 @@ struct bt_trace *bt_trace_create(void)
                goto error;
        }
 
-       ret = bt_trace_common_initialize(BT_TO_COMMON(trace), bt_trace_destroy);
+       ret = bt_trace_initialize(trace, bt_trace_destroy);
        if (ret) {
-               /* bt_trace_common_initialize() logs errors */
+               /* bt_trace_initialize() logs errors */
                goto error;
        }
 
@@ -249,11 +249,11 @@ error:
 
 const char *bt_trace_get_name(struct bt_trace *trace)
 {
-       return bt_trace_common_get_name(BT_TO_COMMON(trace));
+       BT_ASSERT_PRE_NON_NULL(trace, "Trace");
+       return trace->name ? trace->name->str : NULL;
 }
 
-BT_HIDDEN
-int bt_trace_common_set_name(struct bt_trace_common *trace, const char *name)
+int bt_trace_set_name(struct bt_trace *trace, const char *name)
 {
        int ret = 0;
 
@@ -272,7 +272,7 @@ int bt_trace_common_set_name(struct bt_trace_common *trace, const char *name)
        if (trace->frozen) {
                BT_LOGW("Invalid parameter: trace is frozen: "
                        "addr=%p, name=\"%s\"",
-                       trace, bt_trace_common_get_name(trace));
+                       trace, bt_trace_get_name(trace));
                ret = -1;
                goto end;
        }
@@ -291,18 +291,13 @@ end:
        return ret;
 }
 
-int bt_trace_set_name(struct bt_trace *trace, const char *name)
-{
-       return bt_trace_common_set_name(BT_TO_COMMON(trace), name);
-}
-
 const unsigned char *bt_trace_get_uuid(struct bt_trace *trace)
 {
-       return bt_trace_common_get_uuid(BT_TO_COMMON(trace));
+       BT_ASSERT_PRE_NON_NULL(trace, "Trace");
+       return trace->uuid_set ? trace->uuid : NULL;
 }
 
-BT_HIDDEN
-int bt_trace_common_set_uuid(struct bt_trace_common *trace,
+int bt_trace_set_uuid(struct bt_trace *trace,
                const unsigned char *uuid)
 {
        int ret = 0;
@@ -322,7 +317,7 @@ int bt_trace_common_set_uuid(struct bt_trace_common *trace,
        if (trace->frozen) {
                BT_LOGW("Invalid parameter: trace is frozen: "
                        "addr=%p, name=\"%s\"",
-                       trace, bt_trace_common_get_name(trace));
+                       trace, bt_trace_get_name(trace));
                ret = -1;
                goto end;
        }
@@ -331,7 +326,7 @@ int bt_trace_common_set_uuid(struct bt_trace_common *trace,
        trace->uuid_set = BT_TRUE;
        BT_LOGV("Set trace's UUID: addr=%p, name=\"%s\", "
                "uuid=\"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\"",
-               trace, bt_trace_common_get_name(trace),
+               trace, bt_trace_get_name(trace),
                (unsigned int) uuid[0],
                (unsigned int) uuid[1],
                (unsigned int) uuid[2],
@@ -353,14 +348,7 @@ end:
        return ret;
 }
 
-int bt_trace_set_uuid(struct bt_trace *trace,
-               const unsigned char *uuid)
-{
-       return bt_trace_common_set_uuid(BT_TO_COMMON(trace), uuid);
-}
-
-BT_HIDDEN
-int bt_trace_common_set_environment_field(struct bt_trace_common *trace,
+int bt_trace_set_environment_field(struct bt_trace *trace,
                const char *name, struct bt_value *value)
 {
        int ret = 0;
@@ -383,11 +371,19 @@ int bt_trace_common_set_environment_field(struct bt_trace_common *trace,
                goto end;
        }
 
+       if (trace->is_static) {
+               BT_LOGW("Invalid parameter: trace is static: "
+                       "addr=%p, name=\"%s\"",
+                       trace, bt_trace_get_name(trace));
+               ret = -1;
+               goto end;
+       }
+
        if (!bt_identifier_is_valid(name)) {
                BT_LOGW("Invalid parameter: environment field's name is not a valid CTF identifier: "
                        "trace-addr=%p, trace-name=\"%s\", "
                        "env-name=\"%s\"",
-                       trace, bt_trace_common_get_name(trace), name);
+                       trace, bt_trace_get_name(trace), name);
                ret = -1;
                goto end;
        }
@@ -396,7 +392,7 @@ int bt_trace_common_set_environment_field(struct bt_trace_common *trace,
                BT_LOGW("Invalid parameter: environment field's value is not an integer or string value: "
                        "trace-addr=%p, trace-name=\"%s\", "
                        "env-name=\"%s\", env-value-type=%s",
-                       trace, bt_trace_common_get_name(trace), name,
+                       trace, bt_trace_get_name(trace), name,
                        bt_value_type_string(bt_value_get_type(value)));
                ret = -1;
                goto end;
@@ -417,7 +413,7 @@ int bt_trace_common_set_environment_field(struct bt_trace_common *trace,
                        BT_LOGW("Invalid parameter: trace is frozen and environment field already exists with this name: "
                                "trace-addr=%p, trace-name=\"%s\", "
                                "env-name=\"%s\"",
-                               trace, bt_trace_common_get_name(trace), name);
+                               trace, bt_trace_get_name(trace), name);
                        ret = -1;
                        goto end;
                }
@@ -431,40 +427,19 @@ int bt_trace_common_set_environment_field(struct bt_trace_common *trace,
                BT_LOGE("Cannot set environment field's value: "
                        "trace-addr=%p, trace-name=\"%s\", "
                        "env-name=\"%s\"",
-                       trace, bt_trace_common_get_name(trace), name);
+                       trace, bt_trace_get_name(trace), name);
        } else {
                BT_LOGV("Set environment field's value: "
                        "trace-addr=%p, trace-name=\"%s\", "
                        "env-name=\"%s\", value-addr=%p",
-                       trace, bt_trace_common_get_name(trace), name, value);
+                       trace, bt_trace_get_name(trace), name, value);
        }
 
 end:
        return ret;
 }
 
-int bt_trace_set_environment_field(struct bt_trace *trace,
-               const char *name, struct bt_value *value)
-{
-       int ret;
-
-       if (trace->is_static) {
-               BT_LOGW("Invalid parameter: trace is static: "
-                       "addr=%p, name=\"%s\"",
-                       trace, bt_trace_get_name(trace));
-               ret = -1;
-               goto end;
-       }
-
-       ret = bt_trace_common_set_environment_field(BT_TO_COMMON(trace),
-               name, value);
-
-end:
-       return ret;
-}
-
-BT_HIDDEN
-int bt_trace_common_set_environment_field_string(struct bt_trace_common *trace,
+int bt_trace_set_environment_field_string(struct bt_trace *trace,
                const char *name, const char *value)
 {
        int ret = 0;
@@ -483,8 +458,8 @@ int bt_trace_common_set_environment_field_string(struct bt_trace_common *trace,
                goto end;
        }
 
-       /* bt_trace_common_set_environment_field() logs errors */
-       ret = bt_trace_common_set_environment_field(trace, name,
+       /* bt_trace_set_environment_field() logs errors */
+       ret = bt_trace_set_environment_field(trace, name,
                env_value_string_obj);
 
 end:
@@ -492,16 +467,8 @@ end:
        return ret;
 }
 
-int bt_trace_set_environment_field_string(struct bt_trace *trace,
-               const char *name, const char *value)
-{
-       return bt_trace_common_set_environment_field_string(BT_TO_COMMON(trace),
-               name, value);
-}
-
-BT_HIDDEN
-int bt_trace_common_set_environment_field_integer(
-               struct bt_trace_common *trace, const char *name, int64_t value)
+int bt_trace_set_environment_field_integer(
+               struct bt_trace *trace, const char *name, int64_t value)
 {
        int ret = 0;
        struct bt_value *env_value_integer_obj = NULL;
@@ -513,8 +480,8 @@ int bt_trace_common_set_environment_field_integer(
                goto end;
        }
 
-       /* bt_trace_common_set_environment_field() logs errors */
-       ret = bt_trace_common_set_environment_field(trace, name,
+       /* bt_trace_set_environment_field() logs errors */
+       ret = bt_trace_set_environment_field(trace, name,
                env_value_integer_obj);
 
 end:
@@ -522,42 +489,41 @@ end:
        return ret;
 }
 
-int bt_trace_set_environment_field_integer(
-               struct bt_trace *trace, const char *name, int64_t value)
-{
-       return bt_trace_common_set_environment_field_integer(
-               BT_TO_COMMON(trace), name, value);
-}
-
 int64_t bt_trace_get_environment_field_count(struct bt_trace *trace)
 {
-       return bt_trace_common_get_environment_field_count(BT_TO_COMMON(trace));
+       int64_t ret;
+
+       BT_ASSERT_PRE_NON_NULL(trace, "Trace");
+       ret = bt_attributes_get_count(trace->environment);
+       BT_ASSERT(ret >= 0);
+       return ret;
 }
 
 const char *
 bt_trace_get_environment_field_name_by_index(struct bt_trace *trace,
                uint64_t index)
 {
-       return bt_trace_common_get_environment_field_name_by_index(
-               BT_TO_COMMON(trace), index);
+       BT_ASSERT_PRE_NON_NULL(trace, "Trace");
+       return bt_attributes_get_field_name(trace->environment, index);
 }
 
 struct bt_value *bt_trace_borrow_environment_field_value_by_index(
                struct bt_trace *trace, uint64_t index)
 {
-       return bt_trace_common_borrow_environment_field_value_by_index(
-               BT_TO_COMMON(trace), index);
+       BT_ASSERT_PRE_NON_NULL(trace, "Trace");
+       return bt_attributes_borrow_field_value(trace->environment, index);
 }
 
 struct bt_value *bt_trace_borrow_environment_field_value_by_name(
                struct bt_trace *trace, const char *name)
 {
-       return bt_trace_common_borrow_environment_field_value_by_name(
-               BT_TO_COMMON(trace), name);
+       BT_ASSERT_PRE_NON_NULL(trace, "Trace");
+       BT_ASSERT_PRE_NON_NULL(name, "Name");
+       return bt_attributes_borrow_field_value_by_name(trace->environment,
+               name);
 }
 
-BT_HIDDEN
-int bt_trace_common_add_clock_class(struct bt_trace_common *trace,
+int bt_trace_add_clock_class(struct bt_trace *trace,
                struct bt_clock_class *clock_class)
 {
        int ret = 0;
@@ -568,22 +534,30 @@ int bt_trace_common_add_clock_class(struct bt_trace_common *trace,
                goto end;
        }
 
+       if (trace->is_static) {
+               BT_LOGW("Invalid parameter: trace is static: "
+                       "addr=%p, name=\"%s\"",
+                       trace, bt_trace_get_name(trace));
+               ret = -1;
+               goto end;
+       }
+
        if (!bt_clock_class_is_valid(clock_class)) {
                BT_LOGW("Invalid parameter: clock class is invalid: "
                        "trace-addr=%p, trace-name=\"%s\", "
                        "clock-class-addr=%p, clock-class-name=\"%s\"",
-                       trace, bt_trace_common_get_name(trace),
+                       trace, bt_trace_get_name(trace),
                        clock_class, bt_clock_class_get_name(clock_class));
                ret = -1;
                goto end;
        }
 
        /* Check for duplicate clock classes */
-       if (bt_trace_common_has_clock_class(trace, clock_class)) {
+       if (bt_trace_has_clock_class(trace, clock_class)) {
                BT_LOGW("Invalid parameter: clock class already exists in trace: "
                        "trace-addr=%p, trace-name=\"%s\", "
                        "clock-class-addr=%p, clock-class-name=\"%s\"",
-                       trace, bt_trace_common_get_name(trace),
+                       trace, bt_trace_get_name(trace),
                        clock_class, bt_clock_class_get_name(clock_class));
                ret = -1;
                goto end;
@@ -600,52 +574,37 @@ int bt_trace_common_add_clock_class(struct bt_trace_common *trace,
        BT_LOGV("Added clock class to trace: "
                "trace-addr=%p, trace-name=\"%s\", "
                "clock-class-addr=%p, clock-class-name=\"%s\"",
-               trace, bt_trace_common_get_name(trace),
+               trace, bt_trace_get_name(trace),
                clock_class, bt_clock_class_get_name(clock_class));
 
 end:
        return ret;
 }
 
-int bt_trace_add_clock_class(struct bt_trace *trace,
-               struct bt_clock_class *clock_class)
-{
-       int ret;
-
-       if (trace->is_static) {
-               BT_LOGW("Invalid parameter: trace is static: "
-                       "addr=%p, name=\"%s\"",
-                       trace, bt_trace_get_name(trace));
-               ret = -1;
-               goto end;
-       }
-
-       ret = bt_trace_common_add_clock_class(BT_TO_COMMON(trace),
-               clock_class);
-
-end:
-       return ret;
-}
-
 int64_t bt_trace_get_clock_class_count(struct bt_trace *trace)
 {
-       return bt_trace_common_get_clock_class_count(BT_TO_COMMON(trace));
+       BT_ASSERT_PRE_NON_NULL(trace, "Trace");
+       return trace->clock_classes->len;
 }
 
 struct bt_clock_class *bt_trace_borrow_clock_class_by_index(
                struct bt_trace *trace, uint64_t index)
 {
-       return bt_trace_common_borrow_clock_class_by_index(
-               BT_TO_COMMON(trace), index);
+       BT_ASSERT_PRE_NON_NULL(trace, "Trace");
+       BT_ASSERT_PRE(index < trace->clock_classes->len,
+               "Index is out of bounds: index=%" PRIu64 ", "
+               "count=%u",
+               index, trace->clock_classes->len);
+       return g_ptr_array_index(trace->clock_classes, index);
 }
 
 static
-bool packet_header_field_type_is_valid(struct bt_trace_common *trace,
-               struct bt_field_type_common *packet_header_type)
+bool packet_header_field_type_is_valid(struct bt_trace *trace,
+               struct bt_field_type *packet_header_type)
 {
        int ret;
        bool is_valid = true;
-       struct bt_field_type_common *field_type = NULL;
+       struct bt_field_type *field_type = NULL;
 
        if (!packet_header_type) {
                /*
@@ -678,7 +637,7 @@ bool packet_header_field_type_is_valid(struct bt_trace_common *trace,
         * integer field type. Also it must be the first field of the
         * packet header field type.
         */
-       field_type = bt_field_type_common_structure_borrow_field_type_by_name(
+       field_type = bt_field_type_structure_borrow_field_type_by_name(
                packet_header_type, "magic");
        if (field_type) {
                const char *field_name;
@@ -691,21 +650,21 @@ bool packet_header_field_type_is_valid(struct bt_trace_common *trace,
                        goto invalid;
                }
 
-               if (bt_field_type_common_integer_is_signed(field_type)) {
+               if (bt_field_type_integer_is_signed(field_type)) {
                        BT_LOGW("Invalid packet header field type: `magic` field must be an unsigned integer field type: "
                                "magic-ft-addr=%p", field_type);
                        goto invalid;
                }
 
-               if (bt_field_type_common_integer_get_size(field_type) != 32) {
+               if (bt_field_type_integer_get_size(field_type) != 32) {
                        BT_LOGW("Invalid packet header field type: `magic` field must be a 32-bit unsigned integer field type: "
                                "magic-ft-addr=%p, magic-ft-size=%u",
                                field_type,
-                               bt_field_type_common_integer_get_size(field_type));
+                               bt_field_type_integer_get_size(field_type));
                        goto invalid;
                }
 
-               ret = bt_field_type_common_structure_borrow_field_by_index(
+               ret = bt_field_type_structure_borrow_field_by_index(
                        packet_header_type, &field_name, NULL, 0);
                BT_ASSERT(ret == 0);
 
@@ -721,10 +680,10 @@ bool packet_header_field_type_is_valid(struct bt_trace_common *trace,
         * If there's a `uuid` field, it must be an array field type of
         * length 16 with an 8-bit unsigned integer element field type.
         */
-       field_type = bt_field_type_common_structure_borrow_field_type_by_name(
+       field_type = bt_field_type_structure_borrow_field_type_by_name(
                packet_header_type, "uuid");
        if (field_type) {
-               struct bt_field_type_common *elem_ft;
+               struct bt_field_type *elem_ft;
 
                if (field_type->id != BT_FIELD_TYPE_ID_ARRAY) {
                        BT_LOGW("Invalid packet header field type: `uuid` field must be an array field type: "
@@ -734,15 +693,15 @@ bool packet_header_field_type_is_valid(struct bt_trace_common *trace,
                        goto invalid;
                }
 
-               if (bt_field_type_common_array_get_length(field_type) != 16) {
+               if (bt_field_type_array_get_length(field_type) != 16) {
                        BT_LOGW("Invalid packet header field type: `uuid` array field type's length must be 16: "
                                "uuid-ft-addr=%p, uuid-ft-length=%" PRId64,
                                field_type,
-                               bt_field_type_common_array_get_length(field_type));
+                               bt_field_type_array_get_length(field_type));
                        goto invalid;
                }
 
-               elem_ft = bt_field_type_common_array_borrow_element_field_type(field_type);
+               elem_ft = bt_field_type_array_borrow_element_field_type(field_type);
                BT_ASSERT(elem_ft);
 
                if (elem_ft->id != BT_FIELD_TYPE_ID_INTEGER) {
@@ -753,17 +712,17 @@ bool packet_header_field_type_is_valid(struct bt_trace_common *trace,
                        goto invalid;
                }
 
-               if (bt_field_type_common_integer_is_signed(elem_ft)) {
+               if (bt_field_type_integer_is_signed(elem_ft)) {
                        BT_LOGW("Invalid packet header field type: `uuid` field's element field type must be an unsigned integer field type: "
                                "elem-ft-addr=%p", elem_ft);
                        goto invalid;
                }
 
-               if (bt_field_type_common_integer_get_size(elem_ft) != 8) {
+               if (bt_field_type_integer_get_size(elem_ft) != 8) {
                        BT_LOGW("Invalid packet header field type: `uuid` field's element field type must be an 8-bit unsigned integer field type: "
                                "elem-ft-addr=%p, elem-ft-size=%u",
                                elem_ft,
-                               bt_field_type_common_integer_get_size(elem_ft));
+                               bt_field_type_integer_get_size(elem_ft));
                        goto invalid;
                }
        }
@@ -772,7 +731,7 @@ bool packet_header_field_type_is_valid(struct bt_trace_common *trace,
         * The `stream_id` field must exist if there's more than one
         * stream classes in the trace.
         */
-       field_type = bt_field_type_common_structure_borrow_field_type_by_name(
+       field_type = bt_field_type_structure_borrow_field_type_by_name(
                packet_header_type, "stream_id");
 
        if (!field_type && trace->stream_classes->len >= 1) {
@@ -794,7 +753,7 @@ bool packet_header_field_type_is_valid(struct bt_trace_common *trace,
                        goto invalid;
                }
 
-               if (bt_field_type_common_integer_is_signed(field_type)) {
+               if (bt_field_type_integer_is_signed(field_type)) {
                        BT_LOGW("Invalid packet header field type: `stream_id` field must be an unsigned integer field type: "
                                "stream-id-ft-addr=%p", field_type);
                        goto invalid;
@@ -805,7 +764,7 @@ bool packet_header_field_type_is_valid(struct bt_trace_common *trace,
         * If there's a `packet_seq_num` field, it must be an unsigned
         * integer field type.
         */
-       field_type = bt_field_type_common_structure_borrow_field_type_by_name(
+       field_type = bt_field_type_structure_borrow_field_type_by_name(
                packet_header_type, "packet_seq_num");
        if (field_type) {
                if (field_type->id != BT_FIELD_TYPE_ID_INTEGER) {
@@ -816,7 +775,7 @@ bool packet_header_field_type_is_valid(struct bt_trace_common *trace,
                        goto invalid;
                }
 
-               if (bt_field_type_common_integer_is_signed(field_type)) {
+               if (bt_field_type_integer_is_signed(field_type)) {
                        BT_LOGW("Invalid packet header field type: `packet_seq_num` field must be an unsigned integer field type: "
                                "packet-seq-num-ft-addr=%p", field_type);
                        goto invalid;
@@ -833,13 +792,13 @@ end:
 }
 
 static
-bool packet_context_field_type_is_valid(struct bt_trace_common *trace,
-               struct bt_stream_class_common *stream_class,
-               struct bt_field_type_common *packet_context_type,
+bool packet_context_field_type_is_valid(struct bt_trace *trace,
+               struct bt_stream_class *stream_class,
+               struct bt_field_type *packet_context_type,
                bool check_ts_begin_end_mapped)
 {
        bool is_valid = true;
-       struct bt_field_type_common *field_type = NULL;
+       struct bt_field_type *field_type = NULL;
 
        if (!packet_context_type) {
                /* No packet context field type: valid at this point */
@@ -859,7 +818,7 @@ bool packet_context_field_type_is_valid(struct bt_trace_common *trace,
         * If there's a `packet_size` field, it must be an unsigned
         * integer field type.
         */
-       field_type = bt_field_type_common_structure_borrow_field_type_by_name(
+       field_type = bt_field_type_structure_borrow_field_type_by_name(
                packet_context_type, "packet_size");
        if (field_type) {
                if (field_type->id != BT_FIELD_TYPE_ID_INTEGER) {
@@ -870,7 +829,7 @@ bool packet_context_field_type_is_valid(struct bt_trace_common *trace,
                        goto invalid;
                }
 
-               if (bt_field_type_common_integer_is_signed(field_type)) {
+               if (bt_field_type_integer_is_signed(field_type)) {
                        BT_LOGW("Invalid packet context field type: `packet_size` field must be an unsigned integer field type: "
                                "packet-size-ft-addr=%p", field_type);
                        goto invalid;
@@ -881,7 +840,7 @@ bool packet_context_field_type_is_valid(struct bt_trace_common *trace,
         * If there's a `content_size` field, it must be an unsigned
         * integer field type.
         */
-       field_type = bt_field_type_common_structure_borrow_field_type_by_name(
+       field_type = bt_field_type_structure_borrow_field_type_by_name(
                packet_context_type, "content_size");
        if (field_type) {
                if (field_type->id != BT_FIELD_TYPE_ID_INTEGER) {
@@ -892,7 +851,7 @@ bool packet_context_field_type_is_valid(struct bt_trace_common *trace,
                        goto invalid;
                }
 
-               if (bt_field_type_common_integer_is_signed(field_type)) {
+               if (bt_field_type_integer_is_signed(field_type)) {
                        BT_LOGW("Invalid packet context field type: `content_size` field must be an unsigned integer field type: "
                                "content-size-ft-addr=%p", field_type);
                        goto invalid;
@@ -903,7 +862,7 @@ bool packet_context_field_type_is_valid(struct bt_trace_common *trace,
         * If there's a `events_discarded` field, it must be an unsigned
         * integer field type.
         */
-       field_type = bt_field_type_common_structure_borrow_field_type_by_name(
+       field_type = bt_field_type_structure_borrow_field_type_by_name(
                packet_context_type, "events_discarded");
        if (field_type) {
                if (field_type->id != BT_FIELD_TYPE_ID_INTEGER) {
@@ -914,7 +873,7 @@ bool packet_context_field_type_is_valid(struct bt_trace_common *trace,
                        goto invalid;
                }
 
-               if (bt_field_type_common_integer_is_signed(field_type)) {
+               if (bt_field_type_integer_is_signed(field_type)) {
                        BT_LOGW("Invalid packet context field type: `events_discarded` field must be an unsigned integer field type: "
                                "events-discarded-ft-addr=%p", field_type);
                        goto invalid;
@@ -927,7 +886,7 @@ bool packet_context_field_type_is_valid(struct bt_trace_common *trace,
         * trace, then we cannot automatically set the mapped clock
         * class of this field, so it must have a mapped clock class.
         */
-       field_type = bt_field_type_common_structure_borrow_field_type_by_name(
+       field_type = bt_field_type_structure_borrow_field_type_by_name(
                packet_context_type, "timestamp_begin");
        if (field_type) {
                if (field_type->id != BT_FIELD_TYPE_ID_INTEGER) {
@@ -938,7 +897,7 @@ bool packet_context_field_type_is_valid(struct bt_trace_common *trace,
                        goto invalid;
                }
 
-               if (bt_field_type_common_integer_is_signed(field_type)) {
+               if (bt_field_type_integer_is_signed(field_type)) {
                        BT_LOGW("Invalid packet context field type: `timestamp_begin` field must be an unsigned integer field type: "
                                "timestamp-begin-ft-addr=%p", field_type);
                        goto invalid;
@@ -946,7 +905,7 @@ bool packet_context_field_type_is_valid(struct bt_trace_common *trace,
 
                if (check_ts_begin_end_mapped) {
                        struct bt_clock_class *clock_class =
-                               bt_field_type_common_integer_borrow_mapped_clock_class(
+                               bt_field_type_integer_borrow_mapped_clock_class(
                                        field_type);
 
                        if (!clock_class) {
@@ -963,7 +922,7 @@ bool packet_context_field_type_is_valid(struct bt_trace_common *trace,
         * trace, then we cannot automatically set the mapped clock
         * class of this field, so it must have a mapped clock class.
         */
-       field_type = bt_field_type_common_structure_borrow_field_type_by_name(
+       field_type = bt_field_type_structure_borrow_field_type_by_name(
                packet_context_type, "timestamp_end");
        if (field_type) {
                if (field_type->id != BT_FIELD_TYPE_ID_INTEGER) {
@@ -974,7 +933,7 @@ bool packet_context_field_type_is_valid(struct bt_trace_common *trace,
                        goto invalid;
                }
 
-               if (bt_field_type_common_integer_is_signed(field_type)) {
+               if (bt_field_type_integer_is_signed(field_type)) {
                        BT_LOGW("Invalid packet context field type: `timestamp_end` field must be an unsigned integer field type: "
                                "timestamp-end-ft-addr=%p", field_type);
                        goto invalid;
@@ -982,7 +941,7 @@ bool packet_context_field_type_is_valid(struct bt_trace_common *trace,
 
                if (check_ts_begin_end_mapped) {
                        struct bt_clock_class *clock_class =
-                               bt_field_type_common_integer_borrow_mapped_clock_class(
+                               bt_field_type_integer_borrow_mapped_clock_class(
                                        field_type);
 
                        if (!clock_class) {
@@ -1003,12 +962,12 @@ end:
 }
 
 static
-bool event_header_field_type_is_valid(struct bt_trace_common *trace,
-               struct bt_stream_class_common *stream_class,
-               struct bt_field_type_common *event_header_type)
+bool event_header_field_type_is_valid(struct bt_trace *trace,
+               struct bt_stream_class *stream_class,
+               struct bt_field_type *event_header_type)
 {
        bool is_valid = true;
-       struct bt_field_type_common *field_type = NULL;
+       struct bt_field_type *field_type = NULL;
 
        /*
         * We do not validate that the `timestamp` field exists here
@@ -1021,7 +980,7 @@ bool event_header_field_type_is_valid(struct bt_trace_common *trace,
                 * No event header field type: stream class must have
                 * only one event class.
                 */
-               if (bt_stream_class_common_get_event_class_count(stream_class) > 1) {
+               if (bt_stream_class_get_event_class_count(stream_class) > 1) {
                        BT_LOGW_STR("Invalid event header field type: "
                                "event header field type does not exist but there's more than one event class in the stream class.");
                        goto invalid;
@@ -1045,15 +1004,15 @@ bool event_header_field_type_is_valid(struct bt_trace_common *trace,
         * field type or an enumeration field type with an unsigned
         * integer container field type.
         */
-       field_type = bt_field_type_common_structure_borrow_field_type_by_name(
+       field_type = bt_field_type_structure_borrow_field_type_by_name(
                event_header_type, "id");
        if (field_type) {
-               struct bt_field_type_common *int_ft;
+               struct bt_field_type *int_ft;
 
                if (field_type->id == BT_FIELD_TYPE_ID_INTEGER) {
                        int_ft = field_type;
                } else if (field_type->id == BT_FIELD_TYPE_ID_ENUM) {
-                       int_ft = bt_field_type_common_enumeration_borrow_container_field_type(
+                       int_ft = bt_field_type_enumeration_borrow_container_field_type(
                                field_type);
                } else {
                        BT_LOGW("Invalid event header field type: `id` field must be an integer or enumeration field type: "
@@ -1064,7 +1023,7 @@ bool event_header_field_type_is_valid(struct bt_trace_common *trace,
                }
 
                BT_ASSERT(int_ft);
-               if (bt_field_type_common_integer_is_signed(int_ft)) {
+               if (bt_field_type_integer_is_signed(int_ft)) {
                        BT_LOGW("Invalid event header field type: `id` field must be an unsigned integer or enumeration field type: "
                                "id-ft-addr=%p", int_ft);
                        goto invalid;
@@ -1081,14 +1040,14 @@ end:
 }
 
 static
-int check_packet_header_type_has_no_clock_class(struct bt_trace_common *trace)
+int check_packet_header_type_has_no_clock_class(struct bt_trace *trace)
 {
        int ret = 0;
 
        if (trace->packet_header_field_type) {
                struct bt_clock_class *clock_class = NULL;
 
-               ret = bt_field_type_common_validate_single_clock_class(
+               ret = bt_field_type_validate_single_clock_class(
                        trace->packet_header_field_type,
                        &clock_class);
                bt_put(clock_class);
@@ -1098,7 +1057,7 @@ int check_packet_header_type_has_no_clock_class(struct bt_trace_common *trace)
                                "a clock class: "
                                "trace-addr=%p, trace-name=\"%s\", "
                                "clock-class-name=\"%s\"",
-                               trace, bt_trace_common_get_name(trace),
+                               trace, bt_trace_get_name(trace),
                                clock_class ?
                                        bt_clock_class_get_name(clock_class) :
                                        NULL);
@@ -1109,15 +1068,8 @@ int check_packet_header_type_has_no_clock_class(struct bt_trace_common *trace)
        return ret;
 }
 
-BT_HIDDEN
-int bt_trace_common_add_stream_class(struct bt_trace_common *trace,
-               struct bt_stream_class_common *stream_class,
-               bt_validation_flag_copy_field_type_func copy_field_type_func,
-               struct bt_clock_class *init_expected_clock_class,
-               int (*map_clock_classes_func)(struct bt_stream_class_common *stream_class,
-                       struct bt_field_type_common *packet_context_field_type,
-                       struct bt_field_type_common *event_header_field_type),
-               bool check_ts_begin_end_mapped)
+int bt_trace_add_stream_class(struct bt_trace *trace,
+               struct bt_stream_class *stream_class)
 {
        int ret;
        int64_t i;
@@ -1129,16 +1081,13 @@ int bt_trace_common_add_stream_class(struct bt_trace_common *trace,
                BT_VALIDATION_FLAG_STREAM;
        const enum bt_validation_flag ec_validation_flags =
                BT_VALIDATION_FLAG_EVENT;
-       struct bt_field_type_common *packet_header_type = NULL;
-       struct bt_field_type_common *packet_context_type = NULL;
-       struct bt_field_type_common *event_header_type = NULL;
-       struct bt_field_type_common *stream_event_ctx_type = NULL;
+       struct bt_field_type *packet_header_type = NULL;
+       struct bt_field_type *packet_context_type = NULL;
+       struct bt_field_type *event_header_type = NULL;
+       struct bt_field_type *stream_event_ctx_type = NULL;
        int64_t event_class_count;
-       struct bt_trace_common *current_parent_trace = NULL;
-       struct bt_clock_class *expected_clock_class =
-               bt_get(init_expected_clock_class);
-
-       BT_ASSERT(copy_field_type_func);
+       struct bt_trace *current_parent_trace = NULL;
+       struct bt_clock_class *expected_clock_class = NULL;
 
        if (!trace) {
                BT_LOGW_STR("Invalid parameter: trace is NULL.");
@@ -1146,6 +1095,12 @@ int bt_trace_common_add_stream_class(struct bt_trace_common *trace,
                goto end;
        }
 
+       if (trace->is_static) {
+               BT_LOGW_STR("Invalid parameter: trace is static.");
+               ret = -1;
+               goto end;
+       }
+
        if (!stream_class) {
                BT_LOGW_STR("Invalid parameter: stream class is NULL.");
                ret = -1;
@@ -1156,24 +1111,24 @@ int bt_trace_common_add_stream_class(struct bt_trace_common *trace,
                "trace-addr=%p, trace-name=\"%s\", "
                "stream-class-addr=%p, stream-class-name=\"%s\", "
                "stream-class-id=%" PRId64,
-               trace, bt_trace_common_get_name(trace),
-               stream_class, bt_stream_class_common_get_name(stream_class),
-               bt_stream_class_common_get_id(stream_class));
+               trace, bt_trace_get_name(trace),
+               stream_class, bt_stream_class_get_name(stream_class),
+               bt_stream_class_get_id(stream_class));
 
-       current_parent_trace = bt_stream_class_common_borrow_trace(stream_class);
+       current_parent_trace = bt_stream_class_borrow_trace(stream_class);
        if (current_parent_trace) {
                /* Stream class is already associated to a trace, abort. */
                BT_LOGW("Invalid parameter: stream class is already part of a trace: "
                        "stream-class-trace-addr=%p, "
                        "stream-class-trace-name=\"%s\"",
                        current_parent_trace,
-                       bt_trace_common_get_name(current_parent_trace));
+                       bt_trace_get_name(current_parent_trace));
                ret = -1;
                goto end;
        }
 
        event_class_count =
-               bt_stream_class_common_get_event_class_count(stream_class);
+               bt_stream_class_get_event_class_count(stream_class);
        BT_ASSERT(event_class_count >= 0);
 
        if (!stream_class->frozen) {
@@ -1181,7 +1136,7 @@ int bt_trace_common_add_stream_class(struct bt_trace_common *trace,
                 * Stream class is not frozen yet. Validate that the
                 * stream class contains at most a single clock class
                 * because the previous
-                * bt_stream_class_common_add_event_class() calls did
+                * bt_stream_class_add_event_class() calls did
                 * not make this validation since the stream class's
                 * direct field types (packet context, event header,
                 * event context) could change afterwards. This stream
@@ -1191,13 +1146,13 @@ int bt_trace_common_add_stream_class(struct bt_trace_common *trace,
                 * At this point we're also sure that the stream class's
                 * clock, if any, has the same class as the stream
                 * class's expected clock class, if any. This is why, if
-                * bt_stream_class_common_validate_single_clock_class()
+                * bt_stream_class_validate_single_clock_class()
                 * succeeds below, the call to
                 * bt_stream_class_map_clock_class() at the end of this
                 * function is safe because it maps to the same, single
                 * clock class.
                 */
-               ret = bt_stream_class_common_validate_single_clock_class(
+               ret = bt_stream_class_validate_single_clock_class(
                        stream_class, &expected_clock_class);
                if (ret) {
                        BT_LOGW("Invalid parameter: stream class or one of its "
@@ -1209,8 +1164,8 @@ int bt_trace_common_add_stream_class(struct bt_trace_common *trace,
                                "stream-class-name=\"%s\", "
                                "expected-clock-class-addr=%p, "
                                "expected-clock-class-name=\"%s\"",
-                               stream_class, bt_stream_class_common_get_id(stream_class),
-                               bt_stream_class_common_get_name(stream_class),
+                               stream_class, bt_stream_class_get_id(stream_class),
+                               bt_stream_class_get_name(stream_class),
                                expected_clock_class,
                                expected_clock_class ?
                                        bt_clock_class_get_name(expected_clock_class) :
@@ -1237,20 +1192,20 @@ int bt_trace_common_add_stream_class(struct bt_trace_common *trace,
         * class of this stream class can be validated individually.
         */
        packet_header_type =
-               bt_trace_common_borrow_packet_header_field_type(trace);
+               bt_trace_borrow_packet_header_field_type(trace);
        packet_context_type =
-               bt_stream_class_common_borrow_packet_context_field_type(stream_class);
+               bt_stream_class_borrow_packet_context_field_type(stream_class);
        event_header_type =
-               bt_stream_class_common_borrow_event_header_field_type(stream_class);
+               bt_stream_class_borrow_event_header_field_type(stream_class);
        stream_event_ctx_type =
-               bt_stream_class_common_borrow_event_context_field_type(stream_class);
+               bt_stream_class_borrow_event_context_field_type(stream_class);
 
        BT_LOGD("Validating trace and stream class field types.");
        ret = bt_validate_class_types(trace->environment,
                packet_header_type, packet_context_type, event_header_type,
                stream_event_ctx_type, NULL, NULL, trace->valid,
                stream_class->valid, 1, &trace_sc_validation_output,
-               trace_sc_validation_flags, copy_field_type_func);
+               trace_sc_validation_flags, bt_field_type_copy);
 
        if (ret) {
                /*
@@ -1285,17 +1240,17 @@ int bt_trace_common_add_stream_class(struct bt_trace_common *trace,
 
        /* Validate each event class individually */
        for (i = 0; i < event_class_count; i++) {
-               struct bt_event_class_common *event_class =
-                       bt_stream_class_common_borrow_event_class_by_index(
+               struct bt_event_class *event_class =
+                       bt_stream_class_borrow_event_class_by_index(
                                stream_class, i);
-               struct bt_field_type_common *event_context_type = NULL;
-               struct bt_field_type_common *event_payload_type = NULL;
+               struct bt_field_type *event_context_type = NULL;
+               struct bt_field_type *event_payload_type = NULL;
 
                event_context_type =
-                       bt_event_class_common_borrow_context_field_type(
+                       bt_event_class_borrow_context_field_type(
                                event_class);
                event_payload_type =
-                       bt_event_class_common_borrow_payload_field_type(
+                       bt_event_class_borrow_payload_field_type(
                                event_class);
 
                /*
@@ -1305,8 +1260,8 @@ int bt_trace_common_add_stream_class(struct bt_trace_common *trace,
                 */
                BT_LOGD("Validating event class's field types: "
                        "addr=%p, name=\"%s\", id=%" PRId64,
-                       event_class, bt_event_class_common_get_name(event_class),
-                       bt_event_class_common_get_id(event_class));
+                       event_class, bt_event_class_get_name(event_class),
+                       bt_event_class_get_id(event_class));
                ret = bt_validate_class_types(trace->environment,
                        trace_sc_validation_output.packet_header_type,
                        trace_sc_validation_output.packet_context_type,
@@ -1314,7 +1269,7 @@ int bt_trace_common_add_stream_class(struct bt_trace_common *trace,
                        trace_sc_validation_output.stream_event_ctx_type,
                        event_context_type, event_payload_type,
                        1, 1, event_class->valid, &ec_validation_outputs[i],
-                       ec_validation_flags, copy_field_type_func);
+                       ec_validation_flags, bt_field_type_copy);
 
                if (ret) {
                        BT_LOGE("Failed to validate event class field types: "
@@ -1333,7 +1288,7 @@ int bt_trace_common_add_stream_class(struct bt_trace_common *trace,
                }
        }
 
-       stream_id = bt_stream_class_common_get_id(stream_class);
+       stream_id = bt_stream_class_get_id(stream_class);
        if (stream_id < 0) {
                stream_id = trace->next_stream_id++;
                if (stream_id < 0) {
@@ -1344,7 +1299,7 @@ int bt_trace_common_add_stream_class(struct bt_trace_common *trace,
 
                /* Try to assign a new stream id */
                for (i = 0; i < trace->stream_classes->len; i++) {
-                       if (stream_id == bt_stream_class_common_get_id(
+                       if (stream_id == bt_stream_class_get_id(
                                trace->stream_classes->pdata[i])) {
                                /* Duplicate stream id found */
                                BT_LOGW("Duplicate stream class ID: "
@@ -1354,7 +1309,7 @@ int bt_trace_common_add_stream_class(struct bt_trace_common *trace,
                        }
                }
 
-               if (bt_stream_class_common_set_id_no_check(stream_class,
+               if (bt_stream_class_set_id_no_check(stream_class,
                                stream_id)) {
                        /* TODO Should retry with a different stream id */
                        BT_LOGE("Cannot set stream class's ID: "
@@ -1378,8 +1333,7 @@ int bt_trace_common_add_stream_class(struct bt_trace_common *trace,
 
        if (!packet_context_field_type_is_valid(trace,
                        stream_class,
-                       trace_sc_validation_output.packet_context_type,
-                       check_ts_begin_end_mapped)) {
+                       trace_sc_validation_output.packet_context_type, true)) {
                BT_LOGW_STR("Invalid stream class's packet context field type.");
                ret = -1;
                goto end;
@@ -1393,25 +1347,6 @@ int bt_trace_common_add_stream_class(struct bt_trace_common *trace,
                goto end;
        }
 
-       /*
-        * Now is the time to automatically map specific field types of
-        * the stream class's packet context and event header field
-        * types to the stream class's clock's class if they are not
-        * mapped to a clock class yet. We do it here because we know
-        * that after this point, everything is frozen so it won't be
-        * possible for the user to modify the stream class's clock, or
-        * to map those field types to other clock classes.
-        */
-       if (map_clock_classes_func) {
-               if (map_clock_classes_func(stream_class,
-                               trace_sc_validation_output.packet_context_type,
-                               trace_sc_validation_output.event_header_type)) {
-                       /* map_clock_classes_func() logs errors */
-                       ret = -1;
-                       goto end;
-               }
-       }
-
        bt_object_set_parent(&stream_class->base, &trace->base);
        g_ptr_array_add(trace->stream_classes, stream_class);
 
@@ -1434,8 +1369,8 @@ int bt_trace_common_add_stream_class(struct bt_trace_common *trace,
        bt_validation_output_put_types(&trace_sc_validation_output);
 
        for (i = 0; i < event_class_count; i++) {
-               struct bt_event_class_common *event_class =
-                       bt_stream_class_common_borrow_event_class_by_index(
+               struct bt_event_class *event_class =
+                       bt_stream_class_borrow_event_class_by_index(
                                stream_class, i);
 
                bt_validation_replace_types(NULL, NULL, event_class,
@@ -1452,8 +1387,8 @@ int bt_trace_common_add_stream_class(struct bt_trace_common *trace,
        /*
         * Freeze the trace and the stream class.
         */
-       bt_stream_class_common_freeze(stream_class);
-       bt_trace_common_freeze(trace);
+       bt_stream_class_freeze(stream_class);
+       bt_trace_freeze(trace);
 
        /*
         * It is safe to set the stream class's unique clock class
@@ -1463,13 +1398,16 @@ int bt_trace_common_add_stream_class(struct bt_trace_common *trace,
                BT_MOVE(stream_class->clock_class, expected_clock_class);
        }
 
+       /* Notify listeners of the trace's schema modification. */
+       bt_stream_class_visit(stream_class,
+                       bt_trace_object_modification, trace);
        BT_LOGD("Added stream class to trace: "
                "trace-addr=%p, trace-name=\"%s\", "
                "stream-class-addr=%p, stream-class-name=\"%s\", "
                "stream-class-id=%" PRId64,
-               trace, bt_trace_common_get_name(trace),
-               stream_class, bt_stream_class_common_get_name(stream_class),
-               bt_stream_class_common_get_id(stream_class));
+               trace, bt_trace_get_name(trace),
+               stream_class, bt_stream_class_get_name(stream_class),
+               bt_stream_class_get_id(stream_class));
 
 end:
        if (ret) {
@@ -1489,80 +1427,98 @@ end:
        return ret;
 }
 
-int bt_trace_add_stream_class(struct bt_trace *trace,
-               struct bt_stream_class *stream_class)
-{
-       int ret = 0;
-
-       if (!trace) {
-               BT_LOGW_STR("Invalid parameter: trace is NULL.");
-               ret = -1;
-               goto end;
-       }
-
-       if (trace->is_static) {
-               BT_LOGW_STR("Invalid parameter: trace is static.");
-               ret = -1;
-               goto end;
-       }
-
-       ret = bt_trace_common_add_stream_class(BT_TO_COMMON(trace),
-               BT_TO_COMMON(stream_class),
-               (bt_validation_flag_copy_field_type_func) bt_field_type_copy,
-               NULL, NULL, true);
-       if (ret) {
-               goto end;
-       }
-
-       /* Notifiy listeners of the trace's schema modification. */
-       bt_stream_class_common_visit(BT_TO_COMMON(stream_class),
-                       bt_trace_object_modification, trace);
-
-end:
-       return ret;
-}
-
 int64_t bt_trace_get_stream_count(struct bt_trace *trace)
 {
-       return bt_trace_common_get_stream_count(BT_TO_COMMON(trace));
+       BT_ASSERT_PRE_NON_NULL(trace, "Trace");
+       return (int64_t) trace->streams->len;
 }
 
 struct bt_stream *bt_trace_borrow_stream_by_index(
                struct bt_trace *trace, uint64_t index)
 {
-       return BT_FROM_COMMON(bt_trace_common_borrow_stream_by_index(
-               BT_TO_COMMON(trace), index));
+       BT_ASSERT_PRE_NON_NULL(trace, "Trace");
+       BT_ASSERT_PRE(index < trace->streams->len,
+               "Index is out of bounds: index=%" PRIu64 ", "
+               "count=%u",
+               index, trace->streams->len);
+       return g_ptr_array_index(trace->streams, index);
 }
 
 int64_t bt_trace_get_stream_class_count(struct bt_trace *trace)
 {
-       return bt_trace_common_get_stream_class_count(BT_TO_COMMON(trace));
+       BT_ASSERT_PRE_NON_NULL(trace, "Trace");
+       return (int64_t) trace->stream_classes->len;
 }
 
 struct bt_stream_class *bt_trace_borrow_stream_class_by_index(
                struct bt_trace *trace, uint64_t index)
 {
-       return BT_FROM_COMMON(bt_trace_common_borrow_stream_class_by_index(
-               BT_TO_COMMON(trace), index));
+       BT_ASSERT_PRE_NON_NULL(trace, "Trace");
+       BT_ASSERT_PRE(index < trace->stream_classes->len,
+               "Index is out of bounds: index=%" PRIu64 ", "
+               "count=%u",
+               index, trace->stream_classes->len);
+       return g_ptr_array_index(trace->stream_classes, index);
 }
 
 struct bt_stream_class *bt_trace_borrow_stream_class_by_id(
-               struct bt_trace *trace, uint64_t id)
+               struct bt_trace *trace, uint64_t id_param)
 {
-       return BT_FROM_COMMON(
-               bt_trace_common_borrow_stream_class_by_id(
-                       BT_TO_COMMON(trace), id));
+       int i;
+       struct bt_stream_class *stream_class = NULL;
+       int64_t id = (int64_t) id_param;
+
+       BT_ASSERT_PRE_NON_NULL(trace, "Trace");
+       BT_ASSERT_PRE(id >= 0,
+               "Invalid stream class ID: %" PRIu64, id_param);
+
+       for (i = 0; i < trace->stream_classes->len; i++) {
+               struct bt_stream_class *stream_class_candidate;
+
+               stream_class_candidate =
+                       g_ptr_array_index(trace->stream_classes, i);
+
+               if (bt_stream_class_get_id(stream_class_candidate) ==
+                               (int64_t) id) {
+                       stream_class = stream_class_candidate;
+                       goto end;
+               }
+       }
+
+end:
+       return stream_class;
 }
 
 struct bt_clock_class *bt_trace_borrow_clock_class_by_name(
                struct bt_trace *trace, const char *name)
 {
-       return bt_trace_common_borrow_clock_class_by_name(BT_TO_COMMON(trace),
-               name);
+       size_t i;
+       struct bt_clock_class *clock_class = NULL;
+
+       BT_ASSERT_PRE_NON_NULL(trace, "Trace");
+       BT_ASSERT_PRE_NON_NULL(name, "Name");
+
+       for (i = 0; i < trace->clock_classes->len; i++) {
+               struct bt_clock_class *cur_clk =
+                       g_ptr_array_index(trace->clock_classes, i);
+               const char *cur_clk_name = bt_clock_class_get_name(cur_clk);
+
+               if (!cur_clk_name) {
+                       goto end;
+               }
+
+               if (!strcmp(cur_clk_name, name)) {
+                       clock_class = cur_clk;
+                       goto end;
+               }
+       }
+
+end:
+       return clock_class;
 }
 
 BT_HIDDEN
-bt_bool bt_trace_common_has_clock_class(struct bt_trace_common *trace,
+bt_bool bt_trace_has_clock_class(struct bt_trace *trace,
                struct bt_clock_class *clock_class)
 {
        struct search_query query = { .value = clock_class, .found = 0 };
@@ -1577,12 +1533,12 @@ bt_bool bt_trace_common_has_clock_class(struct bt_trace_common *trace,
 enum bt_byte_order bt_trace_get_native_byte_order(
                struct bt_trace *trace)
 {
-       return bt_trace_common_get_native_byte_order(BT_TO_COMMON(trace));
+       BT_ASSERT_PRE_NON_NULL(trace, "Trace");
+       return trace->native_byte_order;
 }
 
-BT_HIDDEN
-int bt_trace_common_set_native_byte_order(struct bt_trace_common *trace,
-               enum bt_byte_order byte_order, bool allow_unspecified)
+int bt_trace_set_native_byte_order(struct bt_trace *trace,
+               enum bt_byte_order byte_order)
 {
        int ret = 0;
 
@@ -1595,15 +1551,7 @@ int bt_trace_common_set_native_byte_order(struct bt_trace_common *trace,
        if (trace->frozen) {
                BT_LOGW("Invalid parameter: trace is frozen: "
                        "addr=%p, name=\"%s\"",
-                       trace, bt_trace_common_get_name(trace));
-               ret = -1;
-               goto end;
-       }
-
-       if (byte_order == BT_BYTE_ORDER_UNSPECIFIED && !allow_unspecified) {
-               BT_LOGW("Invalid parameter: BT_BYTE_ORDER_UNSPECIFIED byte order is not allowed: "
-                       "addr=%p, name=\"%s\"",
-                       trace, bt_trace_common_get_name(trace));
+                       trace, bt_trace_get_name(trace));
                ret = -1;
                goto end;
        }
@@ -1613,7 +1561,7 @@ int bt_trace_common_set_native_byte_order(struct bt_trace_common *trace,
                        byte_order != BT_BYTE_ORDER_NETWORK) {
                BT_LOGW("Invalid parameter: invalid byte order: "
                        "addr=%p, name=\"%s\", bo=%s",
-                       trace, bt_trace_common_get_name(trace),
+                       trace, bt_trace_get_name(trace),
                        bt_common_byte_order_string(byte_order));
                ret = -1;
                goto end;
@@ -1622,30 +1570,22 @@ int bt_trace_common_set_native_byte_order(struct bt_trace_common *trace,
        trace->native_byte_order = byte_order;
        BT_LOGV("Set trace's native byte order: "
                "addr=%p, name=\"%s\", bo=%s",
-               trace, bt_trace_common_get_name(trace),
+               trace, bt_trace_get_name(trace),
                bt_common_byte_order_string(byte_order));
 
 end:
        return ret;
 }
 
-int bt_trace_set_native_byte_order(struct bt_trace *trace,
-               enum bt_byte_order byte_order)
-{
-       return bt_trace_common_set_native_byte_order(BT_TO_COMMON(trace),
-               byte_order, true);
-}
-
 struct bt_field_type *bt_trace_borrow_packet_header_field_type(
                struct bt_trace *trace)
 {
-       return BT_FROM_COMMON(bt_trace_common_borrow_packet_header_field_type(
-               BT_TO_COMMON(trace)));
+       BT_ASSERT_PRE_NON_NULL(trace, "Trace");
+       return trace->packet_header_field_type;
 }
 
-BT_HIDDEN
-int bt_trace_common_set_packet_header_field_type(struct bt_trace_common *trace,
-               struct bt_field_type_common *packet_header_type)
+int bt_trace_set_packet_header_field_type(struct bt_trace *trace,
+               struct bt_field_type *packet_header_type)
 {
        int ret = 0;
 
@@ -1658,7 +1598,7 @@ int bt_trace_common_set_packet_header_field_type(struct bt_trace_common *trace,
        if (trace->frozen) {
                BT_LOGW("Invalid parameter: trace is frozen: "
                        "addr=%p, name=\"%s\"",
-                       trace, bt_trace_common_get_name(trace));
+                       trace, bt_trace_get_name(trace));
                ret = -1;
                goto end;
        }
@@ -1668,7 +1608,7 @@ int bt_trace_common_set_packet_header_field_type(struct bt_trace_common *trace,
                        packet_header_type->id != BT_FIELD_TYPE_ID_STRUCT) {
                BT_LOGW("Invalid parameter: packet header field type must be a structure field type if it exists: "
                        "addr=%p, name=\"%s\", ft-addr=%p, ft-id=%s",
-                       trace, bt_trace_common_get_name(trace),
+                       trace, bt_trace_get_name(trace),
                        packet_header_type,
                        bt_common_field_type_id_string(packet_header_type->id));
                ret = -1;
@@ -1679,18 +1619,11 @@ int bt_trace_common_set_packet_header_field_type(struct bt_trace_common *trace,
        trace->packet_header_field_type = bt_get(packet_header_type);
        BT_LOGV("Set trace's packet header field type: "
                "addr=%p, name=\"%s\", packet-context-ft-addr=%p",
-               trace, bt_trace_common_get_name(trace), packet_header_type);
+               trace, bt_trace_get_name(trace), packet_header_type);
 end:
        return ret;
 }
 
-int bt_trace_set_packet_header_field_type(struct bt_trace *trace,
-               struct bt_field_type *packet_header_type)
-{
-       return bt_trace_common_set_packet_header_field_type(BT_TO_COMMON(trace),
-               (void *) packet_header_type);
-}
-
 static
 int64_t get_stream_class_count(void *element)
 {
@@ -1823,14 +1756,14 @@ int bt_trace_set_is_static(struct bt_trace *trace)
                goto end;
        }
 
-       ret = check_packet_header_type_has_no_clock_class(BT_TO_COMMON(trace));
+       ret = check_packet_header_type_has_no_clock_class(trace);
        if (ret) {
                /* check_packet_header_type_has_no_clock_class() logs errors */
                goto end;
        }
 
        trace->is_static = BT_TRUE;
-       bt_trace_common_freeze(BT_TO_COMMON(trace));
+       bt_trace_freeze(trace);
        BT_LOGV("Set trace static: addr=%p, name=\"%s\"",
                trace, bt_trace_get_name(trace));
 
@@ -1992,12 +1925,12 @@ struct bt_packet_header_field *bt_trace_create_packet_header_field(
        struct bt_field_wrapper *field_wrapper;
 
        BT_ASSERT_PRE_NON_NULL(trace, "Trace");
-       BT_ASSERT_PRE(trace->common.packet_header_field_type,
+       BT_ASSERT_PRE(trace->packet_header_field_type,
                "Trace has no packet header field type: %!+t",
                trace);
        field_wrapper = bt_field_wrapper_create(
                &trace->packet_header_field_pool,
-               (void *) trace->common.packet_header_field_type);
+               (void *) trace->packet_header_field_type);
        if (!field_wrapper) {
                BT_LIB_LOGE("Cannot allocate one packet header field from trace: "
                        "%![trace-]+t", trace);
@@ -2005,7 +1938,7 @@ struct bt_packet_header_field *bt_trace_create_packet_header_field(
        }
 
        BT_ASSERT(field_wrapper->field);
-       bt_trace_common_freeze(BT_TO_COMMON(trace));
+       bt_trace_freeze(trace);
        goto end;
 
 error:
index b4e889cb6f3eeb490755eb2020bcefdf0535e7dc..cc653ec52e50f5a102516b08f40750874b380f1d 100644 (file)
  */
 static
 int validate_event_class_types(struct bt_value *environment,
-               struct bt_field_type_common *packet_header_type,
-               struct bt_field_type_common *packet_context_type,
-               struct bt_field_type_common *event_header_type,
-               struct bt_field_type_common *stream_event_ctx_type,
-               struct bt_field_type_common *event_context_type,
-               struct bt_field_type_common *event_payload_type)
+               struct bt_field_type *packet_header_type,
+               struct bt_field_type *packet_context_type,
+               struct bt_field_type *event_header_type,
+               struct bt_field_type *stream_event_ctx_type,
+               struct bt_field_type *event_context_type,
+               struct bt_field_type *event_payload_type)
 {
        int ret = 0;
 
@@ -82,7 +82,7 @@ int validate_event_class_types(struct bt_value *environment,
 
        /* Validate field types individually */
        if (event_context_type) {
-               ret = bt_field_type_common_validate(event_context_type);
+               ret = bt_field_type_validate(event_context_type);
                if (ret) {
                        BT_LOGW("Invalid event class's context field type: "
                                "ret=%d", ret);
@@ -91,7 +91,7 @@ int validate_event_class_types(struct bt_value *environment,
        }
 
        if (event_payload_type) {
-               ret = bt_field_type_common_validate(event_payload_type);
+               ret = bt_field_type_validate(event_payload_type);
                if (ret) {
                        BT_LOGW("Invalid event class's payload field type: "
                                "ret=%d", ret);
@@ -113,10 +113,10 @@ end:
  */
 static
 int validate_stream_class_types(struct bt_value *environment,
-               struct bt_field_type_common *packet_header_type,
-               struct bt_field_type_common *packet_context_type,
-               struct bt_field_type_common *event_header_type,
-               struct bt_field_type_common *stream_event_ctx_type)
+               struct bt_field_type *packet_header_type,
+               struct bt_field_type *packet_context_type,
+               struct bt_field_type *event_header_type,
+               struct bt_field_type *stream_event_ctx_type)
 {
        int ret = 0;
 
@@ -143,7 +143,7 @@ int validate_stream_class_types(struct bt_value *environment,
 
        /* Validate field types individually */
        if (packet_context_type) {
-               ret = bt_field_type_common_validate(packet_context_type);
+               ret = bt_field_type_validate(packet_context_type);
                if (ret) {
                        BT_LOGW("Invalid stream class's packet context field type: "
                                "ret=%d", ret);
@@ -152,7 +152,7 @@ int validate_stream_class_types(struct bt_value *environment,
        }
 
        if (event_header_type) {
-               ret = bt_field_type_common_validate(event_header_type);
+               ret = bt_field_type_validate(event_header_type);
                if (ret) {
                        BT_LOGW("Invalid stream class's event header field type: "
                                "ret=%d", ret);
@@ -161,7 +161,7 @@ int validate_stream_class_types(struct bt_value *environment,
        }
 
        if (stream_event_ctx_type) {
-               ret = bt_field_type_common_validate(
+               ret = bt_field_type_validate(
                        stream_event_ctx_type);
                if (ret) {
                        BT_LOGW("Invalid stream class's event context field type: "
@@ -181,7 +181,7 @@ end:
  */
 static
 int validate_trace_types(struct bt_value *environment,
-               struct bt_field_type_common *packet_header_type)
+               struct bt_field_type *packet_header_type)
 {
        int ret = 0;
 
@@ -200,7 +200,7 @@ int validate_trace_types(struct bt_value *environment,
 
        /* Validate field types individually */
        if (packet_header_type) {
-               ret = bt_field_type_common_validate(packet_header_type);
+               ret = bt_field_type_validate(packet_header_type);
                if (ret) {
                        BT_LOGW("Invalid trace's packet header field type: "
                                "ret=%d", ret);
@@ -219,10 +219,10 @@ end:
  * `field_type` is owned by the caller.
  */
 static
-int field_type_contains_sequence_or_variant_ft(struct bt_field_type_common *type)
+int field_type_contains_sequence_or_variant_ft(struct bt_field_type *type)
 {
        int ret = 0;
-       enum bt_field_type_id type_id = bt_field_type_common_get_type_id(type);
+       enum bt_field_type_id type_id = bt_field_type_get_type_id(type);
 
        switch (type_id) {
        case BT_FIELD_TYPE_ID_SEQUENCE:
@@ -233,7 +233,7 @@ int field_type_contains_sequence_or_variant_ft(struct bt_field_type_common *type
        case BT_FIELD_TYPE_ID_STRUCT:
        {
                int i;
-               int field_count = bt_field_type_common_get_field_count(type);
+               int field_count = bt_field_type_get_field_count(type);
 
                if (field_count < 0) {
                        ret = -1;
@@ -241,8 +241,8 @@ int field_type_contains_sequence_or_variant_ft(struct bt_field_type_common *type
                }
 
                for (i = 0; i < field_count; ++i) {
-                       struct bt_field_type_common *child_type =
-                               bt_field_type_common_borrow_field_at_index(
+                       struct bt_field_type *child_type =
+                               bt_field_type_borrow_field_at_index(
                                        type, i);
 
                        ret = field_type_contains_sequence_or_variant_ft(
@@ -263,12 +263,12 @@ end:
 
 BT_HIDDEN
 int bt_validate_class_types(struct bt_value *environment,
-               struct bt_field_type_common *packet_header_type,
-               struct bt_field_type_common *packet_context_type,
-               struct bt_field_type_common *event_header_type,
-               struct bt_field_type_common *stream_event_ctx_type,
-               struct bt_field_type_common *event_context_type,
-               struct bt_field_type_common *event_payload_type,
+               struct bt_field_type *packet_header_type,
+               struct bt_field_type *packet_context_type,
+               struct bt_field_type *event_header_type,
+               struct bt_field_type *stream_event_ctx_type,
+               struct bt_field_type *event_context_type,
+               struct bt_field_type *event_payload_type,
                int trace_valid, int stream_class_valid, int event_class_valid,
                struct bt_validation_output *output,
                enum bt_validation_flag validate_flags,
@@ -318,7 +318,7 @@ int bt_validate_class_types(struct bt_value *environment,
 
        /* Validate trace */
        if ((validate_flags & BT_VALIDATION_FLAG_TRACE) && !trace_valid) {
-               struct bt_field_type_common *packet_header_type_copy = NULL;
+               struct bt_field_type *packet_header_type_copy = NULL;
 
                /* Create field type copies */
                if (packet_header_type) {
@@ -349,7 +349,7 @@ int bt_validate_class_types(struct bt_value *environment,
                         * caller, it cannot be modified any way since
                         * it will be resolved.
                         */
-                       bt_field_type_common_freeze(packet_header_type_copy);
+                       bt_field_type_freeze(packet_header_type_copy);
                }
 
 skip_packet_header_type_copy:
@@ -368,9 +368,9 @@ skip_packet_header_type_copy:
        /* Validate stream class */
        if ((validate_flags & BT_VALIDATION_FLAG_STREAM) &&
                        !stream_class_valid) {
-               struct bt_field_type_common *packet_context_type_copy = NULL;
-               struct bt_field_type_common *event_header_type_copy = NULL;
-               struct bt_field_type_common *stream_event_ctx_type_copy = NULL;
+               struct bt_field_type *packet_context_type_copy = NULL;
+               struct bt_field_type *event_header_type_copy = NULL;
+               struct bt_field_type *stream_event_ctx_type_copy = NULL;
 
                if (packet_context_type) {
                        contains_seq_var =
@@ -399,7 +399,7 @@ skip_packet_header_type_copy:
                         * caller, it cannot be modified any way since
                         * it will be resolved.
                         */
-                       bt_field_type_common_freeze(packet_context_type_copy);
+                       bt_field_type_freeze(packet_context_type_copy);
                }
 
 skip_packet_context_type_copy:
@@ -430,7 +430,7 @@ skip_packet_context_type_copy:
                         * caller, it cannot be modified any way since
                         * it will be resolved.
                         */
-                       bt_field_type_common_freeze(event_header_type_copy);
+                       bt_field_type_freeze(event_header_type_copy);
                }
 
 skip_event_header_type_copy:
@@ -462,7 +462,7 @@ skip_event_header_type_copy:
                         * caller, it cannot be modified any way since
                         * it will be resolved.
                         */
-                       bt_field_type_common_freeze(stream_event_ctx_type_copy);
+                       bt_field_type_freeze(stream_event_ctx_type_copy);
                }
 
 skip_stream_event_ctx_type_copy:
@@ -494,8 +494,8 @@ sc_validation_done:
        /* Validate event class */
        if ((validate_flags & BT_VALIDATION_FLAG_EVENT) &&
                        !event_class_valid) {
-               struct bt_field_type_common *event_context_type_copy = NULL;
-               struct bt_field_type_common *event_payload_type_copy = NULL;
+               struct bt_field_type *event_context_type_copy = NULL;
+               struct bt_field_type *event_payload_type_copy = NULL;
 
                if (event_context_type) {
                        contains_seq_var =
@@ -524,7 +524,7 @@ sc_validation_done:
                         * caller, it cannot be modified any way since
                         * it will be resolved.
                         */
-                       bt_field_type_common_freeze(event_context_type_copy);
+                       bt_field_type_freeze(event_context_type_copy);
                }
 
 skip_event_context_type_copy:
@@ -555,7 +555,7 @@ skip_event_context_type_copy:
                         * caller, it cannot be modified any way since
                         * it will be resolved.
                         */
-                       bt_field_type_common_freeze(event_payload_type_copy);
+                       bt_field_type_freeze(event_payload_type_copy);
                }
 
 skip_event_payload_type_copy:
@@ -607,22 +607,22 @@ error:
 }
 
 BT_HIDDEN
-void bt_validation_replace_types(struct bt_trace_common *trace,
-               struct bt_stream_class_common *stream_class,
-               struct bt_event_class_common *event_class,
+void bt_validation_replace_types(struct bt_trace *trace,
+               struct bt_stream_class *stream_class,
+               struct bt_event_class *event_class,
                struct bt_validation_output *output,
                enum bt_validation_flag replace_flags)
 {
        if ((replace_flags & BT_VALIDATION_FLAG_TRACE) && trace) {
-               bt_field_type_common_freeze(trace->packet_header_field_type);
+               bt_field_type_freeze(trace->packet_header_field_type);
                BT_MOVE(trace->packet_header_field_type,
                        output->packet_header_type);
        }
 
        if ((replace_flags & BT_VALIDATION_FLAG_STREAM) && stream_class) {
-               bt_field_type_common_freeze(stream_class->packet_context_field_type);
-               bt_field_type_common_freeze(stream_class->event_header_field_type);
-               bt_field_type_common_freeze(stream_class->event_context_field_type);
+               bt_field_type_freeze(stream_class->packet_context_field_type);
+               bt_field_type_freeze(stream_class->event_header_field_type);
+               bt_field_type_freeze(stream_class->event_context_field_type);
                BT_MOVE(stream_class->packet_context_field_type,
                        output->packet_context_type);
                BT_MOVE(stream_class->event_header_field_type,
@@ -632,8 +632,8 @@ void bt_validation_replace_types(struct bt_trace_common *trace,
        }
 
        if ((replace_flags & BT_VALIDATION_FLAG_EVENT) && event_class) {
-               bt_field_type_common_freeze(event_class->context_field_type);
-               bt_field_type_common_freeze(event_class->payload_field_type);
+               bt_field_type_freeze(event_class->context_field_type);
+               bt_field_type_freeze(event_class->payload_field_type);
                BT_MOVE(event_class->context_field_type, output->event_context_type);
                BT_MOVE(event_class->payload_field_type, output->event_payload_type);
        }
index 7556a545b4481ca4f62e8b53807c2d6a9f98354b..80fe9ef3939cb04927ff7a286762566517e37455 100644 (file)
@@ -109,8 +109,6 @@ static char __thread lib_logging_buf[LIB_LOGGING_BUF_SIZE];
                strcat(tmp_prefix, (_prefix2));                         \
        } while (0)
 
-typedef void (*format_func)(char **, bool, const char *, void *);
-
 static inline void format_component(char **buf_ch, bool extended,
                const char *prefix, struct bt_component *component);
 
@@ -157,8 +155,8 @@ static inline void format_object_pool(char **buf_ch, bool extended,
        }
 }
 
-static inline void format_field_type_common(char **buf_ch, bool extended,
-               const char *prefix, struct bt_field_type_common *field_type)
+static inline void format_field_type(char **buf_ch, bool extended,
+               const char *prefix, struct bt_field_type *field_type)
 {
        BUF_APPEND(", %stype-id=%s, %salignment=%u",
                PRFIELD(bt_common_field_type_id_string(field_type->id)),
@@ -177,38 +175,39 @@ static inline void format_field_type_common(char **buf_ch, bool extended,
        switch (field_type->id) {
        case BT_FIELD_TYPE_ID_INTEGER:
        {
-               struct bt_field_type_common_integer *integer =
-                       BT_FROM_COMMON(field_type);
+               struct bt_field_type_integer *integer = (void *) field_type;
 
                BUF_APPEND(", %ssize=%u, %sis-signed=%d, %sbyte-order=%s, "
                        "%sbase=%d, %sencoding=%s, "
                        "%smapped-clock-class-addr=%p",
                        PRFIELD(integer->size), PRFIELD(integer->is_signed),
-                       PRFIELD(bt_common_byte_order_string(integer->user_byte_order)),
+                       PRFIELD(bt_common_byte_order_string(
+                               integer->user_byte_order)),
                        PRFIELD(integer->base),
-                       PRFIELD(bt_common_string_encoding_string(integer->encoding)),
+                       PRFIELD(bt_common_string_encoding_string(
+                               integer->encoding)),
                        PRFIELD(integer->mapped_clock_class));
 
                if (integer->mapped_clock_class) {
                        BUF_APPEND(", %smapped-clock-class-name=\"%s\"",
-                               PRFIELD(bt_clock_class_get_name(integer->mapped_clock_class)));
+                               PRFIELD(bt_clock_class_get_name(
+                                       integer->mapped_clock_class)));
                }
                break;
        }
        case BT_FIELD_TYPE_ID_FLOAT:
        {
-               struct bt_field_type_common_floating_point *flt =
-                       BT_FROM_COMMON(field_type);
+               struct bt_field_type_floating_point *flt = (void *) field_type;
 
                BUF_APPEND(", %sexp-dig=%u, %smant-dig=%u, %sbyte-order=%s",
                        PRFIELD(flt->exp_dig), PRFIELD(flt->mant_dig),
-                       PRFIELD(bt_common_byte_order_string(flt->user_byte_order)));
+                       PRFIELD(bt_common_byte_order_string(
+                               flt->user_byte_order)));
                break;
        }
        case BT_FIELD_TYPE_ID_ENUM:
        {
-               struct bt_field_type_common_enumeration *enm =
-                       BT_FROM_COMMON(field_type);
+               struct bt_field_type_enumeration *enm = (void *) field_type;
 
                BUF_APPEND(", %smapping-count=%u",
                        PRFIELD(enm->entries->len));
@@ -216,17 +215,16 @@ static inline void format_field_type_common(char **buf_ch, bool extended,
        }
        case BT_FIELD_TYPE_ID_STRING:
        {
-               struct bt_field_type_common_string *str =
-                       BT_FROM_COMMON(field_type);
+               struct bt_field_type_string *str = (void *) field_type;
 
                BUF_APPEND(", %sencoding=%s",
-                       PRFIELD(bt_common_string_encoding_string(str->encoding)));
+                       PRFIELD(bt_common_string_encoding_string(
+                               str->encoding)));
                break;
        }
        case BT_FIELD_TYPE_ID_STRUCT:
        {
-               struct bt_field_type_common_structure *structure =
-                       BT_FROM_COMMON(field_type);
+               struct bt_field_type_structure *structure = (void *) field_type;
 
                BUF_APPEND(", %sfield-count=%u",
                        PRFIELD(structure->fields->len));
@@ -234,8 +232,7 @@ static inline void format_field_type_common(char **buf_ch, bool extended,
        }
        case BT_FIELD_TYPE_ID_SEQUENCE:
        {
-               struct bt_field_type_common_sequence *seq =
-                       BT_FROM_COMMON(field_type);
+               struct bt_field_type_sequence *seq = (void *) field_type;
 
                BUF_APPEND(", %slength-ft-addr=\"%s\", %selem-ft-addr=%p",
                        PRFIELD(seq->length_field_name->str),
@@ -244,8 +241,7 @@ static inline void format_field_type_common(char **buf_ch, bool extended,
        }
        case BT_FIELD_TYPE_ID_VARIANT:
        {
-               struct bt_field_type_common_variant *variant =
-                       BT_FROM_COMMON(field_type);
+               struct bt_field_type_variant *variant = (void *) field_type;
 
                BUF_APPEND(", %stag-name=\"%s\", %sfield-count=%u",
                        PRFIELD(variant->tag_name->str),
@@ -257,19 +253,11 @@ static inline void format_field_type_common(char **buf_ch, bool extended,
        }
 }
 
-static inline void format_field_type(char **buf_ch, bool extended,
-               const char *prefix, struct bt_field_type *field_type)
-{
-       format_field_type_common(buf_ch, extended, prefix,
-               (void *) field_type);
-}
-
-static inline void format_field_common_integer_extended(char **buf_ch,
-               const char *prefix, struct bt_field_common *field)
+static inline void format_field_integer_extended(char **buf_ch,
+               const char *prefix, struct bt_field *field)
 {
-       struct bt_field_common_integer *integer = BT_FROM_COMMON(field);
-       struct bt_field_type_common_integer *field_type =
-               BT_FROM_COMMON(field->type);
+       struct bt_field_integer *integer = (void *) field;
+       struct bt_field_type_integer *field_type = (void *) field->type;
        const char *fmt = NULL;
 
        BT_ASSERT(field_type);
@@ -295,9 +283,11 @@ static inline void format_field_common_integer_extended(char **buf_ch,
        }
 }
 
-static inline void format_field_common(char **buf_ch, bool extended,
-               const char *prefix, struct bt_field_common *field)
+static inline void format_field(char **buf_ch, bool extended,
+               const char *prefix, struct bt_field *field)
 {
+       struct bt_field *common_field = (void *) field;
+
        BUF_APPEND(", %sis-set=%d", PRFIELD(field->payload_set));
 
        if (extended) {
@@ -321,21 +311,19 @@ static inline void format_field_common(char **buf_ch, bool extended,
        switch (field->type->id) {
        case BT_FIELD_TYPE_ID_INTEGER:
        {
-               format_field_common_integer_extended(buf_ch, prefix, field);
+               format_field_integer_extended(buf_ch, prefix, field);
                break;
        }
        case BT_FIELD_TYPE_ID_FLOAT:
        {
-               struct bt_field_common_floating_point *flt =
-                       BT_FROM_COMMON(field);
+               struct bt_field_floating_point *flt = (void *) field;
 
                BUF_APPEND(", %svalue=%f", PRFIELD(flt->payload));
                break;
        }
        case BT_FIELD_TYPE_ID_STRING:
        {
-               struct bt_field_common_string *str =
-                       BT_FROM_COMMON(field);
+               struct bt_field_string *str = (void *) field;
 
                if (str->buf) {
                        BT_ASSERT(str->buf->data);
@@ -347,8 +335,7 @@ static inline void format_field_common(char **buf_ch, bool extended,
        }
        case BT_FIELD_TYPE_ID_SEQUENCE:
        {
-               struct bt_field_common_sequence *seq =
-                       BT_FROM_COMMON(field);
+               struct bt_field_sequence *seq = (void *) field;
 
                BUF_APPEND(", %slength=%" PRIu64, PRFIELD(seq->length));
 
@@ -360,8 +347,7 @@ static inline void format_field_common(char **buf_ch, bool extended,
        }
        case BT_FIELD_TYPE_ID_VARIANT:
        {
-               struct bt_field_common_variant *variant =
-                       BT_FROM_COMMON(field);
+               struct bt_field_variant *variant = (void *) field;
 
                BUF_APPEND(", %scur-field-addr=%p",
                        PRFIELD(variant->current_field));
@@ -370,18 +356,6 @@ static inline void format_field_common(char **buf_ch, bool extended,
        default:
                break;
        }
-}
-
-static inline void format_field(char **buf_ch, bool extended,
-               const char *prefix, struct bt_field *field)
-{
-       struct bt_field_common *common_field = (void *) field;
-
-       format_field_common(buf_ch, extended, prefix, (void *) field);
-
-       if (!extended) {
-               return;
-       }
 
        if (!common_field->type) {
                return;
@@ -390,9 +364,9 @@ static inline void format_field(char **buf_ch, bool extended,
        switch (common_field->type->id) {
        case BT_FIELD_TYPE_ID_ENUM:
        {
-               struct bt_field_common_integer *integer = (void *) field;
-               struct bt_field_type_common_enumeration *enum_ft =
-                       BT_FROM_COMMON(common_field->type);
+               struct bt_field_integer *integer = (void *) field;
+               struct bt_field_type_enumeration *enum_ft =
+                       (void *) common_field->type;
 
                if (enum_ft->container_ft) {
                        if (enum_ft->container_ft->is_signed) {
@@ -417,14 +391,16 @@ static inline void format_field_path(char **buf_ch, bool extended,
 
        if (field_path->indexes) {
                BT_ASSERT(field_path->indexes);
-               BUF_APPEND(", %sindex-count=%u", PRFIELD(field_path->indexes->len));
+               BUF_APPEND(", %sindex-count=%u",
+                       PRFIELD(field_path->indexes->len));
        }
 
        if (!extended || !field_path->indexes) {
                return;
        }
 
-       BUF_APPEND(", %spath=[%s", PRFIELD(bt_common_scope_string(field_path->root)));
+       BUF_APPEND(", %spath=[%s",
+               PRFIELD(bt_common_scope_string(field_path->root)));
 
        for (i = 0; i < field_path->indexes->len; i++) {
                int index = g_array_index(field_path->indexes, int, i);
@@ -435,9 +411,11 @@ static inline void format_field_path(char **buf_ch, bool extended,
        BUF_APPEND("%s", "]");
 }
 
-static inline void format_trace_common(char **buf_ch, bool extended,
-               const char *prefix, struct bt_trace_common *trace)
+static inline void format_trace(char **buf_ch, bool extended,
+               const char *prefix, struct bt_trace *trace)
 {
+       char tmp_prefix[64];
+
        if (trace->name) {
                BUF_APPEND(", %sname=\"%s\"", PRFIELD(trace->name->str));
        }
@@ -469,30 +447,16 @@ static inline void format_trace_common(char **buf_ch, bool extended,
 
        BUF_APPEND(", %spacket-header-ft-addr=%p",
                PRFIELD(trace->packet_header_field_type));
-}
-
-static inline void format_trace(char **buf_ch, bool extended,
-               const char *prefix, struct bt_trace *trace)
-{
-       char tmp_prefix[64];
-
-       format_trace_common(buf_ch, extended, prefix, BT_TO_COMMON(trace));
-
-       if (!extended) {
-               return;
-       }
-
        BUF_APPEND(", %sis-static=%d", PRFIELD(trace->is_static));
        SET_TMP_PREFIX("phf-pool-");
        format_object_pool(buf_ch, extended, prefix,
                &trace->packet_header_field_pool);
 }
 
-static inline void format_stream_class_common(char **buf_ch, bool extended,
-               const char *prefix, struct bt_stream_class_common *stream_class,
-               format_func trace_format_func)
+static inline void format_stream_class(char **buf_ch, bool extended,
+               const char *prefix, struct bt_stream_class *stream_class)
 {
-       struct bt_trace_common *trace;
+       struct bt_trace *trace;
        char tmp_prefix[64];
 
        if (stream_class->id_set) {
@@ -519,28 +483,14 @@ static inline void format_stream_class_common(char **buf_ch, bool extended,
                PRFIELD(stream_class->packet_context_field_type),
                PRFIELD(stream_class->event_header_field_type),
                PRFIELD(stream_class->event_context_field_type));
-       trace = bt_stream_class_common_borrow_trace(stream_class);
+       trace = bt_stream_class_borrow_trace(stream_class);
        if (!trace) {
                return;
        }
 
        BUF_APPEND(", %strace-addr=%p", PRFIELD(trace));
        SET_TMP_PREFIX("trace-");
-       trace_format_func(buf_ch, false, tmp_prefix, trace);
-}
-
-static inline void format_stream_class(char **buf_ch, bool extended,
-               const char *prefix, struct bt_stream_class *stream_class)
-{
-       char tmp_prefix[64];
-
-       format_stream_class_common(buf_ch, extended, prefix,
-               BT_TO_COMMON(stream_class), (format_func) format_trace);
-
-       if (!extended) {
-               return;
-       }
-
+       format_trace(buf_ch, false, tmp_prefix, trace);
        SET_TMP_PREFIX("ehf-pool-");
        format_object_pool(buf_ch, extended, prefix,
                &stream_class->event_header_field_pool);
@@ -549,19 +499,18 @@ static inline void format_stream_class(char **buf_ch, bool extended,
                &stream_class->packet_context_field_pool);
 }
 
-static inline void format_event_class_common(char **buf_ch, bool extended,
-               const char *prefix, struct bt_event_class_common *event_class,
-               format_func format_stream_class_func,
-               format_func format_trace_func)
+static inline void format_event_class(char **buf_ch, bool extended,
+               const char *prefix, struct bt_event_class *event_class)
 {
-       struct bt_stream_class_common *stream_class;
-       struct bt_trace_common *trace;
+       struct bt_stream_class *stream_class;
+       struct bt_trace *trace;
        char tmp_prefix[64];
 
        BUF_APPEND(", %sid=%" PRId64, PRFIELD(event_class->id));
 
        if (event_class->name) {
-               BUF_APPEND(", %sname=\"%s\"", PRFIELD(event_class->name->str));
+               BUF_APPEND(", %sname=\"%s\"",
+                       PRFIELD(event_class->name->str));
        }
 
        if (!extended) {
@@ -570,7 +519,8 @@ static inline void format_event_class_common(char **buf_ch, bool extended,
 
        BUF_APPEND(", %sis-frozen=%d, %slog-level=%s",
                PRFIELD(event_class->frozen),
-               PRFIELD(bt_common_event_class_log_level_string(event_class->log_level)));
+               PRFIELD(bt_common_event_class_log_level_string(
+                       event_class->log_level)));
 
        if (event_class->emf_uri) {
                BUF_APPEND(", %semf-uri=\"%s\"",
@@ -581,48 +531,31 @@ static inline void format_event_class_common(char **buf_ch, bool extended,
                PRFIELD(event_class->context_field_type),
                PRFIELD(event_class->payload_field_type));
 
-       stream_class = bt_event_class_common_borrow_stream_class(event_class);
+       stream_class = bt_event_class_borrow_stream_class(event_class);
        if (!stream_class) {
                return;
        }
 
        BUF_APPEND(", %sstream-class-addr=%p", PRFIELD(stream_class));
        SET_TMP_PREFIX("stream-class-");
-       format_stream_class_func(buf_ch, false, tmp_prefix, stream_class);
-       trace = bt_stream_class_common_borrow_trace(stream_class);
+       format_stream_class(buf_ch, false, tmp_prefix, stream_class);
+       trace = bt_stream_class_borrow_trace(stream_class);
        if (!trace) {
                return;
        }
 
        BUF_APPEND(", %strace-addr=%p", PRFIELD(trace));
        SET_TMP_PREFIX("trace-");
-       format_trace_func(buf_ch, false, tmp_prefix, trace);
-}
-
-static inline void format_event_class(char **buf_ch, bool extended,
-               const char *prefix, struct bt_event_class *event_class)
-{
-       char tmp_prefix[64];
-
-       format_event_class_common(buf_ch, extended, prefix,
-               BT_TO_COMMON(event_class), (format_func) format_stream_class,
-               (format_func) format_trace);
-
-       if (!extended) {
-               return;
-       }
-
+       format_trace(buf_ch, false, tmp_prefix, trace);
        SET_TMP_PREFIX("event-pool-");
        format_object_pool(buf_ch, extended, prefix, &event_class->event_pool);
 }
 
-static inline void format_stream_common(char **buf_ch, bool extended,
-               const char *prefix, struct bt_stream_common *stream,
-               format_func format_stream_class_func,
-               format_func format_trace_func)
+static inline void format_stream(char **buf_ch, bool extended,
+               const char *prefix, struct bt_stream *stream)
 {
-       struct bt_stream_class_common *stream_class;
-       struct bt_trace_common *trace;
+       struct bt_stream_class *stream_class;
+       struct bt_trace *trace;
        char tmp_prefix[64];
 
        BUF_APPEND(", %sid=%" PRId64, PRFIELD(stream->id));
@@ -635,15 +568,15 @@ static inline void format_stream_common(char **buf_ch, bool extended,
                return;
        }
 
-       stream_class = bt_stream_common_borrow_class(stream);
+       stream_class = bt_stream_borrow_class(stream);
        if (!stream_class) {
                return;
        }
 
        BUF_APPEND(", %sstream-class-addr=%p", PRFIELD(stream_class));
        SET_TMP_PREFIX("stream-class-");
-       format_stream_class_func(buf_ch, false, tmp_prefix, stream_class);
-       trace = bt_stream_class_common_borrow_trace(stream_class);
+       format_stream_class(buf_ch, false, tmp_prefix, stream_class);
+       trace = bt_stream_class_borrow_trace(stream_class);
        if (!trace) {
                return;
        }
@@ -655,17 +588,7 @@ static inline void format_stream_common(char **buf_ch, bool extended,
 
        BUF_APPEND(", %strace-addr=%p", PRFIELD(trace));
        SET_TMP_PREFIX("trace-");
-       format_trace_common(buf_ch, false, tmp_prefix, trace);
-}
-
-static inline void format_stream(char **buf_ch, bool extended,
-               const char *prefix, struct bt_stream *stream)
-{
-       char tmp_prefix[64];
-
-       format_stream_common(buf_ch, extended, prefix, BT_TO_COMMON(stream),
-               (format_func) format_stream_class,
-               (format_func) format_trace);
+       format_trace(buf_ch, false, tmp_prefix, trace);
        SET_TMP_PREFIX("packet-pool-");
        format_object_pool(buf_ch, extended, prefix, &stream->packet_pool);
 }
@@ -694,7 +617,8 @@ static inline void format_packet(char **buf_ch, bool extended,
        BUF_APPEND(", %sstream-addr=%p", PRFIELD(stream));
        SET_TMP_PREFIX("stream-");
        format_stream(buf_ch, false, tmp_prefix, stream);
-       trace = (struct bt_trace *) bt_object_borrow_parent(&stream->common.base);
+       trace = (struct bt_trace *)
+               bt_object_borrow_parent(&stream->base);
        if (!trace) {
                return;
        }
@@ -704,14 +628,13 @@ static inline void format_packet(char **buf_ch, bool extended,
        format_trace(buf_ch, false, tmp_prefix, trace);
 }
 
-static inline void format_event_common(char **buf_ch, bool extended,
-               const char *prefix, struct bt_event_common *event,
-               format_func format_event_class_func,
-               format_func format_stream_class_func,
-               format_func format_trace_func)
+static inline void format_event(char **buf_ch, bool extended,
+               const char *prefix, struct bt_event *event)
 {
-       struct bt_trace_common *trace;
-       struct bt_stream_class_common *stream_class;
+       struct bt_packet *packet;
+       struct bt_stream *stream;
+       struct bt_trace *trace;
+       struct bt_stream_class *stream_class;
        char tmp_prefix[64];
 
        if (!extended) {
@@ -722,7 +645,8 @@ static inline void format_event_common(char **buf_ch, bool extended,
                "%sstream-context-field-addr=%p, "
                "%scontext-field-addr=%p, %spayload-field-addr=%p, ",
                PRFIELD(event->frozen),
-               PRFIELD(event->header_field ? event->header_field->field : NULL),
+               PRFIELD(event->header_field ?
+                       event->header_field->field : NULL),
                PRFIELD(event->stream_event_context_field),
                PRFIELD(event->context_field),
                PRFIELD(event->payload_field));
@@ -733,37 +657,21 @@ static inline void format_event_common(char **buf_ch, bool extended,
        }
 
        SET_TMP_PREFIX("event-class-");
-       format_event_class_func(buf_ch, false, tmp_prefix, event->class);
-       stream_class = bt_event_class_common_borrow_stream_class(event->class);
+       format_event_class(buf_ch, false, tmp_prefix, event->class);
+       stream_class = bt_event_class_borrow_stream_class(event->class);
        if (stream_class) {
                BUF_APPEND(", %sstream-class-addr=%p", PRFIELD(stream_class));
                SET_TMP_PREFIX("stream-class-");
-               format_stream_class_func(buf_ch, false, tmp_prefix,
+               format_stream_class(buf_ch, false, tmp_prefix,
                        stream_class);
 
-               trace = bt_stream_class_common_borrow_trace(stream_class);
+               trace = bt_stream_class_borrow_trace(stream_class);
                if (trace) {
                        BUF_APPEND(", %strace-addr=%p", PRFIELD(trace));
                        SET_TMP_PREFIX("trace-");
-                       format_trace_func(buf_ch, false, tmp_prefix, trace);
+                       format_trace(buf_ch, false, tmp_prefix, trace);
                }
        }
-}
-
-static inline void format_event(char **buf_ch, bool extended,
-               const char *prefix, struct bt_event *event)
-{
-       struct bt_packet *packet;
-       struct bt_stream *stream;
-       char tmp_prefix[64];
-
-       format_event_common(buf_ch, extended, prefix, BT_TO_COMMON(event),
-               (format_func) format_event_class,
-               (format_func) format_stream_class, (format_func) format_trace);
-
-       if (!extended) {
-               return;
-       }
 
        SET_TMP_PREFIX("cvs-");
        format_clock_value_set(buf_ch, extended, tmp_prefix, &event->cv_set);
@@ -1218,41 +1126,6 @@ static inline void format_plugin(char **buf_ch, bool extended,
        }
 }
 
-static inline void format_stream_class_common_common(char **buf_ch,
-               bool extended, const char *prefix,
-               struct bt_stream_class_common *stream_class)
-{
-       format_stream_class_common(buf_ch, extended, prefix, stream_class,
-               (format_func) format_trace_common);
-}
-
-static inline void format_event_class_common_common(char **buf_ch,
-               bool extended, const char *prefix,
-               struct bt_event_class_common *event_class)
-{
-       format_event_class_common(buf_ch, extended, prefix, event_class,
-               (format_func) format_stream_class_common,
-               (format_func) format_trace_common);
-}
-
-static inline void format_event_common_common(char **buf_ch,
-               bool extended, const char *prefix,
-               struct bt_event_common *event)
-{
-       format_event_common(buf_ch, extended, prefix, event,
-               (format_func) format_event_class_common,
-               (format_func) format_stream_class_common,
-               (format_func) format_trace_common);
-}
-
-static inline void format_stream_common_common(char **buf_ch, bool extended,
-               const char *prefix, struct bt_stream_common *stream)
-{
-       format_stream_common(buf_ch, extended, prefix, stream,
-               (format_func) format_stream_class_common,
-               (format_func) format_trace_common);
-}
-
 static inline void handle_conversion_specifier_bt(void *priv_data,
                char **buf_ch, size_t avail_size,
                const char **out_fmt_ch, va_list *args)
@@ -1262,10 +1135,6 @@ static inline void handle_conversion_specifier_bt(void *priv_data,
        char prefix[64];
        char *prefix_ch = prefix;
        void *obj;
-       enum {
-               CAT_DEFAULT,
-               CAT_COMMON,
-       } cat = CAT_DEFAULT;
 
        /* skip "%!" */
        fmt_ch += 2;
@@ -1294,11 +1163,6 @@ static inline void handle_conversion_specifier_bt(void *priv_data,
                fmt_ch++;
        }
 
-       if (*fmt_ch == '_') {
-               cat = CAT_COMMON;
-               fmt_ch++;
-       }
-
        obj = va_arg(*args, void *);
        BUF_APPEND("%saddr=%p", prefix, obj);
 
@@ -1306,106 +1170,75 @@ static inline void handle_conversion_specifier_bt(void *priv_data,
                goto update_fmt;
        }
 
-       switch (cat) {
-       case CAT_DEFAULT:
-               switch (*fmt_ch) {
-               case 'F':
-                       format_field_type(buf_ch, extended, prefix, obj);
-                       break;
-               case 'f':
-                       format_field(buf_ch, extended, prefix, obj);
-                       break;
-               case 'P':
-                       format_field_path(buf_ch, extended, prefix, obj);
-                       break;
-               case 'E':
-                       format_event_class(buf_ch, extended, prefix, obj);
-                       break;
-               case 'e':
-                       format_event(buf_ch, extended, prefix, obj);
-                       break;
-               case 'S':
-                       format_stream_class(buf_ch, extended, prefix, obj);
-                       break;
-               case 's':
-                       format_stream(buf_ch, extended, prefix, obj);
-                       break;
-               case 'a':
-                       format_packet(buf_ch, extended, prefix, obj);
-                       break;
-               case 't':
-                       format_trace(buf_ch, extended, prefix, obj);
-                       break;
-               case 'K':
-                       format_clock_class(buf_ch, extended, prefix, obj);
-                       break;
-               case 'k':
-                       format_clock_value(buf_ch, extended, prefix, obj);
-                       break;
-               case 'v':
-                       format_value(buf_ch, extended, prefix, obj);
-                       break;
-               case 'n':
-                       format_notification(buf_ch, extended, prefix, obj);
-                       break;
-               case 'i':
-                       format_notification_iterator(buf_ch, extended, prefix, obj);
-                       break;
-               case 'C':
-                       format_component_class(buf_ch, extended, prefix, obj);
-                       break;
-               case 'c':
-                       format_component(buf_ch, extended, prefix, obj);
-                       break;
-               case 'p':
-                       format_port(buf_ch, extended, prefix, obj);
-                       break;
-               case 'x':
-                       format_connection(buf_ch, extended, prefix, obj);
-                       break;
-               case 'u':
-                       format_plugin(buf_ch, extended, prefix, obj);
-                       break;
-               case 'g':
-                       format_graph(buf_ch, extended, prefix, obj);
-                       break;
-               case 'o':
-                       format_object_pool(buf_ch, extended, prefix, obj);
-                       break;
-               case 'O':
-                       format_object(buf_ch, extended, prefix, obj);
-                       break;
-               default:
-                       abort();
-               }
+       switch (*fmt_ch) {
+       case 'F':
+               format_field_type(buf_ch, extended, prefix, obj);
                break;
-       case CAT_COMMON:
-               switch (*fmt_ch) {
-               case 'F':
-                       format_field_type_common(buf_ch, extended, prefix, obj);
-                       break;
-               case 'f':
-                       format_field_common(buf_ch, extended, prefix, obj);
-                       break;
-               case 'E':
-                       format_event_class_common_common(buf_ch, extended, prefix, obj);
-                       break;
-               case 'e':
-                       format_event_common_common(buf_ch, extended, prefix, obj);
-                       break;
-               case 'S':
-                       format_stream_class_common_common(buf_ch, extended, prefix, obj);
-                       break;
-               case 's':
-                       format_stream_common_common(buf_ch, extended, prefix, obj);
-                       break;
-               case 't':
-                       format_trace_common(buf_ch, extended, prefix, obj);
-                       break;
-               default:
-                       abort();
-               }
+       case 'f':
+               format_field(buf_ch, extended, prefix, obj);
+               break;
+       case 'P':
+               format_field_path(buf_ch, extended, prefix, obj);
+               break;
+       case 'E':
+               format_event_class(buf_ch, extended, prefix, obj);
+               break;
+       case 'e':
+               format_event(buf_ch, extended, prefix, obj);
+               break;
+       case 'S':
+               format_stream_class(buf_ch, extended, prefix, obj);
                break;
+       case 's':
+               format_stream(buf_ch, extended, prefix, obj);
+               break;
+       case 'a':
+               format_packet(buf_ch, extended, prefix, obj);
+               break;
+       case 't':
+               format_trace(buf_ch, extended, prefix, obj);
+               break;
+       case 'K':
+               format_clock_class(buf_ch, extended, prefix, obj);
+               break;
+       case 'k':
+               format_clock_value(buf_ch, extended, prefix, obj);
+               break;
+       case 'v':
+               format_value(buf_ch, extended, prefix, obj);
+               break;
+       case 'n':
+               format_notification(buf_ch, extended, prefix, obj);
+               break;
+       case 'i':
+               format_notification_iterator(buf_ch, extended, prefix, obj);
+               break;
+       case 'C':
+               format_component_class(buf_ch, extended, prefix, obj);
+               break;
+       case 'c':
+               format_component(buf_ch, extended, prefix, obj);
+               break;
+       case 'p':
+               format_port(buf_ch, extended, prefix, obj);
+               break;
+       case 'x':
+               format_connection(buf_ch, extended, prefix, obj);
+               break;
+       case 'u':
+               format_plugin(buf_ch, extended, prefix, obj);
+               break;
+       case 'g':
+               format_graph(buf_ch, extended, prefix, obj);
+               break;
+       case 'o':
+               format_object_pool(buf_ch, extended, prefix, obj);
+               break;
+       case 'O':
+               format_object(buf_ch, extended, prefix, obj);
+               break;
+       default:
+               abort();
        }
 
 update_fmt:
This page took 0.263243 seconds and 4 git commands to generate.