From 65643fb0ed46a65b9fe12fe7eae779a3b5b1b19f Mon Sep 17 00:00:00 2001 From: agra Date: Tue, 19 May 2026 19:37:43 +0300 Subject: [PATCH] ffi 1.28-1.30: batch uikit migrations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Three Phase 1D clusters in one commit (user opted for less iOS-sim verification between each). 1.28 — `show_keyboard` / `hide_keyboard` use `#objc_call(u8)` against `becomeFirstResponder` / `resignFirstResponder`. Compile-only; chess startup doesn't reach the keyboard path, so the runtime side of this cluster is a verification gap to backfill at the end of Phase 1D. 1.29 — `uikit_create_gl_context` migrates `alloc` / `initWithAPI:` / `setCurrentContext:` and folds in the same `mainScreen.nativeScale` read shape already migrated in 1.27. EAGL context creation runs on launch, so this cluster IS runtime-exercised. 1.30 — `uikit_subscribe_keyboard_notifications` migrates the `defaultCenter` + `addObserver:selector:name:object:` pair. First standalone exercise of a 4-keyword selector through `#objc_call`. Notification-center wiring runs at launch, so runtime-exercised. Net -23 lines across the file. iOS-sim chess regression smoke: app launches cleanly into a fresh board state. Status-bar clearance, sharp rendering, and asset loading all good — confirming clusters 1.25–1.27 still work alongside the new ones. --- library/modules/platform/uikit.sx | 41 ++++++++++--------------------- 1 file changed, 13 insertions(+), 28 deletions(-) diff --git a/library/modules/platform/uikit.sx b/library/modules/platform/uikit.sx index aa2c13d..4ceaffb 100644 --- a/library/modules/platform/uikit.sx +++ b/library/modules/platform/uikit.sx @@ -220,18 +220,14 @@ impl Platform for UIKitPlatform { show_keyboard :: (self: *UIKitPlatform) { inline if OS == .ios { if self.text_field == null { return; } - sel_become := sel_registerName("becomeFirstResponder".ptr); - msg_b : (*void, *void) -> u8 = xx objc_msgSend; - msg_b(self.text_field, sel_become); + #objc_call(u8)(self.text_field, "becomeFirstResponder"); } } hide_keyboard :: (self: *UIKitPlatform) { inline if OS == .ios { if self.text_field == null { return; } - sel_resign := sel_registerName("resignFirstResponder".ptr); - msg_b : (*void, *void) -> u8 = xx objc_msgSend; - msg_b(self.text_field, sel_resign); + #objc_call(u8)(self.text_field, "resignFirstResponder"); } } @@ -439,26 +435,16 @@ uikit_create_gl_context :: (plat: *UIKitPlatform) { EAGLContext := objc_getClass("EAGLContext".ptr); UIScreen := objc_getClass("UIScreen".ptr); - sel_alloc := sel_registerName("alloc".ptr); - sel_init_with_api := sel_registerName("initWithAPI:".ptr); - sel_set_current_ctx := sel_registerName("setCurrentContext:".ptr); - sel_main_screen := sel_registerName("mainScreen".ptr); - sel_native_scale := sel_registerName("nativeScale".ptr); - - msg_o : (*void, *void) -> *void = xx objc_msgSend; - msg_oo : (*void, *void, *void) -> void = xx objc_msgSend; - msg_oi32 : (*void, *void, s32) -> *void = xx objc_msgSend; - msg_d : (*void, *void) -> f64 = xx objc_msgSend; // Read the screen scale up-front so callers can size font caches and // textures with the right DPI before the window even exists. - screen := msg_o(UIScreen, sel_main_screen); - scale_d : f64 = msg_d(screen, sel_native_scale); + screen := #objc_call(*void)(UIScreen, "mainScreen"); + scale_d := #objc_call(f64)(screen, "nativeScale"); plat.dpi_scale = xx scale_d; - ctx_raw := msg_o(EAGLContext, sel_alloc); - plat.gl_ctx = msg_oi32(ctx_raw, sel_init_with_api, EAGL_API_GLES3); - msg_oo(EAGLContext, sel_set_current_ctx, plat.gl_ctx); + ctx_raw := #objc_call(*void)(EAGLContext, "alloc"); + plat.gl_ctx = #objc_call(*void)(ctx_raw, "initWithAPI:", EAGL_API_GLES3); + #objc_call(void)(EAGLContext, "setCurrentContext:", plat.gl_ctx); load_gl(@ios_gl_proc); } @@ -485,13 +471,12 @@ uikit_did_finish_launching :: (self: *void, _cmd: *void, app: *void, opts: *void uikit_subscribe_keyboard_notifications :: (delegate: *void) { inline if OS != .ios { return; } NSNotificationCenter := objc_getClass("NSNotificationCenter".ptr); - sel_default_center := sel_registerName("defaultCenter".ptr); - sel_add_observer := sel_registerName("addObserver:selector:name:object:".ptr); - msg_o : (*void, *void) -> *void = xx objc_msgSend; - msg_o5 : (*void, *void, *void, *void, *void, *void) -> void = xx objc_msgSend; - center := msg_o(NSNotificationCenter, sel_default_center); - msg_o5(center, sel_add_observer, delegate, sel_registerName("sxKeyboardWillChangeFrame:".ptr), - ns_string("UIKeyboardWillChangeFrameNotification".ptr), xx 0); + center := #objc_call(*void)(NSNotificationCenter, "defaultCenter"); + #objc_call(void)(center, "addObserver:selector:name:object:", + delegate, + sel_registerName("sxKeyboardWillChangeFrame:".ptr), + ns_string("UIKeyboardWillChangeFrameNotification".ptr), + xx 0); } uikit_scene_will_connect :: (self: *void, _cmd: *void, scene: *void, session: *void, options: *void) callconv(.c) {