lib: add bit array field class and field types
[babeltrace.git] / src / lib / trace-ir / field.h
index f20378fcfc4edc9dc9f4c624fd7d1c0ebdb9b20c..ad25231cf82b0ac24f3772a089a4d608ee6eb35f 100644 (file)
                ((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_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_SELECTOR || \
+               ((const struct bt_field *) (_field))->class->type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_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))
@@ -98,6 +105,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 +136,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 +214,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.032747 seconds and 4 git commands to generate.