From 91ab69b83528bf8a9db22a56c870ab2320e37179 Mon Sep 17 00:00:00 2001 From: Svyatoslav Scherbina Date: Mon, 11 Dec 2017 13:28:49 +0300 Subject: [PATCH] Support bool-typed bitfields in interop --- .../kotlin/native/interop/gen/jvm/StubGenerator.kt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/jvm/StubGenerator.kt b/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/jvm/StubGenerator.kt index cb26432824d..c278e500d97 100644 --- a/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/jvm/StubGenerator.kt +++ b/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/jvm/StubGenerator.kt @@ -405,7 +405,7 @@ class StubGenerator( out("var ${field.name.asSimpleName()}: $kotlinType") - val signed = field.type.getUnderlyingIntegerType().isSigned + val signed = field.type.isIntegerTypeSigned() val readBitsExpr = "readBits(this.rawPtr, ${field.offset}, ${field.size}, $signed).${rawType.convertor!!}()" @@ -422,10 +422,11 @@ class StubGenerator( } } - private tailrec fun Type.getUnderlyingIntegerType(): IntegerType = when (this) { - is IntegerType -> this - is EnumType -> this.def.baseType.getUnderlyingIntegerType() - is Typedef -> this.def.aliased.getUnderlyingIntegerType() + private tailrec fun Type.isIntegerTypeSigned(): Boolean = when (this) { + is IntegerType -> this.isSigned + is BoolType -> false + is EnumType -> this.def.baseType.isIntegerTypeSigned() + is Typedef -> this.def.aliased.isIntegerTypeSigned() else -> error(this) }