ffi M4.A: stdlib NSObject + autoreleasepool helper + extends rooting
Declare `NSObject` in std/objc.sx as `#foreign #objc_class("NSObject")`
with the canonical instance + class-method surface every Obj-C class
inherits: `retain`/`release`/`autorelease`/`new`/`alloc`/`init`/
`description`/`hash`/`isEqual_`/`isKindOfClass_`/`respondsToSelector_`/
`class`. Root the foreign-class hierarchy in uikit.sx at NSObject by
adding `#extends NSObject;` to every previously-unrooted declaration
(NSValue, NSNumber, NSDictionary, NSSet, NSNotification, NSBundle,
NSNotificationCenter, NSRunLoop, CADisplayLink, CALayer, EAGLContext,
UIScreen, UIResponder) plus deeper chain fixes (NSMutableDictionary
extends NSDictionary; UIWindow extends UIView; UIViewController
extends UIResponder). After this, M2.3's extends-chain walk finds
`retain`/`release` on any UIKit-typed value:
view := UIView.alloc().init();
defer view.release(); // canonical sx idiom — no language magic
Plus `autoreleasepool(body: Closure())` stdlib helper that wraps
`body` in `objc_autoreleasePoolPush` / `defer objc_autoreleasePoolPop`.
Required for Foundation factory returns; closure-call frame is real
cost so hot loops should inline the push/defer-pop pattern manually.
Smoke test `ffi-objc-arc-01-autoreleasepool.sx` exercises both
patterns; refresh of two IR snapshots picks up the new stdlib decls
appearing in test outputs that include `modules/std/objc.sx`.
185/185 example tests pass; chess on iOS-sim green.
This commit is contained in:
@@ -798,6 +798,15 @@ declare ptr @ns_string(ptr, ptr) #0
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @c_string(ptr, ptr) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @objc_autoreleasePoolPush() #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare void @objc_autoreleasePoolPop(ptr) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare void @autoreleasepool(ptr, [2 x i64]) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define internal i32 @universal_imp(ptr %0, ptr %1, i32 %2, i32 %3, i32 %4, i32 %5) #0 {
|
||||
entry:
|
||||
@@ -944,3 +953,5 @@ entry:
|
||||
store ptr %selN, ptr @OBJC_SELECTOR_REFERENCES_actualSelectorName, align 8
|
||||
ret void
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user