alef 0.25.60

Opinionated polyglot binding generator for Rust libraries
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

    static final MethodHandle {{ handle_name }} = LINKER.downcallHandle(
        LIB.find("{{ ffi_name }}")
            .or(() -> LIB.find("_{{ ffi_name }}"))
            // Try underscore-prefixed variant for macOS
            .or(() -> LINKER.defaultLookup().find("{{ ffi_name }}"))
            // Fallback to default lookup
            .or(() -> LINKER.defaultLookup().find("_{{ ffi_name }}"))
            // Fallback underscore variant
            .orElseThrow(() -> new ExceptionInInitializerError(
                "Native symbol not found: " + "{{ ffi_name }}" +
                " (tried: {{ ffi_name }}, _{{ ffi_name }}). " +
                "Ensure the native library was compiled with this function exported. " +
                "If this is an optional feature, check that all required features are enabled.")),
        {{ layout }}
    );