Replace assert() -> BT_ASSERT() and some preconditions with BT_ASSERT_PRE()
[babeltrace.git] / include / babeltrace / ctf-ir / fields-internal.h
index 22d551a59576fd8b939b24e6e7d1c61e4955200c..874e75f342a9e2c82fb4ee667928b5a9e3b75563 100644 (file)
 #include <stdbool.h>
 #include <glib.h>
 
-struct bt_ctf_stream_pos;
+struct bt_stream_pos;
 
-struct bt_ctf_field {
+struct bt_field {
        struct bt_object base;
-       struct bt_ctf_field_type *type;
+       struct bt_field_type *type;
        bool payload_set;
        bool frozen;
 };
 
-struct bt_ctf_field_integer {
-       struct bt_ctf_field parent;
+struct bt_field_integer {
+       struct bt_field parent;
        union {
                int64_t signd;
                uint64_t unsignd;
        } payload;
 };
 
-struct bt_ctf_field_enumeration {
-       struct bt_ctf_field parent;
-       struct bt_ctf_field *payload;
+struct bt_field_enumeration {
+       struct bt_field parent;
+       struct bt_field *payload;
 };
 
-struct bt_ctf_field_floating_point {
-       struct bt_ctf_field parent;
+struct bt_field_floating_point {
+       struct bt_field parent;
        double payload;
 };
 
-struct bt_ctf_field_structure {
-       struct bt_ctf_field parent;
-       GHashTable *field_name_to_index;
-       GPtrArray *fields; /* Array of pointers to struct bt_ctf_field */
+struct bt_field_structure {
+       struct bt_field parent;
+       GPtrArray *fields; /* Array of pointers to struct bt_field */
 };
 
-struct bt_ctf_field_variant {
-       struct bt_ctf_field parent;
-       struct bt_ctf_field *tag;
-       struct bt_ctf_field *payload;
+struct bt_field_variant {
+       struct bt_field parent;
+       struct bt_field *tag;
+       struct bt_field *payload;
 };
 
-struct bt_ctf_field_array {
-       struct bt_ctf_field parent;
-       GPtrArray *elements; /* Array of pointers to struct bt_ctf_field */
+struct bt_field_array {
+       struct bt_field parent;
+       GPtrArray *elements; /* Array of pointers to struct bt_field */
 };
 
-struct bt_ctf_field_sequence {
-       struct bt_ctf_field parent;
-       struct bt_ctf_field *length;
-       GPtrArray *elements; /* Array of pointers to struct bt_ctf_field */
+struct bt_field_sequence {
+       struct bt_field parent;
+       struct bt_field *length;
+       GPtrArray *elements; /* Array of pointers to struct bt_field */
 };
 
-struct bt_ctf_field_string {
-       struct bt_ctf_field parent;
+struct bt_field_string {
+       struct bt_field parent;
        GString *payload;
 };
 
+BT_HIDDEN
+int bt_field_serialize_recursive(struct bt_field *field,
+               struct bt_stream_pos *pos,
+               enum bt_byte_order native_byte_order);
+
 /* Validate that the field's payload is set (returns 0 if set). */
 BT_HIDDEN
-int bt_ctf_field_validate(struct bt_ctf_field *field);
+int _bt_field_validate_recursive(struct bt_field *field);
+
+BT_HIDDEN
+void _bt_field_freeze_recursive(struct bt_field *field);
 
-/* Mark field payload as unset. */
 BT_HIDDEN
-int bt_ctf_field_reset(struct bt_ctf_field *field);
+bt_bool _bt_field_is_set_recursive(struct bt_field *field);
 
 BT_HIDDEN
-int bt_ctf_field_serialize(struct bt_ctf_field *field,
-               struct bt_ctf_stream_pos *pos,
-               enum bt_ctf_byte_order native_byte_order);
+void _bt_field_reset_recursive(struct bt_field *field);
 
 BT_HIDDEN
-void bt_ctf_field_freeze(struct bt_ctf_field *field);
+void _bt_field_set(struct bt_field *field, bool val);
+
+#ifdef BT_DEV_MODE
+# define bt_field_validate_recursive           _bt_field_validate_recursive
+# define bt_field_freeze_recursive             _bt_field_freeze_recursive
+# define bt_field_is_set_recursive             _bt_field_is_set_recursive
+# define bt_field_reset_recursive              _bt_field_reset_recursive
+# define bt_field_set                          _bt_field_set
+#else
+# define bt_field_validate_recursive(_field)   (-1)
+# define bt_field_freeze_recursive(_field)
+# define bt_field_is_set_recursive(_field)     (BT_FALSE)
+# define bt_field_reset_recursive(_field)              (BT_TRUE)
+# define bt_field_set(_field, _val)
+#endif
 
 BT_HIDDEN
-bt_bool bt_ctf_field_is_set(struct bt_ctf_field *field);
+int64_t bt_field_sequence_get_int_length(struct bt_field *field);
 
 #endif /* BABELTRACE_CTF_IR_FIELDS_INTERNAL_H */
This page took 0.026097 seconds and 4 git commands to generate.