#include <babeltrace/trace-ir/fields-internal.h>
#include <babeltrace/trace-ir/fields.h>
#include <babeltrace/trace-ir/utils-internal.h>
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
#include <babeltrace/trace-ir/clock-class.h>
#include <babeltrace/trace-ir/clock-class-internal.h>
#include <babeltrace/object-internal.h>
-#include <babeltrace/ref.h>
+#include <babeltrace/object.h>
#include <babeltrace/compiler-internal.h>
#include <babeltrace/endian-internal.h>
#include <babeltrace/assert-internal.h>
#include <inttypes.h>
#include <stdlib.h>
-enum bt_field_class_id bt_field_class_get_id(struct bt_field_class *fc)
+enum bt_field_class_type bt_field_class_get_type(struct bt_field_class *fc)
{
BT_ASSERT_PRE_NON_NULL(fc, "Field class");
- return fc->id;
+ return fc->type;
}
static
-void init_field_class(struct bt_field_class *fc, enum bt_field_class_id id,
+void init_field_class(struct bt_field_class *fc, enum bt_field_class_type type,
bt_object_release_func release_func)
{
BT_ASSERT(fc);
- BT_ASSERT(bt_field_class_has_known_id(fc));
+ BT_ASSERT(bt_field_class_has_known_type(fc));
BT_ASSERT(release_func);
bt_object_init_shared(&fc->base, release_func);
- fc->id = id;
+ fc->type = type;
}
static
-void init_integer_field_class(struct bt_field_class_integer *fc, enum bt_field_class_id id,
+void init_integer_field_class(struct bt_field_class_integer *fc,
+ enum bt_field_class_type type,
bt_object_release_func release_func)
{
- init_field_class((void *) fc, id, release_func);
+ init_field_class((void *) fc, type, release_func);
fc->range = 64;
fc->base = BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_DECIMAL;
}
}
static inline
-struct bt_field_class *create_integer_field_class(enum bt_field_class_id id)
+struct bt_field_class *create_integer_field_class(enum bt_field_class_type type)
{
struct bt_field_class_integer *int_fc = NULL;
- BT_LOGD("Creating default integer field classe object: id=%s",
- bt_common_field_class_id_string(id));
+ BT_LOGD("Creating default integer field classe object: type=%s",
+ bt_common_field_class_type_string(type));
int_fc = g_new0(struct bt_field_class_integer, 1);
if (!int_fc) {
BT_LOGE_STR("Failed to allocate one integer field classe.");
goto error;
}
- init_integer_field_class(int_fc, id, destroy_integer_field_class);
+ init_integer_field_class(int_fc, type, destroy_integer_field_class);
BT_LIB_LOGD("Created integer field classe object: %!+F", int_fc);
goto end;
error:
- BT_PUT(int_fc);
+ BT_OBJECT_PUT_REF_AND_RESET(int_fc);
end:
return (void *) int_fc;
struct bt_field_class *bt_field_class_unsigned_integer_create(void)
{
- return create_integer_field_class(BT_FIELD_CLASS_ID_UNSIGNED_INTEGER);
+ return create_integer_field_class(BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER);
}
struct bt_field_class *bt_field_class_signed_integer_create(void)
{
- return create_integer_field_class(BT_FIELD_CLASS_ID_SIGNED_INTEGER);
+ return create_integer_field_class(BT_FIELD_CLASS_TYPE_SIGNED_INTEGER);
}
uint64_t bt_field_class_integer_get_field_value_range(
BT_ASSERT_PRE(size <= 64,
"Unsupported size for integer field classe's field value range "
"(maximum is 64): size=%" PRIu64, size);
- BT_ASSERT_PRE(int_fc->common.id == BT_FIELD_CLASS_ID_UNSIGNED_INTEGER ||
- int_fc->common.id == BT_FIELD_CLASS_ID_SIGNED_INTEGER ||
+ BT_ASSERT_PRE(
+ int_fc->common.type == BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER ||
+ int_fc->common.type == BT_FIELD_CLASS_TYPE_SIGNED_INTEGER ||
size_is_valid_for_enumeration_field_class(fc, size),
"Invalid field value range for enumeration field classe: "
"at least one of the current mapping ranges contains values "
}
static
-struct bt_field_class *create_enumeration_field_class(enum bt_field_class_id id)
+struct bt_field_class *create_enumeration_field_class(enum bt_field_class_type type)
{
struct bt_field_class_enumeration *enum_fc = NULL;
- BT_LOGD("Creating default enumeration field classe object: id=%s",
- bt_common_field_class_id_string(id));
+ BT_LOGD("Creating default enumeration field classe object: type=%s",
+ bt_common_field_class_type_string(type));
enum_fc = g_new0(struct bt_field_class_enumeration, 1);
if (!enum_fc) {
BT_LOGE_STR("Failed to allocate one enumeration field classe.");
goto error;
}
- init_integer_field_class((void *) enum_fc, id,
+ init_integer_field_class((void *) enum_fc, type,
destroy_enumeration_field_class);
enum_fc->mappings = g_array_new(FALSE, TRUE,
sizeof(struct bt_field_class_enumeration_mapping));
goto end;
error:
- BT_PUT(enum_fc);
+ BT_OBJECT_PUT_REF_AND_RESET(enum_fc);
end:
return (void *) enum_fc;
struct bt_field_class *bt_field_class_unsigned_enumeration_create(void)
{
return create_enumeration_field_class(
- BT_FIELD_CLASS_ID_UNSIGNED_ENUMERATION);
+ BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION);
}
struct bt_field_class *bt_field_class_signed_enumeration_create(void)
{
return create_enumeration_field_class(
- BT_FIELD_CLASS_ID_SIGNED_ENUMERATION);
+ BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION);
}
uint64_t bt_field_class_enumeration_get_mapping_count(struct bt_field_class *fc)
BT_ASSERT_PRE_NON_NULL(name, "Name (output)");
BT_ASSERT_PRE_NON_NULL(ranges, "Ranges (output)");
BT_ASSERT_PRE_VALID_INDEX(index, enum_fc->mappings->len);
- BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_ID_UNSIGNED_ENUMERATION,
+ BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION,
"Field class");
mapping = BT_FIELD_CLASS_ENUM_MAPPING_AT_INDEX(fc, index);
*name = mapping->label->str;
BT_ASSERT_PRE_NON_NULL(name, "Name (output)");
BT_ASSERT_PRE_NON_NULL(ranges, "Ranges (output)");
BT_ASSERT_PRE_VALID_INDEX(index, enum_fc->mappings->len);
- BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_ID_SIGNED_ENUMERATION,
+ BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION,
"Field class");
mapping = BT_FIELD_CLASS_ENUM_MAPPING_AT_INDEX(fc, index);
*name = mapping->label->str;
BT_ASSERT_PRE_NON_NULL(fc, "Field class");
BT_ASSERT_PRE_NON_NULL(label_array, "Label array (output)");
BT_ASSERT_PRE_NON_NULL(count, "Count (output)");
- BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_ID_UNSIGNED_ENUMERATION,
+ BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION,
"Field class");
g_ptr_array_set_size(enum_fc->label_buf, 0);
BT_ASSERT_PRE_NON_NULL(fc, "Field class");
BT_ASSERT_PRE_NON_NULL(label_array, "Label array (output)");
BT_ASSERT_PRE_NON_NULL(count, "Count (output)");
- BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_ID_SIGNED_ENUMERATION,
+ BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION,
"Field class");
g_ptr_array_set_size(enum_fc->label_buf, 0);
struct bt_field_class_enumeration *enum_fc = (void *) fc;
BT_ASSERT_PRE_NON_NULL(fc, "Field class");
- BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_ID_UNSIGNED_ENUMERATION,
+ BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION,
"Field class");
BT_ASSERT_PRE(range_lower <= range_upper,
"Range's upper bound is less than lower bound: "
struct bt_field_class_enumeration *enum_fc = (void *) fc;
BT_ASSERT_PRE_NON_NULL(fc, "Field class");
- BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_ID_SIGNED_ENUMERATION,
+ BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION,
"Field class");
BT_ASSERT_PRE(range_lower <= range_upper,
"Range's upper bound is less than lower bound: "
goto error;
}
- init_field_class((void *) real_fc, BT_FIELD_CLASS_ID_REAL,
+ init_field_class((void *) real_fc, BT_FIELD_CLASS_TYPE_REAL,
destroy_real_field_class);
BT_LIB_LOGD("Created real field classe object: %!+F", real_fc);
goto end;
error:
- BT_PUT(real_fc);
+ BT_OBJECT_PUT_REF_AND_RESET(real_fc);
end:
return (void *) real_fc;
struct bt_field_class_real *real_fc = (void *) fc;
BT_ASSERT_PRE_NON_NULL(fc, "Field class");
- BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_ID_REAL, "Field class");
+ BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_TYPE_REAL, "Field class");
return real_fc->is_single_precision;
}
struct bt_field_class_real *real_fc = (void *) fc;
BT_ASSERT_PRE_NON_NULL(fc, "Field class");
- BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_ID_REAL, "Field class");
+ BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_TYPE_REAL, "Field class");
BT_ASSERT_PRE_FC_HOT(fc, "Field class");
real_fc->is_single_precision = (bool) is_single_precision;
BT_LIB_LOGV("Set real field classe's \"is single precision\" property: "
static
int init_named_field_classes_container(
struct bt_field_class_named_field_class_container *fc,
- enum bt_field_class_id id, bt_object_release_func release_func)
+ enum bt_field_class_type type, bt_object_release_func release_func)
{
int ret = 0;
- init_field_class((void *) fc, id, release_func);
+ init_field_class((void *) fc, type, release_func);
fc->named_fcs = g_array_new(FALSE, TRUE,
sizeof(struct bt_named_field_class));
if (!fc->named_fcs) {
}
BT_LOGD_STR("Putting named field classe's field classe.");
- bt_put(named_fc->fc);
+ bt_object_put_ref(named_fc->fc);
}
static
}
ret = init_named_field_classes_container((void *) struct_fc,
- BT_FIELD_CLASS_ID_STRUCTURE, destroy_structure_field_class);
+ BT_FIELD_CLASS_TYPE_STRUCTURE, destroy_structure_field_class);
if (ret) {
goto error;
}
goto end;
error:
- BT_PUT(struct_fc);
+ BT_OBJECT_PUT_REF_AND_RESET(struct_fc);
end:
return (void *) struct_fc;
named_fc = &g_array_index(container_fc->named_fcs,
struct bt_named_field_class, container_fc->named_fcs->len - 1);
named_fc->name = name_str;
- named_fc->fc = bt_get(fc);
+ named_fc->fc = bt_object_get_ref(fc);
g_hash_table_insert(container_fc->name_to_index, named_fc->name->str,
GUINT_TO_POINTER(container_fc->named_fcs->len - 1));
bt_field_class_freeze(fc);
const char *name, struct bt_field_class *member_fc)
{
BT_ASSERT_PRE_NON_NULL(fc, "Field class");
- BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_ID_STRUCTURE, "Field class");
+ BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_TYPE_STRUCTURE, "Field class");
return append_named_field_class_to_container_field_class((void *) fc,
name, member_fc);
}
struct bt_field_class_structure *struct_fc = (void *) fc;
BT_ASSERT_PRE_NON_NULL(fc, "Field class");
- BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_ID_STRUCTURE, "Field class");
+ BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_TYPE_STRUCTURE, "Field class");
return (uint64_t) struct_fc->common.named_fcs->len;
}
const char **name, struct bt_field_class **out_fc)
{
BT_ASSERT_PRE_NON_NULL(fc, "Field class");
- BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_ID_STRUCTURE, "Field class");
+ BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_TYPE_STRUCTURE, "Field class");
borrow_named_field_class_from_container_field_class_at_index((void *) fc,
index, name, out_fc);
}
struct bt_field_class *fc, const char *name)
{
BT_ASSERT_PRE_NON_NULL(fc, "Field class");
- BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_ID_STRUCTURE, "Field class");
+ BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_TYPE_STRUCTURE, "Field class");
return borrow_field_class_from_container_field_class_by_name((void *) fc,
name);
}
BT_LIB_LOGD("Destroying variant field classe object: %!+F", fc);
finalize_named_field_classes_container((void *) fc);
BT_LOGD_STR("Putting selector field path.");
- bt_put(fc->selector_field_path);
+ bt_object_put_ref(fc->selector_field_path);
g_free(fc);
}
}
ret = init_named_field_classes_container((void *) var_fc,
- BT_FIELD_CLASS_ID_VARIANT, destroy_variant_field_class);
+ BT_FIELD_CLASS_TYPE_VARIANT, destroy_variant_field_class);
if (ret) {
goto error;
}
goto end;
error:
- BT_PUT(var_fc);
+ BT_OBJECT_PUT_REF_AND_RESET(var_fc);
end:
return (void *) var_fc;
BT_ASSERT_PRE_NON_NULL(fc, "Variant field classe");
BT_ASSERT_PRE_NON_NULL(selector_fc, "Selector field classe");
- BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_ID_VARIANT, "Field class");
+ BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_TYPE_VARIANT, "Field class");
BT_ASSERT_PRE_FC_IS_ENUM(selector_fc, "Selector field classe");
BT_ASSERT_PRE_FC_HOT(fc, "Variant field classe");
var_fc->selector_fc = selector_fc;
const char *name, struct bt_field_class *option_fc)
{
BT_ASSERT_PRE_NON_NULL(fc, "Field class");
- BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_ID_VARIANT, "Field class");
+ BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_TYPE_VARIANT, "Field class");
return append_named_field_class_to_container_field_class((void *) fc,
name, option_fc);
}
struct bt_field_class *fc, const char *name)
{
BT_ASSERT_PRE_NON_NULL(fc, "Field class");
- BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_ID_VARIANT, "Field class");
+ BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_TYPE_VARIANT, "Field class");
return borrow_field_class_from_container_field_class_by_name((void *) fc,
name);
}
struct bt_field_class_variant *var_fc = (void *) fc;
BT_ASSERT_PRE_NON_NULL(fc, "Field class");
- BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_ID_VARIANT, "Field class");
+ BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_TYPE_VARIANT, "Field class");
return (uint64_t) var_fc->common.named_fcs->len;
}
const char **name, struct bt_field_class **out_fc)
{
BT_ASSERT_PRE_NON_NULL(fc, "Field class");
- BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_ID_VARIANT, "Field class");
+ BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_TYPE_VARIANT, "Field class");
borrow_named_field_class_from_container_field_class_at_index((void *) fc,
index, name, out_fc);
}
struct bt_field_class_variant *var_fc = (void *) fc;
BT_ASSERT_PRE_NON_NULL(fc, "Field class");
- BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_ID_VARIANT,
+ BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_TYPE_VARIANT,
"Field class");
return var_fc->selector_field_path;
}
static
void init_array_field_class(struct bt_field_class_array *fc,
- enum bt_field_class_id id, bt_object_release_func release_func,
+ enum bt_field_class_type type, bt_object_release_func release_func,
struct bt_field_class *element_fc)
{
BT_ASSERT(element_fc);
- init_field_class((void *) fc, id, release_func);
- fc->element_fc = bt_get(element_fc);
+ init_field_class((void *) fc, type, release_func);
+ fc->element_fc = bt_object_get_ref(element_fc);
bt_field_class_freeze(element_fc);
}
{
BT_ASSERT(array_fc);
BT_LOGD_STR("Putting element field classe.");
- bt_put(array_fc->element_fc);
+ bt_object_put_ref(array_fc->element_fc);
}
static
goto error;
}
- init_array_field_class((void *) array_fc, BT_FIELD_CLASS_ID_STATIC_ARRAY,
+ init_array_field_class((void *) array_fc, BT_FIELD_CLASS_TYPE_STATIC_ARRAY,
destroy_static_array_field_class, element_fc);
array_fc->length = length;
BT_LIB_LOGD("Created static array field classe object: %!+F", array_fc);
goto end;
error:
- BT_PUT(array_fc);
+ BT_OBJECT_PUT_REF_AND_RESET(array_fc);
end:
return (void *) array_fc;
struct bt_field_class_static_array *array_fc = (void *) fc;
BT_ASSERT_PRE_NON_NULL(fc, "Field class");
- BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_ID_STATIC_ARRAY,
+ BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_TYPE_STATIC_ARRAY,
"Field class");
return (uint64_t) array_fc->length;
}
BT_LIB_LOGD("Destroying dynamic array field classe object: %!+F", fc);
finalize_array_field_class((void *) fc);
BT_LOGD_STR("Putting length field path.");
- bt_put(fc->length_field_path);
+ bt_object_put_ref(fc->length_field_path);
g_free(fc);
}
goto error;
}
- init_array_field_class((void *) array_fc, BT_FIELD_CLASS_ID_DYNAMIC_ARRAY,
+ init_array_field_class((void *) array_fc, BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY,
destroy_dynamic_array_field_class, element_fc);
BT_LIB_LOGD("Created dynamic array field classe object: %!+F", array_fc);
goto end;
error:
- BT_PUT(array_fc);
+ BT_OBJECT_PUT_REF_AND_RESET(array_fc);
end:
return (void *) array_fc;
BT_ASSERT_PRE_NON_NULL(fc, "Dynamic array field classe");
BT_ASSERT_PRE_NON_NULL(length_fc, "Length field classe");
- BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_ID_DYNAMIC_ARRAY,
+ BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY,
"Field class");
BT_ASSERT_PRE_FC_IS_UNSIGNED_INT(length_fc, "Length field classe");
BT_ASSERT_PRE_FC_HOT(fc, "Dynamic array field classe");
struct bt_field_class_dynamic_array *seq_fc = (void *) fc;
BT_ASSERT_PRE_NON_NULL(fc, "Field class");
- BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_ID_DYNAMIC_ARRAY,
+ BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY,
"Field class");
return seq_fc->length_field_path;
}
goto error;
}
- init_field_class((void *) string_fc, BT_FIELD_CLASS_ID_STRING,
+ init_field_class((void *) string_fc, BT_FIELD_CLASS_TYPE_STRING,
destroy_string_field_class);
BT_LIB_LOGD("Created string field classe object: %!+F", string_fc);
goto end;
error:
- BT_PUT(string_fc);
+ BT_OBJECT_PUT_REF_AND_RESET(string_fc);
end:
return (void *) string_fc;
"Field class is already part of a trace: %!+F", fc);
fc->part_of_trace = true;
- switch (fc->id) {
- case BT_FIELD_CLASS_ID_STRUCTURE:
- case BT_FIELD_CLASS_ID_VARIANT:
+ switch (fc->type) {
+ case BT_FIELD_CLASS_TYPE_STRUCTURE:
+ case BT_FIELD_CLASS_TYPE_VARIANT:
{
struct bt_field_class_named_field_class_container *container_fc =
(void *) fc;
break;
}
- case BT_FIELD_CLASS_ID_STATIC_ARRAY:
- case BT_FIELD_CLASS_ID_DYNAMIC_ARRAY:
+ case BT_FIELD_CLASS_TYPE_STATIC_ARRAY:
+ case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY:
{
struct bt_field_class_array *array_fc = (void *) fc;