[cfe-commits] r142477 - in /cfe/trunk/bindings/python: clang/cindex.py tests/cindex/test_type.py
Douglas Gregor
dgregor at apple.com
Tue Oct 18 22:51:43 PDT 2011
Author: dgregor
Date: Wed Oct 19 00:51:43 2011
New Revision: 142477
URL: http://llvm.org/viewvc/llvm-project?rev=142477&view=rev
Log:
Add support for constant arrays, from Anders Waldenborg!.
Modified:
cfe/trunk/bindings/python/clang/cindex.py
cfe/trunk/bindings/python/tests/cindex/test_type.py
Modified: cfe/trunk/bindings/python/clang/cindex.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/clang/cindex.py?rev=142477&r1=142476&r2=142477&view=diff
==============================================================================
--- cfe/trunk/bindings/python/clang/cindex.py (original)
+++ cfe/trunk/bindings/python/clang/cindex.py Wed Oct 19 00:51:43 2011
@@ -1091,6 +1091,18 @@
"""
return Type_get_result(self)
+ def get_array_element_type(self):
+ """
+ Retrieve the type of the elements of the array type.
+ """
+ return Type_get_array_element(self)
+
+ def get_array_size(self):
+ """
+ Retrieve the size of the constant array.
+ """
+ return Type_get_array_size(self)
+
## CIndex Objects ##
# CIndex objects (derived from ClangObject) are essentially lightweight
@@ -1688,6 +1700,14 @@
Type_get_result.restype = Type
Type_get_result.errcheck = Type.from_result
+Type_get_array_element = lib.clang_getArrayElementType
+Type_get_array_element.argtypes = [Type]
+Type_get_array_element.restype = Type
+Type_get_array_element.errcheck = Type.from_result
+
+Type_get_array_size = lib.clang_getArraySize
+Type_get_array_size.argtype = [Type]
+Type_get_array_size.restype = c_longlong
# Index Functions
Index_create = lib.clang_createIndex
Modified: cfe/trunk/bindings/python/tests/cindex/test_type.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/cindex/test_type.py?rev=142477&r1=142476&r2=142477&view=diff
==============================================================================
--- cfe/trunk/bindings/python/tests/cindex/test_type.py (original)
+++ cfe/trunk/bindings/python/tests/cindex/test_type.py Wed Oct 19 00:51:43 2011
@@ -90,6 +90,10 @@
fields = list(n.get_children())
assert fields[0].spelling == 'A'
assert fields[0].type.kind == TypeKind.CONSTANTARRAY
+ assert fields[0].type.get_array_element_type() is not None
+ assert fields[0].type.get_array_element_type().kind == TypeKind.POINTER
+ assert fields[0].type.get_array_size() == 2
+
break
else:
assert False, "Didn't find teststruct??"
More information about the cfe-commits
mailing list