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>
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(
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
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:
_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,
}
}
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)";
}
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");
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;
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;
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;
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();
/* 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` */
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") ||
/* 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;
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");
struct fs_sink_ctf_field_class **user_tgt_fc)
{
int ret;
- bt_scope tgt_scope;
+ bt_field_path_scope tgt_scope;
*create_before = false;
* 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)
{
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));
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) {
}
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) {
(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));
{
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);
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;
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:
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
)
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):