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) {