Fix enum entries processing in C reverse interop. (#1232)

This commit is contained in:
Nikolay Igotti
2018-01-15 20:16:30 +03:00
committed by GitHub
parent 865ae7c9d6
commit 1aa2e26344
4 changed files with 77 additions and 4 deletions
+3 -1
View File
@@ -2361,7 +2361,9 @@ task produce_dynamic(type: DynamicKonanTest) {
"Impl2.I: e 5 Impl2\n" +
"String is Kotlin/Native\n" +
"RO property is 42\n" +
"RW property is 239\n"
"RW property is 239\n" +
"enum100 = 100\n" +
"object = 42\n"
}
task buildKonanStdlibTests(type: BuildKonanTest) {
@@ -14,6 +14,22 @@ open class Base {
}
// Enum.
enum class Enum(val code: Int) {
ONE(1),
TWO(2),
HUNDRED(100)
}
// Object.
interface Codeable {
fun asCode(): Int
}
val an_object = object : Codeable {
override fun asCode() = 42
}
class Child : Base() {
override fun fooParam(arg0: String, arg1: Int) = println("Child.fooParam: $arg0 $arg1")
@@ -13,8 +13,12 @@ int main(void) {
T_(Base) casted_child = { .pinned = child.pinned };
T_(I) casted_impl1 = { .pinned = impl1.pinned };
T_(I) casted_impl2 = { .pinned = impl2.pinned };
T_(Enum) enum1 = __ kotlin.root.Enum.HUNDRED.get();
T_(Codeable) object1 = __ kotlin.root.get_an_object();
const char* string = __ kotlin.root.getString();
__ kotlin.root.hello();
__ kotlin.root.Base.foo(base);
__ kotlin.root.Base.fooParam(base, "a", 1);
@@ -29,11 +33,17 @@ int main(void) {
__ kotlin.root.Child.set_rwProperty(child, 238);
printf("RW property is %d\n", __ kotlin.root.Child.get_rwProperty(child));
printf("enum100 = %d\n", __ kotlin.root.Enum.get_code(enum1));
printf("object = %d\n", __ kotlin.root.Codeable.asCode(object1));
__ DisposeString(string);
__ DisposeStablePointer(base.pinned);
__ DisposeStablePointer(child.pinned);
__ DisposeStablePointer(impl1.pinned);
__ DisposeStablePointer(impl2.pinned);
__ DisposeStablePointer(enum1.pinned);
__ DisposeStablePointer(object1.pinned);
return 0;
}