[cfe-commits] r156752 - in /cfe/trunk/bindings/python: clang/cindex.py tests/cindex/test_cursor.py

Gregory Szorc gregory.szorc at gmail.com
Sun May 13 20:53:29 PDT 2012


Author: gps
Date: Sun May 13 22:53:29 2012
New Revision: 156752

URL: http://llvm.org/viewvc/llvm-project?rev=156752&view=rev
Log:
[clang.py] Implement Cursor.result_type

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=156752&r1=156751&r2=156752&view=diff
==============================================================================
--- cfe/trunk/bindings/python/clang/cindex.py (original)
+++ cfe/trunk/bindings/python/clang/cindex.py Sun May 13 22:53:29 2012
@@ -1024,6 +1024,14 @@
         return self._type
 
     @property
+    def result_type(self):
+        """Retrieve the Type of the result for this Cursor."""
+        if not hasattr(self, '_result_type'):
+            self._result_type = Type_get_result(self.type)
+
+        return self._result_type
+
+    @property
     def underlying_typedef_type(self):
         """Return the underlying type of a typedef declaration.
 

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=156752&r1=156751&r2=156752&view=diff
==============================================================================
--- cfe/trunk/bindings/python/tests/cindex/test_cursor.py (original)
+++ cfe/trunk/bindings/python/tests/cindex/test_cursor.py Sun May 13 22:53:29 2012
@@ -172,3 +172,11 @@
             break
     else:
         assert False, "Couldn't find annotation"
+
+def test_result_type():
+    tu = get_tu('int foo();')
+    foo = get_cursor(tu, 'foo')
+
+    assert foo is not None
+    t = foo.result_type
+    assert t.kind == TypeKind.INT





More information about the cfe-commits mailing list