diff --git a/library/modules/platform/uikit.sx b/library/modules/platform/uikit.sx index 22180b7..c712a1f 100644 --- a/library/modules/platform/uikit.sx +++ b/library/modules/platform/uikit.sx @@ -217,12 +217,12 @@ SxSceneDelegate :: #objc_class("SxSceneDelegate") { uikit_scene_will_connect(xx self, xx 0, scene, session, options); } - window :: (self: *Self) -> *void { - if g_uikit_plat == null { return xx 0; } + window :: (self: *Self) -> ?*UIWindow { + if g_uikit_plat == null { return null; } return g_uikit_plat.window; } - setWindow :: (self: *Self, w: *void) { + setWindow :: (self: *Self, w: ?*UIWindow) { if g_uikit_plat == null { return; } g_uikit_plat.window = w; } @@ -247,12 +247,15 @@ GpuMode :: enum { } UIKitPlatform :: struct { - window: *void = null; // UIWindow* - root_vc: *void = null; // UIViewController* - gl_view: *void = null; // SxGLView* OR SxMetalView* (depending on gpu_mode) - gl_layer: *void = null; // CAEAGLLayer* OR CAMetalLayer* (= gl_view.layer) - gl_ctx: *void = null; // EAGLContext* (null in metal mode) - display_link: *void = null; + window: ?*UIWindow = null; + root_vc: ?*UIViewController = null; + // SxGLView (gles mode) or SxMetalView (metal mode) — both extend + // UIView, so the common method surface is reachable as *UIView. + gl_view: ?*UIView = null; + // CAEAGLLayer (gles) or CAMetalLayer (metal) — both extend CALayer. + gl_layer: ?*CALayer = null; + gl_ctx: ?*EAGLContext = null; + display_link: ?*CADisplayLink = null; color_renderbuffer: u32 = 0; framebuffer: u32 = 0; gl_initialized: bool = false; diff --git a/src/ir/lower.zig b/src/ir/lower.zig index 7ce9072..d0a2a22 100644 --- a/src/ir/lower.zig +++ b/src/ir/lower.zig @@ -4713,6 +4713,14 @@ pub const Lowering = struct { try out.appendSlice(self.alloc, "^v"); } }, + .optional => |o| { + // sx's `?T` is a nullable T. At the Obj-C ABI boundary + // nullability is just "this pointer may be null" — the + // wire-level encoding is the same as T. Unwrap and + // recurse. (Same goes for `?*UIView` etc. — the + // underlying pointer kind drives the encoding char.) + return self.appendObjcEncoding(out, o.child, span); + }, else => return self.bailObjcEncoding(span, "type kind not yet supported by Obj-C encoding", @intFromEnum(std.meta.activeTag(info))), } }