diff options
author | Gregory Szorc <gregory.szorc@gmail.com> | 2012-02-17 07:47:38 +0000 |
---|---|---|
committer | Gregory Szorc <gregory.szorc@gmail.com> | 2012-02-17 07:47:38 +0000 |
commit | bf8ca0049ea4faa7b089001e837e0ebbaec2ac6d (patch) | |
tree | 781bc8fdf65790478a49a36b64706d6d02590a14 /bindings/python/clang/cindex.py | |
parent | 860576050b4d163a2f182cfdd67d8c5a48e32c08 (diff) |
[clang.py] Implement Type.element_count
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150800 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 0d41eaafc0..d38eb1bfec 100644 --- a/bindings/python/clang/cindex.py +++ b/bindings/python/clang/cindex.py @@ -1150,6 +1150,20 @@ class Type(Structure): return result + @property + def element_count(self): + """Retrieve the number of elements in this type. + + Returns an int. + + If the Type is not an array or vector, this raises. + """ + result = Type_get_num_elements(self) + if result < 0: + raise Exception('Type does not have elements.') + + return result + @staticmethod def from_result(res, fn, args): assert isinstance(res, Type) @@ -1899,6 +1913,10 @@ Type_get_element_type.argtypes = [Type] Type_get_element_type.restype = Type Type_get_element_type.errcheck = Type.from_result +Type_get_num_elements = lib.clang_getNumElements +Type_get_num_elements.argtypes = [Type] +Type_get_num_elements.restype = c_longlong + Type_get_array_element = lib.clang_getArrayElementType Type_get_array_element.argtypes = [Type] Type_get_array_element.restype = Type |