Support singleton objects in C interop. (#1940)
This commit is contained in:
@@ -2896,6 +2896,7 @@ task produce_dynamic(type: DynamicKonanTest) {
|
||||
"RW property is 239\n" +
|
||||
"enum100 = 100\n" +
|
||||
"object = 42\n" +
|
||||
"singleton = I am single\n" +
|
||||
"topLevel = 777 3\n"
|
||||
}
|
||||
|
||||
|
||||
@@ -45,6 +45,10 @@ val an_object = object : Codeable {
|
||||
override fun asCode() = 42
|
||||
}
|
||||
|
||||
object Singleton {
|
||||
override fun toString() = "I am single"
|
||||
}
|
||||
|
||||
class Child : Base() {
|
||||
override fun fooParam(arg0: String, arg1: Int) = println("Child.fooParam: $arg0 $arg1")
|
||||
|
||||
|
||||
@@ -15,8 +15,10 @@ int main(void) {
|
||||
T_(I) casted_impl2 = { .pinned = impl2.pinned };
|
||||
T_(Enum) enum1 = __ kotlin.root.Enum.HUNDRED.get();
|
||||
T_(Codeable) object1 = __ kotlin.root.get_an_object();
|
||||
T_(Singleton) singleton = __ kotlin.root.Singleton._instance();
|
||||
|
||||
const char* string = __ kotlin.root.getString();
|
||||
const char* string1 = __ kotlin.root.getString();
|
||||
const char* string2 = __ kotlin.root.Singleton.toString(singleton);
|
||||
|
||||
__ kotlin.root.hello();
|
||||
__ kotlin.root.Base.foo(base);
|
||||
@@ -26,7 +28,7 @@ int main(void) {
|
||||
__ kotlin.root.I.foo(casted_impl1, "d", 4, casted_impl1);
|
||||
__ kotlin.root.I.foo(casted_impl2, "e", 5, casted_impl2);
|
||||
|
||||
printf("String is %s\n", string);
|
||||
printf("String is %s\n", string1);
|
||||
|
||||
printf("RO property is %d\n", __ kotlin.root.Child.get_roProperty(child));
|
||||
__ kotlin.root.Child.set_rwProperty(child, 238);
|
||||
@@ -36,13 +38,17 @@ int main(void) {
|
||||
|
||||
printf("object = %d\n", __ kotlin.root.Codeable.asCode(object1));
|
||||
|
||||
printf("singleton = %s\n", string2);
|
||||
|
||||
topLevelFunctionVoidFromC(42, 0);
|
||||
__ kotlin.root.topLevelFunctionVoid(42, 0);
|
||||
printf("topLevel = %d %d\n", topLevelFunctionFromC(780, 3), __ kotlin.root.topLevelFunctionFromCShort(5, 2));
|
||||
|
||||
__ kotlin.root.useInlineClasses(42, "bar", base);
|
||||
|
||||
__ DisposeString(string);
|
||||
__ DisposeStablePointer(singleton.pinned);
|
||||
__ DisposeString(string1);
|
||||
__ DisposeString(string2);
|
||||
__ DisposeStablePointer(base.pinned);
|
||||
__ DisposeStablePointer(child.pinned);
|
||||
__ DisposeStablePointer(impl1.pinned);
|
||||
|
||||
Reference in New Issue
Block a user