13 JNI examples migrated (1410-1419/1423/1424/1425): import runtime classes
'#foreign #jni_class("X") {' → '#jni_class("X") extern {'. 1417 (all-runtimes)
also exercises #jni_interface/#objc_class/#objc_protocol/#swift_class/#swift_struct/
#swift_protocol — all take the postfix modifier (verified by probe), migrated via a
generalized '#foreign #<directive>("X") {' → '… extern {' rewrite. No 14xx snapshot
asserts on 'foreign'; empty snapshot diff, corpus-validated.
KEPT comment-only #foreign in 1426 (jni-extern-class test, no decls). Suite green
(647 corpus / 444 unit, 0 failed).
34 lines
958 B
Plaintext
34 lines
958 B
Plaintext
// Regression: when a `#jni_call` method returns a type the
|
|
// `Call<T>Method` switch in `emit_llvm.zig` can't dispatch
|
|
// (anything outside void/bool/i32/i64/f32/f64/pointer), the
|
|
// compiler must emit a DIAGNOSTIC at lower time rather than
|
|
// silently producing `LLVMGetUndef` at codegen time. Without
|
|
// this guard, the chess Android touch bug shipped: an
|
|
// unsupported return type silently became `undef` and showed
|
|
// up as garbage arguments downstream.
|
|
//
|
|
// Here we declare a JNI method returning `i8` (jbyte, not yet
|
|
// wired into the call-method switch). The compile must fail
|
|
// with a clear message naming the method + return type.
|
|
|
|
#import "modules/std.sx";
|
|
|
|
Buf :: #jni_class("java/nio/ByteBuffer") extern {
|
|
get :: (self: *Self) -> i8;
|
|
}
|
|
|
|
g_should_call : bool = false;
|
|
|
|
unused :: (env: *void, b: *Buf) {
|
|
#jni_env(env) {
|
|
_ := b.get();
|
|
}
|
|
}
|
|
|
|
main :: () -> i32 {
|
|
if g_should_call {
|
|
unused(null, null);
|
|
}
|
|
0
|
|
}
|