Fix (Python bindings): Return a string if a sequence's element are chars
[babeltrace.git] / bindings / python / python-complements.c
index 5c65fb0f0e37f2044a0518faf95d798fff364ffa..6f947bd04e331cb3675a3820b8166e6e2af18e5f 100644 (file)
@@ -19,6 +19,8 @@
  */
 
 #include "python-complements.h"
+#include <babeltrace/ctf-writer/event-types-internal.h>
+#include <babeltrace/ctf-writer/event-fields-internal.h>
 
 /* FILE functions
    ----------------------------------------------------
@@ -133,6 +135,68 @@ end:
        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)
 {
@@ -143,3 +207,32 @@ struct definition_sequence *_bt_python_get_sequence_from_def(
 
        return NULL;
 }
+
+int _bt_python_field_integer_get_signedness(const struct bt_ctf_field *field)
+{
+       int ret;
+
+       if (!field || field->type->declaration->id != CTF_TYPE_INTEGER) {
+               ret = -1;
+               goto end;
+       }
+
+       const struct bt_ctf_field_type_integer *type = container_of(field->type,
+               const struct bt_ctf_field_type_integer, parent);
+       ret = type->declaration.signedness;
+end:
+       return ret;
+}
+
+enum ctf_type_id _bt_python_get_field_type(const struct bt_ctf_field *field)
+{
+       enum ctf_type_id type_id = CTF_TYPE_UNKNOWN;
+
+       if (!field) {
+               goto end;
+       }
+
+       type_id = field->type->declaration->id;
+end:
+       return type_id;
+}
This page took 0.023846 seconds and 4 git commands to generate.