refactor(ffi-linkage): Phase 7.3 — migrate 14xx ffi-jni examples #foreign→extern
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).
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
|
||||
#import "modules/std.sx";
|
||||
|
||||
Buf :: #foreign #jni_class("java/nio/ByteBuffer") {
|
||||
Buf :: #jni_class("java/nio/ByteBuffer") extern {
|
||||
get :: (self: *Self) -> i8;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Phase 2 step 2.0 (PLAN-FFI.md): xfail parser test for the
|
||||
// type-introducer `Foo :: #foreign #jni_class("java/path/Foo") { }` directive.
|
||||
// type-introducer `Foo :: #jni_class("java/path/Foo") extern { }` directive.
|
||||
//
|
||||
// Today's parser doesn't recognize `#jni_class` as a known hash
|
||||
// directive after `::`, so it falls through to expression parsing
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
#import "modules/std.sx";
|
||||
|
||||
Foo :: #foreign #jni_class("java/path/Foo") { }
|
||||
Foo :: #jni_class("java/path/Foo") extern { }
|
||||
|
||||
main :: () -> i32 {
|
||||
print("parse-only ok\n");
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
// `Self` here refers to the enclosing `View` type — resolved at
|
||||
// 2.x sema, not at parse time.
|
||||
View :: #foreign #jni_class("android/view/View") {
|
||||
View :: #jni_class("android/view/View") extern {
|
||||
getId :: (self: *Self) -> i32;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#import "modules/std.sx";
|
||||
|
||||
Math :: #foreign #jni_class("java/lang/Math") {
|
||||
Math :: #jni_class("java/lang/Math") extern {
|
||||
abs :: (n: i32) -> i32; // no `self: *Self` → class method
|
||||
}
|
||||
|
||||
|
||||
@@ -12,9 +12,9 @@
|
||||
|
||||
#import "modules/std.sx";
|
||||
|
||||
View :: #foreign #jni_class("android/view/View") { }
|
||||
View :: #jni_class("android/view/View") extern { }
|
||||
|
||||
Window :: #foreign #jni_class("android/view/Window") {
|
||||
Window :: #jni_class("android/view/Window") extern {
|
||||
#extends View;
|
||||
getDecorView :: (self: *Self) -> *View;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#import "modules/std.sx";
|
||||
|
||||
Point :: #foreign #jni_class("android/graphics/Point") {
|
||||
Point :: #jni_class("android/graphics/Point") extern {
|
||||
x: i32;
|
||||
y: i32;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
#import "modules/std.sx";
|
||||
|
||||
Foo :: #foreign #jni_class("com/example/Foo") {
|
||||
Foo :: #jni_class("com/example/Foo") extern {
|
||||
weirdMethod :: (self: *Self) -> i32 #jni_method_descriptor("()I");
|
||||
}
|
||||
|
||||
|
||||
@@ -17,27 +17,27 @@
|
||||
|
||||
#import "modules/std.sx";
|
||||
|
||||
IFoo :: #foreign #jni_interface("com/example/IFoo") {
|
||||
IFoo :: #jni_interface("com/example/IFoo") extern {
|
||||
bar :: (self: *Self) -> i32;
|
||||
}
|
||||
|
||||
NSString :: #foreign #objc_class("NSString") {
|
||||
NSString :: #objc_class("NSString") extern {
|
||||
length :: (self: *Self) -> i32;
|
||||
}
|
||||
|
||||
NSCopying :: #foreign #objc_protocol("NSCopying") {
|
||||
NSCopying :: #objc_protocol("NSCopying") extern {
|
||||
copy :: (self: *Self) -> *Self;
|
||||
}
|
||||
|
||||
URL :: #foreign #swift_class("Foundation.URL") {
|
||||
URL :: #swift_class("Foundation.URL") extern {
|
||||
absoluteString :: (self: *Self) -> *void;
|
||||
}
|
||||
|
||||
Date :: #foreign #swift_struct("Foundation.Date") {
|
||||
Date :: #swift_struct("Foundation.Date") extern {
|
||||
timeIntervalSince1970 :: (self: *Self) -> f64;
|
||||
}
|
||||
|
||||
Hashable :: #foreign #swift_protocol("Swift.Hashable") {
|
||||
Hashable :: #swift_protocol("Swift.Hashable") extern {
|
||||
hash :: (self: *Self) -> i32;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#import "modules/std.sx";
|
||||
|
||||
Activity :: #foreign #jni_class("android/app/Activity") {
|
||||
Activity :: #jni_class("android/app/Activity") extern {
|
||||
getWindow :: (self: *Self) -> *void;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
#import "modules/std.sx";
|
||||
|
||||
MotionEvent :: #foreign #jni_class("android/view/MotionEvent") {
|
||||
MotionEvent :: #jni_class("android/view/MotionEvent") extern {
|
||||
getAction :: (self: *Self) -> i32;
|
||||
getX :: (self: *Self) -> f32;
|
||||
getY :: (self: *Self) -> f32;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
// `*Bundle` resolves through the class registry to `android.os.Bundle`
|
||||
// in the emitted Java — needed for `onCreate`'s @Override to match
|
||||
// NativeActivity's superclass signature.
|
||||
Bundle :: #foreign #jni_class("android/os/Bundle") { }
|
||||
Bundle :: #jni_class("android/os/Bundle") extern { }
|
||||
|
||||
// `#jni_main` flags this as the launchable Android Activity class. The
|
||||
// `onCreate` body is empty for now — slice 4 wires `RegisterNatives`
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#import "modules/std.sx";
|
||||
#import "modules/build.sx";
|
||||
|
||||
Bundle :: #foreign #jni_class("android/os/Bundle") { }
|
||||
Bundle :: #jni_class("android/os/Bundle") extern { }
|
||||
|
||||
SxApp :: #jni_main #jni_class("co/swipelab/sxjnimainsuper/SxApp") {
|
||||
onCreate :: (self: *Self, b: *Bundle) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// `Alias.new(args)` constructor dispatch on a `#foreign #jni_class`
|
||||
// `Alias.new(args)` constructor dispatch on a `extern #jni_class`
|
||||
// (chess-on-Pixel migration, R.6). The sx-side `static new :: (...) ->
|
||||
// *Self;` member lowers to JNI `FindClass + GetMethodID("<init>", sig)
|
||||
// + NewObject(env, clazz, mid, args...)`.
|
||||
@@ -9,10 +9,10 @@
|
||||
#import "modules/std.sx";
|
||||
#import "modules/build.sx";
|
||||
|
||||
Bundle :: #foreign #jni_class("android/os/Bundle") { }
|
||||
JContext :: #foreign #jni_class("android/content/Context") { }
|
||||
Bundle :: #jni_class("android/os/Bundle") extern { }
|
||||
JContext :: #jni_class("android/content/Context") extern { }
|
||||
|
||||
SurfaceView :: #foreign #jni_class("android/view/SurfaceView") {
|
||||
SurfaceView :: #jni_class("android/view/SurfaceView") extern {
|
||||
new :: (ctx: *JContext) -> *Self; // no `self: *Self` → class method
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user