mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 08:21:25 +00:00
GC was deprecated several releases ago and notinally removed a couple of releases ago ... delete more remnants of the old code.
This commit is contained in:
parent
a1514249f3
commit
52c127c950
15 changed files with 20 additions and 126 deletions
|
@ -231,40 +231,6 @@ NSZoneStats (NSZone *zone);
|
|||
void*
|
||||
GSOutOfMemory(NSUInteger size, BOOL retry);
|
||||
|
||||
/**
|
||||
* Called during +initialize to tell the class that instances created
|
||||
* in future should have the specified instance variable as a weak
|
||||
* pointer for garbage collection.<br />
|
||||
* NB. making a pointer weak does not mean that it is automatically
|
||||
* zeroed when the object it points to is garbage collected. To get that
|
||||
* behavior you must asign values to the pointer using the
|
||||
* GSAssignZeroingWeakPointer() function.<br />
|
||||
* This function has no effect if the system is
|
||||
* not built for garbage collection.
|
||||
*/
|
||||
GS_EXPORT void
|
||||
GSMakeWeakPointer(Class theClass, const char *iVarName);
|
||||
|
||||
/**
|
||||
* This function must be used to assign a value to a zeroing weak pointer.<br />
|
||||
* A zeroing weak pointer is one where, when the garbage collector collects
|
||||
* the object pointed to, it also clears the weak pointer.<br />
|
||||
* Assigning zero (nil) will always succeed and has the effect of telling the
|
||||
* garbage collector that it no longer needs to track the previously assigned
|
||||
* object. Apart from that case, a source needs to be garbage collectable for
|
||||
* this function to work, and using a non-garbage collectable value will
|
||||
* cause the function to return NO.<br />
|
||||
* If the destination object (the weak pointer watching the source object)
|
||||
* belongs to a chunk of memory which may be collected before the source
|
||||
* object is collected, it is important that it is finalised and the
|
||||
* finalisation code assigns zero to the pointer.<br />
|
||||
* If garbage collection is not in use, this function performs a simple
|
||||
* assignment returning YES, unless destination is null in which case it
|
||||
* returns NO.
|
||||
*/
|
||||
GS_EXPORT BOOL
|
||||
GSAssignZeroingWeakPointer(void **destination, void *source);
|
||||
|
||||
#endif
|
||||
|
||||
GS_EXPORT NSUInteger
|
||||
|
|
|
@ -490,8 +490,6 @@ GSPrivateSockaddrSetup(NSString *machine, uint16_t port,
|
|||
|
||||
+ (void) initialize
|
||||
{
|
||||
GSMakeWeakPointer(self, "istream");
|
||||
GSMakeWeakPointer(self, "ostream");
|
||||
}
|
||||
|
||||
+ (void) tryInput: (GSSocketInputStream*)i output: (GSSocketOutputStream*)o
|
||||
|
@ -2002,7 +2000,6 @@ setNonBlocking(SOCKET fd)
|
|||
|
||||
+ (void) initialize
|
||||
{
|
||||
GSMakeWeakPointer(self, "_sibling");
|
||||
if (self == [GSSocketInputStream class])
|
||||
{
|
||||
GSObjCAddClassBehavior(self, [GSSocketStream class]);
|
||||
|
@ -2497,7 +2494,6 @@ setNonBlocking(SOCKET fd)
|
|||
|
||||
+ (void) initialize
|
||||
{
|
||||
GSMakeWeakPointer(self, "_sibling");
|
||||
if (self == [GSSocketOutputStream class])
|
||||
{
|
||||
GSObjCAddClassBehavior(self, [GSSocketStream class]);
|
||||
|
@ -3010,7 +3006,6 @@ setNonBlocking(SOCKET fd)
|
|||
|
||||
+ (void) initialize
|
||||
{
|
||||
GSMakeWeakPointer(self, "_sibling");
|
||||
if (self == [GSSocketServerStream class])
|
||||
{
|
||||
GSObjCAddClassBehavior(self, [GSSocketStream class]);
|
||||
|
|
|
@ -141,7 +141,6 @@ static RunLoopEventType typeForStream(NSStream *aStream)
|
|||
|
||||
+ (void) initialize
|
||||
{
|
||||
GSMakeWeakPointer(self, "delegate");
|
||||
}
|
||||
|
||||
- (void) close
|
||||
|
@ -165,7 +164,7 @@ static RunLoopEventType typeForStream(NSStream *aStream)
|
|||
{
|
||||
[self close];
|
||||
}
|
||||
GSAssignZeroingWeakPointer((void**)&_delegate, (void*)0);
|
||||
_delegate = nil;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
|
@ -287,26 +286,11 @@ static RunLoopEventType typeForStream(NSStream *aStream)
|
|||
|| [self streamStatus] == NSStreamStatusError)
|
||||
{
|
||||
_delegateValid = NO;
|
||||
GSAssignZeroingWeakPointer((void**)&_delegate, (void*)0);
|
||||
_delegate = nil;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (delegate == nil)
|
||||
{
|
||||
_delegate = self;
|
||||
}
|
||||
if (delegate == self)
|
||||
{
|
||||
if (_delegate != nil && _delegate != self)
|
||||
{
|
||||
GSAssignZeroingWeakPointer((void**)&_delegate, (void*)0);
|
||||
}
|
||||
_delegate = delegate;
|
||||
}
|
||||
else
|
||||
{
|
||||
GSAssignZeroingWeakPointer((void**)&_delegate, (void*)delegate);
|
||||
}
|
||||
_delegate = (nil == delegate) ? self : delegate;
|
||||
/* We don't want to send any events the the delegate after the
|
||||
* stream has been closed.
|
||||
*/
|
||||
|
@ -787,7 +771,6 @@ static RunLoopEventType typeForStream(NSStream *aStream)
|
|||
if (self == [GSInputStream class])
|
||||
{
|
||||
GSObjCAddClassBehavior(self, [GSStream class]);
|
||||
GSMakeWeakPointer(self, "delegate");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -820,7 +803,6 @@ static RunLoopEventType typeForStream(NSStream *aStream)
|
|||
if (self == [GSOutputStream class])
|
||||
{
|
||||
GSObjCAddClassBehavior(self, [GSStream class]);
|
||||
GSMakeWeakPointer(self, "delegate");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1091,7 +1073,6 @@ static RunLoopEventType typeForStream(NSStream *aStream)
|
|||
|
||||
+ (void) initialize
|
||||
{
|
||||
GSMakeWeakPointer(self, "delegate");
|
||||
}
|
||||
|
||||
+ (id) serverStreamToAddr: (NSString*)addr port: (NSInteger)port
|
||||
|
|
|
@ -77,8 +77,7 @@ typedef GSIMapNode_t *GSIMapNode;
|
|||
#define GSI_MAP_TABLE_S instanceSize
|
||||
|
||||
#define IS_WEAK(M) \
|
||||
(memoryType(M->cb.pf.options, NSPointerFunctionsZeroingWeakMemory) \
|
||||
|| memoryType(M->cb.pf.options, NSPointerFunctionsWeakMemory))
|
||||
memoryType(M->cb.pf.options, NSPointerFunctionsWeakMemory)
|
||||
#define GSI_MAP_HASH(M, X)\
|
||||
(M->legacy ? M->cb.old.hash(M, X.ptr) \
|
||||
: pointerFunctionsHash(&M->cb.pf, X.ptr))
|
||||
|
|
|
@ -82,11 +82,9 @@ typedef GSIMapNode_t *GSIMapNode;
|
|||
#define GSI_MAP_KTYPES GSUNION_PTR | GSUNION_OBJ
|
||||
#define GSI_MAP_VTYPES GSUNION_PTR | GSUNION_OBJ
|
||||
#define IS_WEAK_KEY(M) \
|
||||
(memoryType(M->cb.pf.k.options, NSPointerFunctionsZeroingWeakMemory) \
|
||||
|| memoryType(M->cb.pf.k.options, NSPointerFunctionsWeakMemory))
|
||||
memoryType(M->cb.pf.k.options, NSPointerFunctionsWeakMemory)
|
||||
#define IS_WEAK_VALUE(M) \
|
||||
(memoryType(M->cb.pf.v.options, NSPointerFunctionsZeroingWeakMemory) \
|
||||
|| memoryType(M->cb.pf.v.options, NSPointerFunctionsWeakMemory))
|
||||
memoryType(M->cb.pf.v.options, NSPointerFunctionsWeakMemory)
|
||||
#define GSI_MAP_HASH(M, X)\
|
||||
(M->legacy ? M->cb.old.k.hash(M, X.ptr) \
|
||||
: pointerFunctionsHash(&M->cb.pf.k, X.ptr))
|
||||
|
|
|
@ -31,10 +31,8 @@
|
|||
|
||||
#if defined(OBJC_CAP_ARC)
|
||||
# include <objc/objc-arc.h>
|
||||
# define ARC_WEAK_READ(x) objc_loadWeak((id*)x)
|
||||
# define ARC_WEAK_WRITE(addr, x) objc_storeWeak((id*)addr, (id)x)
|
||||
# define WEAK_READ(x) (*x)
|
||||
# define WEAK_WRITE(addr, x) (*(addr) = x)
|
||||
# define WEAK_READ(x) objc_loadWeak((id*)x)
|
||||
# define WEAK_WRITE(addr, x) objc_storeWeak((id*)addr, (id)x)
|
||||
# define STRONG_WRITE(addr, x) objc_storeStrong((id*)addr, (id)x)
|
||||
# define STRONG_ACQUIRE(x) objc_retain(x)
|
||||
#else
|
||||
|
@ -43,12 +41,6 @@
|
|||
# define STRONG_WRITE(addr, x) ASSIGN(*((id*)addr), ((id)x))
|
||||
# define STRONG_ACQUIRE(x) RETAIN(((id)x))
|
||||
#endif
|
||||
#ifndef ARC_WEAK_WRITE
|
||||
# define ARC_WEAK_WRITE(addr, x) WEAK_WRITE(addr, x)
|
||||
#endif
|
||||
#ifndef ARC_WEAK_READ
|
||||
# define ARC_WEAK_READ(x) WEAK_READ(x)
|
||||
#endif
|
||||
|
||||
|
||||
/* Declare a structure type to copy pointer functions information
|
||||
|
@ -106,10 +98,6 @@ inline static BOOL personalityType(int options, int flag)
|
|||
static inline void *pointerFunctionsRead(PFInfo *PF, void **addr)
|
||||
{
|
||||
if (memoryType(PF->options, NSPointerFunctionsWeakMemory))
|
||||
{
|
||||
return ARC_WEAK_READ((id*)addr);
|
||||
}
|
||||
if (memoryType(PF->options, NSPointerFunctionsZeroingWeakMemory))
|
||||
{
|
||||
return WEAK_READ((id*)addr);
|
||||
}
|
||||
|
@ -122,10 +110,6 @@ static inline void *pointerFunctionsRead(PFInfo *PF, void **addr)
|
|||
static inline void pointerFunctionsAssign(PFInfo *PF, void **addr, void *value)
|
||||
{
|
||||
if (memoryType(PF->options, NSPointerFunctionsWeakMemory))
|
||||
{
|
||||
ARC_WEAK_WRITE(addr, value);
|
||||
}
|
||||
else if (memoryType(PF->options, NSPointerFunctionsZeroingWeakMemory))
|
||||
{
|
||||
WEAK_WRITE(addr, value);
|
||||
}
|
||||
|
@ -203,9 +187,7 @@ pointerFunctionsRelinquish(PFInfo *PF, void **itemptr)
|
|||
if (PF->relinquishFunction != 0)
|
||||
(*PF->relinquishFunction)(*itemptr, PF->sizeFunction);
|
||||
if (memoryType(PF->options, NSPointerFunctionsWeakMemory))
|
||||
ARC_WEAK_WRITE(itemptr, 0);
|
||||
else if (memoryType(PF->options, NSPointerFunctionsZeroingWeakMemory))
|
||||
WEAK_WRITE(itemptr, (void*)0);
|
||||
WEAK_WRITE(itemptr, 0);
|
||||
else
|
||||
*itemptr = 0;
|
||||
}
|
||||
|
@ -222,9 +204,7 @@ pointerFunctionsReplace(PFInfo *PF, void **dst, void *src)
|
|||
if (PF->relinquishFunction != 0)
|
||||
(*PF->relinquishFunction)(*dst, PF->sizeFunction);
|
||||
if (memoryType(PF->options, NSPointerFunctionsWeakMemory))
|
||||
ARC_WEAK_WRITE(dst, 0);
|
||||
else if (memoryType(PF->options, NSPointerFunctionsZeroingWeakMemory))
|
||||
WEAK_WRITE(dst, (void*)0);
|
||||
WEAK_WRITE(dst, 0);
|
||||
else
|
||||
*dst = src;
|
||||
}
|
||||
|
|
|
@ -628,7 +628,6 @@ static NSLock *cached_proxies_gate = nil;
|
|||
{
|
||||
NSNotificationCenter *nc;
|
||||
|
||||
GSMakeWeakPointer(self, "delegate");
|
||||
connectionClass = self;
|
||||
dateClass = [NSDate class];
|
||||
distantObjectClass = [NSDistantObject class];
|
||||
|
@ -2846,8 +2845,10 @@ static NSLock *cached_proxies_gate = nil;
|
|||
[tmp release];
|
||||
tmp = encoder;
|
||||
encoder = nil;
|
||||
NSDebugMLLog(@"RMC", @"RMC %d replying with %s and %u out parameters",
|
||||
seq, (YES == is_void ? "void result" : "result"), out_parameters);
|
||||
NSDebugMLLog(@"RMC", @"RMC %d replying with %s"
|
||||
@" and %u/%u in/out parameters",
|
||||
seq, (YES == is_void ? "void result" : "result"),
|
||||
in_parameters, out_parameters);
|
||||
|
||||
[self _sendOutRmc: tmp type: METHOD_REPLY sequence: seq];
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ static Class concreteClass = 0;
|
|||
+ (id) hashTableWithWeakObjects
|
||||
{
|
||||
return [self hashTableWithOptions:
|
||||
NSPointerFunctionsObjectPersonality | NSPointerFunctionsZeroingWeakMemory];
|
||||
NSPointerFunctionsObjectPersonality | NSPointerFunctionsWeakMemory];
|
||||
}
|
||||
|
||||
+ (id) weakObjectsHashTable
|
||||
|
|
|
@ -1162,8 +1162,7 @@ cifframe_callback(ffi_cif *cif, void *retp, void **args, void *user)
|
|||
if (observation == nil)
|
||||
{
|
||||
observation = [GSKVOObservation new];
|
||||
GSAssignZeroingWeakPointer((void**)&observation->observer,
|
||||
(void*)anObserver);
|
||||
observation->observer = anObserver;
|
||||
observation->context = aContext;
|
||||
observation->options = options;
|
||||
[pathInfo->observations addObject: observation];
|
||||
|
|
|
@ -486,8 +486,6 @@ static NSDictionary *makeReference(unsigned ref)
|
|||
|
||||
+ (void) initialize
|
||||
{
|
||||
GSMakeWeakPointer(self, "delegate");
|
||||
|
||||
if (globalClassMap == 0)
|
||||
{
|
||||
globalClassMap =
|
||||
|
|
|
@ -298,8 +298,6 @@ static NSMapTable *globalClassMap = 0;
|
|||
|
||||
+ (void) initialize
|
||||
{
|
||||
GSMakeWeakPointer(self, "delegate");
|
||||
|
||||
if (globalClassMap == 0)
|
||||
{
|
||||
globalClassMap =
|
||||
|
|
|
@ -80,22 +80,22 @@ static Class concreteClass = 0;
|
|||
{
|
||||
return [self mapTableWithKeyOptions: NSPointerFunctionsObjectPersonality
|
||||
valueOptions: NSPointerFunctionsObjectPersonality
|
||||
| NSPointerFunctionsZeroingWeakMemory];
|
||||
| NSPointerFunctionsWeakMemory];
|
||||
}
|
||||
|
||||
+ (id) mapTableWithWeakToStrongObjects
|
||||
{
|
||||
return [self mapTableWithKeyOptions: NSPointerFunctionsObjectPersonality
|
||||
| NSPointerFunctionsZeroingWeakMemory
|
||||
| NSPointerFunctionsWeakMemory
|
||||
valueOptions: NSPointerFunctionsObjectPersonality];
|
||||
}
|
||||
|
||||
+ (id) mapTableWithWeakToWeakObjects
|
||||
{
|
||||
return [self mapTableWithKeyOptions: NSPointerFunctionsObjectPersonality
|
||||
| NSPointerFunctionsZeroingWeakMemory
|
||||
| NSPointerFunctionsWeakMemory
|
||||
valueOptions: NSPointerFunctionsObjectPersonality
|
||||
| NSPointerFunctionsZeroingWeakMemory];
|
||||
| NSPointerFunctionsWeakMemory];
|
||||
}
|
||||
|
||||
+ (id) strongToStrongObjectsMapTable
|
||||
|
|
|
@ -70,8 +70,6 @@ static Class NSPort_concrete_class;
|
|||
{
|
||||
NSUserDefaults *defs;
|
||||
|
||||
GSMakeWeakPointer(self, "delegate");
|
||||
|
||||
NSPort_abstract_class = self;
|
||||
NSPort_concrete_class = [NSMessagePort class];
|
||||
|
||||
|
|
|
@ -1861,8 +1861,6 @@ NSLog(@"_processTag <%@%@ %@>", flag?@"/": @"", tag, attributes);
|
|||
|
||||
+ (void) initialize
|
||||
{
|
||||
GSMakeWeakPointer(self, "_delegate");
|
||||
GSMakeWeakPointer(self, "_owner");
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
|
|
|
@ -1754,23 +1754,6 @@ GSAtomicMallocZone (void)
|
|||
return &default_zone;
|
||||
}
|
||||
|
||||
GS_DECLARE void
|
||||
GSMakeWeakPointer(Class theClass, const char *iVarName)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GS_DECLARE BOOL
|
||||
GSAssignZeroingWeakPointer(void **destination, void *source)
|
||||
{
|
||||
if (destination == 0)
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
*destination = source;
|
||||
return YES;
|
||||
}
|
||||
|
||||
GS_DECLARE void*
|
||||
NSZoneMalloc (NSZone *zone, NSUInteger size)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue