[Swift Export] Use ExportedBridge instead of ExportForCppRuntime

ExportedBridge annotation actually does what we need in Swift Export.
Unlike ExportForCppRuntime, it prevents symbol from DCE.
This commit is contained in:
Sergey Bogolepov
2023-12-12 18:32:40 +02:00
committed by Space Team
parent d83027720d
commit 01976990e8
7 changed files with 25 additions and 25 deletions
@@ -11,7 +11,7 @@ import org.jetbrains.kotlin.sir.SirType
import org.jetbrains.kotlin.sir.bridge.*
import org.jetbrains.kotlin.sir.util.SirSwiftModule
private const val exportAnnotationFqName = "kotlin.native.internal.ExportForCppRuntime"
private const val exportAnnotationFqName = "kotlin.native.internal.ExportedBridge"
private const val stdintHeader = "stdint.h"
internal class BridgeGeneratorImpl : BridgeGenerator {
@@ -1,12 +1,12 @@
import kotlin.native.internal.ExportForCppRuntime
import kotlin.native.internal.ExportedBridge
@ExportForCppRuntime("a_b_bar_bridge")
@ExportedBridge("a_b_bar_bridge")
public fun a_b_bar_bridge(param1: Int, param2: Long): Int {
val result = a.b.bar(param1, param2)
return result
}
@ExportForCppRuntime("a_b_foo_bridge")
@ExportedBridge("a_b_foo_bridge")
public fun a_b_foo_bridge(param1: Int, param2: Long): Boolean {
val result = a.b.foo(param1, param2)
return result
@@ -1,18 +1,18 @@
import kotlin.native.internal.ExportForCppRuntime
import kotlin.native.internal.ExportedBridge
@ExportForCppRuntime("a")
@ExportedBridge("a")
public fun a(p0: Byte, p1: Short, p2: Int, p3: Long): Int {
val result = pkg.a(p0, p1, p2, p3)
return result
}
@ExportForCppRuntime("b")
@ExportedBridge("b")
public fun b(p0: UByte, p1: UShort, p2: UInt, p3: ULong): UInt {
val result = pkg.b(p0, p1, p2, p3)
return result
}
@ExportForCppRuntime("c")
@ExportedBridge("c")
public fun c(p0: Boolean): Boolean {
val result = pkg.c(p0)
return result
@@ -1,30 +1,30 @@
import kotlin.native.internal.ExportForCppRuntime
import kotlin.native.internal.ExportedBridge
@ExportForCppRuntime("a_bridge")
@ExportedBridge("a_bridge")
public fun a_bridge(): Boolean {
val result = a()
return result
}
@ExportForCppRuntime("b_bridge")
@ExportedBridge("b_bridge")
public fun b_bridge(): Short {
val result = b()
return result
}
@ExportForCppRuntime("c_bridge")
@ExportedBridge("c_bridge")
public fun c_bridge(): Int {
val result = c()
return result
}
@ExportForCppRuntime("d_bridge")
@ExportedBridge("d_bridge")
public fun d_bridge(): Long {
val result = d()
return result
}
@ExportForCppRuntime("e_bridge")
@ExportedBridge("e_bridge")
public fun e_bridge(): Byte {
val result = e()
return result
@@ -1,6 +1,6 @@
import kotlin.native.internal.ExportForCppRuntime
import kotlin.native.internal.ExportedBridge
@ExportForCppRuntime("a_b_foo_bridge")
@ExportedBridge("a_b_foo_bridge")
public fun a_b_foo_bridge(param1: Int, param2: Long): Int {
val result = a.b.foo(param1, param2)
return result
@@ -1,24 +1,24 @@
import kotlin.native.internal.ExportForCppRuntime
import kotlin.native.internal.ExportedBridge
@ExportForCppRuntime("b_bridge")
@ExportedBridge("b_bridge")
public fun b_bridge(): UShort {
val result = b()
return result
}
@ExportForCppRuntime("c_bridge")
@ExportedBridge("c_bridge")
public fun c_bridge(): UInt {
val result = c()
return result
}
@ExportForCppRuntime("d_bridge")
@ExportedBridge("d_bridge")
public fun d_bridge(): ULong {
val result = d()
return result
}
@ExportForCppRuntime("e_bridge")
@ExportedBridge("e_bridge")
public fun e_bridge(): UByte {
val result = e()
return result
+4 -4
View File
@@ -1,18 +1,18 @@
import kotlin.native.internal.ExportForCppRuntime
import kotlin.native.internal.ExportedBridge
@ExportForCppRuntime("namespace1_main_foobar")
@ExportedBridge("namespace1_main_foobar")
public fun namespace1_main_foobar(): Int {
val result = namespace1.main.foobar()
return result
}
@ExportForCppRuntime("namespace1_foo")
@ExportedBridge("namespace1_foo")
public fun namespace1_foo(): Int {
val result = namespace1.foo()
return result
}
@ExportForCppRuntime("namespace2_bar")
@ExportedBridge("namespace2_bar")
public fun namespace2_bar(): Int {
val result = namespace2.bar()
return result