BT_FIELD_CLASS_TYPE_STRING = 8,
BT_FIELD_CLASS_TYPE_STRUCTURE = 9,
BT_FIELD_CLASS_TYPE_STATIC_ARRAY = 10,
- BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY = 11,
- BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR = 12,
- BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR = 13,
- BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR = 14,
- BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR = 15,
- BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR = 16,
- BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR = 17,
- BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR = 18,
+ BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD = 11,
+ BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD = 12,
+ BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR = 13,
+ BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR = 14,
+ BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR = 15,
+ BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR = 16,
+ BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR = 17,
+ BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR = 18,
+ BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR = 19,
} bt_field_class_type;
typedef enum bt_field_class_integer_preferred_display_base {
const bt_field_class *field_class);
extern const bt_field_path *
-bt_field_class_array_dynamic_borrow_length_field_path_const(
+bt_field_class_array_dynamic_with_length_field_borrow_length_field_path_const(
const bt_field_class *field_class);
extern const bt_field_class *
from bt2.field_class import _ArrayFieldClass
from bt2.field_class import _StaticArrayFieldClass
from bt2.field_class import _DynamicArrayFieldClass
+from bt2.field_class import _DynamicArrayWithLengthFieldFieldClass
from bt2.field_class import _BoolFieldClassConst
from bt2.field_class import _BitArrayFieldClassConst
from bt2.field_class import _IntegerFieldClassConst
from bt2.field_class import _ArrayFieldClassConst
from bt2.field_class import _StaticArrayFieldClassConst
from bt2.field_class import _DynamicArrayFieldClassConst
+from bt2.field_class import _DynamicArrayWithLengthFieldFieldClassConst
from bt2.field_path import FieldPathScope
from bt2.field_path import _IndexFieldPathItem
from bt2.field_path import _CurrentArrayElementFieldPathItem
native_bt.FIELD_CLASS_TYPE_STRING: _StringFieldConst,
native_bt.FIELD_CLASS_TYPE_STRUCTURE: _StructureFieldConst,
native_bt.FIELD_CLASS_TYPE_STATIC_ARRAY: _StaticArrayFieldConst,
- native_bt.FIELD_CLASS_TYPE_DYNAMIC_ARRAY: _DynamicArrayFieldConst,
+ native_bt.FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD: _DynamicArrayFieldConst,
+ native_bt.FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD: _DynamicArrayFieldConst,
native_bt.FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR: _OptionFieldConst,
native_bt.FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR: _OptionFieldConst,
native_bt.FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR: _OptionFieldConst,
native_bt.FIELD_CLASS_TYPE_STRING: _StringField,
native_bt.FIELD_CLASS_TYPE_STRUCTURE: _StructureField,
native_bt.FIELD_CLASS_TYPE_STATIC_ARRAY: _StaticArrayField,
- native_bt.FIELD_CLASS_TYPE_DYNAMIC_ARRAY: _DynamicArrayField,
+ native_bt.FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD: _DynamicArrayField,
+ native_bt.FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD: _DynamicArrayField,
native_bt.FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR: _OptionField,
native_bt.FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR: _OptionField,
native_bt.FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR: _OptionField,
class _DynamicArrayFieldClassConst(_ArrayFieldClassConst):
_NAME = 'Const dynamic array'
+
+class _DynamicArrayWithLengthFieldFieldClassConst(_DynamicArrayFieldClassConst):
+ _NAME = 'Const dynamic array (with length field)'
+
@property
def length_field_path(self):
- ptr = native_bt.field_class_array_dynamic_borrow_length_field_path_const(
+ ptr = native_bt.field_class_array_dynamic_with_length_field_borrow_length_field_path_const(
self._ptr
)
if ptr is None:
_NAME = 'Dynamic array'
+class _DynamicArrayWithLengthFieldFieldClass(
+ _DynamicArrayWithLengthFieldFieldClassConst, _DynamicArrayFieldClass
+):
+ _NAME = 'Dynamic array (with length field)'
+
+
_FIELD_CLASS_TYPE_TO_CONST_OBJ = {
native_bt.FIELD_CLASS_TYPE_BOOL: _BoolFieldClassConst,
native_bt.FIELD_CLASS_TYPE_BIT_ARRAY: _BitArrayFieldClassConst,
native_bt.FIELD_CLASS_TYPE_STRING: _StringFieldClassConst,
native_bt.FIELD_CLASS_TYPE_STRUCTURE: _StructureFieldClassConst,
native_bt.FIELD_CLASS_TYPE_STATIC_ARRAY: _StaticArrayFieldClassConst,
- native_bt.FIELD_CLASS_TYPE_DYNAMIC_ARRAY: _DynamicArrayFieldClassConst,
+ native_bt.FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD: _DynamicArrayFieldClassConst,
+ native_bt.FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD: _DynamicArrayWithLengthFieldFieldClassConst,
native_bt.FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR: _OptionFieldClassConst,
native_bt.FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR: _OptionWithBoolSelectorFieldClassConst,
native_bt.FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR: _OptionWithUnsignedIntegerSelectorFieldClassConst,
native_bt.FIELD_CLASS_TYPE_STRING: _StringFieldClass,
native_bt.FIELD_CLASS_TYPE_STRUCTURE: _StructureFieldClass,
native_bt.FIELD_CLASS_TYPE_STATIC_ARRAY: _StaticArrayFieldClass,
- native_bt.FIELD_CLASS_TYPE_DYNAMIC_ARRAY: _DynamicArrayFieldClass,
+ native_bt.FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD: _DynamicArrayFieldClass,
+ native_bt.FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD: _DynamicArrayWithLengthFieldFieldClass,
native_bt.FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR: _OptionFieldClass,
native_bt.FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR: _OptionWithBoolSelectorFieldClass,
native_bt.FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR: _OptionWithUnsignedIntegerSelectorFieldClass,
self._ptr, elem_fc._ptr, length_fc_ptr
)
self._check_field_class_create_status(ptr, 'dynamic array')
- fc = bt2_field_class._DynamicArrayFieldClass._create_from_ptr(ptr)
+ fc = bt2_field_class._create_field_class_from_ptr_and_get_ref(ptr)
self._set_field_class_user_attrs(fc, user_attributes)
return fc
return "STRUCTURE";
case BT_FIELD_CLASS_TYPE_STATIC_ARRAY:
return "STATIC_ARRAY";
- case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY:
- return "DYNAMIC_ARRAY";
+ case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD:
+ return "DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD";
+ case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD:
+ return "DYNAMIC_ARRAY_WITH_LENGTH_FIELD";
case BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR:
return "OPTION_WITHOUT_SELECTOR";
case BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR:
BUF_APPEND(", %slength=%" PRIu64, PRFIELD(array_fc->length));
break;
}
- case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY:
+ case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD:
+ case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD:
{
const struct bt_field_class_array_dynamic *array_fc =
(const void *) field_class;
break;
}
case BT_FIELD_CLASS_TYPE_STATIC_ARRAY:
- case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY:
+ case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD:
+ case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD:
{
const struct bt_field_array *array_field = (const void *) field;
}
if (init_array_field_class((void *) array_fc,
- BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY,
+ length_fc ?
+ BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD :
+ BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD,
destroy_dynamic_array_field_class, element_fc)) {
goto error;
}
}
const struct bt_field_path *
-bt_field_class_array_dynamic_borrow_length_field_path_const(
+bt_field_class_array_dynamic_with_length_field_borrow_length_field_path_const(
const struct bt_field_class *fc)
{
const struct bt_field_class_array_dynamic *seq_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_DYNAMIC_ARRAY,
+ BT_ASSERT_PRE_DEV_FC_HAS_ID(fc,
+ BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD,
"Field class");
return seq_fc->length_field_path;
}
break;
}
case BT_FIELD_CLASS_TYPE_STATIC_ARRAY:
- case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY:
+ case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD:
+ case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD:
{
struct bt_field_class_array *array_fc = (void *) fc;
#define _BT_ASSERT_PRE_FC_IS_ARRAY_COND(_fc) \
(((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_STATIC_ARRAY || \
- ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY)
+ ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD || \
+ ((const struct bt_field_class *) (_fc))->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD)
#define _BT_ASSERT_PRE_FC_IS_ARRAY_FMT(_name) \
_name " is not an array field class: %![fc-]+F"
[BT_FIELD_CLASS_TYPE_STRING] = create_string_field,
[BT_FIELD_CLASS_TYPE_STRUCTURE] = create_structure_field,
[BT_FIELD_CLASS_TYPE_STATIC_ARRAY] = create_static_array_field,
- [BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY] = create_dynamic_array_field,
+ [BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD] = create_dynamic_array_field,
+ [BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD] = create_dynamic_array_field,
[BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR] = create_option_field,
[BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR] = create_option_field,
[BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR] = create_option_field,
[BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR] = create_option_field,
[BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR] = create_variant_field,
- [BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR] = create_variant_field,
- [BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR] = create_variant_field,
+ [BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR] = create_variant_field,
+ [BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR] = create_variant_field,
};
static
[BT_FIELD_CLASS_TYPE_STRING] = destroy_string_field,
[BT_FIELD_CLASS_TYPE_STRUCTURE] = destroy_structure_field,
[BT_FIELD_CLASS_TYPE_STATIC_ARRAY] = destroy_array_field,
- [BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY] = destroy_array_field,
+ [BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD] = destroy_array_field,
+ [BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD] = destroy_array_field,
[BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR] = destroy_option_field,
[BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR] = destroy_option_field,
[BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR] = destroy_option_field,
[BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR] = destroy_option_field,
[BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR] = destroy_variant_field,
- [BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR] = destroy_variant_field,
- [BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR] = destroy_variant_field,
+ [BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR] = destroy_variant_field,
+ [BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR] = destroy_variant_field,
};
struct bt_field_class *bt_field_borrow_class(struct bt_field *field)
struct bt_field_array *array_field = (void *) field;
BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
- BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field,
- BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY, "Field");
+ BT_ASSERT_PRE_DEV_FIELD_IS_DYNAMIC_ARRAY(field, "Field");
BT_ASSERT_PRE_DEV_FIELD_HOT(field, "Field");
if (G_UNLIKELY(length > array_field->fields->len)) {
#define BT_ASSERT_PRE_DEV_FIELD_IS_ARRAY(_field, _name) \
BT_ASSERT_PRE_DEV( \
((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_STATIC_ARRAY || \
- ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY, \
+ ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD || \
+ ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD, \
_name " is not an array field: %![field-]+f", (_field))
+#define BT_ASSERT_PRE_DEV_FIELD_IS_DYNAMIC_ARRAY(_field, _name) \
+ BT_ASSERT_PRE_DEV( \
+ ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD || \
+ ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD, \
+ _name " is not a dynamic array field: %![field-]+f", (_field))
+
#define BT_ASSERT_PRE_DEV_FIELD_IS_OPTION(_field, _name) \
BT_ASSERT_PRE_DEV( \
((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR || \
break;
}
case BT_FIELD_CLASS_TYPE_STATIC_ARRAY:
- case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY:
+ case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD:
+ case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD:
{
struct bt_field_class_array *array_fc = (void *) fc;
struct bt_field_path_item item = {
break;
}
case BT_FIELD_CLASS_TYPE_STATIC_ARRAY:
- case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY:
+ case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD:
+ case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD:
{
struct bt_field_class_array *array_fc = (void *) parent_fc;
tgt_field_path, i);
if (fc->type == BT_FIELD_CLASS_TYPE_STATIC_ARRAY ||
- fc->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY ||
+ fc->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD ||
+ fc->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD ||
fc->type == BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR ||
fc->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR ||
fc->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR ||
tgt_field_path, tgt_i);
if (tgt_fc->type == BT_FIELD_CLASS_TYPE_STATIC_ARRAY ||
- tgt_fc->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY ||
+ tgt_fc->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD ||
+ tgt_fc->type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD ||
tgt_fc->type == BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR ||
tgt_fc->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR ||
tgt_fc->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR ||
{
struct bt_field_class_option_with_selector *opt_fc = (void *) fc;
- if (opt_fc->selector_fc) {
- BT_ASSERT(!opt_fc->selector_field_path);
- opt_fc->selector_field_path = resolve_field_path(
- fc, opt_fc->selector_fc, ctx);
- if (!opt_fc->selector_field_path) {
- ret = -1;
- goto end;
- }
+ BT_ASSERT(opt_fc->selector_fc);
+ BT_ASSERT(!opt_fc->selector_field_path);
+ opt_fc->selector_field_path = resolve_field_path(
+ fc, opt_fc->selector_fc, ctx);
+ if (!opt_fc->selector_field_path) {
+ ret = -1;
+ goto end;
}
break;
}
- case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY:
+ case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD:
{
struct bt_field_class_array_dynamic *dyn_array_fc = (void *) fc;
- if (dyn_array_fc->length_fc) {
- BT_ASSERT(!dyn_array_fc->length_field_path);
- dyn_array_fc->length_field_path = resolve_field_path(
- fc, dyn_array_fc->length_fc, ctx);
- if (!dyn_array_fc->length_field_path) {
- ret = -1;
- goto end;
- }
+ BT_ASSERT(dyn_array_fc->length_fc);
+ BT_ASSERT(!dyn_array_fc->length_field_path);
+ dyn_array_fc->length_field_path = resolve_field_path(
+ fc, dyn_array_fc->length_fc, ctx);
+ if (!dyn_array_fc->length_field_path) {
+ ret = -1;
+ goto end;
}
break;
break;
}
case BT_FIELD_CLASS_TYPE_STATIC_ARRAY:
- case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY:
+ case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD:
+ case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD:
{
struct bt_field_class_array *array_fc = (void *) fc;
break;
}
case BT_FIELD_CLASS_TYPE_STATIC_ARRAY:
- case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY:
+ case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD:
+ case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD:
BT_ASSERT(index < bt_field_array_get_length(base_field));
next_field = bt_field_array_borrow_element_field_by_index(
base_field, index);
*/
if (!seq_fc->base.is_text) {
BT_ASSERT(bt_field_get_class_type(seq_field) ==
- BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY);
+ BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD ||
+ bt_field_get_class_type(seq_field) ==
+ BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD);
ret = bt_field_array_dynamic_set_length(seq_field,
(uint64_t) length);
if (ret) {
fc->length_ref = g_string_new(NULL);
BT_ASSERT(fc->length_ref);
fc->length_is_before =
- bt_field_class_array_dynamic_borrow_length_field_path_const(ir_fc) ==
- NULL;
+ bt_field_class_get_type(ir_fc) ==
+ BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD;
return fc;
}
BT_ASSERT(fc);
/* Resolve length field class before appending to parent */
- resolve_field_class(ctx,
- bt_field_class_array_dynamic_borrow_length_field_path_const(
- fc->base.base.ir_fc),
- fc->length_ref, &fc->length_is_before, NULL);
+ if (bt_field_class_get_type(cur_path_stack_top(ctx)->ir_fc) ==
+ BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD) {
+ resolve_field_class(ctx,
+ bt_field_class_array_dynamic_with_length_field_borrow_length_field_path_const(
+ fc->base.base.ir_fc),
+ fc->length_ref, &fc->length_is_before, NULL);
+ }
append_to_parent_field_class(ctx, (void *) fc);
ret = cur_path_stack_push(ctx, UINT64_C(-1), NULL, false, elem_ir_fc,
case BT_FIELD_CLASS_TYPE_STATIC_ARRAY:
ret = translate_static_array_field_class(ctx);
break;
- case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY:
+ case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD:
+ case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD:
ret = translate_dynamic_array_field_class(ctx);
break;
case BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR:
build_id_field_class = bt_field_borrow_class_const(build_id_field);
BT_ASSERT(bt_field_class_get_type(build_id_field_class) ==
- BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY);
+ BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD ||
+ bt_field_class_get_type(build_id_field_class) ==
+ BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD);
BT_ASSERT(bt_field_class_get_type(
bt_field_class_array_borrow_element_field_class_const(
build_id_field_class)) ==
build_id_field_class = bt_field_borrow_class_const(build_id_field);
BT_ASSERT(bt_field_class_get_type(build_id_field_class) ==
- BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY);
+ BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD ||
+ bt_field_class_get_type(build_id_field_class) ==
+ BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD);
BT_ASSERT(bt_field_class_get_type(
bt_field_class_array_borrow_element_field_class_const(
build_id_field_class)) ==
}
break;
}
- case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY:
+ case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD:
+ case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD:
/* fall through */
case BT_FIELD_CLASS_TYPE_STATIC_ARRAY:
{
array_len = bt_field_array_get_length(in_field);
- if (in_fc_type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY) {
+ if (in_fc_type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD ||
+ in_fc_type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD) {
set_len_status = bt_field_array_dynamic_set_length(
out_field, array_len);
if (set_len_status !=
break;
}
case BT_FIELD_CLASS_TYPE_STATIC_ARRAY:
- case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY:
+ case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD:
+ case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD:
{
BT_ASSERT(bt_field_path_item_get_type(fp_item) ==
BT_FIELD_PATH_ITEM_TYPE_CURRENT_ARRAY_ELEMENT);
out_elem_fc, array_len);
break;
}
- case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY:
+ case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD:
+ case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD:
{
const bt_field_class *in_elem_fc =
bt_field_class_array_borrow_element_field_class_const(
in_field_class);
- const bt_field_path *length_fp =
- bt_field_class_array_dynamic_borrow_length_field_path_const(
- in_field_class);
bt_field_class *out_length_fc = NULL;
-
bt_field_class *out_elem_fc = copy_field_class_array_element(
md_maps, in_elem_fc);
+
if (!out_elem_fc) {
out_field_class = NULL;
goto error;
}
- if (length_fp) {
+ if (fc_type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD) {
+ const bt_field_path *length_fp =
+ bt_field_class_array_dynamic_with_length_field_borrow_length_field_path_const(
+ in_field_class);
const bt_field_class *in_length_fc =
resolve_field_path_to_field_class(length_fp,
md_maps);
ret = field_class_static_array_copy(md_maps,
in_field_class, out_field_class);
break;
- case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY:
+ case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD:
+ case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD:
ret = field_class_dynamic_array_copy(md_maps,
in_field_class, out_field_class);
break;
case BT_FIELD_CLASS_TYPE_STATIC_ARRAY:
type = "Static array";
break;
- case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY:
- type = "Dynamic array";
+ case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD:
+ type = "Dynamic array (no length field)";
+ break;
+ case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD:
+ type = "Dynamic array (with length field)";
break;
case BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR:
type = "Option (no selector)";
break;
}
case BT_FIELD_CLASS_TYPE_STATIC_ARRAY:
- case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY:
+ case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD:
+ case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD:
if (fc_type == BT_FIELD_CLASS_TYPE_STATIC_ARRAY) {
g_string_append(ctx->str, " (Length ");
write_uint_prop_value(ctx,
bt_field_class_array_static_get_length(fc));
g_string_append_c(ctx->str, ')');
- } else {
+ } else if (fc_type == BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD) {
const bt_field_path *length_field_path =
- bt_field_class_array_dynamic_borrow_length_field_path_const(
+ bt_field_class_array_dynamic_with_length_field_borrow_length_field_path_const(
fc);
- if (length_field_path) {
- g_string_append(ctx->str, " (Length field path ");
- write_field_path(ctx, length_field_path);
- g_string_append_c(ctx->str, ')');
- }
+ g_string_append(ctx->str, " (Length field path ");
+ write_field_path(ctx, length_field_path);
+ g_string_append_c(ctx->str, ')');
}
break;
break;
}
case BT_FIELD_CLASS_TYPE_STATIC_ARRAY:
- case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY:
+ case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD:
+ case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD:
if (wrote_user_attrs) {
write_nl(ctx);
} else {
break;
}
case BT_FIELD_CLASS_TYPE_STATIC_ARRAY:
- case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY:
+ case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD:
+ case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD:
{
uint64_t length = bt_field_array_get_length(field);
return print_variant(pretty, field, print_names);
case BT_FIELD_CLASS_TYPE_STATIC_ARRAY:
return print_array(pretty, field, print_names);
- case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY:
+ case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD:
+ case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD:
return print_sequence(pretty, field, print_names);
default:
// TODO: log instead
type(fc.element_field_class), bt2_field_class._SignedIntegerFieldClass
)
+
+class _ArrayFieldClassConstTestCase:
def test_const_attr_element_field_class(self):
fc = self._create_const_array()
self.assertIs(
)
-class StaticArrayFieldClassTestCase(_ArrayFieldClassTestCase, unittest.TestCase):
+class StaticArrayFieldClassTestCase(
+ _ArrayFieldClassTestCase, _ArrayFieldClassConstTestCase, unittest.TestCase
+):
@staticmethod
def _const_value_setter(field):
field.value = [9] * 45
)
-class DynamicArrayFieldClassTestCase(_ArrayFieldClassTestCase, unittest.TestCase):
+class DynamicArrayFieldClassTestCase(
+ _ArrayFieldClassTestCase, _ArrayFieldClassConstTestCase, unittest.TestCase
+):
@staticmethod
def _const_value_setter(field):
field.value = []
def setUp(self):
self._tc = get_default_trace_class()
self._elem_fc = self._tc.create_signed_integer_field_class(23)
- self._len_fc = self._tc.create_unsigned_integer_field_class(12)
def test_create_default(self):
fc = self._tc.create_dynamic_array_field_class(self._elem_fc)
self.assertEqual(fc.element_field_class.addr, self._elem_fc.addr)
+ self.assertEqual(len(fc.user_attributes), 0)
+
+ def test_create_invalid_field_class(self):
+ with self.assertRaises(TypeError):
+ self._tc.create_dynamic_array_field_class(object())
+
+
+class DynamicArrayWithLengthFieldFieldClassTestCase(
+ _ArrayFieldClassTestCase, unittest.TestCase
+):
+ @staticmethod
+ def _const_value_setter(field):
+ field.value = []
+
+ def _create_array(self):
+ return self._tc.create_dynamic_array_field_class(self._elem_fc, self._len_fc)
+
+ def setUp(self):
+ self._tc = get_default_trace_class()
+ self._elem_fc = self._tc.create_signed_integer_field_class(23)
+ self._len_fc = self._tc.create_unsigned_integer_field_class(12)
+
+ def test_create_default(self):
+ fc = self._create_array()
+ self.assertEqual(fc.element_field_class.addr, self._elem_fc.addr)
self.assertIsNone(fc.length_field_path, None)
self.assertEqual(len(fc.user_attributes), 0)
# } inner_struct[2];
# };
- fc = self._tc.create_dynamic_array_field_class(self._elem_fc, self._len_fc)
+ fc = self._create_array()
foo_fc = self._tc.create_single_precision_real_field_class()
bar_fc = self._tc.create_string_field_class()
fc.length_field_path.root_scope, bt2.FieldPathScope.PACKET_CONTEXT
)
- def test_create_invalid_field_class(self):
- with self.assertRaises(TypeError):
- self._tc.create_dynamic_array_field_class(object())
-
def test_create_invalid_length_type(self):
with self.assertRaises(TypeError):
self._tc.create_dynamic_array_field_class(
'_DynamicArrayFieldClass',
'_DynamicArrayFieldClassConst',
'_DynamicArrayFieldConst',
+ '_DynamicArrayWithLengthFieldFieldClass',
+ '_DynamicArrayWithLengthFieldFieldClassConst',
'_EnumerationField',
'_EnumerationFieldClass',
'_EnumerationFieldClassConst',
Payload field class: Structure (3 members):
baddr: Unsigned integer (64-bit, Base 16)
_build_id_length: Unsigned integer (64-bit, Base 10)
- build_id: Dynamic array (Length field path [Event payload: 1]):
+ build_id: Dynamic array (with length field) (Length field path [Event payload: 1]):
Element: Unsigned integer (8-bit, Base 16)
Event class `lttng_ust_statedump:debug_link` (ID 3):
Log level: Debug (line)
Payload field class: Structure (3 members):
baddr: Unsigned integer (64-bit, Base 16)
_build_id_length: Unsigned integer (64-bit, Base 10)
- build_id: Dynamic array (Length field path [Event payload: 1]):
+ build_id: Dynamic array (with length field) (Length field path [Event payload: 1]):
Element: Unsigned integer (8-bit, Base 16)
Event class `lttng_ust_lib:debug_link` (ID 7):
Log level: Debug (line)
Element: Signed integer (64-bit, Base 16)
arrfield2: String
_seqfield1_length: Unsigned integer (64-bit, Base 10)
- seqfield1: Dynamic array (Length field path [Event payload: 11]):
+ seqfield1: Dynamic array (with length field) (Length field path [Event payload: 11]):
Element: Signed integer (8-bit, Base 10)
_seqfield1_hex_length: Unsigned integer (64-bit, Base 10)
- seqfield1_hex: Dynamic array (Length field path [Event payload: 13]):
+ seqfield1_hex: Dynamic array (with length field) (Length field path [Event payload: 13]):
Element: Signed integer (8-bit, Base 16)
_seqfield2_length: Unsigned integer (64-bit, Base 10)
seqfield2: String
_seqfield_network_3_length: Unsigned integer (64-bit, Base 10)
- seqfield_network_3: Dynamic array (Length field path [Event payload: 17]):
+ seqfield_network_3: Dynamic array (with length field) (Length field path [Event payload: 17]):
Element: Signed integer (64-bit, Base 10)
stringfield: String
floatfield: Single-precision real
Payload field class: Structure (3 members):
baddr: Unsigned integer (64-bit, Base 16)
_build_id_length: Unsigned integer (64-bit, Base 10)
- build_id: Dynamic array (Length field path [Event payload: 1]):
+ build_id: Dynamic array (with length field) (Length field path [Event payload: 1]):
Element: Unsigned integer (8-bit, Base 16)
Event class `lttng_ust_statedump:debug_link` (ID 3):
Log level: Debug (line)
Payload field class: Structure (3 members):
baddr: Unsigned integer (64-bit, Base 16)
_build_id_length: Unsigned integer (64-bit, Base 10)
- build_id: Dynamic array (Length field path [Event payload: 1]):
+ build_id: Dynamic array (with length field) (Length field path [Event payload: 1]):
Element: Unsigned integer (8-bit, Base 16)
Event class `lttng_ust_lib:debug_link` (ID 7):
Log level: Debug (line)
Element: Signed integer (64-bit, Base 16)
arrfield2: String
_seqfield1_length: Unsigned integer (64-bit, Base 10)
- seqfield1: Dynamic array (Length field path [Event payload: 11]):
+ seqfield1: Dynamic array (with length field) (Length field path [Event payload: 11]):
Element: Signed integer (8-bit, Base 10)
_seqfield1_hex_length: Unsigned integer (64-bit, Base 10)
- seqfield1_hex: Dynamic array (Length field path [Event payload: 13]):
+ seqfield1_hex: Dynamic array (with length field) (Length field path [Event payload: 13]):
Element: Signed integer (8-bit, Base 16)
_seqfield2_length: Unsigned integer (64-bit, Base 10)
seqfield2: String
_seqfield_network_3_length: Unsigned integer (64-bit, Base 10)
- seqfield_network_3: Dynamic array (Length field path [Event payload: 17]):
+ seqfield_network_3: Dynamic array (with length field) (Length field path [Event payload: 17]):
Element: Signed integer (64-bit, Base 10)
stringfield: String
floatfield: Single-precision real
arrfield3: Static array (Length 3):
Element: Unsigned integer (32-bit, Base 10)
_seqfield1_length: Unsigned integer (64-bit, Base 10)
- seqfield1: Dynamic array (Length field path [Event payload: 8]):
+ seqfield1: Dynamic array (with length field) (Length field path [Event payload: 8]):
Element: Signed integer (8-bit, Base 10)
_seqfield2_length: Unsigned integer (64-bit, Base 10)
seqfield2: String
_seqfield3_length: Unsigned integer (64-bit, Base 10)
- seqfield3: Dynamic array (Length field path [Event payload: 12]):
+ seqfield3: Dynamic array (with length field) (Length field path [Event payload: 12]):
Element: Unsigned integer (32-bit, Base 10)
_seqfield4_length: Unsigned integer (64-bit, Base 10)
- seqfield4: Dynamic array (Length field path [Event payload: 14]):
+ seqfield4: Dynamic array (with length field) (Length field path [Event payload: 14]):
Element: Signed integer (64-bit, Base 10)
stringfield: String
stringfield2: String
_bitfield_seq_length: Unsigned integer (8-bit, Base 10)
bitfield_seq_padding: Structure (0 members)
- bitfield_seq: Dynamic array (Length field path [Event payload: 18]):
+ bitfield_seq: Dynamic array (with length field) (Length field path [Event payload: 18]):
Element: Unsigned integer (1-bit, Base 10)
bitfield_array_padding: Structure (0 members)
bitfield_array: Static array (Length 192):