lib: rename `bt_scope` -> `bt_field_path_scope`
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 24 Jul 2019 21:42:25 +0000 (17:42 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 26 Jul 2019 23:19:09 +0000 (19:19 -0400)
Also rename `bt2.Scope` to `bt2.FieldPathScope`.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ieb4c13a336234bfc30223a4afed4e521472cefe3
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1779
Tested-by: jenkins <jenkins@lttng.org>
include/babeltrace2/trace-ir/field-path-const.h
src/bindings/python/bt2/bt2/__init__.py.in
src/bindings/python/bt2/bt2/field_path.py
src/common/common.h
src/lib/trace-ir/field-path.c
src/lib/trace-ir/field-path.h
src/lib/trace-ir/resolve-field-path.c
src/plugins/ctf/fs-sink/translate-trace-ir-to-ctf-ir.c
src/plugins/lttng-utils/debug-info/trace-ir-metadata-field-class-copy.c
src/plugins/text/details/write.c
tests/bindings/python/bt2/test_field_class.py

index c1b7f76b203a90bec22d78a82c6b532c15f87685..b1bd0154e470eb916f3a6741bfe7705e8e44cd94 100644 (file)
@@ -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(
index 217366c9ec190f26decc1b71e0fc9d4ea46a043e..e18188b8d7623eec9b34e044e3e06824a827e0ab 100644 (file)
@@ -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
index 2df37015be0c946e3d23e89d6d3234d11698c5d1..bb644d05302c43c818b4d24c7dfd04df1c0f27f4 100644 (file)
@@ -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,
 }
index 8c74579b525ff1c38c751a3241d6c8e99dcbc4e5..e2bd1bc92126a05fdd7d79873f64951a3b815b55 100644 (file)
@@ -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)";
        }
index 230db9dd53ecf7b15583f15878c2d1d857d0e103..4e5b16f70a657c4de728557a9e9a184e9df3e1ef 100644 (file)
@@ -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");
index 9241d077793775012edbda157909b165e69d1bea..834f7f0fe9de381fd3563a6598999a7409efd99b 100644 (file)
@@ -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;
index 59910bdc1e02fcb6264050e6549d9cf9cfb80801..8865a2a5b89586632cc9bbce314e9d13d9c5e259 100644 (file)
@@ -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();
index 4b20ddead094533def0c2378a6bd88165617dd2d..980e5503ad115c5da64a44fe21e2f9aa7d35ed8a 100644 (file)
@@ -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));
index 4d31bec8368e44cc50c064e3927cd3023b1c58cc..d1d852be19c49ecdafe7d3c93bf3a53c2536edec 100644 (file)
@@ -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;
index 746a69cadd427813985617bbf0cb1d8a449ba091..01d2de91ff2244b7a3b226235b72870f4e9bec83 100644 (file)
@@ -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:
index d99416119caac1d7130dd7bad210583be7007f66..b9b7a2f9919a4c55ac51bc0d4a835f9a99cc740c 100644 (file)
@@ -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):
This page took 0.033299 seconds and 4 git commands to generate.