| 1 |
// This file was autogenerated by some hot garbage in the `uniffi` crate. |
| 2 |
// Trust me, you don't want to mess with it! |
| 3 |
|
| 4 |
{%- call kt::docstring_value(ci.namespace_docstring(), 0) %} |
| 5 |
|
| 6 |
@file:Suppress("NAME_SHADOWING") |
| 7 |
|
| 8 |
package {{ config.package_name() }} |
| 9 |
|
| 10 |
// Common helper code. |
| 11 |
// |
| 12 |
// Ideally this would live in a separate .kt file where it can be unittested etc |
| 13 |
// in isolation, and perhaps even published as a re-useable package. |
| 14 |
// |
| 15 |
// However, it's important that the details of how this helper code works (e.g. the |
| 16 |
// way that different builtin types are passed across the FFI) exactly match what's |
| 17 |
// expected by the Rust code on the other side of the interface. In practice right |
| 18 |
// now that means coming from the exact some version of `uniffi` that was used to |
| 19 |
// compile the Rust component. The easiest way to ensure this is to bundle the Kotlin |
| 20 |
// helpers directly inline like we're doing here. |
| 21 |
|
| 22 |
import com.sun.jna.Library |
| 23 |
import com.sun.jna.IntegerType |
| 24 |
import com.sun.jna.Native |
| 25 |
import com.sun.jna.Pointer |
| 26 |
import com.sun.jna.Structure |
| 27 |
import com.sun.jna.Callback |
| 28 |
import com.sun.jna.ptr.* |
| 29 |
import java.nio.ByteBuffer |
| 30 |
import java.nio.ByteOrder |
| 31 |
import java.nio.CharBuffer |
| 32 |
import java.nio.charset.CodingErrorAction |
| 33 |
import java.util.concurrent.atomic.AtomicLong |
| 34 |
import java.util.concurrent.ConcurrentHashMap |
| 35 |
|
| 36 |
{%- for req in self.imports() %} |
| 37 |
{{ req.render() }} |
| 38 |
{%- endfor %} |
| 39 |
|
| 40 |
{% include "RustBufferTemplate.kt" %} |
| 41 |
{% include "FfiConverterTemplate.kt" %} |
| 42 |
{% include "Helpers.kt" %} |
| 43 |
{% include "HandleMap.kt" %} |
| 44 |
|
| 45 |
// Contains loading, initialization code, |
| 46 |
// and the FFI Function declarations in a com.sun.jna.Library. |
| 47 |
{% include "NamespaceLibraryTemplate.kt" %} |
| 48 |
|
| 49 |
// Async support |
| 50 |
{%- if ci.has_async_fns() %} |
| 51 |
{% include "Async.kt" %} |
| 52 |
{%- endif %} |
| 53 |
|
| 54 |
// Public interface members begin here. |
| 55 |
{{ type_helper_code }} |
| 56 |
|
| 57 |
{%- for func in ci.function_definitions() %} |
| 58 |
{%- include "TopLevelFunctionTemplate.kt" %} |
| 59 |
{%- endfor %} |
| 60 |
|
| 61 |
{% import "macros.kt" as kt %} |