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

@@ -15,14 +15,14 @@
#import "modules/platform/types.sx";
#import "modules/platform/api.sx";
UIApplicationMain :: (argc: i32, argv: *void, principal_class: *NSString, delegate_class: *NSString) -> i32 #foreign;
dlsym :: (handle: *void, name: [*]u8) -> *void #foreign;
chdir :: (path: [*]u8) -> i32 #foreign;
UIApplicationMain :: (argc: i32, argv: *void, principal_class: *NSString, delegate_class: *NSString) -> i32 extern;
dlsym :: (handle: *void, name: [*]u8) -> *void extern;
chdir :: (path: [*]u8) -> i32 extern;
// QuartzCore's wall-clock helper used by CoreAnimation. Seconds since boot,
// monotonic. We use it as the timebase for keyboard-inset lockstep so the
// per-frame interpolation lines up with UIKit's own animation timestamp.
CACurrentMediaTime :: () -> f64 #foreign;
CACurrentMediaTime :: () -> f64 extern;
// kEAGLRenderingAPIOpenGLES3 = 3
@@ -58,13 +58,13 @@ CGRect :: struct {
// side name maps to its Obj-C selector via the default mangling rule
// (split on `_`; each piece becomes a keyword with `:`).
NSValue :: #foreign #objc_class("NSValue") {
NSValue :: #objc_class("NSValue") extern {
#extends NSObject;
// CGRect unboxing — returns by value via the sret/HFA path.
CGRectValue :: (self: *Self) -> CGRect;
}
NSNumber :: #foreign #objc_class("NSNumber") {
NSNumber :: #objc_class("NSNumber") extern {
#extends NSObject;
// Class method (no `self: *Self` first param → static dispatch).
numberWithBool :: (b: i8) -> *NSNumber;
@@ -73,36 +73,36 @@ NSNumber :: #foreign #objc_class("NSNumber") {
unsignedLongValue :: (self: *Self) -> u64;
}
NSDictionary :: #foreign #objc_class("NSDictionary") {
NSDictionary :: #objc_class("NSDictionary") extern {
#extends NSObject;
objectForKey :: (self: *Self, key: *NSString) -> *void;
}
NSMutableDictionary :: #foreign #objc_class("NSMutableDictionary") {
NSMutableDictionary :: #objc_class("NSMutableDictionary") extern {
#extends NSDictionary;
dictionary :: () -> *NSMutableDictionary;
setObject_forKey :: (self: *Self, obj: *void, key: *void);
}
NSSet :: #foreign #objc_class("NSSet") {
NSSet :: #objc_class("NSSet") extern {
#extends NSObject;
anyObject :: (self: *Self) -> *void;
}
// ── Notifications + Bundle (Phase 3.2 C2) ──────────────────────────────
NSNotification :: #foreign #objc_class("NSNotification") {
NSNotification :: #objc_class("NSNotification") extern {
#extends NSObject;
userInfo :: (self: *Self) -> *NSDictionary;
}
NSBundle :: #foreign #objc_class("NSBundle") {
NSBundle :: #objc_class("NSBundle") extern {
#extends NSObject;
mainBundle :: () -> *NSBundle;
resourcePath :: (self: *Self) -> *NSString;
}
NSNotificationCenter :: #foreign #objc_class("NSNotificationCenter") {
NSNotificationCenter :: #objc_class("NSNotificationCenter") extern {
#extends NSObject;
defaultCenter :: () -> *NSNotificationCenter;
addObserver_selector_name_object :: (self: *Self, observer: *void, sel: *void, name: *NSString, obj: *void);
@@ -110,12 +110,12 @@ NSNotificationCenter :: #foreign #objc_class("NSNotificationCenter") {
// ── RunLoop + display timing (Phase 3.2 C3) ────────────────────────────
NSRunLoop :: #foreign #objc_class("NSRunLoop") {
NSRunLoop :: #objc_class("NSRunLoop") extern {
#extends NSObject;
currentRunLoop :: () -> *NSRunLoop;
}
CADisplayLink :: #foreign #objc_class("CADisplayLink") {
CADisplayLink :: #objc_class("CADisplayLink") extern {
#extends NSObject;
displayLinkWithTarget_selector :: (target: *void, sel: *void) -> *CADisplayLink;
addToRunLoop_forMode :: (self: *Self, runloop: *NSRunLoop, mode: *NSString);
@@ -126,23 +126,23 @@ CADisplayLink :: #foreign #objc_class("CADisplayLink") {
// ── View tree + GL drawables (Phase 3.2 C5) ────────────────────────────
// (Declared before UIView so `layer :: (...) -> *CALayer` can reference it.)
CALayer :: #foreign #objc_class("CALayer") {
CALayer :: #objc_class("CALayer") extern {
#extends NSObject;
setOpaque :: (self: *Self, opaque: i8);
}
CAEAGLLayer :: #foreign #objc_class("CAEAGLLayer") {
CAEAGLLayer :: #objc_class("CAEAGLLayer") extern {
#extends CALayer;
class :: () -> *void;
setDrawableProperties :: (self: *Self, props: *void);
}
CAMetalLayer :: #foreign #objc_class("CAMetalLayer") {
CAMetalLayer :: #objc_class("CAMetalLayer") extern {
#extends CALayer;
class :: () -> *void;
}
EAGLContext :: #foreign #objc_class("EAGLContext") {
EAGLContext :: #objc_class("EAGLContext") extern {
#extends NSObject;
alloc :: () -> *EAGLContext;
initWithAPI :: (self: *Self, api: i32) -> *EAGLContext;
@@ -153,7 +153,7 @@ EAGLContext :: #foreign #objc_class("EAGLContext") {
// ── UIKit chrome (Phase 3.2 C4) ────────────────────────────────────────
UIScreen :: #foreign #objc_class("UIScreen") {
UIScreen :: #objc_class("UIScreen") extern {
#extends NSObject;
mainScreen :: () -> *UIScreen;
nativeScale :: (self: *Self) -> f64;
@@ -164,13 +164,13 @@ UIScreen :: #foreign #objc_class("UIScreen") {
// Most UIKit classes inherit from it; sx-defined classes that
// participate in lifecycle callbacks (delegates, scene delegates)
// extend it so the runtime picks up the responder-chain behavior.
UIResponder :: #foreign #objc_class("UIResponder") {
UIResponder :: #objc_class("UIResponder") extern {
#extends NSObject;
becomeFirstResponder :: (self: *Self) -> i8;
resignFirstResponder :: (self: *Self) -> i8;
}
UIView :: #foreign #objc_class("UIView") {
UIView :: #objc_class("UIView") extern {
#extends UIResponder;
safeAreaInsets :: (self: *Self) -> UIEdgeInsets;
addSubview :: (self: *Self, view: *void);
@@ -178,7 +178,7 @@ UIView :: #foreign #objc_class("UIView") {
setContentScaleFactor :: (self: *Self, scale: f64);
}
UIWindow :: #foreign #objc_class("UIWindow") {
UIWindow :: #objc_class("UIWindow") extern {
#extends UIView;
alloc :: () -> *UIWindow;
initWithWindowScene :: (self: *Self, scene: *void) -> *UIWindow;
@@ -187,14 +187,14 @@ UIWindow :: #foreign #objc_class("UIWindow") {
screen :: (self: *Self) -> *UIScreen;
}
UIViewController :: #foreign #objc_class("UIViewController") {
UIViewController :: #objc_class("UIViewController") extern {
#extends UIResponder;
alloc :: () -> *UIViewController;
init :: (self: *Self) -> *UIViewController;
setView :: (self: *Self, view: *void);
}
UITextField :: #foreign #objc_class("UITextField") {
UITextField :: #objc_class("UITextField") extern {
#extends UIResponder;
alloc :: () -> *UITextField;
init :: (self: *Self) -> *UITextField;
@@ -203,7 +203,7 @@ UITextField :: #foreign #objc_class("UITextField") {
// SxAppDelegate — UIApplicationMain's delegate class (the app delegate, a
// UIResponder — NOT the UIApplication principal class). Method bodies
// dispatch to UIKitPlatform methods on the shared `g_uikit_plat`.
SxAppDelegate :: #objc_class("SxAppDelegate") {
SxAppDelegate :: #objc_class("SxAppDelegate") export {
#extends UIResponder;
application_didFinishLaunchingWithOptions :: (self: *Self, app: *void, opts: *void) -> BOOL {
@@ -233,7 +233,7 @@ SxAppDelegate :: #objc_class("SxAppDelegate") {
// SxSceneDelegate — iOS 13+ scene-based lifecycle delegate. Two
// `#implements` declarations formally conform to the scene-delegate
// protocols — iOS rejects the class otherwise.
SxSceneDelegate :: #objc_class("SxSceneDelegate") {
SxSceneDelegate :: #objc_class("SxSceneDelegate") export {
#extends UIResponder;
#implements UISceneDelegate;
#implements UIWindowSceneDelegate;
@@ -827,7 +827,7 @@ uikit_chdir_to_bundle :: () {
// M3.3 — migrated to declarative `#objc_class` form. The compiler
// synthesises class-pair init, metaclass `+layerClass`, and the
// instance-method IMP trampolines at module init.
SxGLView :: #objc_class("SxGLView") {
SxGLView :: #objc_class("SxGLView") export {
#extends UIView;
layerClass :: () => CAEAGLLayer.class();
@@ -886,7 +886,7 @@ uikit_first_touch :: (touches: *void) -> *void {
//
// M3.4 — migrated to declarative `#objc_class`. Only `+layerClass`
// differs from SxGLView (returns CAMetalLayer instead of CAEAGLLayer).
SxMetalView :: #objc_class("SxMetalView") {
SxMetalView :: #objc_class("SxMetalView") export {
#extends UIView;
layerClass :: () => CAMetalLayer.class();