Disable passing exceptions from Objective-C to Kotlin

since they can't be correctly handled yet.
This commit is contained in:
Svyatoslav Scherbina
2017-08-30 12:19:13 +03:00
committed by SvyatoslavScherbina
parent 12df524138
commit 6b042a5510
2 changed files with 16 additions and 1 deletions
@@ -17,6 +17,7 @@
package org.jetbrains.kotlin.native.interop.gen
import org.jetbrains.kotlin.native.interop.gen.jvm.KotlinPlatform
import org.jetbrains.kotlin.native.interop.indexer.Language
import org.jetbrains.kotlin.native.interop.indexer.NativeLibrary
import org.jetbrains.kotlin.native.interop.indexer.mapFragmentIsCompilable
@@ -120,6 +121,14 @@ class SimpleBridgeGeneratorImpl(
nativeLines.add(" $it")
}
if (libraryForCStubs.language == Language.OBJECTIVE_C) {
// Prevent Objective-C exceptions from passing to Kotlin:
nativeLines.add(1, "@try {")
nativeLines.add("} @catch (id e) { objc_terminate(); }")
// 'objc_terminate' will report the exception.
// TODO: consider implementing this in bitcode generator.
}
nativeLines.add("}")
kotlinLines.add("private external fun $kotlinFunctionName($kotlinParameters): ${returnType.kotlinType}")
@@ -801,7 +801,13 @@ class StubGenerator(
"-I$javaHome/../include/$it"
}
KotlinPlatform.NATIVE -> emptyList()
}
},
additionalPreambleLines = configuration.library.additionalPreambleLines +
when (configuration.library.language) {
Language.C -> emptyList()
Language.OBJECTIVE_C -> listOf("void objc_terminate();")
}
)
/**