*/
#include "python-complements.h"
-#include <babeltrace/ctf-writer/event-types-internal.h>
-#include <babeltrace/ctf-writer/event-fields-internal.h>
-
-/* FILE functions
- ----------------------------------------------------
-*/
-
-FILE *_bt_file_open(char *file_path, char *mode)
-{
- FILE *fp = stdout;
- if (file_path != NULL)
- fp = fopen(file_path, mode);
- return fp;
-}
-
-void _bt_file_close(FILE *fp)
-{
- if (fp != NULL)
- fclose(fp);
-}
-
+#include <babeltrace/ctf-ir/event-types-internal.h>
+#include <babeltrace/ctf-ir/event-fields-internal.h>
+#include <babeltrace/ctf-ir/event-types.h>
+#include <babeltrace/ctf-ir/event.h>
/* List-related functions
----------------------------------------------------
return array;
}
+struct bt_declaration *_bt_python_get_array_element_declaration(
+ struct bt_declaration *field)
+{
+ struct declaration_array *array_decl;
+ struct bt_declaration *ret = NULL;
+
+ if (!field) {
+ goto end;
+ }
+
+ array_decl = container_of(field, struct declaration_array, p);
+ ret = array_decl->elem;
+end:
+ return ret;
+}
+
+struct bt_declaration *_bt_python_get_sequence_element_declaration(
+ struct bt_declaration *field)
+{
+ struct declaration_sequence *sequence_decl;
+ struct bt_declaration *ret = NULL;
+
+ if (!field) {
+ goto end;
+ }
+
+ sequence_decl = container_of(field, struct declaration_sequence, p);
+ ret = sequence_decl->elem;
+end:
+ return ret;
+}
+
+const char *_bt_python_get_array_string(struct bt_definition *field)
+{
+ struct definition_array *array;
+ const char *ret = NULL;
+
+ if (!field) {
+ goto end;
+ }
+
+ array = container_of(field, struct definition_array, p);
+ ret = array->string->str;
+end:
+ return ret;
+}
+
+const char *_bt_python_get_sequence_string(struct bt_definition *field)
+{
+ struct definition_sequence *sequence;
+ const char *ret = NULL;
+
+ if (!field) {
+ goto end;
+ }
+
+ sequence = container_of(field, struct definition_sequence, p);
+ ret = sequence->string->str;
+end:
+ return ret;
+}
+
struct definition_sequence *_bt_python_get_sequence_from_def(
struct bt_definition *field)
{
end:
return type_id;
}
+
+/*
+ * Swig doesn't handle returning pointers via output arguments properly...
+ * These functions only wrap the ctf-ir functions to provide them directly
+ * as regular return values.
+ */
+const char *_bt_python_ctf_field_type_enumeration_get_mapping(
+ struct bt_ctf_field_type *enumeration, size_t index,
+ int64_t *range_start, int64_t *range_end)
+{
+ int ret;
+ const char *name;
+
+ ret = bt_ctf_field_type_enumeration_get_mapping(enumeration, index,
+ &name, range_start, range_end);
+ return !ret ? name : NULL;
+}
+
+const char *_bt_python_ctf_field_type_enumeration_get_mapping_unsigned(
+ struct bt_ctf_field_type *enumeration, size_t index,
+ uint64_t *range_start, uint64_t *range_end)
+{
+ int ret;
+ const char *name;
+
+ ret = bt_ctf_field_type_enumeration_get_mapping_unsigned(enumeration,
+ index, &name, range_start, range_end);
+ return !ret ? name : NULL;
+}
+
+const char *_bt_python_ctf_field_type_structure_get_field_name(
+ struct bt_ctf_field_type *structure, size_t index)
+{
+ int ret;
+ const char *name;
+ struct bt_ctf_field_type *type;
+
+ ret = bt_ctf_field_type_structure_get_field(structure, &name, &type,
+ index);
+ if (ret) {
+ name = NULL;
+ goto end;
+ }
+
+ bt_ctf_field_type_put(type);
+end:
+ return name;
+}
+
+struct bt_ctf_field_type *_bt_python_ctf_field_type_structure_get_field_type(
+ struct bt_ctf_field_type *structure, size_t index)
+{
+ int ret;
+ const char *name;
+ struct bt_ctf_field_type *type;
+
+ ret = bt_ctf_field_type_structure_get_field(structure, &name, &type,
+ index);
+ return !ret ? type : NULL;
+}
+
+const char *_bt_python_ctf_field_type_variant_get_field_name(
+ struct bt_ctf_field_type *variant, size_t index)
+{
+ int ret;
+ const char *name;
+ struct bt_ctf_field_type *type;
+
+ ret = bt_ctf_field_type_variant_get_field(variant, &name, &type,
+ index);
+ if (ret) {
+ name = NULL;
+ goto end;
+ }
+
+ bt_ctf_field_type_put(type);
+end:
+ return name;
+}
+
+struct bt_ctf_field_type *_bt_python_ctf_field_type_variant_get_field_type(
+ struct bt_ctf_field_type *variant, size_t index)
+{
+ int ret;
+ const char *name;
+ struct bt_ctf_field_type *type;
+
+ ret = bt_ctf_field_type_variant_get_field(variant, &name, &type,
+ index);
+ return !ret ? type : NULL;
+}
+
+const char *_bt_python_ctf_event_class_get_field_name(
+ struct bt_ctf_event_class *event_class, size_t index)
+{
+ int ret;
+ const char *name;
+ struct bt_ctf_field_type *type;
+
+ ret = bt_ctf_event_class_get_field(event_class, &name, &type,
+ index);
+ if (ret) {
+ name = NULL;
+ goto end;
+ }
+
+ bt_ctf_field_type_put(type);
+end:
+ return name;
+}
+
+struct bt_ctf_field_type *_bt_python_ctf_event_class_get_field_type(
+ struct bt_ctf_event_class *event_class, size_t index)
+{
+ int ret;
+ const char *name;
+ struct bt_ctf_field_type *type;
+
+ ret = bt_ctf_event_class_get_field(event_class, &name, &type,
+ index);
+ return !ret ? type : NULL;
+}
+