X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=include%2Fbabeltrace%2Fctf-ir%2Ffield-types-internal.h;h=a15b9c0a13e5e62b283c1d4ab8f723b90b034e69;hp=f408f50b7f3727105305949ba6536d320b2715c2;hb=312c056ae3d374b253fa0cfe5ed576c0b0e5e569;hpb=d2bd5ad3da0dba99582f74450e49a34689461d80 diff --git a/include/babeltrace/ctf-ir/field-types-internal.h b/include/babeltrace/ctf-ir/field-types-internal.h index f408f50b..a15b9c0a 100644 --- a/include/babeltrace/ctf-ir/field-types-internal.h +++ b/include/babeltrace/ctf-ir/field-types-internal.h @@ -27,28 +27,63 @@ * SOFTWARE. */ -#include -#include -#include -#include -#include +#include #include #include #include #include #include +#include #include -typedef void (*type_freeze_func)(struct bt_ctf_field_type *); -typedef int (*type_serialize_func)(struct bt_ctf_field_type *, - struct metadata_context *); +#define BT_ASSERT_PRE_FT_COMMON_HAS_ID(_ft, _type_id, _name) \ + BT_ASSERT_PRE(((struct bt_field_type_common *) (_ft))->id == (_type_id), \ + _name " has the wrong type ID: expected-type-id=%s, " \ + "%![ft-]+_F", bt_common_field_type_id_string(_type_id), (_ft)) + +#define BT_ASSERT_PRE_FT_HOT(_ft, _name) \ + BT_ASSERT_PRE_HOT((_ft), (_name), ": +%!+_F", (_ft)) + +#define BT_FIELD_TYPE_COMMON_STRUCTURE_FIELD_AT_INDEX(_ft, _index) \ + (&g_array_index(((struct bt_field_type_common_structure *) (_ft))->fields, \ + struct bt_field_type_common_structure_field, (_index))) + +#define BT_FIELD_TYPE_COMMON_VARIANT_CHOICE_AT_INDEX(_ft, _index) \ + (&g_array_index(((struct bt_field_type_common_variant *) (_ft))->choices, \ + struct bt_field_type_common_variant_choice, (_index))) + +struct bt_field_common; +struct bt_field_type_common; +struct bt_field_type; + +typedef void (*bt_field_type_common_method_freeze)( + struct bt_field_type_common *); +typedef int (*bt_field_type_common_method_validate)( + struct bt_field_type_common *); +typedef void (*bt_field_type_common_method_set_byte_order)( + struct bt_field_type_common *, enum bt_byte_order); +typedef struct bt_field_type_common *(*bt_field_type_common_method_copy)( + struct bt_field_type_common *); +typedef int (*bt_field_type_common_method_compare)( + struct bt_field_type_common *, + struct bt_field_type_common *); + +struct bt_field_type_common_methods { + bt_field_type_common_method_freeze freeze; + bt_field_type_common_method_validate validate; + bt_field_type_common_method_set_byte_order set_byte_order; + bt_field_type_common_method_copy copy; + bt_field_type_common_method_compare compare; +}; -struct bt_ctf_field_type { +struct bt_field_type_common { struct bt_object base; - enum bt_ctf_field_type_id id; + enum bt_field_type_id id; unsigned int alignment; - type_freeze_func freeze; - type_serialize_func serialize; + + /* Virtual table */ + struct bt_field_type_common_methods *methods; + /* * A type can't be modified once it is added to an event or after a * a field has been instanciated from it. @@ -61,16 +96,45 @@ struct bt_ctf_field_type { * a valid field type are also valid (and thus frozen). */ int valid; + + /* + * Specialized data for either CTF IR or CTF writer APIs. + * Having this here ensures that: + * + * * The type-specific common data is always found at the same + * offset when the common API has a `struct + * bt_field_type_common *` so that you can cast it to `struct + * bt_field_type_common_integer *` for example and access the + * common integer field type fields. + * + * * The specific CTF IR and CTF writer APIs can access their + * specific field type fields in this union at an offset known + * at build time. This avoids a pointer to specific data so + * that all the fields, common or specific, of a CTF IR + * integer field type or of a CTF writer integer field type, + * for example, are contained within the same contiguous block + * of memory. + */ + union { + struct { + } ir; + struct { + void *serialize_func; + } writer; + } spec; }; -struct bt_ctf_field_type_integer { - struct bt_ctf_field_type parent; - struct bt_ctf_clock_class *mapped_clock; - enum bt_ctf_byte_order user_byte_order; +struct bt_field_type_common_integer { + struct bt_field_type_common common; + + /* Owned by this */ + struct bt_clock_class *mapped_clock_class; + + enum bt_byte_order user_byte_order; bt_bool is_signed; unsigned int size; - enum bt_ctf_integer_base base; - enum bt_ctf_string_encoding encoding; + enum bt_integer_base base; + enum bt_string_encoding encoding; }; struct enumeration_mapping { @@ -78,7 +142,6 @@ struct enumeration_mapping { uint64_t _unsigned; int64_t _signed; } range_start; - union { uint64_t _unsigned; int64_t _signed; @@ -86,24 +149,32 @@ struct enumeration_mapping { GQuark string; }; -struct bt_ctf_field_type_enumeration { - struct bt_ctf_field_type parent; - struct bt_ctf_field_type *container; - GPtrArray *entries; /* Array of ptrs to struct enumeration_mapping */ - /* Only set during validation. */ +struct bt_field_type_common_enumeration { + struct bt_field_type_common common; + + /* Owned by this */ + struct bt_field_type_common_integer *container_ft; + + /* Array of `struct enumeration_mapping *`, owned by this */ + GPtrArray *entries; + + /* Only set during validation */ bt_bool has_overlapping_ranges; }; -enum bt_ctf_field_type_enumeration_mapping_iterator_type { +enum bt_field_type_enumeration_mapping_iterator_type { ITERATOR_BY_NAME, ITERATOR_BY_SIGNED_VALUE, ITERATOR_BY_UNSIGNED_VALUE, }; -struct bt_ctf_field_type_enumeration_mapping_iterator { +struct bt_field_type_enumeration_mapping_iterator { struct bt_object base; - struct bt_ctf_field_type_enumeration *enumeration_type; - enum bt_ctf_field_type_enumeration_mapping_iterator_type type; + + /* Owned by this */ + struct bt_field_type_common_enumeration *enumeration_ft; + + enum bt_field_type_enumeration_mapping_iterator_type type; int index; union { GQuark name_quark; @@ -112,223 +183,610 @@ struct bt_ctf_field_type_enumeration_mapping_iterator { } u; }; -struct bt_ctf_field_type_floating_point { - struct bt_ctf_field_type parent; - enum bt_ctf_byte_order user_byte_order; +struct bt_field_type_common_floating_point { + struct bt_field_type_common common; + enum bt_byte_order user_byte_order; unsigned int exp_dig; unsigned int mant_dig; }; -struct structure_field { +struct bt_field_type_common_structure_field { GQuark name; - struct bt_ctf_field_type *type; + + /* Owned by this */ + struct bt_field_type_common *type; }; -struct bt_ctf_field_type_structure { - struct bt_ctf_field_type parent; +struct bt_field_type_common_structure { + struct bt_field_type_common common; GHashTable *field_name_to_index; - GPtrArray *fields; /* Array of pointers to struct structure_field */ + + /* + * Array of `struct bt_field_type_common_structure_field`, + * owned by this + */ + GArray *fields; +}; + +struct bt_field_type_common_variant_choice_range { + union { + int64_t i; + uint64_t u; + } lower; + union { + int64_t i; + uint64_t u; + } upper; +}; + +struct bt_field_type_common_variant_choice { + GQuark name; + + /* Owned by this */ + struct bt_field_type_common *type; + + /* Array of `struct bt_field_type_common_variant_choice_range` */ + GArray *ranges; }; -struct bt_ctf_field_type_variant { - struct bt_ctf_field_type parent; +struct bt_field_type_common_variant { + struct bt_field_type_common common; GString *tag_name; - struct bt_ctf_field_type_enumeration *tag; - struct bt_ctf_field_path *tag_field_path; - GHashTable *field_name_to_index; - GPtrArray *fields; /* Array of pointers to struct structure_field */ + bool choices_up_to_date; + + /* Owned by this */ + struct bt_field_type_common_enumeration *tag_ft; + + /* Owned by this */ + struct bt_field_path *tag_field_path; + + GHashTable *choice_name_to_index; + + /* + * Array of `struct bt_field_type_common_variant_choice`, + * owned by this */ + GArray *choices; }; -struct bt_ctf_field_type_array { - struct bt_ctf_field_type parent; - struct bt_ctf_field_type *element_type; - unsigned int length; /* Number of elements */ +struct bt_field_type_common_array { + struct bt_field_type_common common; + + /* Owned by this */ + struct bt_field_type_common *element_ft; + + unsigned int length; }; -struct bt_ctf_field_type_sequence { - struct bt_ctf_field_type parent; - struct bt_ctf_field_type *element_type; +struct bt_field_type_common_sequence { + struct bt_field_type_common common; + + /* Owned by this */ + struct bt_field_type_common *element_ft; + GString *length_field_name; - struct bt_ctf_field_path *length_field_path; + + /* Owned by this */ + struct bt_field_path *length_field_path; }; -struct bt_ctf_field_type_string { - struct bt_ctf_field_type parent; - enum bt_ctf_string_encoding encoding; +struct bt_field_type_common_string { + struct bt_field_type_common common; + enum bt_string_encoding encoding; }; +#ifdef BT_DEV_MODE +# define bt_field_type_freeze _bt_field_type_freeze +# define bt_field_type_common_freeze _bt_field_type_common_freeze +#else +# define bt_field_type_freeze(_ft) +# define bt_field_type_common_freeze(_ft) +#endif + +typedef struct bt_field_common *(* bt_field_common_create_func)( + struct bt_field_type_common *); + +BT_HIDDEN +void bt_field_type_common_initialize(struct bt_field_type_common *ft, + bool init_bo, bt_object_release_func release_func, + struct bt_field_type_common_methods *methods); + +BT_HIDDEN +void bt_field_type_common_integer_initialize( + struct bt_field_type_common *ft, + unsigned int size, bt_object_release_func release_func, + struct bt_field_type_common_methods *methods); + +BT_HIDDEN +void bt_field_type_common_floating_point_initialize( + struct bt_field_type_common *ft, + bt_object_release_func release_func, + struct bt_field_type_common_methods *methods); + +BT_HIDDEN +void bt_field_type_common_enumeration_initialize( + struct bt_field_type_common *ft, + struct bt_field_type_common *container_ft, + bt_object_release_func release_func, + struct bt_field_type_common_methods *methods); + +BT_HIDDEN +void bt_field_type_common_string_initialize( + struct bt_field_type_common *ft, + bt_object_release_func release_func, + struct bt_field_type_common_methods *methods); + +BT_HIDDEN +void bt_field_type_common_structure_initialize( + struct bt_field_type_common *ft, + bt_object_release_func release_func, + struct bt_field_type_common_methods *methods); + +BT_HIDDEN +void bt_field_type_common_array_initialize( + struct bt_field_type_common *ft, + struct bt_field_type_common *element_ft, + unsigned int length, bt_object_release_func release_func, + struct bt_field_type_common_methods *methods); + +BT_HIDDEN +void bt_field_type_common_sequence_initialize( + struct bt_field_type_common *ft, + struct bt_field_type_common *element_ft, + const char *length_field_name, + bt_object_release_func release_func, + struct bt_field_type_common_methods *methods); + +BT_HIDDEN +void bt_field_type_common_variant_initialize( + struct bt_field_type_common *ft, + struct bt_field_type_common *tag_ft, + const char *tag_name, + bt_object_release_func release_func, + struct bt_field_type_common_methods *methods); + +BT_HIDDEN +void bt_field_type_common_integer_destroy(struct bt_object *obj); + +BT_HIDDEN +void bt_field_type_common_floating_point_destroy(struct bt_object *obj); + +BT_HIDDEN +void bt_field_type_common_enumeration_destroy_recursive(struct bt_object *obj); + +BT_HIDDEN +void bt_field_type_common_string_destroy(struct bt_object *obj); + +BT_HIDDEN +void bt_field_type_common_structure_destroy_recursive(struct bt_object *obj); + +BT_HIDDEN +void bt_field_type_common_array_destroy_recursive(struct bt_object *obj); + +BT_HIDDEN +void bt_field_type_common_sequence_destroy_recursive(struct bt_object *obj); + +BT_HIDDEN +void bt_field_type_common_variant_destroy_recursive(struct bt_object *obj); + +BT_HIDDEN +int bt_field_type_common_integer_validate(struct bt_field_type_common *ft); + +BT_HIDDEN +int bt_field_type_common_enumeration_validate_recursive( + struct bt_field_type_common *ft); + +BT_HIDDEN +int bt_field_type_common_sequence_validate_recursive( + struct bt_field_type_common *ft); + +BT_HIDDEN +int bt_field_type_common_array_validate_recursive( + struct bt_field_type_common *ft); + +BT_HIDDEN +int bt_field_type_common_structure_validate_recursive( + struct bt_field_type_common *ft); + +BT_HIDDEN +int bt_field_type_common_variant_validate_recursive( + struct bt_field_type_common *type); + +BT_HIDDEN +int bt_field_type_common_validate(struct bt_field_type_common *ft); + +BT_HIDDEN +int bt_field_type_common_integer_get_size(struct bt_field_type_common *ft); + +BT_HIDDEN +bt_bool bt_field_type_common_integer_is_signed(struct bt_field_type_common *ft); + +BT_HIDDEN +int bt_field_type_common_integer_set_is_signed(struct bt_field_type_common *ft, + bt_bool is_signed); + +BT_HIDDEN +int bt_field_type_common_integer_set_size(struct bt_field_type_common *ft, + unsigned int size); + +BT_HIDDEN +enum bt_integer_base bt_field_type_common_integer_get_base( + struct bt_field_type_common *ft); + +BT_HIDDEN +int bt_field_type_common_integer_set_base(struct bt_field_type_common *ft, + enum bt_integer_base base); + +BT_HIDDEN +enum bt_string_encoding bt_field_type_common_integer_get_encoding( + struct bt_field_type_common *ft); + +BT_HIDDEN +int bt_field_type_common_integer_set_encoding(struct bt_field_type_common *ft, + enum bt_string_encoding encoding); + +BT_HIDDEN +struct bt_clock_class *bt_field_type_common_integer_borrow_mapped_clock_class( + struct bt_field_type_common *ft); + +BT_HIDDEN +int bt_field_type_common_integer_set_mapped_clock_class_no_check_frozen( + struct bt_field_type_common *ft, + struct bt_clock_class *clock_class); + +BT_HIDDEN +int bt_field_type_common_integer_set_mapped_clock_class( + struct bt_field_type_common *ft, + struct bt_clock_class *clock_class); + +BT_HIDDEN +struct bt_field_type_enumeration_mapping_iterator * +bt_field_type_common_enumeration_find_mappings_by_name( + struct bt_field_type_common *ft, const char *name); + +BT_HIDDEN +struct bt_field_type_enumeration_mapping_iterator * +bt_field_type_common_enumeration_signed_find_mappings_by_value( + struct bt_field_type_common *ft, int64_t value); + +BT_HIDDEN +struct bt_field_type_enumeration_mapping_iterator * +bt_field_type_common_enumeration_unsigned_find_mappings_by_value( + struct bt_field_type_common *ft, uint64_t value); + BT_HIDDEN -void bt_ctf_field_type_freeze(struct bt_ctf_field_type *type); +int bt_field_type_common_enumeration_signed_get_mapping_by_index( + struct bt_field_type_common *ft, uint64_t index, + const char **mapping_name, int64_t *range_begin, + int64_t *range_end); BT_HIDDEN -struct bt_ctf_field_type *bt_ctf_field_type_variant_get_field_type_signed( - struct bt_ctf_field_type_variant *variant, int64_t tag_value); +int bt_field_type_common_enumeration_unsigned_get_mapping_by_index( + struct bt_field_type_common *ft, uint64_t index, + const char **mapping_name, uint64_t *range_begin, + uint64_t *range_end); BT_HIDDEN -struct bt_ctf_field_type *bt_ctf_field_type_variant_get_field_type_unsigned( - struct bt_ctf_field_type_variant *variant, uint64_t tag_value); +struct bt_field_type_common * +bt_field_type_common_enumeration_borrow_container_field_type( + struct bt_field_type_common *ft); BT_HIDDEN -int bt_ctf_field_type_serialize(struct bt_ctf_field_type *type, - struct metadata_context *context); +int bt_field_type_common_enumeration_signed_add_mapping( + struct bt_field_type_common *ft, const char *string, + int64_t range_start, int64_t range_end); BT_HIDDEN -int bt_ctf_field_type_validate(struct bt_ctf_field_type *type); +int bt_field_type_common_enumeration_unsigned_add_mapping( + struct bt_field_type_common *ft, const char *string, + uint64_t range_start, uint64_t range_end); BT_HIDDEN -int bt_ctf_field_type_structure_get_field_name_index( - struct bt_ctf_field_type *structure, const char *name); +int64_t bt_field_type_common_enumeration_get_mapping_count( + struct bt_field_type_common *ft); BT_HIDDEN -int bt_ctf_field_type_variant_get_field_name_index( - struct bt_ctf_field_type *variant, const char *name); +int bt_field_type_common_floating_point_get_exponent_digits( + struct bt_field_type_common *ft); BT_HIDDEN -int bt_ctf_field_type_sequence_set_length_field_path( - struct bt_ctf_field_type *type, - struct bt_ctf_field_path *path); +int bt_field_type_common_floating_point_set_exponent_digits( + struct bt_field_type_common *ft, + unsigned int exponent_digits); BT_HIDDEN -int bt_ctf_field_type_variant_set_tag_field_path(struct bt_ctf_field_type *type, - struct bt_ctf_field_path *path); +int bt_field_type_common_floating_point_get_mantissa_digits( + struct bt_field_type_common *type); BT_HIDDEN -int bt_ctf_field_type_variant_set_tag_field_type(struct bt_ctf_field_type *type, - struct bt_ctf_field_type *tag_type); +int bt_field_type_common_floating_point_set_mantissa_digits( + struct bt_field_type_common *ft, unsigned int mantissa_digits); BT_HIDDEN -int bt_ctf_field_type_array_set_element_type(struct bt_ctf_field_type *array, - struct bt_ctf_field_type *element_type); +int bt_field_type_common_structure_replace_field( + struct bt_field_type_common *ft, + const char *field_name, + struct bt_field_type_common *field_type); BT_HIDDEN -int bt_ctf_field_type_sequence_set_element_type(struct bt_ctf_field_type *array, - struct bt_ctf_field_type *element_type); +int bt_field_type_common_structure_add_field(struct bt_field_type_common *ft, + struct bt_field_type_common *field_type, + const char *field_name); BT_HIDDEN -int64_t bt_ctf_field_type_get_field_count(struct bt_ctf_field_type *type); +int64_t bt_field_type_common_structure_get_field_count( + struct bt_field_type_common *ft); BT_HIDDEN -struct bt_ctf_field_type *bt_ctf_field_type_get_field_at_index( - struct bt_ctf_field_type *type, int index); +int bt_field_type_common_structure_borrow_field_by_index( + struct bt_field_type_common *ft, + const char **field_name, + struct bt_field_type_common **field_type, uint64_t index); BT_HIDDEN -int bt_ctf_field_type_get_field_index(struct bt_ctf_field_type *type, +struct bt_field_type_common * +bt_field_type_common_structure_borrow_field_type_by_name( + struct bt_field_type_common *ft, const char *name); + +BT_HIDDEN +struct bt_field_type_common * +bt_field_type_common_variant_borrow_tag_field_type( + struct bt_field_type_common *ft); + +BT_HIDDEN +const char *bt_field_type_common_variant_get_tag_name( + struct bt_field_type_common *ft); + +BT_HIDDEN +int bt_field_type_common_variant_set_tag_name( + struct bt_field_type_common *ft, const char *name); + +BT_HIDDEN +int bt_field_type_common_variant_add_field(struct bt_field_type_common *ft, + struct bt_field_type_common *field_type, + const char *field_name); + +BT_HIDDEN +int bt_field_type_common_variant_update_choices( + struct bt_field_type_common *ft); + +BT_HIDDEN +struct bt_field_type_common * +bt_field_type_common_variant_borrow_field_type_by_name( + struct bt_field_type_common *ft, + const char *field_name); + +BT_HIDDEN +int64_t bt_field_type_common_variant_get_field_count( + struct bt_field_type_common *ft); + +BT_HIDDEN +int bt_field_type_common_variant_borrow_field_by_index( + struct bt_field_type_common *ft, + const char **field_name, + struct bt_field_type_common **field_type, uint64_t index); + +BT_HIDDEN +struct bt_field_type_common * +bt_field_type_common_array_borrow_element_field_type( + struct bt_field_type_common *ft); + +BT_HIDDEN +int bt_field_type_common_array_set_element_field_type( + struct bt_field_type_common *ft, + struct bt_field_type_common *element_ft); + +BT_HIDDEN +int64_t bt_field_type_common_array_get_length(struct bt_field_type_common *ft); + +BT_HIDDEN +struct bt_field_type_common * +bt_field_type_common_sequence_borrow_element_field_type( + struct bt_field_type_common *ft); + +BT_HIDDEN +int bt_field_type_common_sequence_set_element_field_type( + struct bt_field_type_common *ft, + struct bt_field_type_common *element_ft); + +BT_HIDDEN +const char *bt_field_type_common_sequence_get_length_field_name( + struct bt_field_type_common *ft); + +BT_HIDDEN +enum bt_string_encoding bt_field_type_common_string_get_encoding( + struct bt_field_type_common *ft); + +BT_HIDDEN +int bt_field_type_common_string_set_encoding(struct bt_field_type_common *ft, + enum bt_string_encoding encoding); + +BT_HIDDEN +int bt_field_type_common_get_alignment(struct bt_field_type_common *type); + +BT_HIDDEN +int bt_field_type_common_set_alignment(struct bt_field_type_common *ft, + unsigned int alignment); + +BT_HIDDEN +enum bt_byte_order bt_field_type_common_get_byte_order( + struct bt_field_type_common *ft); + +BT_HIDDEN +int bt_field_type_common_set_byte_order(struct bt_field_type_common *ft, + enum bt_byte_order byte_order); + +BT_HIDDEN +enum bt_field_type_id bt_field_type_common_get_type_id( + struct bt_field_type_common *ft); + +BT_HIDDEN +void _bt_field_type_common_freeze(struct bt_field_type_common *ft); + +BT_HIDDEN +void _bt_field_type_freeze(struct bt_field_type *ft); + +BT_HIDDEN +struct bt_field_type_common * +bt_field_type_common_variant_borrow_field_type_signed( + struct bt_field_type_common_variant *var_ft, + int64_t tag_value); + +BT_HIDDEN +struct bt_field_type_common * +bt_field_type_common_variant_borrow_field_type_unsigned( + struct bt_field_type_common_variant *var_ft, + uint64_t tag_value); + +BT_HIDDEN +struct bt_field_type_common *bt_field_type_common_copy( + struct bt_field_type_common *ft); + +BT_HIDDEN +int bt_field_type_common_structure_get_field_name_index( + struct bt_field_type_common *ft, const char *name); + +BT_HIDDEN +int bt_field_type_common_variant_get_field_name_index( + struct bt_field_type_common *ft, const char *name); + +BT_HIDDEN +int bt_field_type_common_sequence_set_length_field_path( + struct bt_field_type_common *ft, struct bt_field_path *path); + +BT_HIDDEN +int bt_field_type_common_variant_set_tag_field_path( + struct bt_field_type_common *ft, + struct bt_field_path *path); + +BT_HIDDEN +int bt_field_type_common_variant_set_tag_field_type( + struct bt_field_type_common *ft, + struct bt_field_type_common *tag_ft); + +BT_HIDDEN +void bt_field_type_common_generic_freeze(struct bt_field_type_common *ft); + +BT_HIDDEN +void bt_field_type_common_enumeration_freeze_recursive( + struct bt_field_type_common *ft); + +BT_HIDDEN +void bt_field_type_common_structure_freeze_recursive( + struct bt_field_type_common *ft); + +BT_HIDDEN +void bt_field_type_common_variant_freeze_recursive( + struct bt_field_type_common *ft); + +BT_HIDDEN +void bt_field_type_common_array_freeze_recursive( + struct bt_field_type_common *ft); + +BT_HIDDEN +void bt_field_type_common_sequence_freeze_recursive( + struct bt_field_type_common *type); + +BT_HIDDEN +void bt_field_type_common_integer_set_byte_order( + struct bt_field_type_common *ft, enum bt_byte_order byte_order); + +BT_HIDDEN +void bt_field_type_common_enumeration_set_byte_order_recursive( + struct bt_field_type_common *ft, enum bt_byte_order byte_order); + +BT_HIDDEN +void bt_field_type_common_floating_point_set_byte_order( + struct bt_field_type_common *ft, enum bt_byte_order byte_order); + +BT_HIDDEN +void bt_field_type_common_structure_set_byte_order_recursive( + struct bt_field_type_common *ft, + enum bt_byte_order byte_order); + +BT_HIDDEN +void bt_field_type_common_variant_set_byte_order_recursive( + struct bt_field_type_common *ft, + enum bt_byte_order byte_order); + +BT_HIDDEN +void bt_field_type_common_array_set_byte_order_recursive( + struct bt_field_type_common *ft, + enum bt_byte_order byte_order); + +BT_HIDDEN +void bt_field_type_common_sequence_set_byte_order_recursive( + struct bt_field_type_common *ft, + enum bt_byte_order byte_order); + +BT_HIDDEN +int bt_field_type_common_integer_compare(struct bt_field_type_common *ft_a, + struct bt_field_type_common *ft_b); + +BT_HIDDEN +int bt_field_type_common_floating_point_compare( + struct bt_field_type_common *ft_a, + struct bt_field_type_common *ft_b); + +BT_HIDDEN +int bt_field_type_common_enumeration_compare_recursive( + struct bt_field_type_common *ft_a, + struct bt_field_type_common *ft_b); + +BT_HIDDEN +int bt_field_type_common_string_compare(struct bt_field_type_common *ft_a, + struct bt_field_type_common *ft_b); + +BT_HIDDEN +int bt_field_type_common_structure_compare_recursive( + struct bt_field_type_common *ft_a, + struct bt_field_type_common *ft_b); + +BT_HIDDEN +int bt_field_type_common_variant_compare_recursive( + struct bt_field_type_common *ft_a, + struct bt_field_type_common *ft_b); + +BT_HIDDEN +int bt_field_type_common_array_compare_recursive( + struct bt_field_type_common *ft_a, + struct bt_field_type_common *ft_b); + +BT_HIDDEN +int bt_field_type_common_sequence_compare_recursive( + struct bt_field_type_common *ft_a, + struct bt_field_type_common *ft_b); + +BT_HIDDEN +int bt_field_type_common_compare(struct bt_field_type_common *ft_a, + struct bt_field_type_common *ft_b); + +BT_HIDDEN +int64_t bt_field_type_common_get_field_count(struct bt_field_type_common *ft); + +BT_HIDDEN +struct bt_field_type_common *bt_field_type_common_borrow_field_at_index( + struct bt_field_type_common *ft, int index); + +BT_HIDDEN +int bt_field_type_common_get_field_index(struct bt_field_type_common *ft, const char *name); BT_HIDDEN -int bt_ctf_field_type_integer_set_mapped_clock_class_no_check( - struct bt_ctf_field_type *int_field_type, - struct bt_ctf_clock_class *clock_class); - -static inline -const char *bt_ctf_field_type_id_string(enum bt_ctf_field_type_id type_id) -{ - switch (type_id) { - case BT_CTF_FIELD_TYPE_ID_UNKNOWN: - return "BT_CTF_FIELD_TYPE_ID_UNKNOWN"; - case BT_CTF_FIELD_TYPE_ID_INTEGER: - return "BT_CTF_FIELD_TYPE_ID_INTEGER"; - case BT_CTF_FIELD_TYPE_ID_FLOAT: - return "BT_CTF_FIELD_TYPE_ID_FLOAT"; - case BT_CTF_FIELD_TYPE_ID_ENUM: - return "BT_CTF_FIELD_TYPE_ID_ENUM"; - case BT_CTF_FIELD_TYPE_ID_STRING: - return "BT_CTF_FIELD_TYPE_ID_STRING"; - case BT_CTF_FIELD_TYPE_ID_STRUCT: - return "BT_CTF_FIELD_TYPE_ID_STRUCT"; - case BT_CTF_FIELD_TYPE_ID_ARRAY: - return "BT_CTF_FIELD_TYPE_ID_ARRAY"; - case BT_CTF_FIELD_TYPE_ID_SEQUENCE: - return "BT_CTF_FIELD_TYPE_ID_SEQUENCE"; - case BT_CTF_FIELD_TYPE_ID_VARIANT: - return "BT_CTF_FIELD_TYPE_ID_VARIANT"; - default: - return "(unknown)"; - } -}; +struct bt_field_path *bt_field_type_common_variant_borrow_tag_field_path( + struct bt_field_type_common *ft); -static inline -const char *bt_ctf_byte_order_string(enum bt_ctf_byte_order bo) -{ - switch (bo) { - case BT_CTF_BYTE_ORDER_UNKNOWN: - return "BT_CTF_BYTE_ORDER_UNKNOWN"; - case BT_CTF_BYTE_ORDER_NONE: - return "BT_CTF_BYTE_ORDER_NONE"; - case BT_CTF_BYTE_ORDER_NATIVE: - return "BT_CTF_BYTE_ORDER_NATIVE"; - case BT_CTF_BYTE_ORDER_LITTLE_ENDIAN: - return "BT_CTF_BYTE_ORDER_LITTLE_ENDIAN"; - case BT_CTF_BYTE_ORDER_BIG_ENDIAN: - return "BT_CTF_BYTE_ORDER_BIG_ENDIAN"; - case BT_CTF_BYTE_ORDER_NETWORK: - return "BT_CTF_BYTE_ORDER_NETWORK"; - default: - return "(unknown)"; - } -}; +BT_HIDDEN +struct bt_field_path *bt_field_type_common_sequence_borrow_length_field_path( + struct bt_field_type_common *ft); -static inline -const char *bt_ctf_string_encoding_string(enum bt_ctf_string_encoding encoding) -{ - switch (encoding) { - case BT_CTF_STRING_ENCODING_UNKNOWN: - return "BT_CTF_STRING_ENCODING_UNKNOWN"; - case BT_CTF_STRING_ENCODING_NONE: - return "BT_CTF_STRING_ENCODING_NONE"; - case BT_CTF_STRING_ENCODING_UTF8: - return "BT_CTF_STRING_ENCODING_UTF8"; - case BT_CTF_STRING_ENCODING_ASCII: - return "BT_CTF_STRING_ENCODING_ASCII"; - default: - return "(unknown)"; - } -}; +BT_HIDDEN +int bt_field_type_common_validate_single_clock_class( + struct bt_field_type_common *ft, + struct bt_clock_class **expected_clock_class); -static inline -const char *bt_ctf_integer_base_string(enum bt_ctf_integer_base base) -{ - switch (base) { - case BT_CTF_INTEGER_BASE_UNKNOWN: - return "BT_CTF_INTEGER_BASE_UNKNOWN"; - case BT_CTF_INTEGER_BASE_UNSPECIFIED: - return "BT_CTF_INTEGER_BASE_UNSPECIFIED"; - case BT_CTF_INTEGER_BASE_BINARY: - return "BT_CTF_INTEGER_BASE_BINARY"; - case BT_CTF_INTEGER_BASE_OCTAL: - return "BT_CTF_INTEGER_BASE_OCTAL"; - case BT_CTF_INTEGER_BASE_DECIMAL: - return "BT_CTF_INTEGER_BASE_DECIMAL"; - case BT_CTF_INTEGER_BASE_HEXADECIMAL: - return "BT_CTF_INTEGER_BASE_HEXADECIMAL"; - default: - return "(unknown)"; - } -} - -static inline -const char *bt_ctf_scope_string(enum bt_ctf_scope scope) -{ - switch (scope) { - case BT_CTF_SCOPE_UNKNOWN: - return "BT_CTF_SCOPE_UNKNOWN"; - case BT_CTF_SCOPE_TRACE_PACKET_HEADER: - return "BT_CTF_SCOPE_TRACE_PACKET_HEADER"; - case BT_CTF_SCOPE_STREAM_PACKET_CONTEXT: - return "BT_CTF_SCOPE_STREAM_PACKET_CONTEXT"; - case BT_CTF_SCOPE_STREAM_EVENT_HEADER: - return "BT_CTF_SCOPE_STREAM_EVENT_HEADER"; - case BT_CTF_SCOPE_STREAM_EVENT_CONTEXT: - return "BT_CTF_SCOPE_STREAM_EVENT_CONTEXT"; - case BT_CTF_SCOPE_EVENT_CONTEXT: - return "BT_CTF_SCOPE_EVENT_CONTEXT"; - case BT_CTF_SCOPE_EVENT_PAYLOAD: - return "BT_CTF_SCOPE_EVENT_PAYLOAD"; - case BT_CTF_SCOPE_ENV: - return "BT_CTF_SCOPE_ENV"; - default: - return "(unknown)"; - } -} +BT_HIDDEN +int64_t bt_field_type_common_variant_find_choice_index( + struct bt_field_type_common *ft, uint64_t uval, + bool is_signed); #endif /* BABELTRACE_CTF_IR_FIELD_TYPES_INTERNAL_H */