Support native top-level functions

This commit is contained in:
Andrey Breslav
2014-12-01 22:15:03 +03:00
parent 56216c4bd8
commit 6596c6d943
5 changed files with 44 additions and 2 deletions
@@ -9,6 +9,8 @@ object ObjWithNative {
platformStatic native fun bar(l: Long, s: String = ""): Double
}
native fun topLevel(x: Int = 1): Double
fun box(): String {
var d = 0.0
@@ -27,5 +29,13 @@ fun box(): String {
catch (e: java.lang.UnsatisfiedLinkError) {
if (e.getMessage() != "foo.ObjWithNative.foo(I)D") return "Fail 2: " + e.getMessage()
}
try {
d = topLevel()
return "Link error expected on object"
}
catch (e: java.lang.UnsatisfiedLinkError) {
if (e.getMessage() != "foo.FooPackage.topLevel(I)D") return "Fail 3: " + e.getMessage()
}
return "OK"
}
@@ -0,0 +1,20 @@
package foo
import kotlin.jvm.*
import kotlin.platform.*
native fun bar(l: Long, s: String): Double
fun box(): String {
var d = 0.0
try {
d = bar(1, "")
return "Link error expected on object"
}
catch (e: java.lang.UnsatisfiedLinkError) {
if (e.getMessage() != "foo.FooPackage.bar(JLjava/lang/String;)D") return "Fail 1: " + e.getMessage()
}
return "OK"
}