[cfe-commits] r167216 - in /cfe/trunk/bindings/python: clang/cindex.py tests/cindex/test_cursor.py
Gregory Szorc
gregory.szorc at gmail.com
Wed Oct 31 22:46:31 PDT 2012
Author: gps
Date: Thu Nov 1 00:46:30 2012
New Revision: 167216
URL: http://llvm.org/viewvc/llvm-project?rev=167216&view=rev
Log:
[clang.py] Add Cursor.get_arguments()
Patch provided by Matthias Kleine <matthias_kleine at gmx.de>
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=167216&r1=167215&r2=167216&view=diff
==============================================================================
--- cfe/trunk/bindings/python/clang/cindex.py (original)
+++ cfe/trunk/bindings/python/clang/cindex.py Thu Nov 1 00:46:30 2012
@@ -1271,6 +1271,12 @@
# created.
return self._tu
+ def get_arguments(self):
+ """Return an iterator for accessing the arguments of this cursor."""
+ num_args = conf.lib.clang_Cursor_getNumArguments(self)
+ for i in range(0, num_args):
+ yield conf.lib.clang_Cursor_getArgument(self, i)
+
def get_children(self):
"""Return an iterator for accessing the children of this cursor."""
@@ -2973,6 +2979,15 @@
("clang_visitChildren",
[Cursor, callbacks['cursor_visit'], py_object],
c_uint),
+
+ ("clang_Cursor_getNumArguments",
+ [Cursor],
+ c_int),
+
+ ("clang_Cursor_getArgument",
+ [Cursor, c_uint],
+ Cursor,
+ Cursor.from_result),
]
class LibclangError(Exception):
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=167216&r1=167215&r2=167216&view=diff
==============================================================================
--- cfe/trunk/bindings/python/tests/cindex/test_cursor.py (original)
+++ cfe/trunk/bindings/python/tests/cindex/test_cursor.py Thu Nov 1 00:46:30 2012
@@ -241,3 +241,12 @@
assert len(tokens) == 7
assert tokens[0].spelling == 'int'
assert tokens[1].spelling == 'foo'
+
+def test_get_arguments():
+ tu = get_tu('void foo(int i, int j);')
+ foo = get_cursor(tu, 'foo')
+ arguments = list(foo.get_arguments())
+
+ assert len(arguments) == 2
+ assert arguments[0].spelling == "i"
+ assert arguments[1].spelling == "j"
More information about the cfe-commits
mailing list