size_t index, unsigned char *OUTPUT);
int _bt_python_ctf_clock_set_uuid_index(struct bt_ctf_clock *clock,
size_t index, unsigned char value);
-
+struct bt_iter_pos *_bt_python_create_iter_pos(void);
/* context.h, context-internal.h */
%rename("_bt_context_create") bt_context_create(void);
#include <babeltrace/ctf-ir/event-types.h>
#include <babeltrace/ctf-ir/event.h>
#include <babeltrace/ctf-ir/clock-internal.h>
+#include <babeltrace/iterator.h>
+#include <glib.h>
/* List-related functions
----------------------------------------------------
end:
return ret;
}
+
+/*
+ * 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);
+}
size_t index, unsigned char *value);
int _bt_python_ctf_clock_set_uuid_index(struct bt_ctf_clock *clock,
size_t index, unsigned char value);
+
+/* iterator */
+struct bt_iter_pos *_bt_python_create_iter_pos(void);
they need *from* an event before accessing the next one.
"""
- begin_pos_ptr = nbt._bt_iter_pos()
- end_pos_ptr = nbt._bt_iter_pos()
+ begin_pos_ptr = nbt._bt_python_create_iter_pos()
+ end_pos_ptr = nbt._bt_python_create_iter_pos()
begin_pos_ptr.type = nbt.SEEK_BEGIN
end_pos_ptr.type = nbt.SEEK_LAST
for event in self._events(begin_pos_ptr, end_pos_ptr):
yield event
+ nbt._bt_iter_free_pos(begin_pos_ptr);
+ nbt._bt_iter_free_pos(end_pos_ptr);
+
def events_timestamps(self, timestamp_begin, timestamp_end):
"""
Generates the ordered :class:`Event` objects of all the opened
See :attr:`events` for notes and limitations.
"""
- begin_pos_ptr = nbt._bt_iter_pos()
- end_pos_ptr = nbt._bt_iter_pos()
+ begin_pos_ptr = nbt._bt_python_create_iter_pos()
+ end_pos_ptr = nbt._bt_python_create_iter_pos()
begin_pos_ptr.type = end_pos_ptr.type = nbt.SEEK_TIME
begin_pos_ptr.u.seek_time = timestamp_begin
end_pos_ptr.u.seek_time = timestamp_end
for event in self._events(begin_pos_ptr, end_pos_ptr):
yield event
+ nbt._bt_iter_free_pos(begin_pos_ptr);
+ nbt._bt_iter_free_pos(end_pos_ptr);
+
@property
def timestamp_begin(self):
"""