KT-63264: Introduce a new ExportedBridge annotation

Swift Export Frontend generates a Kotlin file/library that contains a
set of simple bridging functions that connect Swift wrappers to their
Kotlin counterparts.
There are certain requirements for these wrappers:
1. They should not be DCEd when compiling a binary library.
In other words, these functions are roots.
2. They should provide a stable simple binary name.
3. Their signatures should be much simpler and restricted comparing to
other Kotlin functions.

Altogether, these requirements should be covered by introducing the new
ExportedBridge annotation.

Note: Frontend checks of ExportedBridge functions are not implemented
yet.
This commit is contained in:
Sergey Bogolepov
2023-11-25 11:58:08 +02:00
committed by Space Team
parent 8be547b834
commit ce4eecebf4
7 changed files with 30 additions and 5 deletions
@@ -5,6 +5,8 @@
package kotlin.native.internal
import kotlin.experimental.ExperimentalNativeApi
/**
* Makes this function to be possible to call by given name from C++ part of runtime using C ABI.
* The parameters are mapped in an implementation-dependent manner.
@@ -180,3 +182,13 @@ internal annotation class InternalForKotlinNativeTests
@InternalForKotlinNativeTests
@Target(AnnotationTarget.FILE)
public annotation class ReflectionPackageName(val name: String)
/**
* Indicates that the marked function is an exported bridge between Kotlin and the platform.
* This annotation prevents the function from being removed by DCE
* and specifies a stable [bridgeName] for the function symbol.
*/
@Target(AnnotationTarget.FUNCTION)
@Retention(value = AnnotationRetention.BINARY)
@ExperimentalNativeApi
public annotation class ExportedBridge(val bridgeName: String)