alef 0.110.2

Opinionated polyglot binding generator for Rust libraries
Documentation
1
2
3
4
5
6
7
8
9
10
    private static void checkLastError() throws Throwable {
        int errCode = (int)(long) NativeLib.{{ prefix_upper }}_LAST_ERROR_CODE.invoke();
        if (errCode != 0) {
            var ctxPtr = (MemorySegment) NativeLib.{{ prefix_upper }}_LAST_ERROR_CONTEXT.invoke();
            String msg = ctxPtr.equals(MemorySegment.NULL)
                ? "Native call failed with error code " + errCode
                : ctxPtr.reinterpret(Long.MAX_VALUE).getString(0);
            throw NativeLib.lastErrorException(errCode, msg);
        }
    }