[Swift Export] KT-63516

Add a sir-compiler-bridge module that adds Kotlin and C bridges
for SIR. As SIR is still WIP, the module accepts `BridgeRequest`
instances instead of SIR elements.
This commit is contained in:
Sergey Bogolepov
2023-11-16 15:58:43 +02:00
committed by Space Team
parent 7c15e3f229
commit fe9ab0a1fc
36 changed files with 701 additions and 0 deletions
@@ -0,0 +1,6 @@
#include <stdint.h>
int32_t a_b_bar_bridge(int32_t param1, int64_t param2);
_Bool a_b_foo_bridge(int32_t param1, int64_t param2);
@@ -0,0 +1,13 @@
import kotlin.native.internal.ExportForCppRuntime
@ExportForCppRuntime("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")
public fun a_b_foo_bridge(param1: Int, param2: Long): Boolean {
val result = a.b.foo(param1, param2)
return result
}
@@ -0,0 +1,4 @@
fqName=a.b.foo
bridgeName=a_b_foo_bridge
parameters=param1:int param2:long
returnType=boolean
@@ -0,0 +1,4 @@
fqName=a.b.bar
bridgeName=a_b_bar_bridge
parameters=param1:int param2:long
returnType=int
@@ -0,0 +1,7 @@
#include <stdint.h>
int32_t a(int8_t p0, int16_t p1, int32_t p2, int64_t p3);
uint32_t b(uint8_t p0, uint16_t p1, uint32_t p2, uint64_t p3);
_Bool c(_Bool p0);
@@ -0,0 +1,20 @@
import kotlin.native.internal.ExportForCppRuntime
@ExportForCppRuntime("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")
public fun b(p0: UByte, p1: UShort, p2: UInt, p3: ULong): UInt {
val result = pkg.b(p0, p1, p2, p3)
return result
}
@ExportForCppRuntime("c")
public fun c(p0: Boolean): Boolean {
val result = pkg.c(p0)
return result
}
@@ -0,0 +1,4 @@
fqName=pkg.a
bridgeName=a
returnType=int
parameters=p0:byte p1:short p2:int p3:long
@@ -0,0 +1,4 @@
fqName=pkg.b
bridgeName=b
returnType=uint
parameters=p0:ubyte p1:ushort p2:uint p3:ulong
@@ -0,0 +1,4 @@
fqName=pkg.c
bridgeName=c
returnType=boolean
parameters=p0:boolean
@@ -0,0 +1,11 @@
#include <stdint.h>
_Bool a_bridge();
int16_t b_bridge();
int32_t c_bridge();
int64_t d_bridge();
int8_t e_bridge();
@@ -0,0 +1,31 @@
import kotlin.native.internal.ExportForCppRuntime
@ExportForCppRuntime("a_bridge")
public fun a_bridge(): Boolean {
val result = a()
return result
}
@ExportForCppRuntime("b_bridge")
public fun b_bridge(): Short {
val result = b()
return result
}
@ExportForCppRuntime("c_bridge")
public fun c_bridge(): Int {
val result = c()
return result
}
@ExportForCppRuntime("d_bridge")
public fun d_bridge(): Long {
val result = d()
return result
}
@ExportForCppRuntime("e_bridge")
public fun e_bridge(): Byte {
val result = e()
return result
}
@@ -0,0 +1,3 @@
fqName=a
bridgeName=a_bridge
returnType=boolean
@@ -0,0 +1,3 @@
fqName=b
bridgeName=b_bridge
returnType=short
@@ -0,0 +1,3 @@
fqName=c
bridgeName=c_bridge
returnType=int
@@ -0,0 +1,3 @@
fqName=d
bridgeName=d_bridge
returnType=long
@@ -0,0 +1,3 @@
fqName=e
bridgeName=e_bridge
returnType=byte
@@ -0,0 +1,3 @@
#include <stdint.h>
int32_t a_b_foo_bridge(int32_t param1, int64_t param2);
@@ -0,0 +1,7 @@
import kotlin.native.internal.ExportForCppRuntime
@ExportForCppRuntime("a_b_foo_bridge")
public fun a_b_foo_bridge(param1: Int, param2: Long): Int {
val result = a.b.foo(param1, param2)
return result
}
@@ -0,0 +1,4 @@
fqName=a.b.foo
bridgeName=a_b_foo_bridge
parameters=param1:int param2:long
returnType=int
@@ -0,0 +1,9 @@
#include <stdint.h>
uint16_t b_bridge();
uint32_t c_bridge();
uint64_t d_bridge();
uint8_t e_bridge();
@@ -0,0 +1,25 @@
import kotlin.native.internal.ExportForCppRuntime
@ExportForCppRuntime("b_bridge")
public fun b_bridge(): UShort {
val result = b()
return result
}
@ExportForCppRuntime("c_bridge")
public fun c_bridge(): UInt {
val result = c()
return result
}
@ExportForCppRuntime("d_bridge")
public fun d_bridge(): ULong {
val result = d()
return result
}
@ExportForCppRuntime("e_bridge")
public fun e_bridge(): UByte {
val result = e()
return result
}
@@ -0,0 +1,3 @@
fqName=b
bridgeName=b_bridge
returnType=ushort
@@ -0,0 +1,3 @@
fqName=c
bridgeName=c_bridge
returnType=uint
@@ -0,0 +1,3 @@
fqName=d
bridgeName=d_bridge
returnType=ulong
@@ -0,0 +1,3 @@
fqName=e
bridgeName=e_bridge
returnType=ubyte