#include "field-class.h"
#include "lib/func-status.h"
-#define BT_ASSERT_PRE_DEV_FIELD_HOT(_field, _name) \
- BT_ASSERT_PRE_DEV_HOT((const struct bt_field *) (_field), (_name), \
- ": %!+f", (_field))
+#define BT_ASSERT_PRE_DEV_FIELD_HOT(_field) \
+ BT_ASSERT_PRE_DEV_HOT((const struct bt_field *) (_field), \
+ "Field", ": %!+f", (_field))
static
void reset_single_field(struct bt_field *field);
struct bt_field_class *bt_field_borrow_class(struct bt_field *field)
{
- BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
+ BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
return field->class;
}
const struct bt_field_class *bt_field_borrow_class_const(
const struct bt_field *field)
{
- BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
+ BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
return field->class;
}
enum bt_field_class_type bt_field_get_class_type(const struct bt_field *field)
{
- BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
+ BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
return field->class->type;
}
{
const struct bt_field_bool *bool_field = (const void *) field;
- BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
- BT_ASSERT_PRE_DEV_FIELD_IS_SET(field, "Field");
+ BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
+ BT_ASSERT_PRE_DEV_FIELD_IS_SET(field);
BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field, BT_FIELD_CLASS_TYPE_BOOL,
"Field");
return (bt_bool) bool_field->value;
{
struct bt_field_bool *bool_field = (void *) field;
- BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
+ BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field, BT_FIELD_CLASS_TYPE_BOOL,
"Field");
- BT_ASSERT_PRE_DEV_FIELD_HOT(field, "Field");
+ BT_ASSERT_PRE_DEV_FIELD_HOT(field);
bool_field->value = (bool) value;
bt_field_set_single(field, true);
}
{
const struct bt_field_bit_array *ba_field = (const void *) field;
- BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
- BT_ASSERT_PRE_DEV_FIELD_IS_SET(field, "Field");
+ BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
+ BT_ASSERT_PRE_DEV_FIELD_IS_SET(field);
BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field,
BT_FIELD_CLASS_TYPE_BIT_ARRAY, "Field");
return ba_field->value_as_int;
struct bt_field_bit_array *ba_field = (void *) field;
struct bt_field_class_bit_array *ba_fc;
- BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
+ BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field,
BT_FIELD_CLASS_TYPE_BIT_ARRAY, "Field");
- BT_ASSERT_PRE_DEV_FIELD_HOT(field, "Field");
+ BT_ASSERT_PRE_DEV_FIELD_HOT(field);
ba_fc = (void *) field->class;
ba_field->value_as_int = value;
{
const struct bt_field_integer *int_field = (const void *) field;
- BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
- BT_ASSERT_PRE_DEV_FIELD_IS_SET(field, "Field");
+ BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
+ BT_ASSERT_PRE_DEV_FIELD_IS_SET(field);
BT_ASSERT_PRE_DEV_FIELD_IS_SIGNED_INT(field, "Field");
return int_field->value.i;
}
{
struct bt_field_integer *int_field = (void *) field;
- BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
+ BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
BT_ASSERT_PRE_DEV_FIELD_IS_SIGNED_INT(field, "Field");
- BT_ASSERT_PRE_DEV_FIELD_HOT(field, "Field");
+ BT_ASSERT_PRE_DEV_FIELD_HOT(field);
BT_ASSERT_PRE_DEV(bt_util_value_is_in_range_signed(
((struct bt_field_class_integer *) field->class)->range, value),
"Value is out of bounds: value=%" PRId64 ", %![field-]+f, "
{
const struct bt_field_integer *int_field = (const void *) field;
- BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
- BT_ASSERT_PRE_DEV_FIELD_IS_SET(field, "Field");
+ BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
+ BT_ASSERT_PRE_DEV_FIELD_IS_SET(field);
BT_ASSERT_PRE_DEV_FIELD_IS_UNSIGNED_INT(field, "Field");
return int_field->value.u;
}
{
struct bt_field_integer *int_field = (void *) field;
- BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
+ BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
BT_ASSERT_PRE_DEV_FIELD_IS_UNSIGNED_INT(field, "Field");
- BT_ASSERT_PRE_DEV_FIELD_HOT(field, "Field");
+ BT_ASSERT_PRE_DEV_FIELD_HOT(field);
BT_ASSERT_PRE_DEV(bt_util_value_is_in_range_unsigned(
((struct bt_field_class_integer *) field->class)->range, value),
"Value is out of bounds: value=%" PRIu64 ", %![field-]+f, "
{
const struct bt_field_real *real_field = (const void *) field;
- BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
- BT_ASSERT_PRE_DEV_FIELD_IS_SET(field, "Field");
+ BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
+ BT_ASSERT_PRE_DEV_FIELD_IS_SET(field);
BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field,
BT_FIELD_CLASS_TYPE_SINGLE_PRECISION_REAL, "Field");
return (float) real_field->value;
{
const struct bt_field_real *real_field = (const void *) field;
- BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
- BT_ASSERT_PRE_DEV_FIELD_IS_SET(field, "Field");
+ BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
+ BT_ASSERT_PRE_DEV_FIELD_IS_SET(field);
BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field,
BT_FIELD_CLASS_TYPE_DOUBLE_PRECISION_REAL, "Field");
{
struct bt_field_real *real_field = (void *) field;
- BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
+ BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field,
BT_FIELD_CLASS_TYPE_SINGLE_PRECISION_REAL, "Field");
- BT_ASSERT_PRE_DEV_FIELD_HOT(field, "Field");
+ BT_ASSERT_PRE_DEV_FIELD_HOT(field);
real_field->value = (double) value;
bt_field_set_single(field, true);
{
struct bt_field_real *real_field = (void *) field;
- BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
+ BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field,
BT_FIELD_CLASS_TYPE_DOUBLE_PRECISION_REAL, "Field");
- BT_ASSERT_PRE_DEV_FIELD_HOT(field, "Field");
+ BT_ASSERT_PRE_DEV_FIELD_HOT(field);
real_field->value = value;
bt_field_set_single(field, true);
const struct bt_field_integer *int_field = (const void *) field;
BT_ASSERT_PRE_DEV_NO_ERROR();
- BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
+ BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
BT_ASSERT_PRE_DEV_NON_NULL(label_array, "Label array (output)");
BT_ASSERT_PRE_DEV_NON_NULL(label_array, "Count (output)");
- BT_ASSERT_PRE_DEV_FIELD_IS_SET(field, "Field");
+ BT_ASSERT_PRE_DEV_FIELD_IS_SET(field);
BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field,
BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION, "Field");
return (int)
const struct bt_field_integer *int_field = (const void *) field;
BT_ASSERT_PRE_DEV_NO_ERROR();
- BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
+ BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
BT_ASSERT_PRE_DEV_NON_NULL(label_array, "Label array (output)");
BT_ASSERT_PRE_DEV_NON_NULL(label_array, "Count (output)");
- BT_ASSERT_PRE_DEV_FIELD_IS_SET(field, "Field");
+ BT_ASSERT_PRE_DEV_FIELD_IS_SET(field);
BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field,
BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION, "Field");
return (int)
{
const struct bt_field_string *string_field = (const void *) field;
- BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
- BT_ASSERT_PRE_DEV_FIELD_IS_SET(field, "Field");
+ BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
+ BT_ASSERT_PRE_DEV_FIELD_IS_SET(field);
BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field, BT_FIELD_CLASS_TYPE_STRING,
"Field");
return (const char *) string_field->buf->data;
{
const struct bt_field_string *string_field = (const void *) field;
- BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
- BT_ASSERT_PRE_DEV_FIELD_IS_SET(field, "Field");
+ BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
+ BT_ASSERT_PRE_DEV_FIELD_IS_SET(field);
BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field, BT_FIELD_CLASS_TYPE_STRING,
"Field");
return string_field->length;
struct bt_field *field, const char *value)
{
BT_ASSERT_PRE_DEV_NO_ERROR();
- BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
+ BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
BT_ASSERT_PRE_DEV_NON_NULL(value, "Value");
- BT_ASSERT_PRE_DEV_FIELD_HOT(field, "Field");
+ BT_ASSERT_PRE_DEV_FIELD_HOT(field);
BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field, BT_FIELD_CLASS_TYPE_STRING,
"Field");
clear_string_field(field);
uint64_t new_length;
BT_ASSERT_PRE_DEV_NO_ERROR();
- BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
+ BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
BT_ASSERT_PRE_DEV_NON_NULL(value, "Value");
- BT_ASSERT_PRE_DEV_FIELD_HOT(field, "Field");
+ BT_ASSERT_PRE_DEV_FIELD_HOT(field);
BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field,
BT_FIELD_CLASS_TYPE_STRING, "Field");
void bt_field_string_clear(struct bt_field *field)
{
- BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
- BT_ASSERT_PRE_DEV_FIELD_HOT(field, "Field");
+ BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
+ BT_ASSERT_PRE_DEV_FIELD_HOT(field);
BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field,
BT_FIELD_CLASS_TYPE_STRING, "Field");
clear_string_field(field);
{
const struct bt_field_array *array_field = (const void *) field;
- BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
+ BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
BT_ASSERT_PRE_DEV_FIELD_IS_ARRAY(field, "Field");
return array_field->length;
}
struct bt_field_array *array_field = (void *) field;
BT_ASSERT_PRE_DEV_NO_ERROR();
- BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
+ BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
BT_ASSERT_PRE_DEV_FIELD_IS_DYNAMIC_ARRAY(field, "Field");
- BT_ASSERT_PRE_DEV_FIELD_HOT(field, "Field");
+ BT_ASSERT_PRE_DEV_FIELD_HOT(field);
if (G_UNLIKELY(length > array_field->fields->len)) {
/* Make more room */
{
struct bt_field_array *array_field = (void *) field;
- BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
+ BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
BT_ASSERT_PRE_DEV_FIELD_IS_ARRAY(field, "Field");
BT_ASSERT_PRE_DEV_VALID_INDEX(index, array_field->length);
return array_field->fields->pdata[index];
{
struct bt_field_structure *struct_field = (void *) field;
- BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
+ BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field,
BT_FIELD_CLASS_TYPE_STRUCTURE, "Field");
BT_ASSERT_PRE_DEV_VALID_INDEX(index, struct_field->fields->len);
gpointer orig_key;
gpointer index;
- BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
+ BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
BT_ASSERT_PRE_DEV_NON_NULL(name, "Field name");
BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field,
BT_FIELD_CLASS_TYPE_STRUCTURE, "Field");
{
struct bt_field_option *opt_field = (void *) field;
- BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
+ BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
BT_ASSERT_PRE_DEV_FIELD_IS_OPTION(field, "Field");
- BT_ASSERT_PRE_DEV_FIELD_HOT(field, "Field");
+ BT_ASSERT_PRE_DEV_FIELD_HOT(field);
if (has_field) {
opt_field->selected_field = opt_field->content_field;
{
struct bt_field_option *opt_field = (void *) field;
- BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
+ BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
BT_ASSERT_PRE_DEV_FIELD_IS_OPTION(field, "Field");
return opt_field->selected_field;
}
{
struct bt_field_variant *var_field = (void *) field;
- BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
+ BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
BT_ASSERT_PRE_DEV_FIELD_IS_VARIANT(field, "Field");
BT_ASSERT_PRE_DEV(var_field->selected_field,
"Variant field has no selected field: %!+f", field);
bt_field_variant_borrow_selected_option_class_const(
const struct bt_field *field)
{
- BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
+ BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
BT_ASSERT_PRE_DEV_FIELD_IS_VARIANT(field, "Field");
return borrow_variant_field_selected_class_option(field);
}
bt_field_variant_with_selector_field_integer_unsigned_borrow_selected_option_class_const(
const struct bt_field *field)
{
- BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
+ BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field,
BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD, "Field");
return (const void *) borrow_variant_field_selected_class_option(field);
bt_field_variant_with_selector_field_integer_signed_borrow_selected_option_class_const(
const struct bt_field *field)
{
- BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
+ BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field,
BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD, "Field");
return (const void *) borrow_variant_field_selected_class_option(field);
struct bt_field_variant *var_field = (void *) field;
BT_ASSERT_PRE_DEV_NO_ERROR();
- BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
+ BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
BT_ASSERT_PRE_DEV_FIELD_IS_VARIANT(field, "Field");
- BT_ASSERT_PRE_DEV_FIELD_HOT(field, "Field");
+ BT_ASSERT_PRE_DEV_FIELD_HOT(field);
BT_ASSERT_PRE_DEV_VALID_INDEX(index, var_field->fields->len);
var_field->selected_field = var_field->fields->pdata[index];
var_field->selected_index = index;
{
const struct bt_field_variant *var_field = (const void *) field;
- BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
+ BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
BT_ASSERT_PRE_DEV_FIELD_IS_VARIANT(field, "Field");
BT_ASSERT_PRE_DEV(var_field->selected_field,
"Variant field has no selected field: %!+f", field);