BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_FP_ID, (_fp), \
_BT_ASSERT_PRE_FP_NAME)
-#define BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(_field_id, _field, _cls_type_id, _cls_type, _name) \
- BT_ASSERT_PRE_DEV("is-" _cls_type_id ":" _field_id, \
+#define BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE_FROM_FUNC(_func, _field_id, _field, _cls_type_id, _cls_type, _name) \
+ BT_ASSERT_PRE_DEV_FROM_FUNC(_func, "is-" _cls_type_id ":" _field_id, \
((const struct bt_field *) (_field))->class->type == (_cls_type), \
_name " has the wrong class type: expected-class-type=%s, " \
"%![field-]+f", \
bt_common_field_class_type_string(_cls_type), (_field))
+#define BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(_field_id, _field, _cls_type_id, _cls_type, _name) \
+ BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE_FROM_FUNC(__func__, \
+ _field_id, (_field), _cls_type_id, _cls_type, _name)
+
#define BT_ASSERT_PRE_DEV_FIELD_IS_UNSIGNED_INT(_field_id, _field, _name) \
BT_ASSERT_PRE_DEV( \
"is-unsigned-integer-field:" _field_id, \
_name " is not a signed integer field: %![field-]+f", \
(_field))
-#define BT_ASSERT_PRE_DEV_FIELD_IS_ARRAY(_field_id, _field, _name) \
- BT_ASSERT_PRE_DEV( \
+#define BT_ASSERT_PRE_DEV_FIELD_IS_ARRAY_FROM_FUNC(_func, _field_id, _field, _name) \
+ BT_ASSERT_PRE_DEV_FROM_FUNC(_func, \
"is-array-field:" _field_id, \
((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_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_ARRAY(_field_id, _field, _name) \
+ BT_ASSERT_PRE_DEV_FIELD_IS_ARRAY_FROM_FUNC(__func__, _field_id, \
+ (_field), _name)
+
#define BT_ASSERT_PRE_DEV_FIELD_IS_DYNAMIC_ARRAY(_field_id, _field, _name) \
BT_ASSERT_PRE_DEV( \
"is-dynamic-array-field:" _field_id, \
BT_ASSERT_PRE_NON_NULL(_BT_ASSERT_PRE_FIELD_ID, (_field), \
_BT_ASSERT_PRE_FIELD_NAME)
+#define BT_ASSERT_PRE_DEV_FIELD_NON_NULL_FROM_FUNC(_func, _field) \
+ BT_ASSERT_PRE_DEV_NON_NULL_FROM_FUNC(_func, \
+ _BT_ASSERT_PRE_FIELD_ID, (_field), \
+ _BT_ASSERT_PRE_FIELD_NAME)
+
#define BT_ASSERT_PRE_DEV_FIELD_NON_NULL(_field) \
BT_ASSERT_PRE_DEV_NON_NULL(_BT_ASSERT_PRE_FIELD_ID, (_field), \
_BT_ASSERT_PRE_FIELD_NAME)
static inline
struct bt_field *borrow_array_field_element_field_by_index(
- struct bt_field *field, uint64_t index)
+ struct bt_field *field, uint64_t index, const char *api_func)
{
struct bt_field_array *array_field = (void *) field;
- BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
- BT_ASSERT_PRE_DEV_FIELD_IS_ARRAY("field", field, "Field");
- BT_ASSERT_PRE_DEV_VALID_INDEX(index, array_field->length);
+ BT_ASSERT_PRE_DEV_FIELD_NON_NULL_FROM_FUNC(api_func, field);
+ BT_ASSERT_PRE_DEV_FIELD_IS_ARRAY_FROM_FUNC(api_func, "field", field,
+ "Field");
+ BT_ASSERT_PRE_DEV_VALID_INDEX_FROM_FUNC(api_func, index,
+ array_field->length);
return array_field->fields->pdata[index];
}
struct bt_field *bt_field_array_borrow_element_field_by_index(
struct bt_field *field, uint64_t index)
{
- return borrow_array_field_element_field_by_index(field, index);
+ return borrow_array_field_element_field_by_index(field, index,
+ __func__);
}
const struct bt_field *
bt_field_array_borrow_element_field_by_index_const(
const struct bt_field *field, uint64_t index)
{
- return borrow_array_field_element_field_by_index((void *) field, index);
+ return borrow_array_field_element_field_by_index((void *) field, index,
+ __func__);
}
static inline
struct bt_field *borrow_structure_field_member_field_by_index(
- struct bt_field *field, uint64_t index)
+ struct bt_field *field, uint64_t index, const char *api_func)
{
struct bt_field_structure *struct_field = (void *) field;
- BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
- BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE("field", field,
- "structure-field", BT_FIELD_CLASS_TYPE_STRUCTURE, "Field");
- BT_ASSERT_PRE_DEV_VALID_INDEX(index, struct_field->fields->len);
+ BT_ASSERT_PRE_DEV_FIELD_NON_NULL_FROM_FUNC(api_func, field);
+ BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE_FROM_FUNC(api_func, "field",
+ field, "structure-field", BT_FIELD_CLASS_TYPE_STRUCTURE,
+ "Field");
+ BT_ASSERT_PRE_DEV_VALID_INDEX_FROM_FUNC(api_func, index,
+ struct_field->fields->len);
return struct_field->fields->pdata[index];
}
struct bt_field *field, uint64_t index)
{
return borrow_structure_field_member_field_by_index(field,
- index);
+ index, __func__);
}
const struct bt_field *
const struct bt_field *field, uint64_t index)
{
return borrow_structure_field_member_field_by_index(
- (void *) field, index);
+ (void *) field, index, __func__);
}
static inline
struct bt_field *borrow_structure_field_member_field_by_name(
- struct bt_field *field, const char *name)
+ struct bt_field *field, const char *name, const char *api_func)
{
struct bt_field *ret_field = NULL;
struct bt_field_class_structure *struct_fc;
gpointer orig_key;
gpointer index;
- BT_ASSERT_PRE_DEV_FIELD_NON_NULL(field);
- BT_ASSERT_PRE_DEV_NON_NULL("member-name", name, "Member name");
- BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE("field", field,
- "structure-field", BT_FIELD_CLASS_TYPE_STRUCTURE, "Field");
+ BT_ASSERT_PRE_DEV_FIELD_NON_NULL_FROM_FUNC(api_func, field);
+ BT_ASSERT_PRE_DEV_NON_NULL_FROM_FUNC(api_func, "member-name", name,
+ "Member name");
+ BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE_FROM_FUNC(api_func, "field",
+ field, "structure-field", BT_FIELD_CLASS_TYPE_STRUCTURE,
+ "Field");
struct_fc = (void *) field->class;
if (!g_hash_table_lookup_extended(struct_fc->common.name_to_index, name,
struct bt_field *bt_field_structure_borrow_member_field_by_name(
struct bt_field *field, const char *name)
{
- return borrow_structure_field_member_field_by_name(field, name);
+ return borrow_structure_field_member_field_by_name(field, name,
+ __func__);
}
const struct bt_field *bt_field_structure_borrow_member_field_by_name_const(
const struct bt_field *field, const char *name)
{
return borrow_structure_field_member_field_by_name(
- (void *) field, name);
+ (void *) field, name, __func__);
}
void bt_field_option_set_has_field(struct bt_field *field, bt_bool has_field)