]> granicus.if.org Git - clang/commitdiff
Add support for constant arrays, from Anders Waldenborg!.
authorDouglas Gregor <dgregor@apple.com>
Wed, 19 Oct 2011 05:51:43 +0000 (05:51 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 19 Oct 2011 05:51:43 +0000 (05:51 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142477 91177308-0d34-0410-b5e6-96231b3b80d8

bindings/python/clang/cindex.py
bindings/python/tests/cindex/test_type.py

index 8f1a8b8cce6bc38eebccfd9c9477ca2f78149bd8..1c4ab35e4a50af964d4f1fee095f5c40be31ce66 100644 (file)
@@ -1091,6 +1091,18 @@ class Type(Structure):
         """
         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.argtypes = [Type]
 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
index 35c7bbbfa2fa72d49d17a744e9fcbf4d01d6b6ff..2a35f6e7566774b380fc256e22908ab965fa4290 100644 (file)
@@ -90,6 +90,10 @@ def testConstantArray():
             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??"