---
bindings/python/clang/cindex.py | 8 ++++++++
bindings/python/tests/cindex/test_type.py | 3 +++
2 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/bindings/python/clang/cindex.py b/bindings/python/clang/cindex.py
index 4b25b03..bdcb716 100644
--- a/bindings/python/clang/cindex.py
+++ b/bindings/python/clang/cindex.py
@@ -1139,16 +1139,24 @@ class Type(Structure):
return TypeKind.from_id(self._kind_id)
@property
def arguments_count(self):
"""Retrieve the number of non-variadic arguments for this function type."""
assert self.kind == TypeKind.FUNCTIONPROTO
return Type_get_num_arg_types(self)
+ @property
+ def argument_types(self):
+ """A generator of Type instances corresponding to the arguments for
+ this function type."""
+
+ for i in range(0, self.arguments_count):
+ yield self.get_arg_type(i)
+
@staticmethod
def from_result(res, fn, args):
assert isinstance(res, Type)
return res
def get_canonical(self):
"""
Return the canonical type for a Type.
diff --git a/bindings/python/tests/cindex/test_type.py b/bindings/python/tests/cindex/test_type.py
index d4687a9..d2616bd 100644
--- a/bindings/python/tests/cindex/test_type.py
+++ b/bindings/python/tests/cindex/test_type.py
@@ -128,8 +128,11 @@ def test_function_arguments():
assert f is not None
assert f.type.arguments_count == 2
t0 = f.type.get_arg_type(0)
assert t0.kind == TypeKind.INT
t1 = f.type.get_arg_type(1)
assert t1.kind == TypeKind.INT
+
+ args = list(f.type.argument_types)
+ assert len(args) == 2
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits