lib: commonize some precondition assertion macros
[babeltrace.git] / src / lib / value.c
index f533aba35d6710139a8b5e80d7dc235d91f60683..fbdb9f5a2b439caf54f82c052d89b61076cdcd99 100644 (file)
 #include "common/assert.h"
 #include "func-status.h"
 
+#define BT_ASSERT_PRE_DEV_VALUE_HOT(_value, _name)                     \
+       BT_ASSERT_PRE_DEV_HOT(((struct bt_value *) (_value)), (_name),  \
+               ": %!+v", (_value))
+
 #define BT_VALUE_TO_BOOL(_base) ((struct bt_value_bool *) (_base))
 #define BT_VALUE_TO_INTEGER(_base) ((struct bt_value_integer *) (_base))
 #define BT_VALUE_TO_REAL(_base) ((struct bt_value_real *) (_base))
 #define BT_VALUE_TO_ARRAY(_base) ((struct bt_value_array *) (_base))
 #define BT_VALUE_TO_MAP(_base) ((struct bt_value_map *) (_base))
 
-#define _BT_ASSERT_PRE_VALUE_IS_TYPE_COND(_value, _type)               \
-       (((struct bt_value *) (_value))->type == (_type))
-
-#define _BT_ASSERT_PRE_VALUE_IS_TYPE_FMT                               \
-       "Value has the wrong type ID: expected-type=%s, %![value-]+v"
-
-#define BT_ASSERT_PRE_VALUE_IS_TYPE(_value, _type)                     \
-       BT_ASSERT_PRE(                                                  \
-               _BT_ASSERT_PRE_VALUE_IS_TYPE_COND((_value), (_type)),   \
-               _BT_ASSERT_PRE_VALUE_IS_TYPE_FMT,                       \
-               bt_common_value_type_string(_type), (_value))
-
-#define BT_ASSERT_PRE_DEV_VALUE_IS_TYPE(_value, _type)                 \
-       BT_ASSERT_PRE_DEV(                                              \
-               _BT_ASSERT_PRE_VALUE_IS_TYPE_COND((_value), (_type)),   \
-               _BT_ASSERT_PRE_VALUE_IS_TYPE_FMT,                       \
-               bt_common_value_type_string(_type), (_value))
-
-#define BT_ASSERT_PRE_DEV_VALUE_HOT(_value, _name)                     \
-       BT_ASSERT_PRE_DEV_HOT(((struct bt_value *) (_value)), (_name),  \
-               ": %!+v", (_value))
-
 static
 void bt_value_null_instance_release_func(struct bt_object *obj)
 {
This page took 0.023805 seconds and 4 git commands to generate.