bt_field *next_field = NULL;
bt_field *base_field;
const bt_field_class *base_fc;
+ bt_field_class_type base_fc_type;
size_t index;
BT_ASSERT(!stack_empty(notit->stack));
BT_ASSERT(base_field);
base_fc = bt_field_borrow_class_const(base_field);
BT_ASSERT(base_fc);
+ base_fc_type = bt_field_class_get_type(base_fc);
- switch (bt_field_class_get_type(base_fc)) {
- case BT_FIELD_CLASS_TYPE_STRUCTURE:
- {
+ if (base_fc_type == BT_FIELD_CLASS_TYPE_STRUCTURE) {
BT_ASSERT(index <
bt_field_class_structure_get_member_count(
bt_field_borrow_class_const(
next_field =
bt_field_structure_borrow_member_field_by_index(
base_field, index);
- break;
- }
- case BT_FIELD_CLASS_TYPE_STATIC_ARRAY:
- case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY:
+ } else if (bt_field_class_type_is(base_fc_type,
+ BT_FIELD_CLASS_TYPE_ARRAY)) {
BT_ASSERT(index < bt_field_array_get_length(base_field));
next_field = bt_field_array_borrow_element_field_by_index(
base_field, index);
- break;
- case BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR:
- case BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_SELECTOR:
- case BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_SELECTOR:
+ } else if (bt_field_class_type_is(base_fc_type,
+ BT_FIELD_CLASS_TYPE_VARIANT)) {
BT_ASSERT(index == 0);
next_field = bt_field_variant_borrow_selected_option_field(
base_field);
- break;
- default:
+ } else {
abort();
}
field = borrow_next_field(notit);
BT_ASSERT(field);
BT_ASSERT(bt_field_borrow_class_const(field) == fc->ir_fc);
- BT_ASSERT(bt_field_get_class_type(field) ==
- BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER ||
- bt_field_get_class_type(field) ==
- BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION);
+ BT_ASSERT(bt_field_class_type_is(bt_field_get_class_type(field),
+ BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER));
bt_field_integer_unsigned_set_value(field, value);
stack_top(notit->stack)->index++;
string_field = stack_top(notit->stack)->base;
BT_ASSERT(bt_field_get_class_type(string_field) ==
- BT_FIELD_CLASS_TYPE_STRING);
+ BT_FIELD_CLASS_TYPE_STRING);
/* Append character */
str[0] = (char) value;
field = borrow_next_field(notit);
BT_ASSERT(field);
BT_ASSERT(bt_field_borrow_class_const(field) == fc->ir_fc);
- BT_ASSERT(bt_field_get_class_type(field) ==
- BT_FIELD_CLASS_TYPE_SIGNED_INTEGER ||
- bt_field_get_class_type(field) ==
- BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION);
+ BT_ASSERT(bt_field_class_type_is(bt_field_get_class_type(field),
+ BT_FIELD_CLASS_TYPE_SIGNED_INTEGER));
bt_field_integer_signed_set_value(field, value);
stack_top(notit->stack)->index++;
bt_field_class_type type = bt_field_get_class_type(field);
BT_ASSERT(field);
BT_ASSERT(bt_field_borrow_class_const(field) == fc->ir_fc);
- BT_ASSERT(type == BT_FIELD_CLASS_TYPE_DOUBLE_PRECISION_REAL ||
- type == BT_FIELD_CLASS_TYPE_SINGLE_PRECISION_REAL);
+ BT_ASSERT(bt_field_class_type_is(type, BT_FIELD_CLASS_TYPE_REAL));
if (type == BT_FIELD_CLASS_TYPE_SINGLE_PRECISION_REAL) {
bt_field_real_single_precision_set_value(field, (float) value);
* is a sequence field.
*/
if (!seq_fc->base.is_text) {
- BT_ASSERT(bt_field_get_class_type(seq_field) ==
- BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY);
+ BT_ASSERT(bt_field_class_type_is(
+ bt_field_get_class_type(seq_field),
+ BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY));
ret = bt_field_array_dynamic_set_length(seq_field,
(uint64_t) length);
if (ret) {