mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 09:04:13 +00:00
Fix for MacOS-X compatibility
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@13747 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
f844f8caa2
commit
eca974908b
3 changed files with 72 additions and 7 deletions
|
@ -1,3 +1,10 @@
|
|||
2002-06-01 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSObject.m: Change NSDecrementExtraRefCountWasZero() to
|
||||
refrain from decrementing when the count is zero. Documented
|
||||
the retain/release/retainCopunt methods.
|
||||
* headers/Foundation/NSObject.h: Documented extra ref count functions.
|
||||
|
||||
2002-05-28 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSObject.m: Change order of zombie initialisation for
|
||||
|
|
|
@ -151,10 +151,26 @@ NSCopyObject(NSObject *anObject, unsigned extraBytes, NSZone *zone);
|
|||
|
||||
GS_EXPORT BOOL
|
||||
NSShouldRetainWithZone(NSObject *anObject, NSZone *requestedZone);
|
||||
|
||||
/**
|
||||
* Return the extra reference count of anObject. The reference count
|
||||
* for an object is this value plus one.
|
||||
*/
|
||||
GS_EXPORT unsigned
|
||||
NSExtraRefCount(id anObject);
|
||||
|
||||
/**
|
||||
* Increment the extra reference count for anObject. This is used
|
||||
* by the -retain method.
|
||||
*/
|
||||
GS_EXPORT void
|
||||
NSIncrementExtraRefCount(id anObject);
|
||||
|
||||
/**
|
||||
* Examines the extra reference count for the object and, if non-zero
|
||||
* decrements it. Returns a flag to say whether the count was zero
|
||||
* (and hence whether the extra refrence count was decremented).
|
||||
*/
|
||||
GS_EXPORT BOOL
|
||||
NSDecrementExtraRefCountWasZero(id anObject);
|
||||
|
||||
|
|
|
@ -256,25 +256,27 @@ NSDecrementExtraRefCountWasZero(id anObject)
|
|||
if (allocationLock != 0)
|
||||
{
|
||||
objc_mutex_lock(allocationLock);
|
||||
if (((obj)anObject)[-1].retained-- == 0)
|
||||
if (((obj)anObject)[-1].retained == 0)
|
||||
{
|
||||
objc_mutex_unlock(allocationLock);
|
||||
return YES;
|
||||
}
|
||||
else
|
||||
{
|
||||
((obj)anObject)[-1].retained--;
|
||||
objc_mutex_unlock(allocationLock);
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (((obj)anObject)[-1].retained-- == 0)
|
||||
if (((obj)anObject)[-1].retained == 0)
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
else
|
||||
{
|
||||
((obj)anObject)[-1].retained--;
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
@ -347,10 +349,15 @@ NSDecrementExtraRefCountWasZero (id anObject)
|
|||
objc_mutex_unlock(allocationLock);
|
||||
return YES;
|
||||
}
|
||||
NSCAssert(node->value.uint > 0, NSInternalInconsistencyException);
|
||||
if (--(node->value.uint) == 0)
|
||||
if (node->value.uint == 0)
|
||||
{
|
||||
GSIMapRemoveKey((GSIMapTable)&retain_counts, (GSIMapKey)anObject);
|
||||
objc_mutex_unlock(allocationLock);
|
||||
return YES;
|
||||
}
|
||||
else
|
||||
{
|
||||
(node->value.uint)--;
|
||||
}
|
||||
objc_mutex_unlock(allocationLock);
|
||||
}
|
||||
|
@ -361,13 +368,17 @@ NSDecrementExtraRefCountWasZero (id anObject)
|
|||
{
|
||||
return YES;
|
||||
}
|
||||
NSCAssert(node->value.uint > 0, NSInternalInconsistencyException);
|
||||
if (--(node->value.uint) == 0)
|
||||
if (node->value.uint) == 0)
|
||||
{
|
||||
GSIMapRemoveKey((GSIMapTable)&retain_counts, (GSIMapKey)anObject);
|
||||
return YES;
|
||||
}
|
||||
else
|
||||
{
|
||||
--(node->value.uint);
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
unsigned
|
||||
|
@ -1154,6 +1165,11 @@ static BOOL double_release_check_enabled = NO;
|
|||
return (*msg)(self, aSelector, object1, object2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls the NSDecrementExtraRefCountWasZero() function to test the
|
||||
* extra reference count for the receiver (and decrement it if non-zero).<br />
|
||||
* If it was zero, calls the -dealloc method to destroy the receiver.<br />
|
||||
*/
|
||||
- (oneway void) release
|
||||
{
|
||||
#if GS_WITH_GC == 0
|
||||
|
@ -1177,6 +1193,12 @@ static BOOL double_release_check_enabled = NO;
|
|||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* The class implementation of the release method is a dummy method
|
||||
* having no effect. It is present so that class objects can be stored
|
||||
* in containers (such as NSArray) which will send them retain and
|
||||
* release messages.
|
||||
*/
|
||||
+ (oneway void) release
|
||||
{
|
||||
return;
|
||||
|
@ -1187,6 +1209,10 @@ static BOOL double_release_check_enabled = NO;
|
|||
return __objc_responds_to(self, aSelector);
|
||||
}
|
||||
|
||||
/**
|
||||
* Increments the reference count for the receiver by calling
|
||||
* NSIncrementExtraRefCount()
|
||||
*/
|
||||
- (id) retain
|
||||
{
|
||||
#if GS_WITH_GC == 0
|
||||
|
@ -1195,11 +1221,22 @@ static BOOL double_release_check_enabled = NO;
|
|||
return self;
|
||||
}
|
||||
|
||||
/**
|
||||
* The class implementation of the retain method is a dummy method
|
||||
* having no effect. It is present so that class objects can be stored
|
||||
* in containers (such as NSArray) which will send them retain and
|
||||
* release messages.
|
||||
*/
|
||||
+ (id) retain
|
||||
{
|
||||
return self;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the reference count for the receiver. Each instance has an
|
||||
* implicit reference count of 1, and has an 'extra refrence count'
|
||||
* returned by the NSExtraRefCount() function.
|
||||
*/
|
||||
- (unsigned) retainCount
|
||||
{
|
||||
#if GS_WITH_GC
|
||||
|
@ -1209,6 +1246,11 @@ static BOOL double_release_check_enabled = NO;
|
|||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* The class implementation of the retainCount method always returns
|
||||
* the maximum unsigned integer value, as classes can not be deallocated
|
||||
* the retain count mechanism is a dummy system for them.
|
||||
*/
|
||||
+ (unsigned) retainCount
|
||||
{
|
||||
return UINT_MAX;
|
||||
|
|
Loading…
Reference in a new issue