[lttng-dev] [PATCH babeltrace] Support getting the value of enums

Xiaona Han xiaonahappy13 at 163.com
Fri Jul 26 05:48:02 EDT 2013

Use 'get_enmu_str' to get the string matching the current enumeration.

Signed-off-by: Xiaona Han <xiaonahappy13 at 163.com>
 bindings/python/babeltrace.i.in |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/bindings/python/babeltrace.i.in b/bindings/python/babeltrace.i.in
index c478dfc..d307fdb 100644
--- a/bindings/python/babeltrace.i.in
+++ b/bindings/python/babeltrace.i.in
@@ -560,6 +560,8 @@ struct bt_ctf_event *bt_ctf_iter_read_event(struct bt_ctf_iter *iter);
 %rename("_bt_ctf_get_int_byte_order") bt_ctf_get_int_byte_order(
 		const struct bt_declaration *field);
 %rename("_bt_ctf_get_int_len") bt_ctf_get_int_len(const struct bt_declaration *field);
+%rename("_bt_ctf_get_enum_int") bt_ctf_get_enum_int(const struct bt_definition *field);
+%rename("_bt_ctf_get_enum_str") bt_ctf_get_enum_str(const struct bt_definition *field);
 %rename("_bt_ctf_get_encoding") bt_ctf_get_encoding(const struct bt_declaration *field);
 %rename("_bt_ctf_get_array_len") bt_ctf_get_array_len(const struct bt_declaration *field);
 %rename("_bt_ctf_get_uint64") bt_ctf_get_uint64(const struct bt_definition *field);
@@ -591,6 +593,8 @@ int bt_ctf_get_int_signedness(const struct bt_declaration *field);
 int bt_ctf_get_int_base(const struct bt_declaration *field);
 int bt_ctf_get_int_byte_order(const struct bt_declaration *field);
 ssize_t bt_ctf_get_int_len(const struct bt_declaration *field);
+const struct bt_definition *bt_ctf_get_enum_int(const struct bt_definition *field);
+const char *bt_ctf_get_enum_str(const struct bt_definition *field);
 enum ctf_string_encoding bt_ctf_get_encoding(const struct bt_declaration *field);
 int bt_ctf_get_array_len(const struct bt_declaration *field);
 uint64_t bt_ctf_get_uint64(const struct bt_definition *field);
@@ -918,6 +922,13 @@ class ctf:
 			return _bt_ctf_get_int_len(self._d)
+		def get_enum_str(self):
+			"""
+			Return the string matching the current enumeration.
+			Return None on error.
+			"""
+			return _bt_ctf_get_enum_str(self._d)
 		def get_encoding(self):
 			Return the encoding of an int or a string.

More information about the lttng-dev mailing list