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.
This commit is contained in:
21
examples/ffi-jni-call-07-jboolean-return.sx
Normal file
21
examples/ffi-jni-call-07-jboolean-return.sx
Normal file
@@ -0,0 +1,21 @@
|
||||
// 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;
|
||||
}
|
||||
Reference in New Issue
Block a user