From e7ceb9df3c98e0b0d394f38c8c63fd236a2a0e06 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Wed, 24 Jul 2019 17:42:25 -0400 Subject: [PATCH] lib: rename `bt_scope` -> `bt_field_path_scope` Also rename `bt2.Scope` to `bt2.FieldPathScope`. Signed-off-by: Philippe Proulx Change-Id: Ieb4c13a336234bfc30223a4afed4e521472cefe3 Reviewed-on: https://review.lttng.org/c/babeltrace/+/1779 Tested-by: jenkins --- .../babeltrace2/trace-ir/field-path-const.h | 16 +++++----- src/bindings/python/bt2/bt2/__init__.py.in | 2 +- src/bindings/python/bt2/bt2/field_path.py | 18 +++++------ src/common/common.h | 18 +++++------ src/lib/trace-ir/field-path.c | 2 +- src/lib/trace-ir/field-path.h | 2 +- src/lib/trace-ir/resolve-field-path.c | 20 ++++++------ .../fs-sink/translate-trace-ir-to-ctf-ir.c | 32 +++++++++---------- .../trace-ir-metadata-field-class-copy.c | 10 +++--- src/plugins/text/details/write.c | 8 ++--- tests/bindings/python/bt2/test_field_class.py | 6 ++-- 11 files changed, 68 insertions(+), 66 deletions(-) diff --git a/include/babeltrace2/trace-ir/field-path-const.h b/include/babeltrace2/trace-ir/field-path-const.h index c1b7f76b..b1bd0154 100644 --- a/include/babeltrace2/trace-ir/field-path-const.h +++ b/include/babeltrace2/trace-ir/field-path-const.h @@ -40,14 +40,14 @@ typedef enum bt_field_path_item_type { BT_FIELD_PATH_ITEM_TYPE_CURRENT_ARRAY_ELEMENT, } bt_field_path_item_type; -typedef enum bt_scope { - BT_SCOPE_PACKET_CONTEXT, - BT_SCOPE_EVENT_COMMON_CONTEXT, - BT_SCOPE_EVENT_SPECIFIC_CONTEXT, - BT_SCOPE_EVENT_PAYLOAD, -} bt_scope; - -extern bt_scope bt_field_path_get_root_scope( +typedef enum bt_field_path_scope { + BT_FIELD_PATH_SCOPE_PACKET_CONTEXT, + BT_FIELD_PATH_SCOPE_EVENT_COMMON_CONTEXT, + BT_FIELD_PATH_SCOPE_EVENT_SPECIFIC_CONTEXT, + BT_FIELD_PATH_SCOPE_EVENT_PAYLOAD, +} bt_field_path_scope; + +extern bt_field_path_scope bt_field_path_get_root_scope( const bt_field_path *field_path); extern uint64_t bt_field_path_get_item_count( diff --git a/src/bindings/python/bt2/bt2/__init__.py.in b/src/bindings/python/bt2/bt2/__init__.py.in index 217366c9..e18188b8 100644 --- a/src/bindings/python/bt2/bt2/__init__.py.in +++ b/src/bindings/python/bt2/bt2/__init__.py.in @@ -74,7 +74,7 @@ from bt2.field_class import _VariantFieldClassWithSignedSelector from bt2.field_class import _ArrayFieldClass from bt2.field_class import _StaticArrayFieldClass from bt2.field_class import _DynamicArrayFieldClass -from bt2.field_path import Scope +from bt2.field_path import FieldPathScope from bt2.field_path import _IndexFieldPathItem from bt2.field_path import _CurrentArrayElementFieldPathItem from bt2.graph import Graph diff --git a/src/bindings/python/bt2/bt2/field_path.py b/src/bindings/python/bt2/bt2/field_path.py index 2df37015..bb644d05 100644 --- a/src/bindings/python/bt2/bt2/field_path.py +++ b/src/bindings/python/bt2/bt2/field_path.py @@ -24,11 +24,11 @@ import collections from bt2 import native_bt, object -class Scope: - PACKET_CONTEXT = native_bt.SCOPE_PACKET_CONTEXT - EVENT_COMMON_CONTEXT = native_bt.SCOPE_EVENT_COMMON_CONTEXT - EVENT_SPECIFIC_CONTEXT = native_bt.SCOPE_EVENT_SPECIFIC_CONTEXT - EVENT_PAYLOAD = native_bt.SCOPE_EVENT_PAYLOAD +class FieldPathScope: + PACKET_CONTEXT = native_bt.FIELD_PATH_SCOPE_PACKET_CONTEXT + EVENT_COMMON_CONTEXT = native_bt.FIELD_PATH_SCOPE_EVENT_COMMON_CONTEXT + EVENT_SPECIFIC_CONTEXT = native_bt.FIELD_PATH_SCOPE_EVENT_SPECIFIC_CONTEXT + EVENT_PAYLOAD = native_bt.FIELD_PATH_SCOPE_EVENT_PAYLOAD class _FieldPathItem: @@ -75,8 +75,8 @@ class _FieldPath(object._SharedObject, collections.abc.Iterable): _SCOPE_TO_OBJ = { - native_bt.SCOPE_PACKET_CONTEXT: Scope.PACKET_CONTEXT, - native_bt.SCOPE_EVENT_COMMON_CONTEXT: Scope.EVENT_COMMON_CONTEXT, - native_bt.SCOPE_EVENT_SPECIFIC_CONTEXT: Scope.EVENT_SPECIFIC_CONTEXT, - native_bt.SCOPE_EVENT_PAYLOAD: Scope.EVENT_PAYLOAD, + native_bt.FIELD_PATH_SCOPE_PACKET_CONTEXT: FieldPathScope.PACKET_CONTEXT, + native_bt.FIELD_PATH_SCOPE_EVENT_COMMON_CONTEXT: FieldPathScope.EVENT_COMMON_CONTEXT, + native_bt.FIELD_PATH_SCOPE_EVENT_SPECIFIC_CONTEXT: FieldPathScope.EVENT_SPECIFIC_CONTEXT, + native_bt.FIELD_PATH_SCOPE_EVENT_PAYLOAD: FieldPathScope.EVENT_PAYLOAD, } diff --git a/src/common/common.h b/src/common/common.h index 8c74579b..e2bd1bc9 100644 --- a/src/common/common.h +++ b/src/common/common.h @@ -454,17 +454,17 @@ const char *bt_common_field_class_integer_preferred_display_base_string(enum bt_ } static inline -const char *bt_common_scope_string(enum bt_scope scope) +const char *bt_common_scope_string(enum bt_field_path_scope scope) { switch (scope) { - case BT_SCOPE_PACKET_CONTEXT: - return "BT_SCOPE_PACKET_CONTEXT"; - case BT_SCOPE_EVENT_COMMON_CONTEXT: - return "BT_SCOPE_EVENT_COMMON_CONTEXT"; - case BT_SCOPE_EVENT_SPECIFIC_CONTEXT: - return "BT_SCOPE_EVENT_SPECIFIC_CONTEXT"; - case BT_SCOPE_EVENT_PAYLOAD: - return "BT_SCOPE_EVENT_PAYLOAD"; + case BT_FIELD_PATH_SCOPE_PACKET_CONTEXT: + return "BT_FIELD_PATH_SCOPE_PACKET_CONTEXT"; + case BT_FIELD_PATH_SCOPE_EVENT_COMMON_CONTEXT: + return "BT_FIELD_PATH_SCOPE_EVENT_COMMON_CONTEXT"; + case BT_FIELD_PATH_SCOPE_EVENT_SPECIFIC_CONTEXT: + return "BT_FIELD_PATH_SCOPE_EVENT_SPECIFIC_CONTEXT"; + case BT_FIELD_PATH_SCOPE_EVENT_PAYLOAD: + return "BT_FIELD_PATH_SCOPE_EVENT_PAYLOAD"; default: return "(unknown)"; } diff --git a/src/lib/trace-ir/field-path.c b/src/lib/trace-ir/field-path.c index 230db9dd..4e5b16f7 100644 --- a/src/lib/trace-ir/field-path.c +++ b/src/lib/trace-ir/field-path.c @@ -79,7 +79,7 @@ end: return field_path; } -enum bt_scope bt_field_path_get_root_scope( +enum bt_field_path_scope bt_field_path_get_root_scope( const struct bt_field_path *field_path) { BT_ASSERT_PRE_DEV_NON_NULL(field_path, "Field path"); diff --git a/src/lib/trace-ir/field-path.h b/src/lib/trace-ir/field-path.h index 9241d077..834f7f0f 100644 --- a/src/lib/trace-ir/field-path.h +++ b/src/lib/trace-ir/field-path.h @@ -39,7 +39,7 @@ struct bt_field_path_item { struct bt_field_path { struct bt_object base; - enum bt_scope root; + enum bt_field_path_scope root; /* Array of `struct bt_field_path_item` (items) */ GArray *items; diff --git a/src/lib/trace-ir/resolve-field-path.c b/src/lib/trace-ir/resolve-field-path.c index 59910bdc..8865a2a5 100644 --- a/src/lib/trace-ir/resolve-field-path.c +++ b/src/lib/trace-ir/resolve-field-path.c @@ -105,7 +105,7 @@ end: static int find_field_class(struct bt_field_class *root_fc, - enum bt_scope root_scope, struct bt_field_class *tgt_fc, + enum bt_field_path_scope root_scope, struct bt_field_class *tgt_fc, struct bt_field_path **ret_field_path) { int ret = 0; @@ -139,25 +139,25 @@ struct bt_field_path *find_field_class_in_ctx(struct bt_field_class *fc, struct bt_field_path *field_path = NULL; int ret; - ret = find_field_class(ctx->packet_context, BT_SCOPE_PACKET_CONTEXT, + ret = find_field_class(ctx->packet_context, BT_FIELD_PATH_SCOPE_PACKET_CONTEXT, fc, &field_path); if (ret || field_path) { goto end; } ret = find_field_class(ctx->event_common_context, - BT_SCOPE_EVENT_COMMON_CONTEXT, fc, &field_path); + BT_FIELD_PATH_SCOPE_EVENT_COMMON_CONTEXT, fc, &field_path); if (ret || field_path) { goto end; } ret = find_field_class(ctx->event_specific_context, - BT_SCOPE_EVENT_SPECIFIC_CONTEXT, fc, &field_path); + BT_FIELD_PATH_SCOPE_EVENT_SPECIFIC_CONTEXT, fc, &field_path); if (ret || field_path) { goto end; } - ret = find_field_class(ctx->event_payload, BT_SCOPE_EVENT_PAYLOAD, + ret = find_field_class(ctx->event_payload, BT_FIELD_PATH_SCOPE_EVENT_PAYLOAD, fc, &field_path); if (ret || field_path) { goto end; @@ -214,16 +214,16 @@ end: BT_ASSERT_PRE_DEV_FUNC static inline struct bt_field_class *borrow_root_field_class( - struct bt_resolve_field_path_context *ctx, enum bt_scope scope) + struct bt_resolve_field_path_context *ctx, enum bt_field_path_scope scope) { switch (scope) { - case BT_SCOPE_PACKET_CONTEXT: + case BT_FIELD_PATH_SCOPE_PACKET_CONTEXT: return ctx->packet_context; - case BT_SCOPE_EVENT_COMMON_CONTEXT: + case BT_FIELD_PATH_SCOPE_EVENT_COMMON_CONTEXT: return ctx->event_common_context; - case BT_SCOPE_EVENT_SPECIFIC_CONTEXT: + case BT_FIELD_PATH_SCOPE_EVENT_SPECIFIC_CONTEXT: return ctx->event_specific_context; - case BT_SCOPE_EVENT_PAYLOAD: + case BT_FIELD_PATH_SCOPE_EVENT_PAYLOAD: return ctx->event_payload; default: abort(); diff --git a/src/plugins/ctf/fs-sink/translate-trace-ir-to-ctf-ir.c b/src/plugins/ctf/fs-sink/translate-trace-ir-to-ctf-ir.c index 4b20ddea..980e5503 100644 --- a/src/plugins/ctf/fs-sink/translate-trace-ir-to-ctf-ir.c +++ b/src/plugins/ctf/fs-sink/translate-trace-ir-to-ctf-ir.c @@ -58,7 +58,7 @@ struct ctx { /* Weak */ struct fs_sink_ctf_event_class *cur_ec; - bt_scope cur_scope; + bt_field_path_scope cur_scope; /* * Array of `struct field_path_elem` */ @@ -215,7 +215,7 @@ int cur_path_stack_push(struct ctx *ctx, g_string_append(field_path_elem->name, name); - if (ctx->cur_scope == BT_SCOPE_PACKET_CONTEXT) { + if (ctx->cur_scope == BT_FIELD_PATH_SCOPE_PACKET_CONTEXT) { if (is_reserved_member_name(name, "packet_size") || is_reserved_member_name(name, "content_size") || is_reserved_member_name(name, "timestamp_begin") || @@ -288,19 +288,19 @@ int create_relative_field_ref(struct ctx *ctx, /* Get target field class's name */ switch (bt_field_path_get_root_scope(tgt_ir_field_path)) { - case BT_SCOPE_PACKET_CONTEXT: + case BT_FIELD_PATH_SCOPE_PACKET_CONTEXT: BT_ASSERT(ctx->cur_sc); tgt_fc = ctx->cur_sc->packet_context_fc; break; - case BT_SCOPE_EVENT_COMMON_CONTEXT: + case BT_FIELD_PATH_SCOPE_EVENT_COMMON_CONTEXT: BT_ASSERT(ctx->cur_sc); tgt_fc = ctx->cur_sc->event_common_context_fc; break; - case BT_SCOPE_EVENT_SPECIFIC_CONTEXT: + case BT_FIELD_PATH_SCOPE_EVENT_SPECIFIC_CONTEXT: BT_ASSERT(ctx->cur_ec); tgt_fc = ctx->cur_ec->spec_context_fc; break; - case BT_SCOPE_EVENT_PAYLOAD: + case BT_FIELD_PATH_SCOPE_EVENT_PAYLOAD: BT_ASSERT(ctx->cur_ec); tgt_fc = ctx->cur_ec->payload_fc; break; @@ -449,22 +449,22 @@ int create_absolute_field_ref(struct ctx *ctx, uint64_t i; switch (bt_field_path_get_root_scope(tgt_ir_field_path)) { - case BT_SCOPE_PACKET_CONTEXT: + case BT_FIELD_PATH_SCOPE_PACKET_CONTEXT: BT_ASSERT(ctx->cur_sc); fc = ctx->cur_sc->packet_context_fc; g_string_assign(tgt_field_ref, "stream.packet.context"); break; - case BT_SCOPE_EVENT_COMMON_CONTEXT: + case BT_FIELD_PATH_SCOPE_EVENT_COMMON_CONTEXT: BT_ASSERT(ctx->cur_sc); fc = ctx->cur_sc->event_common_context_fc; g_string_assign(tgt_field_ref, "stream.event.context"); break; - case BT_SCOPE_EVENT_SPECIFIC_CONTEXT: + case BT_FIELD_PATH_SCOPE_EVENT_SPECIFIC_CONTEXT: BT_ASSERT(ctx->cur_ec); fc = ctx->cur_ec->spec_context_fc; g_string_assign(tgt_field_ref, "event.context"); break; - case BT_SCOPE_EVENT_PAYLOAD: + case BT_FIELD_PATH_SCOPE_EVENT_PAYLOAD: BT_ASSERT(ctx->cur_ec); fc = ctx->cur_ec->payload_fc; g_string_assign(tgt_field_ref, "event.fields"); @@ -535,7 +535,7 @@ void resolve_field_class(struct ctx *ctx, struct fs_sink_ctf_field_class **user_tgt_fc) { int ret; - bt_scope tgt_scope; + bt_field_path_scope tgt_scope; *create_before = false; @@ -1551,7 +1551,7 @@ end: * fill it. */ static -int translate_scope_field_class(struct ctx *ctx, bt_scope scope, +int translate_scope_field_class(struct ctx *ctx, bt_field_path_scope scope, struct fs_sink_ctf_field_class **fc, const bt_field_class *ir_fc) { @@ -1630,7 +1630,7 @@ int translate_event_class(struct fs_sink_comp *fs_sink, BT_ASSERT(ec); ctx.cur_sc = sc; ctx.cur_ec = ec; - ret = translate_scope_field_class(&ctx, BT_SCOPE_EVENT_SPECIFIC_CONTEXT, + ret = translate_scope_field_class(&ctx, BT_FIELD_PATH_SCOPE_EVENT_SPECIFIC_CONTEXT, &ec->spec_context_fc, bt_event_class_borrow_specific_context_field_class_const( ir_ec)); @@ -1638,7 +1638,7 @@ int translate_event_class(struct fs_sink_comp *fs_sink, goto end; } - ret = translate_scope_field_class(&ctx, BT_SCOPE_EVENT_PAYLOAD, + ret = translate_scope_field_class(&ctx, BT_FIELD_PATH_SCOPE_EVENT_PAYLOAD, &ec->payload_fc, bt_event_class_borrow_payload_field_class_const(ir_ec)); if (ret) { @@ -1763,7 +1763,7 @@ int translate_stream_class(struct fs_sink_comp *fs_sink, } ctx.cur_sc = *out_sc; - ret = translate_scope_field_class(&ctx, BT_SCOPE_PACKET_CONTEXT, + ret = translate_scope_field_class(&ctx, BT_FIELD_PATH_SCOPE_PACKET_CONTEXT, &(*out_sc)->packet_context_fc, bt_stream_class_borrow_packet_context_field_class_const(ir_sc)); if (ret) { @@ -1780,7 +1780,7 @@ int translate_stream_class(struct fs_sink_comp *fs_sink, (void *) (*out_sc)->packet_context_fc, 8); } - ret = translate_scope_field_class(&ctx, BT_SCOPE_EVENT_COMMON_CONTEXT, + ret = translate_scope_field_class(&ctx, BT_FIELD_PATH_SCOPE_EVENT_COMMON_CONTEXT, &(*out_sc)->event_common_context_fc, bt_stream_class_borrow_event_common_context_field_class_const( ir_sc)); diff --git a/src/plugins/lttng-utils/debug-info/trace-ir-metadata-field-class-copy.c b/src/plugins/lttng-utils/debug-info/trace-ir-metadata-field-class-copy.c index 4d31bec8..d1d852be 100644 --- a/src/plugins/lttng-utils/debug-info/trace-ir-metadata-field-class-copy.c +++ b/src/plugins/lttng-utils/debug-info/trace-ir-metadata-field-class-copy.c @@ -112,7 +112,7 @@ const bt_field_class *resolve_field_path_to_field_class(const bt_field_path *fp, { struct field_class_resolving_context *fc_resolving_ctx; const bt_field_class *fc; - bt_scope fp_scope; + bt_field_path_scope fp_scope; BT_COMP_LOGD("Resolving field path: fp-addr=%p", fp); @@ -120,19 +120,19 @@ const bt_field_class *resolve_field_path_to_field_class(const bt_field_path *fp, fp_scope = bt_field_path_get_root_scope(fp); switch (fp_scope) { - case BT_SCOPE_PACKET_CONTEXT: + case BT_FIELD_PATH_SCOPE_PACKET_CONTEXT: fc = walk_field_path(md_maps, fp, fc_resolving_ctx->packet_context); break; - case BT_SCOPE_EVENT_COMMON_CONTEXT: + case BT_FIELD_PATH_SCOPE_EVENT_COMMON_CONTEXT: fc = walk_field_path(md_maps, fp, fc_resolving_ctx->event_common_context); break; - case BT_SCOPE_EVENT_SPECIFIC_CONTEXT: + case BT_FIELD_PATH_SCOPE_EVENT_SPECIFIC_CONTEXT: fc = walk_field_path(md_maps, fp, fc_resolving_ctx->event_specific_context); break; - case BT_SCOPE_EVENT_PAYLOAD: + case BT_FIELD_PATH_SCOPE_EVENT_PAYLOAD: fc = walk_field_path(md_maps, fp, fc_resolving_ctx->event_payload); break; diff --git a/src/plugins/text/details/write.c b/src/plugins/text/details/write.c index 746a69ca..01d2de91 100644 --- a/src/plugins/text/details/write.c +++ b/src/plugins/text/details/write.c @@ -603,16 +603,16 @@ void write_field_path(struct details_write_ctx *ctx, g_string_append_c(ctx->str, '['); switch (bt_field_path_get_root_scope(field_path)) { - case BT_SCOPE_PACKET_CONTEXT: + case BT_FIELD_PATH_SCOPE_PACKET_CONTEXT: write_str_prop_value(ctx, "Packet context"); break; - case BT_SCOPE_EVENT_COMMON_CONTEXT: + case BT_FIELD_PATH_SCOPE_EVENT_COMMON_CONTEXT: write_str_prop_value(ctx, "Event common context"); break; - case BT_SCOPE_EVENT_SPECIFIC_CONTEXT: + case BT_FIELD_PATH_SCOPE_EVENT_SPECIFIC_CONTEXT: write_str_prop_value(ctx, "Event specific context"); break; - case BT_SCOPE_EVENT_PAYLOAD: + case BT_FIELD_PATH_SCOPE_EVENT_PAYLOAD: write_str_prop_value(ctx, "Event payload"); break; default: diff --git a/tests/bindings/python/bt2/test_field_class.py b/tests/bindings/python/bt2/test_field_class.py index d9941611..b9b7a2f9 100644 --- a/tests/bindings/python/bt2/test_field_class.py +++ b/tests/bindings/python/bt2/test_field_class.py @@ -624,7 +624,7 @@ class _VariantFieldClassWithSelectorTestCase: def test_selector_field_path_root_scope(self): self._fill_default_fc_for_field_path_test() self.assertEqual( - self._fc.selector_field_path.root_scope, bt2.Scope.PACKET_CONTEXT + self._fc.selector_field_path.root_scope, bt2.FieldPathScope.PACKET_CONTEXT ) @@ -749,7 +749,9 @@ class DynamicArrayFieldClassTestCase(unittest.TestCase): def test_field_path_root_scope(self): fc = self._create_field_class_for_field_path_test() - self.assertEqual(fc.length_field_path.root_scope, bt2.Scope.PACKET_CONTEXT) + self.assertEqual( + fc.length_field_path.root_scope, bt2.FieldPathScope.PACKET_CONTEXT + ) def test_create_invalid_field_class(self): with self.assertRaises(TypeError): -- 2.34.1