[cfe-commits] [PATCH] Implement Type.get_arg_type() through clang_getArgType
Tobias Grosser
tobias at grosser.es
Sun Feb 5 04:30:12 PST 2012
On 02/05/2012 06:20 AM, Gregory Szorc wrote:
> ---
> bindings/python/clang/cindex.py | 20 ++++++++++++++++++++
> bindings/python/tests/cindex/test_type.py | 7 ++++++-
> 2 files changed, 26 insertions(+), 1 deletions(-)
>
>
> 0006-Implement-Type.get_arg_type-through-clang_getArgType.patch
>
>
> diff --git a/bindings/python/clang/cindex.py b/bindings/python/clang/cindex.py
> index efc2f52..4b25b03 100644
> --- a/bindings/python/clang/cindex.py
> +++ b/bindings/python/clang/cindex.py
> @@ -1192,16 +1192,31 @@ class Type(Structure):
> return Type_get_pointee(self)
>
> def get_declaration(self):
> """
> Return the cursor for the declaration of the given type.
> """
> return Type_get_declaration(self)
>
> + def get_arg_type(self, index):
> + """Return the Type of a specific argument.
I just realized the names that refer to python classes are commonly
started with an uppercase letter. I criticized this in your earlier
patches, but changed my mind now. I reverted my changes and think it
is a good thing to do. (I also changed a case, where we did not do this
before).+ The first argument is the index of the argument whose
type to retrieve.
> + The first argument is the index of the argument whose type
> to retrieve.
What about referring to the first argument directly with its name 'index'.
For example
index refers to the position of the argument in the argument list. The
first argument has index 0 the last one .arguments_count() - 1.
Thinking about this patch, I am wondering if it would not be more
python-style to just expose an iterator 'arguments'.
We can than use len(type.arguments) to get the number of arguments. And
type.arguments[i] to get the i-th argument.
What do you think?
Tobi
Looking at this patch again, I am wondering
More information about the cfe-commits
mailing list