Hello, I'm curious to learn more about Kotlin/Wasm...
# webassembly
j
Hello, I'm curious to learn more about Kotlin/Wasm and the potential for supporting the target in my KMP libraries. Is there support for interop with native Wasm libraries? I currently use Java, Objective-C, and C SDKs in one of my libraries. If the C SDK were to be compiled for Wasm, would I be able to use it from Kotlin?
i
Hi, yes, you can do that but only for top level functions with primitives for parameters types and return value type, like
i32
,
i64
,
f32
,
f64
, etc. To import such function directly (i.e. without passing the execution through the JS) from side module into the Kotlin one can use
WasmImport
annotation. Something like:
Copy code
@kotlin.wasm.WasmImport("importModule", "importFunction")
external fun foo(a: Int, b: Float): Double
j
Great, so there's limited support currently. Will there be support similar to C and Objective-C interop in the future?