Interop/Indexer: unions don't have natural layout

This commit is contained in:
Svyatoslav Scherbina
2016-10-14 15:18:51 +03:00
parent 6d04320471
commit 32c6e62297
@@ -98,16 +98,27 @@ private class NativeIndexImpl : NativeIndex() {
* Computes [StructDef.hasNaturalLayout] property.
*/
fun structHasNaturalLayout(structDefCursor: CXCursor): Boolean {
val hasAttributes = malloc(Int32Box)
hasAttributes.value = 0
clang_visitChildren(structDefCursor, { cursor, parent, clientData ->
if (clang_isAttribute(cursor.kind.value) != 0) {
clientData.asRef(Int32Box)!!.value = 1
}
CXChildVisitResult.CXChildVisit_Continue
}, hasAttributes.ptr)
val defKind = structDefCursor.kind.value
return hasAttributes.value == 0
when (defKind) {
CXCursorKind.CXCursor_UnionDecl -> return false
CXCursorKind.CXCursor_StructDecl -> {
val hasAttributes = malloc(Int32Box)
hasAttributes.value = 0
clang_visitChildren(structDefCursor, { cursor, parent, clientData ->
if (clang_isAttribute(cursor.kind.value) != 0) {
clientData.asRef(Int32Box)!!.value = 1
}
CXChildVisitResult.CXChildVisit_Continue
}, hasAttributes.ptr)
return hasAttributes.value == 0
}
else -> throw IllegalArgumentException(defKind.toString())
}
}
fun convertType(type: CXType): Type {