struct bt_ctf_event_class *event_class, size_t index);
struct bt_ctf_field_type *_bt_python_ctf_event_class_get_field_type(
struct bt_ctf_event_class *event_class, size_t index);
+int _bt_python_ctf_clock_get_uuid_index(struct bt_ctf_clock *clock,
+ 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);
/* =================================================================
CONTEXT.H, CONTEXT-INTERNAL.H
void bt_ctf_writer_put(struct bt_ctf_writer *writer);
%pythoncode %{
+import uuid
class CTFWriter:
# Used to compare to -1ULL in error checks
if ret < 0:
raise ValueError("Could not set the clock's absolute attribute.")
+ """
+ Get a clock's UUID (an object of type UUID).
+ """
+ @property
+ def uuid(self):
+ uuid_list = []
+ for i in range(16):
+ ret, value = _bt_python_ctf_clock_get_uuid_index(self._c, i)
+ if ret < 0:
+ raise ValueError("Invalid clock instance")
+ uuid_list.append(value)
+ return uuid.UUID(bytes=bytes(uuid_list))
+
+ """
+ Set a clock's UUID (an object of type UUID).
+ """
+ @uuid.setter
+ def uuid(self, uuid):
+ uuid_bytes = uuid.bytes
+ if len(uuid_bytes) != 16:
+ raise ValueError("Invalid UUID provided. UUID length must be 16 bytes")
+ for i in range(len(uuid_bytes)):
+ ret = _bt_python_ctf_clock_set_uuid_index(self._c, i, uuid_bytes[i])
+ if ret < 0:
+ raise ValueError("Invalid clock instance")
+
"""
Get the current time in nanoseconds since the clock's origin (offset and
offset_s attributes).
print("Clock offset is {}".format(clock.offset))
print("Clock is absolute: {}".format(clock.absolute))
print("Clock time is {}".format(clock.time))
+print("Clock UUID is {}".format(clock.uuid))
writer.add_clock(clock)
writer.add_environment_field("Python_version", str(sys.version_info))
#include <babeltrace/ctf-ir/event-fields-internal.h>
#include <babeltrace/ctf-ir/event-types.h>
#include <babeltrace/ctf-ir/event.h>
+#include <babeltrace/ctf-ir/clock-internal.h>
/* List-related functions
----------------------------------------------------
return !ret ? type : NULL;
}
+int _bt_python_ctf_clock_get_uuid_index(struct bt_ctf_clock *clock,
+ size_t index, unsigned char *value)
+{
+ int ret = 0;
+ const unsigned char *uuid;
+
+ if (index >= 16) {
+ ret = -1;
+ goto end;
+ }
+
+ uuid = bt_ctf_clock_get_uuid(clock);
+ if (!uuid) {
+ ret = -1;
+ goto end;
+ }
+
+ *value = uuid[index];
+end:
+ return ret;
+}
+
+int _bt_python_ctf_clock_set_uuid_index(struct bt_ctf_clock *clock,
+ size_t index, unsigned char value)
+{
+ int ret = 0;
+
+ if (index >= 16) {
+ ret = -1;
+ goto end;
+ }
+
+ clock->uuid[index] = value;
+end:
+ return ret;
+}
#include <babeltrace/iterator-internal.h>
#include <babeltrace/ctf/events-internal.h>
#include <babeltrace/ctf-writer/event-fields.h>
+#include <babeltrace/ctf-writer/clock.h>
/* ctf-field-list */
struct bt_definition **_bt_python_field_listcaller(
struct bt_ctf_event_class *event_class, size_t index);
struct bt_ctf_field_type *_bt_python_ctf_event_class_get_field_type(
struct bt_ctf_event_class *event_class, size_t index);
+int _bt_python_ctf_clock_get_uuid_index(struct bt_ctf_clock *clock,
+ 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);