Files
sx/examples/ffi-jni-call-07-jboolean-return.sx
agra 1ee4017426 ffi 1.21: lock in undef shape for #jni_call(bool)
Test-add for the jboolean return. JNI `jboolean` is a single byte (0
or 1); sx's `bool` lowers to LLVM `i1` with byte-coercion at the ABI
boundary. CallBooleanMethod is at vtable slot 37.

IR snapshot captures today's `ret i1 undef`. Next commit adds the
`.bool => Jni.CallBooleanMethod` arm.
2026-05-19 22:33:58 +03:00

22 lines
607 B
Plaintext

// Phase 1 step 1.21 (PLAN-FFI.md): `#jni_call(bool)` (jboolean
// return). JNI's `jboolean` is a single-byte unsigned integer (0 or
// 1) on every supported ABI; sx's `bool` lowers to LLVM `i1` but the
// arg/return coercion path widens it to the byte slot the JNI
// runtime expects. CallBooleanMethod lives at vtable slot 37.
#import "modules/std.sx";
g_should_call : bool = false;
read_bool :: (env: *void, target: *void) -> bool {
#jni_call(bool)(env, target, "isShown", "()Z");
}
main :: () -> s32 {
if g_should_call {
_ := read_bool(null, null);
}
print("ok\n");
0;
}