%rename("_bt_ctf_field_type_enumeration_add_mapping") bt_ctf_field_type_enumeration_add_mapping(struct bt_ctf_field_type *enumeration, const char *name, int64_t range_start, int64_t range_end);
%rename("_bt_ctf_field_type_enumeration_add_mapping_unsigned") bt_ctf_field_type_enumeration_add_mapping_unsigned(struct bt_ctf_field_type *enumeration, const char *name, uint64_t range_start, uint64_t range_end);
%rename("_bt_ctf_field_type_enumeration_get_mapping_count") bt_ctf_field_type_enumeration_get_mapping_count(struct bt_ctf_field_type *enumeration);
-%rename("_bt_ctf_field_type_enumeration_get_mapping") bt_ctf_field_type_enumeration_get_mapping(struct bt_ctf_field_type *enumeration, size_t index, const char **name, int64_t *range_start, int64_t *range_end);
-%rename("_bt_ctf_field_type_enumeration_get_mapping_unsigned") bt_ctf_field_type_enumeration_get_mapping_unsigned(struct bt_ctf_field_type *enumeration, size_t index, const char **name, uint64_t *range_start, uint64_t *range_end);
-%rename("_bt_ctf_field_type_enumeration_get_mapping_index_by_name") bt_ctf_field_type_enumeration_get_mapping_index_by_name(struct bt_ctf_field_type *enumeration, const char *name, size_t *index);
-%rename("_bt_ctf_field_type_enumeration_get_mapping_index_by_value") bt_ctf_field_type_enumeration_get_mapping_index_by_value(struct bt_ctf_field_type *enumeration, int64_t value, size_t *index);
-%rename("_bt_ctf_field_type_enumeration_get_mapping_index_by_unsigned_value") bt_ctf_field_type_enumeration_get_mapping_index_by_unsigned_value(struct bt_ctf_field_type *enumeration, uint64_t value, size_t *index);
+%rename("_bt_ctf_field_type_enumeration_get_mapping") bt_ctf_field_type_enumeration_get_mapping(struct bt_ctf_field_type *enumeration, int index, const char **name, int64_t *range_start, int64_t *range_end);
+%rename("_bt_ctf_field_type_enumeration_get_mapping_unsigned") bt_ctf_field_type_enumeration_get_mapping_unsigned(struct bt_ctf_field_type *enumeration, int index, const char **name, uint64_t *range_start, uint64_t *range_end);
+%rename("_bt_ctf_field_type_enumeration_get_mapping_index_by_name") bt_ctf_field_type_enumeration_get_mapping_index_by_name(struct bt_ctf_field_type *enumeration, const char *name);
+%rename("_bt_ctf_field_type_enumeration_get_mapping_index_by_value") bt_ctf_field_type_enumeration_get_mapping_index_by_value(struct bt_ctf_field_type *enumeration, int64_t value);
+%rename("_bt_ctf_field_type_enumeration_get_mapping_index_by_unsigned_value") bt_ctf_field_type_enumeration_get_mapping_index_by_unsigned_value(struct bt_ctf_field_type *enumeration, uint64_t value);
%rename("_bt_ctf_field_type_floating_point_create") bt_ctf_field_type_floating_point_create(void);
%rename("_bt_ctf_field_type_floating_point_get_exponent_digits") bt_ctf_field_type_floating_point_get_exponent_digits(struct bt_ctf_field_type *floating_point);
%rename("_bt_ctf_field_type_floating_point_set_exponent_digits") bt_ctf_field_type_floating_point_set_exponent_digits(struct bt_ctf_field_type *floating_point, unsigned int exponent_digits);
%rename("_bt_ctf_field_type_structure_create") bt_ctf_field_type_structure_create(void);
%rename("_bt_ctf_field_type_structure_add_field") bt_ctf_field_type_structure_add_field(struct bt_ctf_field_type *structure, struct bt_ctf_field_type *field_type, const char *field_name);
%rename("_bt_ctf_field_type_structure_get_field_count") bt_ctf_field_type_structure_get_field_count(struct bt_ctf_field_type *structure);
-%rename("_bt_ctf_field_type_structure_get_field") bt_ctf_field_type_structure_get_field(struct bt_ctf_field_type *structure, const char **field_name, struct bt_ctf_field_type **field_type, size_t index);
+%rename("_bt_ctf_field_type_structure_get_field") bt_ctf_field_type_structure_get_field(struct bt_ctf_field_type *structure, const char **field_name, struct bt_ctf_field_type **field_type, int index);
%rename("_bt_ctf_field_type_structure_get_field_type_by_name") bt_ctf_field_type_structure_get_field_type_by_name(struct bt_ctf_field_type *structure, const char *field_name);
%rename("_bt_ctf_field_type_variant_create") bt_ctf_field_type_variant_create(struct bt_ctf_field_type *enum_tag, const char *tag_name);
%rename("_bt_ctf_field_type_variant_get_tag_type") bt_ctf_field_type_variant_get_tag_type(struct bt_ctf_field_type *variant);
%rename("_bt_ctf_field_type_variant_get_field_type_by_name") bt_ctf_field_type_variant_get_field_type_by_name(struct bt_ctf_field_type *variant, const char *field_name);
%rename("_bt_ctf_field_type_variant_get_field_type_from_tag") bt_ctf_field_type_variant_get_field_type_from_tag(struct bt_ctf_field_type *variant, struct bt_ctf_field *tag);
%rename("_bt_ctf_field_type_variant_get_field_count") bt_ctf_field_type_variant_get_field_count(struct bt_ctf_field_type *variant);
-%rename("_bt_ctf_field_type_variant_get_field") bt_ctf_field_type_variant_get_field(struct bt_ctf_field_type *variant, const char **field_name, struct bt_ctf_field_type **field_type, size_t index);
+%rename("_bt_ctf_field_type_variant_get_field") bt_ctf_field_type_variant_get_field(struct bt_ctf_field_type *variant, const char **field_name, struct bt_ctf_field_type **field_type, int index);
%rename("_bt_ctf_field_type_array_create") bt_ctf_field_type_array_create(struct bt_ctf_field_type *element_type, unsigned int length);
%rename("_bt_ctf_field_type_array_get_element_type") bt_ctf_field_type_array_get_element_type(struct bt_ctf_field_type *array);
%rename("_bt_ctf_field_type_array_get_length") bt_ctf_field_type_array_get_length(struct bt_ctf_field_type *array);
struct bt_ctf_field_type *bt_ctf_field_type_enumeration_get_container_type(struct bt_ctf_field_type *enumeration);
int bt_ctf_field_type_enumeration_add_mapping(struct bt_ctf_field_type *enumeration, const char *name, int64_t range_start, int64_t range_end);
int bt_ctf_field_type_enumeration_add_mapping_unsigned(struct bt_ctf_field_type *enumeration, const char *name, uint64_t range_start, uint64_t range_end);
-int64_t bt_ctf_field_type_enumeration_get_mapping_count(struct bt_ctf_field_type *enumeration);
-int bt_ctf_field_type_enumeration_get_mapping(struct bt_ctf_field_type *enumeration, size_t index, const char **OUTPUT, int64_t *OUTPUT, int64_t *OUTPUT);
-int bt_ctf_field_type_enumeration_get_mapping_unsigned(struct bt_ctf_field_type *enumeration, size_t index, const char **OUTPUT, uint64_t *OUTPUT, uint64_t *OUTPUT);
-int bt_ctf_field_type_enumeration_get_mapping_index_by_name(struct bt_ctf_field_type *enumeration, const char *name, size_t *OUTPUT);
-int bt_ctf_field_type_enumeration_get_mapping_index_by_value(struct bt_ctf_field_type *enumeration, int64_t value, size_t *OUTPUT);
-int bt_ctf_field_type_enumeration_get_mapping_index_by_unsigned_value(struct bt_ctf_field_type *enumeration, uint64_t value, size_t *OUTPUT);
+int bt_ctf_field_type_enumeration_get_mapping_count(struct bt_ctf_field_type *enumeration);
+int bt_ctf_field_type_enumeration_get_mapping(struct bt_ctf_field_type *enumeration, int index, const char **OUTPUT, int64_t *OUTPUT, int64_t *OUTPUT);
+int bt_ctf_field_type_enumeration_get_mapping_unsigned(struct bt_ctf_field_type *enumeration, int index, const char **OUTPUT, uint64_t *OUTPUT, uint64_t *OUTPUT);
+int bt_ctf_field_type_enumeration_get_mapping_index_by_name(struct bt_ctf_field_type *enumeration, const char *name);
+int bt_ctf_field_type_enumeration_get_mapping_index_by_value(struct bt_ctf_field_type *enumeration, int64_t value);
+int bt_ctf_field_type_enumeration_get_mapping_index_by_unsigned_value(struct bt_ctf_field_type *enumeration, uint64_t value);
struct bt_ctf_field_type *bt_ctf_field_type_floating_point_create(void);
int bt_ctf_field_type_floating_point_get_exponent_digits(struct bt_ctf_field_type *floating_point);
int bt_ctf_field_type_floating_point_set_exponent_digits(struct bt_ctf_field_type *floating_point, unsigned int exponent_digits);
int bt_ctf_field_type_floating_point_set_mantissa_digits(struct bt_ctf_field_type *floating_point, unsigned int mantissa_digits);
struct bt_ctf_field_type *bt_ctf_field_type_structure_create(void);
int bt_ctf_field_type_structure_add_field(struct bt_ctf_field_type *structure, struct bt_ctf_field_type *field_type, const char *field_name);
-int64_t bt_ctf_field_type_structure_get_field_count(struct bt_ctf_field_type *structure);
-int bt_ctf_field_type_structure_get_field(struct bt_ctf_field_type *structure, const char **OUTPUT, struct bt_ctf_field_type **OUTPUT, size_t index);
+int bt_ctf_field_type_structure_get_field_count(struct bt_ctf_field_type *structure);
+int bt_ctf_field_type_structure_get_field(struct bt_ctf_field_type *structure, const char **OUTPUT, struct bt_ctf_field_type **OUTPUT, int index);
struct bt_ctf_field_type *bt_ctf_field_type_structure_get_field_type_by_name(struct bt_ctf_field_type *structure, const char *field_name);
struct bt_ctf_field_type *bt_ctf_field_type_variant_create(struct bt_ctf_field_type *enum_tag, const char *tag_name);
struct bt_ctf_field_type *bt_ctf_field_type_variant_get_tag_type(struct bt_ctf_field_type *variant);
int bt_ctf_field_type_variant_add_field(struct bt_ctf_field_type *variant, struct bt_ctf_field_type *field_type, const char *field_name);
struct bt_ctf_field_type *bt_ctf_field_type_variant_get_field_type_by_name(struct bt_ctf_field_type *variant, const char *field_name);
struct bt_ctf_field_type *bt_ctf_field_type_variant_get_field_type_from_tag(struct bt_ctf_field_type *variant, struct bt_ctf_field *tag);
-int64_t bt_ctf_field_type_variant_get_field_count(struct bt_ctf_field_type *variant);
-int bt_ctf_field_type_variant_get_field(struct bt_ctf_field_type *variant, const char **OUTPUT, struct bt_ctf_field_type **OUTPUT, size_t index);
+int bt_ctf_field_type_variant_get_field_count(struct bt_ctf_field_type *variant);
+int bt_ctf_field_type_variant_get_field(struct bt_ctf_field_type *variant, const char **OUTPUT, struct bt_ctf_field_type **OUTPUT, int index);
struct bt_ctf_field_type *bt_ctf_field_type_array_create(struct bt_ctf_field_type *element_type, unsigned int length);
struct bt_ctf_field_type *bt_ctf_field_type_array_get_element_type(struct bt_ctf_field_type *array);
int64_t bt_ctf_field_type_array_get_length(struct bt_ctf_field_type *array);
%rename("_bt_ctf_event_class_get_stream_class") bt_ctf_event_class_get_stream_class(struct bt_ctf_event_class *event_class);
%rename("_bt_ctf_event_class_add_field") bt_ctf_event_class_add_field(struct bt_ctf_event_class *event_class, struct bt_ctf_field_type *type, const char *name);
%rename("_bt_ctf_event_class_get_field_count") bt_ctf_event_class_get_field_count(struct bt_ctf_event_class *event_class);
-%rename("_bt_ctf_event_class_get_field") bt_ctf_event_class_get_field(struct bt_ctf_event_class *event_class, const char **field_name, struct bt_ctf_field_type **field_type, size_t index);
+%rename("_bt_ctf_event_class_get_field") bt_ctf_event_class_get_field(struct bt_ctf_event_class *event_class, const char **field_name, struct bt_ctf_field_type **field_type, int index);
%rename("_bt_ctf_event_class_get_field_by_name") bt_ctf_event_class_get_field_by_name(struct bt_ctf_event_class *event_class, const char *name);
%rename("_bt_ctf_event_class_get") bt_ctf_event_class_get(struct bt_ctf_event_class *event_class);
%rename("_bt_ctf_event_class_put") bt_ctf_event_class_put(struct bt_ctf_event_class *event_class);
int bt_ctf_event_class_set_id(struct bt_ctf_event_class *event_class, uint32_t id);
struct bt_ctf_stream_class *bt_ctf_event_class_get_stream_class(struct bt_ctf_event_class *event_class);
int bt_ctf_event_class_add_field(struct bt_ctf_event_class *event_class, struct bt_ctf_field_type *type, const char *name);
-int64_t bt_ctf_event_class_get_field_count(struct bt_ctf_event_class *event_class);
-int bt_ctf_event_class_get_field(struct bt_ctf_event_class *event_class, const char **field_name, struct bt_ctf_field_type **field_type, size_t index);
+int bt_ctf_event_class_get_field_count(struct bt_ctf_event_class *event_class);
+int bt_ctf_event_class_get_field(struct bt_ctf_event_class *event_class, const char **field_name, struct bt_ctf_field_type **field_type, int index);
struct bt_ctf_field_type *bt_ctf_event_class_get_field_by_name(struct bt_ctf_event_class *event_class, const char *name);
void bt_ctf_event_class_get(struct bt_ctf_event_class *event_class);
void bt_ctf_event_class_put(struct bt_ctf_event_class *event_class);
%rename("_bt_ctf_event_get_clock") bt_ctf_event_get_clock(struct bt_ctf_event *event);
%rename("_bt_ctf_event_get_payload") bt_ctf_event_get_payload(struct bt_ctf_event *event, const char *name);
%rename("_bt_ctf_event_set_payload") bt_ctf_event_set_payload(struct bt_ctf_event *event, const char *name, struct bt_ctf_field *value);
-%rename("_bt_ctf_event_get_payload_by_index") bt_ctf_event_get_payload_by_index(struct bt_ctf_event *event, size_t index);
+%rename("_bt_ctf_event_get_payload_by_index") bt_ctf_event_get_payload_by_index(struct bt_ctf_event *event, int index);
%rename("_bt_ctf_event_get") bt_ctf_event_get(struct bt_ctf_event *event);
%rename("_bt_ctf_event_put") bt_ctf_event_put(struct bt_ctf_event *event);
struct bt_ctf_clock *bt_ctf_event_get_clock(struct bt_ctf_event *event);
struct bt_ctf_field *bt_ctf_event_get_payload(struct bt_ctf_event *event, const char *name);
int bt_ctf_event_set_payload(struct bt_ctf_event *event, const char *name, struct bt_ctf_field *value);
-struct bt_ctf_field *bt_ctf_event_get_payload_by_index(struct bt_ctf_event *event, size_t index);
+struct bt_ctf_field *bt_ctf_event_get_payload_by_index(struct bt_ctf_event *event, int index);
void bt_ctf_event_get(struct bt_ctf_event *event);
void bt_ctf_event_put(struct bt_ctf_event *event);
%rename("_bt_ctf_stream_class_set_id") bt_ctf_stream_class_set_id(struct bt_ctf_stream_class *stream_class, uint32_t id);
%rename("_bt_ctf_stream_class_add_event_class") bt_ctf_stream_class_add_event_class(struct bt_ctf_stream_class *stream_class, struct bt_ctf_event_class *event_class);
%rename("_bt_ctf_stream_class_get_event_class_count") bt_ctf_stream_class_get_event_class_count(struct bt_ctf_stream_class *stream_class);
-%rename("_bt_ctf_stream_class_get_event_class") bt_ctf_stream_class_get_event_class(struct bt_ctf_stream_class *stream_class, size_t index);
+%rename("_bt_ctf_stream_class_get_event_class") bt_ctf_stream_class_get_event_class(struct bt_ctf_stream_class *stream_class, int index);
%rename("_bt_ctf_stream_class_get_event_class_by_name") bt_ctf_stream_class_get_event_class_by_name(struct bt_ctf_stream_class *stream_class, const char *name);
%rename("_bt_ctf_stream_class_get_packet_context_type") bt_ctf_stream_class_get_packet_context_type(struct bt_ctf_stream_class *stream_class);
%rename("_bt_ctf_stream_class_set_packet_context_type") bt_ctf_stream_class_set_packet_context_type(struct bt_ctf_stream_class *stream_class, struct bt_ctf_field_type *packet_context_type);
int64_t bt_ctf_stream_class_get_id(struct bt_ctf_stream_class *stream_class);
int bt_ctf_stream_class_set_id(struct bt_ctf_stream_class *stream_class, uint32_t id);
int bt_ctf_stream_class_add_event_class(struct bt_ctf_stream_class *stream_class, struct bt_ctf_event_class *event_class);
-int64_t bt_ctf_stream_class_get_event_class_count(struct bt_ctf_stream_class *stream_class);
-struct bt_ctf_event_class *bt_ctf_stream_class_get_event_class(struct bt_ctf_stream_class *stream_class, size_t index);
+int bt_ctf_stream_class_get_event_class_count(struct bt_ctf_stream_class *stream_class);
+struct bt_ctf_event_class *bt_ctf_stream_class_get_event_class(struct bt_ctf_stream_class *stream_class, int index);
struct bt_ctf_event_class *bt_ctf_stream_class_get_event_class_by_name(struct bt_ctf_stream_class *stream_class, const char *name);
struct bt_ctf_field_type *bt_ctf_stream_class_get_packet_context_type(struct bt_ctf_stream_class *stream_class);
int bt_ctf_stream_class_set_packet_context_type(struct bt_ctf_stream_class *stream_class, struct bt_ctf_field_type *packet_context_type);
"""
def get_mapping_by_name(self, name):
- ret, index = _bt_ctf_field_type_enumeration_get_mapping_index_by_name(
+ index = _bt_ctf_field_type_enumeration_get_mapping_index_by_name(
self._ft, name)
- if ret < 0:
+ if index < 0:
return None
if self.container.signed:
def get_mapping_by_value(self, value):
if value < 0:
- ret, index = _bt_ctf_field_type_enumeration_get_mapping_index_by_value(
+ index = _bt_ctf_field_type_enumeration_get_mapping_index_by_value(
self._ft, value)
else:
- ret, index = _bt_ctf_field_type_enumeration_get_mapping_index_by_unsigned_value(
+ index = _bt_ctf_field_type_enumeration_get_mapping_index_by_unsigned_value(
self._ft, value)
- if ret < 0:
+ if index < 0:
return None
if self.container.signed:
}
struct bt_ctf_field *bt_ctf_field_structure_get_field_by_index(
- struct bt_ctf_field *field, size_t index)
+ struct bt_ctf_field *field, int index)
{
int ret;
const char *field_name;
return name;
}
-int64_t bt_ctf_field_type_enumeration_get_mapping_count(
+int bt_ctf_field_type_enumeration_get_mapping_count(
struct bt_ctf_field_type *type)
{
- int64_t ret = 0;
+ int ret = 0;
struct bt_ctf_field_type_enumeration *enumeration;
if (!type || (type->declaration->id != CTF_TYPE_ENUM)) {
enumeration = container_of(type, struct bt_ctf_field_type_enumeration,
parent);
- ret = enumeration->entries->len;
+ ret = (int) enumeration->entries->len;
end:
return ret;
}
static inline
struct enumeration_mapping *get_enumeration_mapping(
- struct bt_ctf_field_type *type, size_t index)
+ struct bt_ctf_field_type *type, int index)
{
struct enumeration_mapping *mapping = NULL;
struct bt_ctf_field_type_enumeration *enumeration;
}
int bt_ctf_field_type_enumeration_get_mapping(
- struct bt_ctf_field_type *type, size_t index,
+ struct bt_ctf_field_type *type, int index,
const char **string, int64_t *range_start, int64_t *range_end)
{
struct enumeration_mapping *mapping;
int ret = 0;
- if (!type || !string || !range_start || !range_end ||
+ if (!type || index < 0 || !string || !range_start || !range_end ||
(type->declaration->id != CTF_TYPE_ENUM)) {
ret = -1;
goto end;
}
int bt_ctf_field_type_enumeration_get_mapping_unsigned(
- struct bt_ctf_field_type *type, size_t index,
+ struct bt_ctf_field_type *type, int index,
const char **string, uint64_t *range_start, uint64_t *range_end)
{
struct enumeration_mapping *mapping;
int ret = 0;
- if (!type || !string || !range_start || !range_end ||
+ if (!type || index < 0 || !string || !range_start || !range_end ||
(type->declaration->id != CTF_TYPE_ENUM)) {
ret = -1;
goto end;
}
int bt_ctf_field_type_enumeration_get_mapping_index_by_name(
- struct bt_ctf_field_type *type, const char *name,
- size_t *index)
+ struct bt_ctf_field_type *type, const char *name)
{
- size_t i;
GQuark name_quark;
struct bt_ctf_field_type_enumeration *enumeration;
- int ret = 0;
+ int i, ret = 0;
- if (!type || !name || !index ||
+ if (!type || !name ||
(type->declaration->id != CTF_TYPE_ENUM)) {
ret = -1;
goto end;
get_enumeration_mapping(type, i);
if (mapping->string == name_quark) {
- *index = i;
+ ret = i;
goto end;
}
}
}
int bt_ctf_field_type_enumeration_get_mapping_index_by_value(
- struct bt_ctf_field_type *type, int64_t value,
- size_t *index)
+ struct bt_ctf_field_type *type, int64_t value)
{
struct bt_ctf_field_type_enumeration *enumeration;
- size_t i;
- int ret = 0;
+ int i, ret = 0;
- if (!type || !index || (type->declaration->id != CTF_TYPE_ENUM)) {
+ if (!type || (type->declaration->id != CTF_TYPE_ENUM)) {
ret = -1;
goto end;
}
if (value >= mapping->range_start._signed &&
value <= mapping->range_end._signed) {
- *index = i;
+ ret = i;
goto end;
}
}
}
int bt_ctf_field_type_enumeration_get_mapping_index_by_unsigned_value(
- struct bt_ctf_field_type *type, uint64_t value,
- size_t *index)
+ struct bt_ctf_field_type *type, uint64_t value)
{
struct bt_ctf_field_type_enumeration *enumeration;
- size_t i;
- int ret = 0;
+ int i, ret = 0;
- if (!type || !index || (type->declaration->id != CTF_TYPE_ENUM)) {
+ if (!type || (type->declaration->id != CTF_TYPE_ENUM)) {
ret = -1;
goto end;
}
if (value >= mapping->range_start._unsigned &&
value <= mapping->range_end._unsigned) {
- *index = i;
+ ret = i;
goto end;
}
}
return ret;
}
-int64_t bt_ctf_field_type_structure_get_field_count(
+int bt_ctf_field_type_structure_get_field_count(
struct bt_ctf_field_type *type)
{
- int64_t ret = 0;
+ int ret = 0;
struct bt_ctf_field_type_structure *structure;
if (!type || (type->declaration->id != CTF_TYPE_STRUCT)) {
structure = container_of(type, struct bt_ctf_field_type_structure,
parent);
- ret = structure->fields->len;
+ ret = (int) structure->fields->len;
end:
return ret;
}
int bt_ctf_field_type_structure_get_field(struct bt_ctf_field_type *type,
const char **field_name, struct bt_ctf_field_type **field_type,
- size_t index)
+ int index)
{
struct bt_ctf_field_type_structure *structure;
struct structure_field *field;
int ret = 0;
- if (!type || !field_name || !field_type ||
+ if (!type || index < 0 || !field_name || !field_type ||
(type->declaration->id != CTF_TYPE_STRUCT)) {
ret = -1;
goto end;
return field_type;
}
-int64_t bt_ctf_field_type_variant_get_field_count(struct bt_ctf_field_type *type)
+int bt_ctf_field_type_variant_get_field_count(struct bt_ctf_field_type *type)
{
- int64_t ret = 0;
+ int ret = 0;
struct bt_ctf_field_type_variant *variant;
if (!type || (type->declaration->id != CTF_TYPE_VARIANT)) {
variant = container_of(type, struct bt_ctf_field_type_variant,
parent);
- ret = variant->fields->len;
+ ret = (int) variant->fields->len;
end:
return ret;
int bt_ctf_field_type_variant_get_field(struct bt_ctf_field_type *type,
const char **field_name, struct bt_ctf_field_type **field_type,
- size_t index)
+ int index)
{
struct bt_ctf_field_type_variant *variant;
struct structure_field *field;
int ret = 0;
- if (!type || !field_name || !field_type ||
+ if (!type || index < 0 || !field_name || !field_type ||
(type->declaration->id != CTF_TYPE_VARIANT)) {
ret = -1;
goto end;
return ret;
}
-int64_t bt_ctf_event_class_get_field_count(
+int bt_ctf_event_class_get_field_count(
struct bt_ctf_event_class *event_class)
{
- int64_t ret;
+ int ret;
if (!event_class) {
ret = -1;
int bt_ctf_event_class_get_field(struct bt_ctf_event_class *event_class,
const char **field_name, struct bt_ctf_field_type **field_type,
- size_t index)
+ int index)
{
int ret;
- if (!event_class) {
+ if (!event_class || index < 0) {
ret = -1;
goto end;
}
}
struct bt_ctf_field *bt_ctf_event_get_payload_by_index(
- struct bt_ctf_event *event, size_t index)
+ struct bt_ctf_event *event, int index)
{
struct bt_ctf_field *field = NULL;
- if (!event) {
+ if (!event || index < 0) {
goto end;
}
return ret;
}
-int64_t bt_ctf_stream_class_get_event_class_count(
+int bt_ctf_stream_class_get_event_class_count(
struct bt_ctf_stream_class *stream_class)
{
- int64_t ret;
+ int ret;
if (!stream_class) {
ret = -1;
goto end;
}
- ret = (int64_t) stream_class->event_classes->len;
+ ret = (int) stream_class->event_classes->len;
end:
return ret;
}
struct bt_ctf_event_class *bt_ctf_stream_class_get_event_class(
- struct bt_ctf_stream_class *stream_class, size_t index)
+ struct bt_ctf_stream_class *stream_class, int index)
{
struct bt_ctf_event_class *event_class = NULL;
- if (!stream_class || index >= stream_class->event_classes->len) {
+ if (!stream_class || index < 0 ||
+ index >= stream_class->event_classes->len) {
goto end;
}
* Returns a field instance on success, NULL on error.
*/
extern struct bt_ctf_field *bt_ctf_field_structure_get_field_by_index(
- struct bt_ctf_field *structure, size_t index);
+ struct bt_ctf_field *structure, int index);
/*
* bt_ctf_field_array_get_field: get an array's field at position "index".
*
* Returns the mapping count on success, a negative value on error.
*/
-extern int64_t bt_ctf_field_type_enumeration_get_mapping_count(
+extern int bt_ctf_field_type_enumeration_get_mapping_count(
struct bt_ctf_field_type *enumeration);
/*
* Returns 0 on success, a negative value on error.
*/
extern int bt_ctf_field_type_enumeration_get_mapping(
- struct bt_ctf_field_type *enumeration, size_t index,
+ struct bt_ctf_field_type *enumeration, int index,
const char **name, int64_t *range_start, int64_t *range_end);
/*
* Returns 0 on success, a negative value on error.
*/
extern int bt_ctf_field_type_enumeration_get_mapping_unsigned(
- struct bt_ctf_field_type *enumeration, size_t index,
+ struct bt_ctf_field_type *enumeration, int index,
const char **name, uint64_t *range_start,
uint64_t *range_end);
*
* @param enumeration Enumeration type.
* @param name Mapping name.
- * @param index Pointer where the enumeration's mapping index will be returned.
*
- * Returns 0 on success, a negative value on error.
+ * Returns mapping index on success, a negative value on error.
*/
extern int bt_ctf_field_type_enumeration_get_mapping_index_by_name(
- struct bt_ctf_field_type *enumeration, const char *name,
- size_t *index);
+ struct bt_ctf_field_type *enumeration, const char *name);
/*
* bt_ctf_field_type_enumeration_get_mapping_index_by_value: get an
*
* @param enumeration Enumeration type.
* @param value Value.
- * @param index Pointer where the enumeration's mapping index will be returned.
*
- * Returns 0 on success, a negative value on error.
+ * Returns mapping index on success, a negative value on error.
*/
extern int bt_ctf_field_type_enumeration_get_mapping_index_by_value(
- struct bt_ctf_field_type *enumeration, int64_t value,
- size_t *index);
+ struct bt_ctf_field_type *enumeration, int64_t value);
/*
* bt_ctf_field_type_enumeration_get_mapping_index_by_unsigned_value: get an
*
* @param enumeration Enumeration type.
* @param value Value.
- * @param index Pointer where the enumeration's mapping index will be returned.
*
* Returns 0 on success, a negative value on error.
*/
extern int bt_ctf_field_type_enumeration_get_mapping_index_by_unsigned_value(
- struct bt_ctf_field_type *enumeration, uint64_t value,
- size_t *index);
+ struct bt_ctf_field_type *enumeration, uint64_t value);
/*
* bt_ctf_field_type_floating_point_create: create a floating point field type.
*
* Returns the field count on success, a negative value on error.
*/
-extern int64_t bt_ctf_field_type_structure_get_field_count(
+extern int bt_ctf_field_type_structure_get_field_count(
struct bt_ctf_field_type *structure);
/*
extern int bt_ctf_field_type_structure_get_field(
struct bt_ctf_field_type *structure,
const char **field_name, struct bt_ctf_field_type **field_type,
- size_t index);
+ int index);
/*
* bt_ctf_field_type_structure_get_field_type_by_name: get a structure field's
*
* Returns the field count on success, a negative value on error.
*/
-extern int64_t bt_ctf_field_type_variant_get_field_count(
+extern int bt_ctf_field_type_variant_get_field_count(
struct bt_ctf_field_type *variant);
/*
*/
extern int bt_ctf_field_type_variant_get_field(
struct bt_ctf_field_type *variant, const char **field_name,
- struct bt_ctf_field_type **field_type, size_t index);
+ struct bt_ctf_field_type **field_type, int index);
/*
* bt_ctf_field_type_array_create: create an array field type.
*
* Returns the event class' field count, a negative value on error.
*/
-extern int64_t bt_ctf_event_class_get_field_count(
+extern int bt_ctf_event_class_get_field_count(
struct bt_ctf_event_class *event_class);
/*
*/
extern int bt_ctf_event_class_get_field(struct bt_ctf_event_class *event_class,
const char **field_name, struct bt_ctf_field_type **field_type,
- size_t index);
+ int index);
/*
* bt_ctf_event_class_get_field_type_by_name: Get an event class's field by name
* Returns the event's field, NULL on error.
*/
extern struct bt_ctf_field *bt_ctf_event_get_payload_by_index(
- struct bt_ctf_event *event, size_t index);
+ struct bt_ctf_event *event, int index);
/*
* bt_ctf_event_get and bt_ctf_event_put: increment and decrement
*
* Returns the stream class' event count, a negative value on error.
*/
-extern int64_t bt_ctf_stream_class_get_event_class_count(
+extern int bt_ctf_stream_class_get_event_class_count(
struct bt_ctf_stream_class *stream_class);
/*
* Returns event class, NULL on error.
*/
extern struct bt_ctf_event_class *bt_ctf_stream_class_get_event_class(
- struct bt_ctf_stream_class *stream_class, size_t index);
+ struct bt_ctf_stream_class *stream_class, int index);
/*
* bt_ctf_stream_class_get_event_class_by_name: Get stream class event class by
const char *mapping_name_negative_test = "negative_value";
const char *ret_char;
double ret_double;
- size_t ret_size_t;
int64_t ret_range_start_int64_t, ret_range_end_int64_t;
uint64_t ret_range_start_uint64_t, ret_range_end_uint64_t;
struct bt_ctf_clock *ret_clock;
-54, -55), "bt_ctf_field_type_enumeration_add_mapping rejects mapping where end < start");
bt_ctf_field_type_enumeration_add_mapping(enum_type, "another entry", -42000, -13000);
- ok(bt_ctf_field_type_enumeration_get_mapping_index_by_value(NULL, -42, &ret_size_t) < 0,
+ ok(bt_ctf_field_type_enumeration_get_mapping_index_by_value(NULL, -42) < 0,
"bt_ctf_field_type_enumeration_get_mapping_index_by_value handles a NULL field type correctly");
- ok(bt_ctf_field_type_enumeration_get_mapping_index_by_value(enum_type, -42, NULL) < 0,
- "bt_ctf_field_type_enumeration_get_mapping_index_by_value handles a NULL index correctly");
- ok(bt_ctf_field_type_enumeration_get_mapping_index_by_value(enum_type, 1000000, &ret_size_t) < 0,
+ ok(bt_ctf_field_type_enumeration_get_mapping_index_by_value(enum_type, 1000000) < 0,
"bt_ctf_field_type_enumeration_get_mapping_index_by_value handles invalid values correctly");
- ok(bt_ctf_field_type_enumeration_get_mapping_index_by_value(enum_type, -55, &ret_size_t) == 0,
- "bt_ctf_field_type_enumeration_get_mapping_index_by_value handles invalid values correctly");
- ok(ret_size_t == 1,
+ ok(bt_ctf_field_type_enumeration_get_mapping_index_by_value(enum_type, -55) == 1,
"bt_ctf_field_type_enumeration_get_mapping_index_by_value returns the correct index");
ok(bt_ctf_event_class_add_field(simple_event_class, enum_type,
uint64_t ret_unsigned_int;
int64_t ret_signed_int;
const char *ret_string;
- size_t ret_size_t;
struct bt_ctf_stream_class *ret_stream_class;
struct bt_ctf_event_class *ret_event_class;
struct bt_ctf_field *packet_context, *packet_context_field;
bt_ctf_field_type_enumeration_add_mapping(enum_variant_type,
"UINT35_TYPE", 2, 7);
- ok(bt_ctf_field_type_enumeration_get_mapping_index_by_name(NULL, "INT16_TYPE",
- &ret_size_t) < 0,
+ ok(bt_ctf_field_type_enumeration_get_mapping_index_by_name(NULL,
+ "INT16_TYPE") < 0,
"bt_ctf_field_type_enumeration_get_mapping_index_by_name handles a NULL field type correctly");
- ok(bt_ctf_field_type_enumeration_get_mapping_index_by_name(enum_variant_type, NULL,
- &ret_size_t) < 0,
+ ok(bt_ctf_field_type_enumeration_get_mapping_index_by_name(
+ enum_variant_type, NULL) < 0,
"bt_ctf_field_type_enumeration_get_mapping_index_by_name handles a NULL name correctly");
- ok(bt_ctf_field_type_enumeration_get_mapping_index_by_name(enum_variant_type, "INT16_TYPE",
- NULL) < 0,
- "bt_ctf_field_type_enumeration_get_mapping_index_by_name handles a NULL index correctly");
- ok(bt_ctf_field_type_enumeration_get_mapping_index_by_name(enum_variant_type, "INT16_TYPE",
- &ret_size_t) == 0,
- "bt_ctf_field_type_enumeration_get_mapping_index_by_name returns a value");
- ok(ret_size_t == 1,
+ ok(bt_ctf_field_type_enumeration_get_mapping_index_by_name(
+ enum_variant_type, "INT16_TYPE") == 1,
"bt_ctf_field_type_enumeration_get_mapping_index_by_name returns the correct index");
- ok(bt_ctf_field_type_enumeration_get_mapping_index_by_unsigned_value(NULL, 1, &ret_size_t) < 0,
+ ok(bt_ctf_field_type_enumeration_get_mapping_index_by_unsigned_value(NULL, 1) < 0,
"bt_ctf_field_type_enumeration_get_mapping_index_by_unsigned_value handles a NULL field type correctly");
- ok(bt_ctf_field_type_enumeration_get_mapping_index_by_unsigned_value(enum_variant_type, 1, NULL) < 0,
- "bt_ctf_field_type_enumeration_get_mapping_index_by_unsigned_value handles a NULL index correctly");
- ok(bt_ctf_field_type_enumeration_get_mapping_index_by_unsigned_value(enum_variant_type, -42, &ret_size_t) < 0,
- "bt_ctf_field_type_enumeration_get_mapping_index_by_unsigned_value handles invalid values correctly");
- ok(bt_ctf_field_type_enumeration_get_mapping_index_by_unsigned_value(enum_variant_type, 5, &ret_size_t) == 0,
+ ok(bt_ctf_field_type_enumeration_get_mapping_index_by_unsigned_value(enum_variant_type, -42) < 0,
"bt_ctf_field_type_enumeration_get_mapping_index_by_unsigned_value handles invalid values correctly");
- ok(ret_size_t == 2,
+ ok(bt_ctf_field_type_enumeration_get_mapping_index_by_unsigned_value(enum_variant_type, 5) == 2,
"bt_ctf_field_type_enumeration_get_mapping_index_by_unsigned_value returns the correct index");
ok(bt_ctf_field_type_variant_add_field(variant_type, uint_3_type,