[cfe-commits] r152513 - in /cfe/trunk/bindings/python: clang/cindex.py tests/cindex/test_cursor.py
Gregory Szorc
gregory.szorc at gmail.com
Sat Mar 10 14:23:28 PST 2012
Author: gps
Date: Sat Mar 10 16:23:27 2012
New Revision: 152513
URL: http://llvm.org/viewvc/llvm-project?rev=152513&view=rev
Log:
[clang.py] Implement Cursor.objc_type_encoding
Modified:
cfe/trunk/bindings/python/clang/cindex.py
cfe/trunk/bindings/python/tests/cindex/test_cursor.py
Modified: cfe/trunk/bindings/python/clang/cindex.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/clang/cindex.py?rev=152513&r1=152512&r2=152513&view=diff
==============================================================================
--- cfe/trunk/bindings/python/clang/cindex.py (original)
+++ cfe/trunk/bindings/python/clang/cindex.py Sat Mar 10 16:23:27 2012
@@ -1008,6 +1008,14 @@
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'):
@@ -1920,6 +1928,11 @@
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]
Modified: cfe/trunk/bindings/python/tests/cindex/test_cursor.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/cindex/test_cursor.py?rev=152513&r1=152512&r2=152513&view=diff
==============================================================================
--- cfe/trunk/bindings/python/tests/cindex/test_cursor.py (original)
+++ cfe/trunk/bindings/python/tests/cindex/test_cursor.py Sat Mar 10 16:23:27 2012
@@ -83,3 +83,10 @@
assert enum.kind == CursorKind.ENUM_DECL
enum_type = enum.enum_type
assert enum_type.kind == TypeKind.UINT
+
+def test_objc_type_encoding():
+ tu = get_tu('int i;', lang='objc')
+ i = get_cursor(tu, 'i')
+
+ assert i is not None
+ assert i.objc_type_encoding == 'i'
More information about the cfe-commits
mailing list