From bcd7ef6f409d0525f278c9bc02da3e188707f754 Mon Sep 17 00:00:00 2001 From: Francis Deslauriers Date: Thu, 5 Sep 2019 12:48:32 -0400 Subject: [PATCH] lib: add non-const FC borrow functions for container FCs Signed-off-by: Francis Deslauriers Change-Id: I015c3038d505873cf0bdf2ce0673f92d757aeb19 Reviewed-on: https://review.lttng.org/c/babeltrace/+/2002 Tested-by: jenkins Reviewed-by: Simon Marchi --- include/babeltrace2/trace-ir/field-class.h | 10 +++++++ src/lib/trace-ir/field-class.c | 31 ++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/include/babeltrace2/trace-ir/field-class.h b/include/babeltrace2/trace-ir/field-class.h index 847064b9..28810004 100644 --- a/include/babeltrace2/trace-ir/field-class.h +++ b/include/babeltrace2/trace-ir/field-class.h @@ -113,6 +113,10 @@ extern bt_field_class_structure_member * bt_field_class_structure_borrow_member_by_name( bt_field_class *field_class, const char *name); +extern bt_field_class * +bt_field_class_structure_member_borrow_field_class( + bt_field_class_structure_member *member); + extern bt_value *bt_field_class_structure_member_borrow_user_attributes( bt_field_class_structure_member *member); @@ -137,6 +141,9 @@ extern bt_field_class *bt_field_class_option_create( bt_field_class *content_field_class, bt_field_class *selector_field_class); +extern bt_field_class *bt_field_class_option_borrow_field_class( + bt_field_class *field_class); + extern bt_field_class *bt_field_class_variant_create( bt_trace_class *trace_class, bt_field_class *selector_field_class); @@ -176,6 +183,9 @@ extern bt_field_class_variant_option * bt_field_class_variant_borrow_option_by_name( bt_field_class *field_class, const char *name); +extern bt_field_class *bt_field_class_variant_option_borrow_field_class( + bt_field_class_variant_option *option); + extern bt_value *bt_field_class_variant_option_borrow_user_attributes( bt_field_class_variant_option *option); diff --git a/src/lib/trace-ir/field-class.c b/src/lib/trace-ir/field-class.c index 610f8f75..4dfed492 100644 --- a/src/lib/trace-ir/field-class.c +++ b/src/lib/trace-ir/field-class.c @@ -1139,6 +1139,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) { @@ -1211,6 +1221,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) @@ -1648,6 +1669,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) -- 2.34.1