From 4191bcd2fbb6a1be731af94bb83a828a1471ef67 Mon Sep 17 00:00:00 2001 From: Xiaona Han Date: Fri, 26 Jul 2013 17:48:02 +0800 Subject: [PATCH] Support getting the value of enums MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Use 'get_enum_str' to get the string matching the current enumeration. Signed-off-by: Xiaona Han Acked-by: Jérémie Galarneau --- bindings/python/babeltrace.i.in | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/bindings/python/babeltrace.i.in b/bindings/python/babeltrace.i.in index ee3e2bd0..50cdd945 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(_bt_ctf_get_decl_from_def(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. -- 2.34.1