refactor(ffi-linkage): Phase 6.2 — migrate platform/ #foreign→extern/export

Pure source rename across uikit/android/android_jni/sdl3 (~64 #foreign sites):
- 30 fn decls '… #foreign;' → '… extern;'
- 34 import runtime classes '#foreign #objc_class/#jni_class("X") {' →
  '#objc_class/#jni_class("X") extern {' (prefix → postfix modifier)
- 4 defined Sx* obj-c classes '#objc_class("X") {' → '… export {'

Behavior-preserving (AST already unified post-Phase-5.0). Verified byte-identical
IR via 'sx ir' on the uikit importers 1610 + 1606 (which compile uikit incl. the
4 defined Sx* classes on host) and an sdl3 probe; android.sx (host-incompatible,
only compiles under OS==.android) verified by an identical 4-error dedup set (the
keyword-neutral 'foreign symbol already bound' message is unchanged). Empty
snapshot diff; suite green (647 corpus / 444 unit, 0 failed).
This commit is contained in:
agra
2026-06-15 04:32:20 +03:00
parent 32e83c90cc
commit 2cd5d7ba82
4 changed files with 68 additions and 68 deletions

View File

@@ -38,31 +38,31 @@
// ── Foreign Java types ──────────────────────────────────────────────────
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 {
getAssets :: (self: *Self) -> *AssetManagerJ;
}
AssetManagerJ :: #foreign #jni_class("android/content/res/AssetManager") { }
AssetManagerJ :: #jni_class("android/content/res/AssetManager") extern { }
Surface :: #foreign #jni_class("android/view/Surface") { }
SurfaceHolder :: #foreign #jni_class("android/view/SurfaceHolder") {
Surface :: #jni_class("android/view/Surface") extern { }
SurfaceHolder :: #jni_class("android/view/SurfaceHolder") extern {
getSurface :: (self: *Self) -> *Surface;
addCallback :: (self: *Self, cb: *SurfaceHolderCallback);
}
SurfaceView :: #foreign #jni_class("android/view/SurfaceView") {
SurfaceView :: #jni_class("android/view/SurfaceView") extern {
new :: (ctx: *JContext) -> *Self; // no `self: *Self` → class method
getHolder :: (self: *Self) -> *SurfaceHolder;
}
SurfaceHolderCallback :: #foreign #jni_class("android/view/SurfaceHolder$Callback") { }
SurfaceHolderCallback :: #jni_class("android/view/SurfaceHolder$Callback") extern { }
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;
}
JView :: #foreign #jni_class("android/view/View") { }
ActivityClass :: #foreign #jni_class("android/app/Activity") {
JView :: #jni_class("android/view/View") extern { }
ActivityClass :: #jni_class("android/app/Activity") extern {
setContentView :: (self: *Self, v: *JView);
}
@@ -70,25 +70,25 @@ ActivityClass :: #foreign #jni_class("android/app/Activity") {
// C side of file_utils — installs the AAssetManager so `read_file_bytes`
// can route through `AAssetManager_open` when running on Android.
sx_android_set_asset_manager :: (mgr: *void) #foreign;
sx_android_set_asset_manager :: (mgr: *void) extern;
__android_log_print :: (prio: i32, tag: *u8, fmt: *u8) -> i32 #foreign;
usleep :: (us: u32) -> i32 #foreign;
__android_log_print :: (prio: i32, tag: *u8, fmt: *u8) -> i32 extern;
usleep :: (us: u32) -> i32 extern;
// libandroid
ANativeWindow_fromSurface :: (env: *void, surface: *void) -> *void #foreign;
ANativeWindow_release :: (window: *void) #foreign;
ANativeWindow_getWidth :: (window: *void) -> i32 #foreign;
ANativeWindow_getHeight :: (window: *void) -> i32 #foreign;
ANativeWindow_setBuffersGeometry :: (w: *void, width: i32, height: i32, fmt: i32) -> i32 #foreign;
ANativeWindow_fromSurface :: (env: *void, surface: *void) -> *void extern;
ANativeWindow_release :: (window: *void) extern;
ANativeWindow_getWidth :: (window: *void) -> i32 extern;
ANativeWindow_getHeight :: (window: *void) -> i32 extern;
ANativeWindow_setBuffersGeometry :: (w: *void, width: i32, height: i32, fmt: i32) -> i32 extern;
AAssetManager_fromJava :: (env: *void, mgr: *void) -> *void #foreign;
AAssetManager_fromJava :: (env: *void, mgr: *void) -> *void extern;
// pthread (link libpthread is built into bionic).
pthread_create :: (thread: *u64, attr: *void, start: (*void) -> *void callconv(.c), arg: *void) -> i32 #foreign;
pthread_mutex_init :: (m: *void, attr: *void) -> i32 #foreign;
pthread_mutex_lock :: (m: *void) -> i32 #foreign;
pthread_mutex_unlock :: (m: *void) -> i32 #foreign;
pthread_create :: (thread: *u64, attr: *void, start: (*void) -> *void callconv(.c), arg: *void) -> i32 extern;
pthread_mutex_init :: (m: *void, attr: *void) -> i32 extern;
pthread_mutex_lock :: (m: *void) -> i32 extern;
pthread_mutex_unlock :: (m: *void) -> i32 extern;
// EGL. Constants from <EGL/egl.h>. We bring up an ES3 context with a
// 24-bit RGB framebuffer + 24-bit depth (same shape chess used under
@@ -112,17 +112,17 @@ EGL_WINDOW_BIT :i32: 0x0004;
EGL_NATIVE_VISUAL_ID :i32: 0x302E;
EGL_CONTEXT_CLIENT_VERSION :i32: 0x3098;
eglGetDisplay :: (id: u64) -> *void #foreign;
eglInitialize :: (d: *void, major: *i32, minor: *i32) -> u32 #foreign;
eglChooseConfig :: (d: *void, attrs: *i32, configs: **void, sz: i32, num: *i32) -> u32 #foreign;
eglGetConfigAttrib :: (d: *void, cfg: *void, attr: i32, value: *i32) -> u32 #foreign;
eglCreateContext :: (d: *void, cfg: *void, share: *void, attrs: *i32) -> *void #foreign;
eglCreateWindowSurface :: (d: *void, cfg: *void, window: *void, attrs: *i32) -> *void #foreign;
eglMakeCurrent :: (d: *void, draw: *void, read: *void, ctx: *void) -> u32 #foreign;
eglSwapBuffers :: (d: *void, surface: *void) -> u32 #foreign;
eglDestroyContext :: (d: *void, ctx: *void) -> u32 #foreign;
eglDestroySurface :: (d: *void, surface: *void) -> u32 #foreign;
eglTerminate :: (d: *void) -> u32 #foreign;
eglGetDisplay :: (id: u64) -> *void extern;
eglInitialize :: (d: *void, major: *i32, minor: *i32) -> u32 extern;
eglChooseConfig :: (d: *void, attrs: *i32, configs: **void, sz: i32, num: *i32) -> u32 extern;
eglGetConfigAttrib :: (d: *void, cfg: *void, attr: i32, value: *i32) -> u32 extern;
eglCreateContext :: (d: *void, cfg: *void, share: *void, attrs: *i32) -> *void extern;
eglCreateWindowSurface :: (d: *void, cfg: *void, window: *void, attrs: *i32) -> *void extern;
eglMakeCurrent :: (d: *void, draw: *void, read: *void, ctx: *void) -> u32 extern;
eglSwapBuffers :: (d: *void, surface: *void) -> u32 extern;
eglDestroyContext :: (d: *void, ctx: *void) -> u32 extern;
eglDestroySurface :: (d: *void, surface: *void) -> u32 extern;
eglTerminate :: (d: *void) -> u32 extern;
// ── Touch ring ──────────────────────────────────────────────────────────