Overview¶
native-kt is a Gradle plugin that creates an interop between Kotlin Multiplatform and C/C++ based on NDL description file.
This project also includes a syntax highlighting plugin.
Runtime¶
This project doesn't provide tools to manipulate native memory from Kotlin.
However, it does require a runtime, which it adds itself. The runtime only includes the functions needed for interop inside generated code.
As a bonus, there is a class for retrieving the current OS and architecture, that you can use.
Target details¶
JVM¶
JNI and Foreign Functions & Memory API are used to interact with native code.
FFM API is supporting critical functions.
Also, there is a JVMCI acceleration for critical functions in supported JVMs (e.g. GraalVM).
JS/Wasm¶
Kotlin JS interoperability is used to interop with Wasm code, compiled by Emscripten.
Not every native program can be compiled to this target. See Emscripten limitations for details.
Native¶
cinterop is used to call native functions. For now, only static linking is supported.
Android¶
Uses JNI as JVM, but with @CriticalNative
acceleration, as well as "!bang notation" for older Android versions
Note
All generated code can be viewed in the build/generated/natives and build/cmake directories.
If you think the code isn't efficient enough and know how to improve it, please let me know in an issue on GitHub.