Skip to content

Commit

Permalink
add access to manual auto-release pool creation
Browse files Browse the repository at this point in the history
  • Loading branch information
LunaTheFoxgirl committed Nov 27, 2024
1 parent 7f393bc commit cd323c7
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion source/foundation/nsurl.d
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public:
have identical URL strings and base URLs.
*/
extern(D)
bool opEquals(NSURL other) {
final bool opEquals(NSURL other) {
return self.send!bool("isEqual:", other);
}
}
Expand Down
19 changes: 19 additions & 0 deletions source/objc/autorelease.d
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import numem.core.memory.alloc : assumeNoGC;
/**
Creates an auto-release pool scope with the given delegate.
*/
@trusted
void autoreleasepool(scope void delegate() scope_) {
auto scope_fn = assumeNoGC!(typeof(scope_))(scope_);

Expand All @@ -28,6 +29,24 @@ void autoreleasepool(scope void delegate() scope_) {
objc_autoreleasePoolPop(ctx);
}

/**
Forcefully pushes an auto-release pool onto the auto-release pool stack.
*/
@system
arpool_ctx autoreleasepool_push() {
return arpool_ctx(objc_autoreleasePoolPush());
}

/**
Forcefully pops an auto-release pool from the auto-release pool stack.
*/
@system
void autoreleasepool_pop(arpool_ctx ctx) {
return objc_autoreleasePoolPop(ctx.ctxptr);
}

/// Opaque type for auto release pool contexts.
struct arpool_ctx { void* ctxptr; alias ctxptr this; }

private:
extern(C) @nogc nothrow:
Expand Down
10 changes: 10 additions & 0 deletions source/objc/rt.d
Original file line number Diff line number Diff line change
Expand Up @@ -897,12 +897,22 @@ private {
extern id objc_autorelease(id obj);
extern bool objc_isUniquelyReferenced(id obj);

extern id objc_releaseAndReturn(id obj);
extern id objc_retainAutoreleaseAndReturn(id obj);
extern id objc_autoreleaseReturnValue(id obj);

// Obtaining Class Definitions
extern int objc_getClassList(Class* buffer, int bufferCount);
extern Class* objc_copyClassList(uint* outCount);
extern Class objc_lookUpClass(const(char)* name);
extern id objc_getClass(const(char)* name);
extern id objc_getMetaClass(const(char)* name);
extern id objc_retainAutoreleaseReturnValue(id obj);
extern id objc_retainAutoreleasedReturnValue(id obj);
extern id objc_claimAutoreleasedReturnValue(id obj);
extern id objc_unsafeClaimAutoreleasedReturnValue(id obj);
extern id objc_retainAutorelease(id obj);


// Working with Instance Variables
extern const(char)* ivar_getName(Ivar v);
Expand Down

0 comments on commit cd323c7

Please sign in to comment.