Skip to content

Commit 9c76968

Browse files
Merge pull request #2 from kai-language/feature/ptr-array-convenience
Added some conveniences for pointers and arrays.
2 parents 11a1dfe + 7747638 commit 9c76968

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Sources/Clang/CTypes.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,10 @@ public struct ComplexType: ClangTypeBacked {
182182

183183
public struct PointerType: ClangTypeBacked {
184184
let clang: CXType
185+
186+
public var pointee: CType? {
187+
return convertType(clang_getPointeeType(clang))
188+
}
185189
}
186190

187191
public struct BlockPointerType: ClangTypeBacked {
@@ -222,6 +226,14 @@ public struct FunctionProtoType: ClangTypeBacked {
222226

223227
public struct ConstantArrayType: ClangTypeBacked {
224228
let clang: CXType
229+
230+
public var element: CType? {
231+
return convertType(clang_getArrayElementType(clang))
232+
}
233+
234+
public var count: Int32 {
235+
return clang_getNumArgTypes(clang)
236+
}
225237
}
226238

227239
public struct VectorType: ClangTypeBacked {
@@ -230,10 +242,18 @@ public struct VectorType: ClangTypeBacked {
230242

231243
public struct IncompleteArrayType: ClangTypeBacked {
232244
let clang: CXType
245+
246+
public var element: CType? {
247+
return convertType(clang_getArrayElementType(clang))
248+
}
233249
}
234250

235251
public struct VariableArrayType: ClangTypeBacked {
236252
let clang: CXType
253+
254+
public var element: CType? {
255+
return convertType(clang_getArrayElementType(clang))
256+
}
237257
}
238258

239259
public struct DependentSizedArrayType: ClangTypeBacked {

0 commit comments

Comments
 (0)