---
bindings/python/clang/cindex.py | 13 +++++++++++++
bindings/python/tests/cindex/test_cursor.py | 9 +++++++++
2 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/bindings/python/clang/cindex.py b/bindings/python/clang/cindex.py
index 3b1e751..b4563eb 100644
--- a/bindings/python/clang/cindex.py
+++ b/bindings/python/clang/cindex.py
@@ -1003,16 +1003,24 @@ class Cursor(Structure):
"""
if not hasattr(self, '_enum_type'):
assert self.kind == CursorKind.ENUM_DECL
self._enum_type = Cursor_enum_type(self)
return self._enum_type
@property
+ def objc_type_encoding(self):
+ """Return the Objective-C type encoding as a str."""
+ if not hasattr(self, '_objc_type_encoding'):
+ self._objc_type_encoding = Cursor_objc_type_encoding(self)
+
+ return self._objc_type_encoding
+
+ @property
def hash(self):
"""Returns a hash of the cursor as an int."""
if not hasattr(self, '_hash'):
self._hash = Cursor_hash(self)
return self._hash
def get_children(self):
@@ -1915,16 +1923,21 @@ Cursor_underlying_type.argtypes = [Cursor]
Cursor_underlying_type.restype = Type
Cursor_underlying_type.errcheck = Type.from_result
Cursor_enum_type = lib.clang_getEnumDeclIntegerType
Cursor_enum_type.argtypes = [Cursor]
Cursor_enum_type.restype = Type
Cursor_enum_type.errcheck = Type.from_result
+Cursor_objc_type_encoding = lib.clang_getDeclObjCTypeEncoding
+Cursor_objc_type_encoding.argtypes = [Cursor]
+Cursor_objc_type_encoding.restype = _CXString
+Cursor_objc_type_encoding.errcheck = _CXString.from_result
+
Cursor_visit_callback = CFUNCTYPE(c_int, Cursor, Cursor, py_object)
Cursor_visit = lib.clang_visitChildren
Cursor_visit.argtypes = [Cursor, Cursor_visit_callback, py_object]
Cursor_visit.restype = c_uint
# Type Functions
Type_get_canonical = lib.clang_getCanonicalType
Type_get_canonical.argtypes = [Type]
diff --git a/bindings/python/tests/cindex/test_cursor.py b/bindings/python/tests/cindex/test_cursor.py
index c1d7c87..be64243 100644
--- a/bindings/python/tests/cindex/test_cursor.py
+++ b/bindings/python/tests/cindex/test_cursor.py
@@ -80,8 +80,17 @@ def test_enum_type():
source = 'enum TEST { FOO=1, BAR=2 };'
tu = get_tu(source)
enum = get_cursor(tu, 'TEST')
assert enum is not None
assert enum.kind == CursorKind.ENUM_DECL
enum_type = enum.enum_type
assert enum_type.kind == TypeKind.UINT
+
+def test_objc_type_encoding():
+ """Ensure Cursor.objc_type_encoding works."""
+
+ tu = get_tu('int i;', lang='objc')
+ i = get_cursor(tu, 'i')
+
+ assert i is not None
+ assert i.objc_type_encoding == 'i'
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits