Fix generation of KtBridges, now it is using actual C Function Name
Merge-request: KT-MR-14337 Merged-by: Artem Olkov <artem.olkov@jetbrains.com>
This commit is contained in:
+9
-2
@@ -20,7 +20,13 @@ internal class BridgeGeneratorImpl : BridgeGenerator {
|
||||
val parameterBridges = request.callable.allParameters.mapIndexed { index, value -> bridgeParameter(value, index) }
|
||||
|
||||
val cDeclaration = request.createCDeclaration()
|
||||
val kotlinBridge = createKotlinBridge(request.bridgeName, request.fqName, kotlinReturnType, parameterBridges.map { it.kotlin })
|
||||
val kotlinBridge = createKotlinBridge(
|
||||
bridgeName = request.bridgeName,
|
||||
cName = request.cDeclarationName(),
|
||||
functionFqName = request.fqName,
|
||||
returnType = kotlinReturnType,
|
||||
parameterBridges = parameterBridges.map { it.kotlin }
|
||||
)
|
||||
return FunctionBridge(
|
||||
KotlinFunctionBridge(kotlinBridge, listOf(exportAnnotationFqName)),
|
||||
CFunctionBridge(cDeclaration, listOf(stdintHeader))
|
||||
@@ -41,12 +47,13 @@ internal fun BridgeRequest.cDeclarationName(): String {
|
||||
|
||||
private fun createKotlinBridge(
|
||||
bridgeName: String,
|
||||
cName: String,
|
||||
functionFqName: List<String>,
|
||||
returnType: KotlinType,
|
||||
parameterBridges: List<KotlinBridgeParameter>,
|
||||
): List<String> {
|
||||
val declaration = createKotlinDeclarationSignature(bridgeName, returnType, parameterBridges)
|
||||
val annotation = "@${exportAnnotationFqName.substringAfterLast('.')}(\"${bridgeName}\")"
|
||||
val annotation = "@${exportAnnotationFqName.substringAfterLast('.')}(\"${cName}\")"
|
||||
val resultName = "result"
|
||||
val callSite = createCallSite(functionFqName, parameterBridges.map { it.name }, resultName)
|
||||
return """
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import kotlin.native.internal.ExportedBridge
|
||||
|
||||
@ExportedBridge("a_b_bar_bridge")
|
||||
@ExportedBridge("a_b_bar_bridge__TypesOfArguments__int32_t_int64_t__")
|
||||
public fun a_b_bar_bridge(param1: Int, param2: Long): Int {
|
||||
val result = a.b.bar(param1, param2)
|
||||
return result
|
||||
}
|
||||
|
||||
@ExportedBridge("a_b_foo_bridge")
|
||||
@ExportedBridge("a_b_foo_bridge__TypesOfArguments__int32_t_int64_t__")
|
||||
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.ExportedBridge
|
||||
|
||||
@ExportedBridge("a")
|
||||
@ExportedBridge("a__TypesOfArguments__int8_t_int16_t_int32_t_int64_t__")
|
||||
public fun a(p0: Byte, p1: Short, p2: Int, p3: Long): Int {
|
||||
val result = pkg.a(p0, p1, p2, p3)
|
||||
return result
|
||||
}
|
||||
|
||||
@ExportedBridge("b")
|
||||
@ExportedBridge("b__TypesOfArguments__uint8_t_uint16_t_uint32_t_uint64_t__")
|
||||
public fun b(p0: UByte, p1: UShort, p2: UInt, p3: ULong): UInt {
|
||||
val result = pkg.b(p0, p1, p2, p3)
|
||||
return result
|
||||
}
|
||||
|
||||
@ExportedBridge("c")
|
||||
@ExportedBridge("c__TypesOfArguments___Bool__")
|
||||
public fun c(p0: Boolean): Boolean {
|
||||
val result = pkg.c(p0)
|
||||
return result
|
||||
|
||||
@@ -6,7 +6,7 @@ public fun getter_bridge(): Boolean {
|
||||
return result
|
||||
}
|
||||
|
||||
@ExportedBridge("setter_bridge")
|
||||
@ExportedBridge("setter_bridge__TypesOfArguments___Bool__")
|
||||
public fun setter_bridge(newValue: Boolean): Unit {
|
||||
val result = variable(newValue)
|
||||
return result
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import kotlin.native.internal.ExportedBridge
|
||||
|
||||
@ExportedBridge("a_b_foo_bridge")
|
||||
@ExportedBridge("a_b_foo_bridge__TypesOfArguments__int32_t_int64_t__")
|
||||
public fun a_b_foo_bridge(param1: Int, param2: Long): Int {
|
||||
val result = a.b.foo(param1, param2)
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user