diff options
author | Gregory Szorc <gregory.szorc@gmail.com> | 2012-02-17 07:44:46 +0000 |
---|---|---|
committer | Gregory Szorc <gregory.szorc@gmail.com> | 2012-02-17 07:44:46 +0000 |
commit | 860576050b4d163a2f182cfdd67d8c5a48e32c08 (patch) | |
tree | 690c036f509b2ac366136f53fbacedbfc0426934 /bindings/python/clang/cindex.py | |
parent | abb943284cabd9131586c2758a4f02baba668ace (diff) |
[clang.py] Implement Type.element_type
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150799 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'bindings/python/clang/cindex.py')
-rw-r--r-- | bindings/python/clang/cindex.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/bindings/python/clang/cindex.py b/bindings/python/clang/cindex.py index 58182f3e09..0d41eaafc0 100644 --- a/bindings/python/clang/cindex.py +++ b/bindings/python/clang/cindex.py @@ -1137,6 +1137,19 @@ class Type(Structure): """Return the kind of this type.""" return TypeKind.from_id(self._kind_id) + @property + def element_type(self): + """Retrieve the Type of elements within this Type. + + If accessed on a type that is not an array, complex, or vector type, an + exception will be raised. + """ + result = Type_get_element_type(self) + if result.kind == TypeKind.INVALID: + raise Exception('Element type not available on this type.') + + return result + @staticmethod def from_result(res, fn, args): assert isinstance(res, Type) @@ -1881,6 +1894,11 @@ Type_get_result.argtypes = [Type] Type_get_result.restype = Type Type_get_result.errcheck = Type.from_result +Type_get_element_type = lib.clang_getElementType +Type_get_element_type.argtypes = [Type] +Type_get_element_type.restype = Type +Type_get_element_type.errcheck = Type.from_result + Type_get_array_element = lib.clang_getArrayElementType Type_get_array_element.argtypes = [Type] Type_get_array_element.restype = Type |