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

Gregory Szorc gregory.szorc at gmail.com
Sat Jun 9 09:21:34 PDT 2012


Author: gps
Date: Sat Jun  9 11:21:34 2012
New Revision: 158277

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

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=158277&r1=158276&r2=158277&view=diff
==============================================================================
--- cfe/trunk/bindings/python/clang/cindex.py (original)
+++ cfe/trunk/bindings/python/clang/cindex.py Sat Jun  9 11:21:34 2012
@@ -949,6 +949,12 @@
         """
         return Cursor_is_def(self)
 
+    def is_static_method(self):
+        """Returns True if the cursor refers to a C++ member function or member
+        function template that is declared 'static'.
+        """
+        return Cursor_is_static_method(self)
+
     def get_definition(self):
         """
         If the cursor is a reference to a declaration or a declaration of
@@ -2176,6 +2182,10 @@
 Cursor_is_def.argtypes = [Cursor]
 Cursor_is_def.restype = bool
 
+Cursor_is_static_method = lib.clang_CXXMethod_isStatic
+Cursor_is_static_method.argtypes = [Cursor]
+Cursor_is_static_method.restype = bool
+
 Cursor_def = lib.clang_getCursorDefinition
 Cursor_def.argtypes = [Cursor]
 Cursor_def.restype = Cursor

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=158277&r1=158276&r2=158277&view=diff
==============================================================================
--- cfe/trunk/bindings/python/tests/cindex/test_cursor.py (original)
+++ cfe/trunk/bindings/python/tests/cindex/test_cursor.py Sat Jun  9 11:21:34 2012
@@ -102,6 +102,22 @@
     assert len(cursors) == 3
     assert cursors[1].canonical == cursors[2].canonical
 
+def test_is_static_method():
+    """Ensure Cursor.is_static_method works."""
+
+    source = 'class X { static void foo(); void bar(); };'
+    tu = get_tu(source, lang='cpp')
+
+    cls = get_cursor(tu, 'X')
+    foo = get_cursor(tu, 'foo')
+    bar = get_cursor(tu, 'bar')
+    assert cls is not None
+    assert foo is not None
+    assert bar is not None
+
+    assert foo.is_static_method()
+    assert not bar.is_static_method()
+
 def test_underlying_type():
     tu = get_tu('typedef int foo;')
     typedef = get_cursor(tu, 'foo')





More information about the cfe-commits mailing list