lib, bt2: rename "signed/unsigned sel." -> "integer signed/unsigned sel."
[babeltrace.git] / src / lib / trace-ir / field.h
index 96df03e749087db6209fb648ffaa1ffe169b0c38..d6fe2bce53f77fc19abadec27d3ebe6448b75328 100644 (file)
 #include "field-class.h"
 #include "utils.h"
 
-#define BT_ASSERT_PRE_FIELD_HAS_CLASS_TYPE(_field, _cls_type, _name)   \
-       BT_ASSERT_PRE(((const struct bt_field *) (_field))->class->type == (_cls_type), \
+#define BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(_field, _cls_type, _name) \
+       BT_ASSERT_PRE_DEV(((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_FIELD_IS_UNSIGNED_INT(_field, _name)             \
-       BT_ASSERT_PRE(                                                  \
+#define BT_ASSERT_PRE_DEV_FIELD_IS_UNSIGNED_INT(_field, _name)         \
+       BT_ASSERT_PRE_DEV(                                              \
                ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER || \
                ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION, \
                _name " is not an unsigned integer field: %![field-]+f", \
                (_field))
 
-#define BT_ASSERT_PRE_FIELD_IS_SIGNED_INT(_field, _name)               \
-       BT_ASSERT_PRE(                                                  \
+#define BT_ASSERT_PRE_DEV_FIELD_IS_SIGNED_INT(_field, _name)           \
+       BT_ASSERT_PRE_DEV(                                              \
                ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_SIGNED_INTEGER || \
                ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION, \
-               _name " is not a signed integer field: %![field-]+f", \
+               _name " is not a signed integer field: %![field-]+f",   \
                (_field))
 
-#define BT_ASSERT_PRE_FIELD_IS_ARRAY(_field, _name)                    \
-       BT_ASSERT_PRE(                                                  \
+#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, \
                _name " is not an array field: %![field-]+f", (_field))
 
-#define BT_ASSERT_PRE_FIELD_IS_SET(_field, _name)                      \
-       BT_ASSERT_PRE(bt_field_is_set(_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 || \
+               ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR || \
+               ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR || \
+               ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR, \
+               _name " is not an option field: %![field-]+f", (_field))
+
+#define BT_ASSERT_PRE_DEV_FIELD_IS_VARIANT(_field, _name)              \
+       BT_ASSERT_PRE_DEV(                                              \
+               ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR || \
+               ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR || \
+               ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR, \
+               _name " is not a variant field: %![field-]+f", (_field))
+
+#define BT_ASSERT_PRE_DEV_FIELD_IS_SET(_field, _name)                  \
+       BT_ASSERT_PRE_DEV(bt_field_is_set(_field),                      \
                _name " is not set: %!+f", (_field))
 
-#define BT_ASSERT_PRE_FIELD_HOT(_field, _name)                         \
-       BT_ASSERT_PRE_HOT((const struct bt_field *) (_field), (_name),  \
+#define BT_ASSERT_PRE_DEV_FIELD_HOT(_field, _name)                     \
+       BT_ASSERT_PRE_DEV_HOT((const struct bt_field *) (_field), (_name), \
                ": %!+f", (_field))
 
 struct bt_field;
@@ -98,6 +113,16 @@ struct bt_field {
        bool frozen;
 };
 
+struct bt_field_bool {
+       struct bt_field common;
+       bool value;
+};
+
+struct bt_field_bit_array {
+       struct bt_field common;
+       uint64_t value_as_int;
+};
+
 struct bt_field_integer {
        struct bt_field common;
 
@@ -119,6 +144,16 @@ struct bt_field_structure {
        GPtrArray *fields;
 };
 
+struct bt_field_option {
+       struct bt_field common;
+
+       /* Owned by this */
+       struct bt_field *content_field;
+
+       /* Weak: equal to `content_field` above or `NULL` */
+       struct bt_field *selected_field;
+};
+
 struct bt_field_variant {
        struct bt_field common;
 
@@ -187,7 +222,6 @@ bt_bool _bt_field_is_set(const struct bt_field *field)
                goto end;
        }
 
-       BT_ASSERT(bt_field_class_has_known_type(field->class));
        BT_ASSERT(field->methods->is_set);
        is_set = field->methods->is_set(field);
 
This page took 0.025825 seconds and 4 git commands to generate.