Support @CName annotation for reverse C interop, similar to @JvmName. (#1237)

This commit is contained in:
Nikolay Igotti
2018-01-17 19:34:00 +03:00
committed by GitHub
parent 76bfb9322d
commit 77f220f335
7 changed files with 111 additions and 33 deletions
+2 -1
View File
@@ -2375,7 +2375,8 @@ task produce_dynamic(type: DynamicKonanTest) {
"RO property is 42\n" +
"RW property is 239\n" +
"enum100 = 100\n" +
"object = 42\n"
"object = 42\n" +
"topLevel = 777 3\n"
}
task buildKonanStdlibTests(type: BuildKonanTest) {
@@ -12,6 +12,16 @@ open class Base {
open fun fooParam(arg0: String, arg1: Int) = println("Base.fooParam: $arg0 $arg1")
@konan.internal.CName(fullName = "", shortName = "strangeName") fun странноеИмя() = 111
}
@konan.internal.CName(fullName = "topLevelFunctionFromC", shortName = "topLevelFunctionFromCShort")
fun topLevelFunction(x1: Int, x2: Int) = x1 - x2
@konan.internal.CName("topLevelFunctionVoidFromC")
fun topLevelFunctionVoid(x1: Int) {
assert(x1 == 42)
}
// Enum.
@@ -18,7 +18,6 @@ int main(void) {
const char* string = __ kotlin.root.getString();
__ kotlin.root.hello();
__ kotlin.root.Base.foo(base);
__ kotlin.root.Base.fooParam(base, "a", 1);
@@ -37,6 +36,10 @@ int main(void) {
printf("object = %d\n", __ kotlin.root.Codeable.asCode(object1));
topLevelFunctionVoidFromC(42);
__ kotlin.root.topLevelFunctionVoid(42);
printf("topLevel = %d %d\n", topLevelFunctionFromC(780, 3), __ kotlin.root.topLevelFunctionFromCShort(5, 2));
__ DisposeString(string);
__ DisposeStablePointer(base.pinned);
__ DisposeStablePointer(child.pinned);