From: Xiaona Han Date: Fri, 26 Jul 2013 09:48:02 +0000 (+0800) Subject: Support getting the value of enums X-Git-Tag: v1.2.0-rc1~66 X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=4191bcd2fbb6a1be731af94bb83a828a1471ef67;hp=db551f282b3a7af4ec820c091f60e328318c6795 Support getting the value of enums Use 'get_enum_str' to get the string matching the current enumeration. Signed-off-by: Xiaona Han Acked-by: Jérémie Galarneau --- 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.