Add intersect mode to python bindings
[babeltrace.git] / bindings / python / python-complements.c
index 6f947bd04e331cb3675a3820b8166e6e2af18e5f..6b47ff9bf9aaaaac16213b00e9cb854c9752b89f 100644 (file)
 #include "python-complements.h"
 #include <babeltrace/ctf-writer/event-types-internal.h>
 #include <babeltrace/ctf-writer/event-fields-internal.h>
+#include <babeltrace/iterator.h>
+#include <babeltrace/ctf/iterator.h>
+#include <babeltrace/ctf/events-internal.h>
+#include <glib.h>
 
 /* FILE functions
    ----------------------------------------------------
@@ -236,3 +240,33 @@ enum ctf_type_id _bt_python_get_field_type(const struct bt_ctf_field *field)
 end:
        return type_id;
 }
+
+/*
+ * Python 3.5 changes the StopIteration exception clearing behaviour which
+ * erroneously marks swig clean-up function as having failed. This explicit
+ * allocation function is intended as a work-around so SWIG doesn't manage
+ * the lifetime of a "temporary" object by itself.
+ */
+struct bt_iter_pos *_bt_python_create_iter_pos(void)
+{
+       return g_new0(struct bt_iter_pos, 1);
+}
+
+struct bt_ctf_iter *_bt_python_ctf_iter_create_intersect(
+               struct bt_context *ctx,
+               struct bt_iter_pos *inter_begin_pos,
+               struct bt_iter_pos *inter_end_pos)
+{
+       return bt_ctf_iter_create_intersect(ctx, &inter_begin_pos,
+                       &inter_end_pos);
+}
+
+int _bt_python_has_intersection(struct bt_context *ctx)
+{
+       int ret;
+       uint64_t begin = 0, end = ULLONG_MAX;
+
+       ret = ctf_find_packets_intersection(ctx, &begin, &end);
+
+       return ret == 0 ? 1 : 0;
+}
This page took 0.024305 seconds and 4 git commands to generate.