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).
32 lines
901 B
Plaintext
32 lines
901 B
Plaintext
// Phase 2 step 2.11 (PLAN-FFI.md): xfail then green for DSL call-site
|
|
// lowering — `inst.method(args)` on a `#jni_class`-typed value lowers
|
|
// to `#jni_call(T)(inst, "method", "(sig)Ret", args...)` with the
|
|
// descriptor auto-derived from the sx signature.
|
|
//
|
|
// `#jni_env(env)` brings env into lexical scope; the omitted-env
|
|
// `#jni_call` form (2.16b) picks it up directly.
|
|
|
|
#import "modules/std.sx";
|
|
|
|
Activity :: #jni_class("android/app/Activity") extern {
|
|
getWindow :: (self: *Self) -> *void;
|
|
}
|
|
|
|
g_should_call : bool = false;
|
|
|
|
unused_jni :: (env: *void, act: *Activity) {
|
|
#jni_env(env) {
|
|
// Today: this fails — sema doesn't know `Activity` as a type, or
|
|
// the method dispatch doesn't recognize foreign-class members.
|
|
win := act.getWindow();
|
|
}
|
|
}
|
|
|
|
main :: () -> i32 {
|
|
if g_should_call {
|
|
unused_jni(null, null);
|
|
}
|
|
print("ok\n");
|
|
0
|
|
}
|