From d403f56673f3352756d629625cccacebb146ff07 Mon Sep 17 00:00:00 2001 From: agra Date: Tue, 26 May 2026 07:48:15 +0300 Subject: [PATCH] uikit: inline three trivial legacy IMP helpers into #objc_class methods MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Three holdover free functions from the pre-M3 era were each just two or three lines that forwarded to a global. With M3 finished, every call site is one #objc_class method body, so the wrapper indirection earns nothing — inline them. Deleted: uikit_window_getter → body of SxSceneDelegate.window uikit_window_setter → body of SxSceneDelegate.setWindow uikit_did_finish_launching → body of SxAppDelegate.application_didFinishLaunchingWithOptions The bigger helpers (uikit_keyboard_will_change_frame, uikit_scene_will_connect, uikit_gl_view_tick/_layout, the four uikit_gl_view_touches_*) stay — their bodies are 30-80 lines each, so wrapping them in a small forwarding method body inside #objc_class is the cleaner factoring. Chess on iOS-sim: board renders, full game state intact. 183 example tests + zig build test green. --- library/modules/platform/uikit.sx | 32 ++++++++++--------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/library/modules/platform/uikit.sx b/library/modules/platform/uikit.sx index d17b179..22180b7 100644 --- a/library/modules/platform/uikit.sx +++ b/library/modules/platform/uikit.sx @@ -186,7 +186,12 @@ SxAppDelegate :: #objc_class("SxAppDelegate") { #extends UIResponder; application_didFinishLaunchingWithOptions :: (self: *Self, app: *void, opts: *void) -> BOOL { - return xx uikit_did_finish_launching(xx self, xx 0, app, opts); + inline if OS == .ios { + if g_uikit_plat != null { + uikit_subscribe_keyboard_notifications(xx self); + } + } + return 1; } sxKeyboardWillChangeFrame :: (self: *Self, notification: *void) { @@ -213,11 +218,13 @@ SxSceneDelegate :: #objc_class("SxSceneDelegate") { } window :: (self: *Self) -> *void { - return uikit_window_getter(xx self, xx 0); + if g_uikit_plat == null { return xx 0; } + return g_uikit_plat.window; } setWindow :: (self: *Self, w: *void) { - uikit_window_setter(xx self, xx 0, w); + if g_uikit_plat == null { return; } + g_uikit_plat.window = w; } } @@ -560,25 +567,6 @@ uikit_create_gl_context :: (plat: *UIKitPlatform) { load_gl(@ios_gl_proc); } -uikit_window_getter :: (self: *void, _cmd: *void) -> *void callconv(.c) { - if g_uikit_plat == null { return xx 0; } - g_uikit_plat.window; -} - -uikit_window_setter :: (self: *void, _cmd: *void, w: *void) callconv(.c) { - if g_uikit_plat == null { return; } - g_uikit_plat.window = w; -} - -uikit_did_finish_launching :: (self: *void, _cmd: *void, app: *void, opts: *void) -> u8 callconv(.c) { - inline if OS == .ios { - if g_uikit_plat != null { - uikit_subscribe_keyboard_notifications(self); - } - } - 1; -} - uikit_subscribe_keyboard_notifications :: (delegate: *void) { inline if OS != .ios { return; } center := NSNotificationCenter.defaultCenter();