uikit: type UIKitPlatform fields properly + handle optional in Obj-C encoding
The UIKitPlatform struct had a string of '*void = null; // UIWindow*' fields — the type lived in a comment, every callsite had to 'xx'-cast back to the real type. Migrated to the real foreign-class pointer types now that M3 declared all the relevant '#objc_class' aliases: window: ?*UIWindow root_vc: ?*UIViewController gl_view: ?*UIView (SxGLView OR SxMetalView — both extend UIView) gl_layer: ?*CALayer (CAEAGLLayer OR CAMetalLayer) gl_ctx: ?*EAGLContext display_link: ?*CADisplayLink Each field is wrapped in '?' since the platform may not have set it yet (gl_ctx is null in metal mode, display_link is null before the first frame, etc.). SxSceneDelegate's window getter/setter now take/return '?*UIWindow' instead of '*void' so calling code doesn't need an xx-cast. Required fix in objcTypeEncodingFromSignature: '?T' (optional) was bailing with 'type kind not yet supported'. Apple's runtime treats nullability as 'pointer may be null' — the wire encoding is the same as T. Recursive unwrap handles ?*UIView → '@', ?*CADisplayLink → '@', etc. Chess on iOS-sim: board renders, full pipeline intact. 183 tests + zig build test green.
This commit is contained in:
@@ -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))),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user