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
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import kotlin.native.internal.ExportedBridge
|
||||
|
||||
@ExportedBridge("__root___foo")
|
||||
@ExportedBridge("__root___foo__TypesOfArguments__int32_t_double__")
|
||||
public fun __root___foo(p: Int, p2: Double): Short {
|
||||
val result = foo(p, p2)
|
||||
return result
|
||||
|
||||
+5
-5
@@ -6,13 +6,13 @@ public fun namespace1_local_functions_foo(): Unit {
|
||||
return result
|
||||
}
|
||||
|
||||
@ExportedBridge("namespace1_main_foobar")
|
||||
@ExportedBridge("namespace1_main_foobar__TypesOfArguments__int32_t__")
|
||||
public fun namespace1_main_foobar(param: Int): Int {
|
||||
val result = namespace1.main.foobar(param)
|
||||
return result
|
||||
}
|
||||
|
||||
@ExportedBridge("namespace1_main_all_args")
|
||||
@ExportedBridge("namespace1_main_all_args__TypesOfArguments___Bool_int8_t_int16_t_int32_t_int64_t_float_double__")
|
||||
public fun namespace1_main_all_args(arg1: Boolean, arg2: Byte, arg3: Short, arg4: Int, arg5: Long, arg10: Float, arg11: Double): Unit {
|
||||
val result = namespace1.main.all_args(arg1, arg2, arg3, arg4, arg5, arg10, arg11)
|
||||
return result
|
||||
@@ -24,19 +24,19 @@ public fun namespace1_bar(): Int {
|
||||
return result
|
||||
}
|
||||
|
||||
@ExportedBridge("namespace2_foo")
|
||||
@ExportedBridge("namespace2_foo__TypesOfArguments__int32_t__")
|
||||
public fun namespace2_foo(arg1: Int): Int {
|
||||
val result = namespace2.foo(arg1)
|
||||
return result
|
||||
}
|
||||
|
||||
@ExportedBridge("overload_foo")
|
||||
@ExportedBridge("overload_foo__TypesOfArguments__int32_t__")
|
||||
public fun overload_foo(arg1: Int): Int {
|
||||
val result = overload.foo(arg1)
|
||||
return result
|
||||
}
|
||||
|
||||
@ExportedBridge("overload_foo")
|
||||
@ExportedBridge("overload_foo__TypesOfArguments__double__")
|
||||
public fun overload_foo(arg1: Double): Int {
|
||||
val result = overload.foo(arg1)
|
||||
return result
|
||||
|
||||
+2
-2
@@ -12,13 +12,13 @@ public fun namespace_main_bar_get(): Int {
|
||||
return result
|
||||
}
|
||||
|
||||
@ExportedBridge("namespace_main_bar_set")
|
||||
@ExportedBridge("namespace_main_bar_set__TypesOfArguments__int32_t__")
|
||||
public fun namespace_main_bar_set(newValue: Int): Unit {
|
||||
val result = namespace.main.bar(newValue)
|
||||
return result
|
||||
}
|
||||
|
||||
@ExportedBridge("namespace_main_foobar")
|
||||
@ExportedBridge("namespace_main_foobar__TypesOfArguments__int32_t__")
|
||||
public fun namespace_main_foobar(param: Int): Int {
|
||||
val result = namespace.main.foobar(param)
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user