X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Flib%2Ftrace-ir%2Ffield-class.c;h=ecb827a5fe836bd816730b9a587f2e4c23067d10;hb=fe4df857056b4a03898f1031f136359ce733b0f5;hp=97409dc98222e21d68a673395a7b1d7d71dc8d5e;hpb=c6962c968f7467ce8f7e880e7de3797139314f9f;p=babeltrace.git diff --git a/src/lib/trace-ir/field-class.c b/src/lib/trace-ir/field-class.c index 97409dc9..ecb827a5 100644 --- a/src/lib/trace-ir/field-class.c +++ b/src/lib/trace-ir/field-class.c @@ -694,20 +694,22 @@ void destroy_real_field_class(struct bt_object *obj) g_free(obj); } -struct bt_field_class *bt_field_class_real_create(bt_trace_class *trace_class) +static +struct bt_field_class *create_real_field_class(bt_trace_class *trace_class, + enum bt_field_class_type type) { struct bt_field_class_real *real_fc = NULL; BT_ASSERT_PRE_NON_NULL(trace_class, "Trace class"); - BT_LOGD_STR("Creating default real field class object."); + BT_LOGD("Creating default real field class object: type=%s", + bt_common_field_class_type_string(type)); real_fc = g_new0(struct bt_field_class_real, 1); if (!real_fc) { BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate one real field class."); goto error; } - if (init_field_class((void *) real_fc, BT_FIELD_CLASS_TYPE_REAL, - destroy_real_field_class)) { + if (init_field_class((void *) real_fc, type, destroy_real_field_class)) { goto error; } @@ -721,26 +723,18 @@ end: return (void *) real_fc; } -bt_bool bt_field_class_real_is_single_precision(const struct bt_field_class *fc) +struct bt_field_class *bt_field_class_real_single_precision_create( + bt_trace_class *trace_class) { - const struct bt_field_class_real *real_fc = (const void *) fc; - - BT_ASSERT_PRE_DEV_NON_NULL(fc, "Field class"); - BT_ASSERT_PRE_DEV_FC_HAS_ID(fc, BT_FIELD_CLASS_TYPE_REAL, "Field class"); - return real_fc->is_single_precision; + return create_real_field_class(trace_class, + BT_FIELD_CLASS_TYPE_SINGLE_PRECISION_REAL); } -void bt_field_class_real_set_is_single_precision(struct bt_field_class *fc, - bt_bool is_single_precision) +struct bt_field_class *bt_field_class_real_double_precision_create( + bt_trace_class *trace_class) { - 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_TYPE_REAL, "Field class"); - BT_ASSERT_PRE_DEV_FC_HOT(fc, "Field class"); - real_fc->is_single_precision = (bool) is_single_precision; - BT_LIB_LOGD("Set real field class's \"is single precision\" property: " - "%!+F", fc); + return create_real_field_class(trace_class, + BT_FIELD_CLASS_TYPE_DOUBLE_PRECISION_REAL); } static @@ -799,9 +793,8 @@ void destroy_named_field_class(gpointer ptr) { struct bt_named_field_class *named_fc = ptr; - BT_OBJECT_PUT_REF_AND_RESET(named_fc->user_attributes); - if (ptr) { + BT_OBJECT_PUT_REF_AND_RESET(named_fc->user_attributes); finalize_named_field_class(ptr); g_free(ptr); } @@ -1140,6 +1133,16 @@ bt_field_class_structure_member_borrow_field_class_const( return named_fc->fc; } +struct bt_field_class * +bt_field_class_structure_member_borrow_field_class( + struct bt_field_class_structure_member *member) +{ + struct bt_named_field_class *named_fc = (void *) member; + + BT_ASSERT_PRE_DEV_NON_NULL(member, "Structure field class member"); + return named_fc->fc; +} + static void destroy_option_field_class(struct bt_object *obj) { @@ -1212,6 +1215,17 @@ const struct bt_field_class *bt_field_class_option_borrow_field_class_const( return opt_fc->content_fc; } +struct bt_field_class *bt_field_class_option_borrow_field_class( + struct bt_field_class *fc) +{ + struct bt_field_class_option *opt_fc = (void *) fc; + + BT_ASSERT_PRE_NON_NULL(fc, "Field class"); + BT_ASSERT_PRE_DEV_FC_HAS_ID(fc, BT_FIELD_CLASS_TYPE_OPTION, + "Field class"); + return opt_fc->content_fc; +} + const struct bt_field_path * bt_field_class_option_borrow_selector_field_path_const( const struct bt_field_class *fc) @@ -1649,6 +1663,16 @@ bt_field_class_variant_option_borrow_field_class_const( return named_fc->fc; } +struct bt_field_class * +bt_field_class_variant_option_borrow_field_class( + struct bt_field_class_variant_option *option) +{ + struct bt_named_field_class *named_fc = (void *) option; + + BT_ASSERT_PRE_DEV_NON_NULL(option, "Variant field class option"); + return named_fc->fc; +} + const struct bt_integer_range_set_unsigned * bt_field_class_variant_with_selector_unsigned_option_borrow_ranges_const( const struct bt_field_class_variant_with_selector_unsigned_option *option)