[Native][Tests] Move existing CExport tests under the InterfaceV1 dir
To avoid collisions with the future InterfaceNone tests
This commit is contained in:
committed by
Space Team
parent
06c0977408
commit
dd25130464
@@ -0,0 +1,6 @@
|
||||
CFoo1::extfoo
|
||||
CFoo1::extfoo
|
||||
CFoo2::extfoo
|
||||
CFoo2::extfoo
|
||||
Int::extfoo
|
||||
Int::extfoo
|
||||
@@ -0,0 +1,28 @@
|
||||
#include "kt36639_api.h"
|
||||
|
||||
#define __ kt36639_symbols()->
|
||||
#define T_(x) kt36639_kref_ ## x
|
||||
|
||||
|
||||
int
|
||||
main() {
|
||||
T_(CFoo1) foo1 = __ kotlin.root.CFoo1.CFoo1();
|
||||
T_(CFoo2) foo2 = __ kotlin.root.CFoo2.CFoo2();
|
||||
T_(kotlin_Int) intV = __ createNullableInt(42);
|
||||
T_(kotlin_Any) any;
|
||||
T_(Foo) foo = { .pinned = foo1.pinned };
|
||||
|
||||
any.pinned = foo1.pinned;
|
||||
__ kotlin.root.CFoo1.callMe(foo1, any);
|
||||
__ kotlin.root.Foo.extfoo(foo, any);
|
||||
any.pinned = foo2.pinned;
|
||||
__ kotlin.root.CFoo1.callMe(foo1, any);
|
||||
__ kotlin.root.Foo.extfoo(foo, any);
|
||||
any.pinned = intV.pinned;
|
||||
__ kotlin.root.CFoo1.callMe(foo1, any);
|
||||
__ kotlin.root.Foo.extfoo(foo, any);
|
||||
|
||||
__ DisposeStablePointer(foo1.pinned);
|
||||
__ DisposeStablePointer(foo2.pinned);
|
||||
__ DisposeStablePointer(intV.pinned);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
interface Foo {
|
||||
fun Any.extfoo()
|
||||
}
|
||||
|
||||
class CFoo1:Foo {
|
||||
override fun Any.extfoo() {
|
||||
when(this) {
|
||||
is CFoo1 -> println("CFoo1::extfoo")
|
||||
is CFoo2 -> println("CFoo2::extfoo")
|
||||
is Int -> println("Int::extfoo")
|
||||
}
|
||||
}
|
||||
|
||||
fun callMe(arg: Any) = arg.extfoo()
|
||||
}
|
||||
|
||||
class CFoo2:Foo {
|
||||
override fun Any.extfoo() {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
#include "smoke0_api.h"
|
||||
|
||||
int main() {
|
||||
if (foo() != 42) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
@file:OptIn(kotlin.experimental.ExperimentalNativeApi::class)
|
||||
|
||||
import kotlin.native.CName
|
||||
|
||||
@CName("foo")
|
||||
fun foo(): Int {
|
||||
return 42
|
||||
}
|
||||
Reference in New Issue
Block a user