Replaced IF_NO_GC() macro calls with the more descriptive IF_NO_ARC()

and deprecate it.  Searched for and removed obsolete references to
garbage collection in comments and documentation.
This commit is contained in:
Richard Frith-Macdonald 2022-02-17 10:08:18 +00:00
parent 6837924e60
commit c76ebf2962
61 changed files with 384 additions and 313 deletions

126
ChangeLog
View file

@ -1,3 +1,69 @@
2022-02-17 Richard Frith-Macdonald <rfm@gnu.org>
* Documentation/manual/BaseLibrary.texi:
* Documentation/manual/WorkingWithObjects.texi:
* Documentation/manual/WritingNewClasses.texi:
* Headers/Foundation/NSGarbageCollector.h:
* Headers/Foundation/NSObject.h:
* Headers/GNUstepBase/GNUstep.h:
* Source/Additions/GSInsensitiveDictionary.m:
* Source/Additions/GSMime.m:
* Source/Additions/GSXML.m:
* Source/Additions/NSData+GNUstepBase.m:
* Source/GSArray.m:
* Source/GSDictionary.m:
* Source/GSFFIInvocation.m:
* Source/GSFTPURLHandle.m:
* Source/GSHTTPAuthentication.m:
* Source/GSInternal.h:
* Source/GSInvocation.h:
* Source/GSSocketStream.m:
* Source/NSArray.m:
* Source/NSAttributedString.m:
* Source/NSBundle.m:
* Source/NSCallBacks.m:
* Source/NSClassDescription.m:
* Source/NSConnection.m:
* Source/NSData.m:
* Source/NSDateFormatter.m:
* Source/NSDistantObject.m:
* Source/NSFileHandle.m:
* Source/NSHost.m:
* Source/NSInvocation.m:
* Source/NSKeyValueObserving.m:
* Source/NSKeyedUnarchiver.m:
* Source/NSMessagePort.m:
* Source/NSMessagePortNameServer.m:
* Source/NSNotificationCenter.m:
* Source/NSNumberFormatter.m:
* Source/NSObject.m:
* Source/NSPortCoder.m:
* Source/NSProcessInfo.m:
* Source/NSRunLoop.m:
* Source/NSScanner.m:
* Source/NSSerializer.m:
* Source/NSSet.m:
* Source/NSSocketPort.m:
* Source/NSSocketPortNameServer.m:
* Source/NSSpellServer.m:
* Source/NSString.m:
* Source/NSTask.m:
* Source/NSTimeZone.m:
* Source/NSURL.m:
* Source/NSURLHandle.m:
* Source/NSURLProtocol.m:
* Source/NSURLResponse.m:
* Source/NSUnarchiver.m:
* Source/NSValueTransformer.m:
* Tools/AGSOutput.m:
* Tools/AGSParser.m:
* Tools/HTMLLinker.m:
* Tools/autogsdoc.m:
* Tools/sfparse.m:
Replaced IF_NO_GC() macro calls with the more descriptive IF_NO_ARC()
and deprecate it. Searched for and removed obsolete references to
garbage collection in comments and documentation.
2022-02-12 Richard Frith-Macdonald <rfm@gnu.org>
* Headers/Foundation/NSExpression.h:
@ -19,6 +85,66 @@
2022-01-30 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSPredicate.m:
* Documentation/manual/BaseLibrary.texi:
* Documentation/manual/WorkingWithObjects.texi:
* Documentation/manual/WritingNewClasses.texi:
* Headers/Foundation/NSGarbageCollector.h:
* Headers/Foundation/NSObject.h:
* Headers/GNUstepBase/GNUstep.h:
* Source/Additions/GSInsensitiveDictionary.m:
* Source/Additions/GSMime.m:
* Source/Additions/GSXML.m:
* Source/Additions/NSData+GNUstepBase.m:
* Source/GSArray.m:
* Source/GSDictionary.m:
* Source/GSFFIInvocation.m:
* Source/GSFTPURLHandle.m:
* Source/GSHTTPAuthentication.m:
* Source/GSInternal.h:
* Source/GSInvocation.h:
* Source/GSSocketStream.m:
* Source/NSArray.m:
* Source/NSAttributedString.m:
* Source/NSBundle.m:
* Source/NSCallBacks.m:
* Source/NSClassDescription.m:
* Source/NSConnection.m:
* Source/NSData.m:
* Source/NSDateFormatter.m:
* Source/NSDistantObject.m:
* Source/NSFileHandle.m:
* Source/NSHost.m:
* Source/NSInvocation.m:
* Source/NSKeyValueObserving.m:
* Source/NSKeyedUnarchiver.m:
* Source/NSMessagePort.m:
* Source/NSMessagePortNameServer.m:
* Source/NSNotificationCenter.m:
* Source/NSNumberFormatter.m:
* Source/NSObject.m:
* Source/NSPortCoder.m:
* Source/NSProcessInfo.m:
* Source/NSRunLoop.m:
* Source/NSScanner.m:
* Source/NSSerializer.m:
* Source/NSSet.m:
* Source/NSSocketPort.m:
* Source/NSSocketPortNameServer.m:
* Source/NSSpellServer.m:
* Source/NSString.m:
* Source/NSTask.m:
* Source/NSTimeZone.m:
* Source/NSURL.m:
* Source/NSURLHandle.m:
* Source/NSURLProtocol.m:
* Source/NSURLResponse.m:
* Source/NSUnarchiver.m:
* Source/NSValueTransformer.m:
* Tools/AGSOutput.m:
* Tools/AGSParser.m:
* Tools/HTMLLinker.m:
* Tools/autogsdoc.m:
* Tools/sfparse.m:
Fix for git #233 by Larry Campbell
2022-01-15 Frederik Seiffert <frederik@algoriddim.com>

View file

@ -950,13 +950,9 @@ to be of general utility by the GNUstep developers. The library is designed
so that it can be built and installed on a system, such as OS X, where GNUstep
is not available but an alternate Foundation implementation is.
It contains the following five categories of classes:
It contains the following categories of classes:
@table @code
@item GCxxx
These are classes that are substituted (behind the scenes) for certain
Foundation classes if the Base library is compiled with garbage collection
enabled. (See @ref{Objects, , Memory Management}.)
@item GSXMLxxx
Classes for parsing XML using DOM- or SAX-like APIs, for processing XPath

View file

@ -180,18 +180,9 @@ pools which provide a degree of automated memory management. This gives
a good degree of control over memory management, but requires some care
in following simple rules. It's pretty efficient.
@item Garbage collection@*
You build the GNUstep base library with garbage collection, and link
with the Boehm GC library @dots{} then never bother about
releasing/deallocating memory. This requires a slightly different
approach to programming @dots{} you need to take care about what happens
when objects are deallocated @dots{} but don't need to worry about
deallocating them.
@end itemize
The recommended approach is to use some standard macros defined in
@code{NSObject.h} which encapsulate the retain/release/autorelease mechanism,
but which permit efficient use of the garbage collection system if you build
but which permit efficient use of Automated reference Counts (ARC) if you build
your software with that. We will justify this recommendation after describing
the three alternatives in greater detail.
@ -481,34 +472,14 @@ Special examples: delegate, target
@end ignore
@subsection Garbage Collection Based Memory Management
@cindex memory management, garbage collection based
@cindex garbage collection
@subsection ObjC-2 and Automated Reference Counting
@cindex ObjC-2 , automated reference counting
@cindex ARC
The GNUstep system can be optionally compiled with a memory sweeping
@b{garbage collection} mechanism using the Boehm conservative garbage
collection library (@url{http://www.hpl.hp.com/personal/Hans_Boehm/gc}).
In this case, you need not worry about retaining and releasing objects; the
garbage collector will automatically track which objects are still referred to
at any given point within the program, and which are not. Those that are not
are automatically deallocated. The situation is largely similar to
programming in Java, except that garbage collection will only be triggered
during memory allocation requests and will be less efficient since pointers
in C are not always explicitly marked.
Whether in Java or Objective-C, life is still not completely worry-free under
garbage collection however. You still must ``help the garbage collector
along'' by explicitly dropping references to objects when they become
unneeded. Failing to do this is easier than you might think, and leads to
memory leaks.
When GNUstep was compiled with garbage collection, the macro flag
@code{GS_WITH_GC} will be defined, which you can use in programs to determine
whether you need to call @code{retain}, @code{release}, etc.. Rather than
doing this manually, however, you may use special macros in place of the
@code{retain} and @code{release} method calls. These macros call the methods
in question when garbage collection is @i{not} available, but do nothing when
it is.
When using a compiler and runtime supporting ObjC-2 and ARC, the reference
counting for objects is handled by the compiler. To enable easy development
(to ObjC-1) code, a number of macros are provided which encapsulate the
manual reference counting required when ARC is not available.
@multitable @columnfractions 0.25 0.75
@item Macro @tab Functionality
@ -528,31 +499,29 @@ it is.
@item @code{ASSIGNCOPY(foo, bar);}
@tab @code{[foo release]; foo = [bar copy];}
@item @code{ASSIGNMUTABLECOPY(foo, bar);}
@tab @code{[foo release]; foo = [bar mutableCopy];}
@item @code{DESTROY(foo);}
@tab @code{[foo release]; foo = nil;}
@item @code{ENTER_POOL}
@tab Like @@autoreleasepool this introduces a code block with a manually created autorelease pool.
@item @code{LEAVE_POOL}
@tab This ends a block created by an ENTER_POOL destroying the autorelease pool created at the start of the block
@item @code{DEALLOC}
@tab @code{[super dealloc];}
@item @code{IF_NO_ARC(...)}
@tab Code to be compiled only if ARC is not in use
@end multitable
In the latter three ``convenience'' macros, appropriate @code{nil} checks are
In the assignment ``convenience'' macros, appropriate @code{nil} checks are
made so that no retain/release messages are sent to @code{nil}.
Some authorities recommend that you always use the RETAIN/RELEASE macros in
place of the actual method calls, in order to allow running in a non-garbage
collecting GNUstep environment yet also save unneeded method calls in the case
your code runs in a garbage collecting enviromnent. On the other hand, if you
know you are always going to be running in a non-garbage collecting
environment, there is no harm in using the method calls, and if you know you
will always have garbage collection available you can save development effort
by avoiding any use of retain/release or RETAIN/RELEASE.
@subsection Current Recommendations
As of May 2004 the garbage collection in GNUstep was still considered beta
quality (some bugs exist). In the OS X world, Apple's Cocoa does @i{not}
employ garbage collection, and it is not clear whether there are plans to
implement it. Therefore the majority of GNUstep programmers use the
RETAIN/RELEASE approach to memory management.
@page

View file

@ -597,13 +597,13 @@ is not always possible given other design constraints.
@subsection Instance Deallocation
As described in @ref{Objects, the previous chapter, Memory Management},
objects should be deallocated when they are no longer needed. When garbage
collection is not being used, this is done through explicit calls to the
@code{dealloc} method. When GC @i{is} being used, @code{dealloc} is still
objects should be deallocated when they are no longer needed. When ARC
is not being used, this is done through explicit calls to the
@code{dealloc} method. When ARC @i{is} being used, @code{dealloc} is still
called implicitly, and should be implemented. However the tasks of the
@code{dealloc} method are fewer in this case.
When garbage collection is @i{not} active, the @code{dealloc} method must
When ARC is @i{not} used, the @code{dealloc} method must
release all other objects that this instance has retained. Usually these are
those instance variables that are objects rather than primitive types. In
certain cases such as container classes, other objects must be released as
@ -612,17 +612,12 @@ as a network connection or open file descriptor, these should be relinquished
as well. Likewise, any memory that has been directly allocated through use
of @code{malloc} or other functions should be released.
When garbage collection @i{is} active, the @code{dealloc} method is still
responsible to relinquish external resources, but other GNUstep objects need
not be released, since they will be garbage collected once this instance has
been.
When ARC @i{is} active, the @code{dealloc} method is still
responsible to relinquish external resources, but other GNUstep objects must
not be released, since they will be managed by ARC.
If you cannot be sure whether your class will be running in a
garbage-collecting environment, it never hurts to execute all of the releases
of other objects. This will not harm the operation of the garbage collector,
though it will result in pointless calls to the retain/release methods that
are stubbed out under garbage collection. If this could cause a performance
hit in your application, you should use the RETAIN/RELEASE macros instead of
If you cannot be sure whether your class will be running in an ARC
environment, you should use the RETAIN/RELEASE macros instead of
the function calls.
Here is an example of a @code{dealloc} implementation:
@ -632,7 +627,7 @@ Here is an example of a @code{dealloc} implementation:
@{
RELEASE(anInstanceVariableObject);
NSZoneFree(NULL, myMemory);
[super dealloc];
DEALLOC
@}
@end example
@ -643,10 +638,11 @@ discussion of GNUstep's raw memory allocation functions.) The @code{NULL}
used indicates that the memory was from the default zone, and is equivalent
to saying '@code{NSDefaultMallocZone()}' instead.
Finally, notice we end with a call to @code{[super dealloc]}. This should
always be done in @code{dealloc} implementations, and you should never
concern yourself with deallocating structures that are associated with a
superclass, since it will take care of this itself.
Finally, notice we end with the DEALLOC macro to call the superclass
implementation (but not for ARC). This should always be done in @code{dealloc}
implementations, and you should never concern yourself with deallocating
structures that are associated with a superclass, since it will take care
of this itself.
@section Protocols

View file

@ -41,58 +41,43 @@ extern "C" {
GS_EXPORT_CLASS
@interface NSGarbageCollector : NSObject
/** Returns the garbage collector instance ... there is only one.<br />
* Returns nil if the process is not using garbage collection.
/** Obsolete ... returns nil because garbage collection no longer exists.
*/
+ (id) defaultCollector;
/** Collects some memory.
/** Obsolete ... does nothing because garbage collection no longer exists.
*/
- (void) collectIfNeeded;
/** Collects all collectable memory.
/** Obsolete ... does nothing because garbage collection no longer exists.
*/
- (void) collectExhaustively;
/** Disables garbage collection until a corresponding call to -enable is made.
* NB. Calls to this method stack, and must be matched by the same number of
* calls to the -enable method.
/** Obsolete ... does nothing because garbage collection no longer exists.
*/
- (void) disable;
/** Makes the area of memory pointed at be uncollectable ... that is to say,
* the memory will not be collected by the garbage collector. You must not
* explicitly free this memory unless you re-enable collection first.<br />
* Calls to this method do not stack, so callig it multiple times for the
* same pointer has the same effect as calling it once.
/** Obsolete ... does nothing because garbage collection no longer exists.
*/
- (void) disableCollectorForPointer: (void *)ptr;
/** Enables garbage collection prevously disabled by a call to the
* -disable method. Since calls to -disable stack, you must make as
* many calls to -enable as to -disable in order to re-start collection.
/** Obsolete ... does nothing because garbage collection no longer exists.
*/
- (void) enable;
/** Enables collection for the area of memory pointed at, which must have
* previously been made uncollectable by a call to the
* -disableCollectorForPointer: method.
/** Obsolete ... does nothing because garbage collection no longer exists.
*/
- (void) enableCollectorForPointer: (void *)ptr;
/** Returns yes if there is a garbage collection progress.
/** Obsolete ... returns NO because garbage collection no longer exists.
*/
- (BOOL) isCollecting;
/** Retunrs YES if garbage collecting is currently enabled.
/** Obsolete ... returns NO because garbage collection no longer exists.
*/
- (BOOL) isEnabled;
/** Returns a zone for holding non-collectable pointers.<br />
* Memory allocated in this zone will not be seen by the garbage collector
* and will never be collected (so it needs to be freed explicitly).
* The presence of pointers from the memory to other objects will not
* prevent those other objects from being collected.
/** Returns the default zone.
*/
- (NSZone*) zone;
@end

View file

@ -31,11 +31,6 @@
#import <objc/objc.h>
#import <Foundation/NSZone.h>
#ifdef GS_WITH_GC
#undef GS_WITH_GC
#endif
#define GS_WITH_GC 0
#import <GNUstepBase/GNUstep.h>
#if defined(__cplusplus)

View file

@ -52,6 +52,12 @@
# define __has_attribute(x) 0
#endif
/* This set of macros is provided to make it relatively simple to write
* code which works both when compiled with an ObjC-2 compiler and ARC
* or with an ObjC-1 compiler with manual retain counting.
* In essence, it conditionally compiles all the operations where manual
* retain count management is needed if ARC is not in use.
*/
#if __has_feature(objc_arc)
#ifndef RETAIN
@ -83,11 +89,14 @@
#ifndef ASSIGNMUTABLECOPY
#define ASSIGNMUTABLECOPY(object,value) object = [(value) mutableCopy]
#endif
#ifndef DESTROY
#define DESTROY(object) object = nil
#endif
#define IF_NO_GC(X)
#ifndef DEALLOC
#define DEALLOC
#endif
#ifndef ENTER_POOL
#define ENTER_POOL @autoreleasepool{
@ -97,8 +106,11 @@
#define LEAVE_POOL }
#endif
#ifndef DEALLOC
#define DEALLOC
#ifndef IF_NO_ARC
#define IF_NO_ARC(X)
#endif
#ifndef IF_NO_GC
#define IF_NO_GC(X)
#endif
#else
@ -214,7 +226,13 @@ void *__object = (void*)(object);\
})
#endif
#define IF_NO_GC(X) X
#ifndef DEALLOC
/**
* DEALLOC calls the superclass implementation of dealloc, unless
* ARC is in use (in which case it does nothing).
*/
#define DEALLOC [super dealloc];
#endif
#ifndef ENTER_POOL
/**
@ -238,13 +256,21 @@ void *__object = (void*)(object);\
#define LEAVE_POOL [_lARP drain];}
#endif
#ifndef DEALLOC
#ifndef IF_NO_ARC
/**
* DEALLOC calls the superclass implementation of dealloc, unless
* ARC is in use (in which case it does nothing).
* Compile-in X if (and only if) ARC is not in use. This is provided
* to handle obscure cases not covered by the other macros.
*/
#define DEALLOC [super dealloc];
#define IF_NO_ARC(X) X
#endif
#ifndef IF_NO_GC
/**
* DEPRECATED ... use IF_NO_ARC() instead.
*/
#define IF_NO_GC(X) X
#endif
#endif
#ifndef CREATE_AUTORELEASE_POOL
@ -265,6 +291,11 @@ void *__object = (void*)(object);\
#endif
/**
* <p>
* This function (macro) is a GNUstep extension.

View file

@ -198,7 +198,7 @@ static SEL objSel;
node = GSIMapNodeForKey(&map, (GSIMapKey)(id)keys[i]);
if (node)
{
IF_NO_GC(RETAIN(objs[i]));
IF_NO_ARC(RETAIN(objs[i]));
RELEASE(node->value.obj);
node->value.obj = objs[i];
}
@ -428,7 +428,7 @@ static SEL objSel;
node = GSIMapNodeForKey(&map, (GSIMapKey)aKey);
if (node)
{
IF_NO_GC(RETAIN(anObject));
IF_NO_ARC(RETAIN(anObject));
RELEASE(node->value.obj);
node->value.obj = anObject;
}

View file

@ -881,7 +881,7 @@ wordData(NSString *word, BOOL *encoded)
if ([parser isComplete] == YES)
{
newDocument = [parser mimeDocument];
IF_NO_GC(RETAIN(newDocument);)
IF_NO_ARC(RETAIN(newDocument);)
}
RELEASE(parser);
return AUTORELEASE(newDocument);
@ -2412,7 +2412,7 @@ NSDebugMLLog(@"GSMime", @"Header parsed - %@", info);
expect = 0;
}
context = [self contextFor: hdr];
IF_NO_GC([context retain];)
IF_NO_ARC([context retain];)
NSDebugMLLog(@"GSMime", @"Parse body expects %u bytes", expect);
}
@ -4749,7 +4749,7 @@ appendString(NSMutableData *m, NSUInteger offset, NSUInteger fold,
tmp = [[NSString alloc] initWithBytes: buffer
length: buflen
encoding: NSASCIIStringEncoding];
IF_NO_GC([tmp autorelease];)
IF_NO_ARC([tmp autorelease];)
return [tmp lowercaseString];
}
buflen = 0;
@ -4977,7 +4977,7 @@ appendString(NSMutableData *m, NSUInteger offset, NSUInteger fold,
{
r = [NSStringClass allocWithZone: NSDefaultMallocZone()];
r = [r initWithData: d encoding: NSUTF8StringEncoding];
IF_NO_GC([r autorelease];)
IF_NO_ARC([r autorelease];)
}
return r;
}
@ -5038,7 +5038,7 @@ appendString(NSMutableData *m, NSUInteger offset, NSUInteger fold,
{
r = [NSStringClass allocWithZone: NSDefaultMallocZone()];
r = [r initWithData: d encoding: NSASCIIStringEncoding];
IF_NO_GC([r autorelease];)
IF_NO_ARC([r autorelease];)
}
return r;
}
@ -6312,7 +6312,7 @@ appendString(NSMutableData *m, NSUInteger offset, NSUInteger fold,
}
s = [NSStringClass allocWithZone: NSDefaultMallocZone()];
s = [s initWithData: content encoding: enc];
IF_NO_GC([s autorelease];)
IF_NO_ARC([s autorelease];)
}
return s;
}
@ -7381,7 +7381,7 @@ appendString(NSMutableData *m, NSUInteger offset, NSUInteger fold,
hdr = [hdr initWithName: @"Content-Type" value: val parameters: nil];
[hdr setObject: type forKey: @"Type"];
[hdr setObject: subtype forKey: @"Subtype"];
IF_NO_GC([hdr autorelease];)
IF_NO_ARC([hdr autorelease];)
}
else
{

View file

@ -4134,7 +4134,7 @@ fatalErrorFunction(void *ctx, const unsigned char *msg, ...)
else
{
result = [GSXPathObject _newWithNativePointer: res context: self];
IF_NO_GC ([result autorelease];)
IF_NO_ARC ([result autorelease];)
}
xmlXPathFreeCompExpr (comp);
@ -4368,7 +4368,7 @@ static BOOL warned = NO; if (warned == NO) { warned = YES; NSLog(@"WARNING, use
newdoc = [newdoc _initFrom: res
parent: self
ownsLib: YES];
IF_NO_GC([newdoc autorelease];)
IF_NO_ARC([newdoc autorelease];)
}
}
/*
@ -4672,7 +4672,7 @@ GS_EXPORT_CLASS
}
self = [[NSString alloc] initWithCharacters: to length: output];
NSZoneFree (NSDefaultMallocZone (), to);
IF_NO_GC([self autorelease];)
IF_NO_ARC([self autorelease];)
}
else
{

View file

@ -865,7 +865,7 @@ static void MD5Transform (uint32_t buf[4], uint32_t const in[16])
d = [NSData dataWithBytes: &bytes[off] length: end - off];
name = [[NSString alloc] initWithData: d
encoding: NSASCIIStringEncoding];
IF_NO_GC(AUTORELEASE(name);)
IF_NO_ARC(AUTORELEASE(name);)
if (namePtr != 0)
{
*namePtr = name;

View file

@ -44,10 +44,6 @@ static SEL oaiSel;
static Class GSInlineArrayClass;
/* This class stores objects inline in data beyond the end of the instance.
* However, when GC is enabled the object data is typed, and all data after
* the end of the class is ignored by the garbage collector (which would
* mean that objects in the array could be collected).
* We therefore do not provide the class when GC is being used.
*/
@interface GSInlineArray : GSArray
{
@ -968,7 +964,7 @@ static Class GSInlineArrayClass;
if ((self = [super init]) != nil)
{
array = anArray;
IF_NO_GC(RETAIN(array));
IF_NO_ARC(RETAIN(array));
pos = 0;
}
return self;

View file

@ -213,7 +213,7 @@ static SEL objSel;
node = GSIMapNodeForKey(&map, (GSIMapKey)(id)keys[i]);
if (node)
{
IF_NO_GC(RETAIN(objs[i]));
IF_NO_ARC(RETAIN(objs[i]));
RELEASE(node->value.obj);
node->value.obj = objs[i];
}
@ -451,7 +451,7 @@ static SEL objSel;
node = GSIMapNodeForKey(&map, (GSIMapKey)aKey);
if (node)
{
IF_NO_GC(RETAIN(anObject));
IF_NO_ARC(RETAIN(anObject));
RELEASE(node->value.obj);
node->value.obj = anObject;
}

View file

@ -607,7 +607,7 @@ GSFFIInvocationCallback(ffi_cif *cif, void *retp, void **args, void *user)
values: args
frame: user
signature: sig];
IF_NO_GC([invocation autorelease];)
IF_NO_ARC([invocation autorelease];)
[invocation setTarget: obj];
[invocation setSelector: selector];

View file

@ -528,7 +528,7 @@ static NSLock *urlLock = nil;
// NSLog(@"Lookup for handle for '%@'", page);
[urlLock lock];
obj = [urlCache objectForKey: page];
IF_NO_GC([[obj retain] autorelease];)
IF_NO_ARC([[obj retain] autorelease];)
[urlLock unlock];
// NSLog(@"Found handle %@", obj);
}
@ -763,7 +763,7 @@ static NSLock *urlLock = nil;
dHandle = [NSFileHandle
fileHandleAsClientInBackgroundAtAddress: h service: p
protocol: @"tcp"];
IF_NO_GC([dHandle retain];)
IF_NO_ARC([dHandle retain];)
nc = [NSNotificationCenter defaultCenter];
[nc addObserver: self
selector: @selector(_data:)

View file

@ -142,7 +142,7 @@ static GSMimeParser *mimeParser = nil;
RELEASE(authentication);
}
}
IF_NO_GC([[authentication retain] autorelease];)
IF_NO_ARC([[authentication retain] autorelease];)
}
NS_HANDLER
{

View file

@ -46,9 +46,7 @@
* public header, but as an opaque private instance variable, while macros
* from this file allow the actual memory to be accessed either as a private
* class. The use of a private class rather than simple heap memory is
* necessary for garbage collection... the runtime is able to ensure that
* garbage collection works properly for the instance variables in the
* private class.
* necessary for automatic reference counting.
*
* Before including the header file containing the public class declaration,
* you must define GS_X_IVARS (where X is the class name) to be the

View file

@ -83,7 +83,7 @@ do {\
}\
} while (0)
#define RETAIN_RETURN_VALUE IF_NO_GC(do { if (*_inf[0].type == _C_ID) RETAIN (*(id*) _retval);} while (0))
#define RETAIN_RETURN_VALUE IF_NO_ARC(do { if (*_inf[0].type == _C_ID) RETAIN (*(id*) _retval);} while (0))
#define _inf ((NSArgumentInfo*)_info)

View file

@ -2173,7 +2173,7 @@ setNonBlocking(SOCKET fd)
int result;
socklen_t len = sizeof(error);
IF_NO_GC([[self retain] autorelease];)
IF_NO_ARC([[self retain] autorelease];)
[self _unschedule];
result = getsockopt([self _sock], SOL_SOCKET, SO_ERROR,
&error, (OPTLEN*)&len);
@ -2633,7 +2633,7 @@ setNonBlocking(SOCKET fd)
socklen_t len = sizeof(error);
int result;
IF_NO_GC([[self retain] autorelease];)
IF_NO_ARC([[self retain] autorelease];)
[self _schedule];
result = getsockopt((intptr_t)_loopID, SOL_SOCKET, SO_ERROR,
&error, (OPTLEN*)&len);

View file

@ -2658,7 +2658,7 @@ compare(id elem1, id elem2, void* context)
if (self != nil)
{
array = anArray;
IF_NO_GC(RETAIN(array));
IF_NO_ARC(RETAIN(array));
pos = 0;
get = [array methodForSelector: oaiSel];
cnt = (NSUInteger (*)(NSArray*, SEL))[array methodForSelector: countSel];

View file

@ -716,7 +716,7 @@ appendUIntData(NSMutableData *d, NSUInteger i)
RELEASE(m);
}
IF_NO_GC(AUTORELEASE(newAttrString));
IF_NO_ARC(AUTORELEASE(newAttrString));
return newAttrString;
}
@ -894,7 +894,7 @@ appendUIntData(NSMutableData *d, NSUInteger i)
newDict = (*initDictImp)(newDict, initDictSel, attrDict);
(*setDictImp)(newDict, setDictSel, value, name);
(*setImp)(self, setSel, newDict, effectiveRange);
IF_NO_GC((*relDictImp)(newDict, relDictSel));
IF_NO_ARC((*relDictImp)(newDict, relDictSel));
if (NSMaxRange(effectiveRange) >= NSMaxRange(aRange))
{
@ -954,7 +954,7 @@ appendUIntData(NSMutableData *d, NSUInteger i)
newDict = (*initDictImp)(newDict, initDictSel, attrDict);
(*addDictImp)(newDict, addDictSel, attributes);
(*setImp)(self, setSel, newDict, effectiveRange);
IF_NO_GC((*relDictImp)(newDict, relDictSel));
IF_NO_ARC((*relDictImp)(newDict, relDictSel));
if (NSMaxRange(effectiveRange) >= NSMaxRange(aRange))
{
@ -1003,7 +1003,7 @@ appendUIntData(NSMutableData *d, NSUInteger i)
newDict = (*initDictImp)(newDict, initDictSel, attrDict);
(*remDictImp)(newDict, remDictSel, name);
(*setImp)(self, setSel, newDict, effectiveRange);
IF_NO_GC((*relDictImp)(newDict, relDictSel));
IF_NO_ARC((*relDictImp)(newDict, relDictSel));
if (NSMaxRange(effectiveRange) >= NSMaxRange(aRange))
{

View file

@ -388,7 +388,7 @@ GSPrivateExecutablePath()
executablePath = [executablePath stringByResolvingSymlinksInPath];
executablePath = [executablePath stringByStandardizingPath];
}
IF_NO_GC([executablePath retain];)
IF_NO_ARC([executablePath retain];)
beenHere = YES;
}
[load_lock unlock];
@ -1627,7 +1627,7 @@ _bundle_load_callback(Class theClass, struct objc_category *theCategory)
if (_byIdentifier)
{
bundle = (NSBundle *)NSMapGet(_byIdentifier, identifier);
IF_NO_GC(
IF_NO_ARC(
[bundle retain]; /* retain - look as if we were alloc'ed */
)
}
@ -1720,7 +1720,7 @@ IF_NO_GC(
bundle = (NSBundle *)NSMapGet(_bundles, path);
if (bundle != nil)
{
IF_NO_GC([bundle retain];)
IF_NO_ARC([bundle retain];)
[load_lock unlock];
[self dealloc];
return bundle;
@ -1770,7 +1770,7 @@ IF_NO_GC(
{
if (bundle != nil)
{
IF_NO_GC([bundle retain];)
IF_NO_ARC([bundle retain];)
[load_lock unlock];
[self dealloc];
return bundle;
@ -1800,7 +1800,7 @@ IF_NO_GC(
* dynamically loaded code, so we want to prevent a bundle
* being loaded twice.
*/
IF_NO_GC([self retain];)
IF_NO_ARC([self retain];)
return;
}
if (_path != nil)
@ -2023,7 +2023,7 @@ IF_NO_GC(
We need it to answer calls like bundleForClass:; also, users
normally want all loaded bundles to appear when they call
+allBundles. */
IF_NO_GC([self retain];)
IF_NO_ARC([self retain];)
classNames = [NSMutableArray arrayWithCapacity: [_bundleClasses count]];
classEnumerator = [_bundleClasses objectEnumerator];

View file

@ -152,7 +152,7 @@ _NS_id_is_equal(void *table, id <NSObject> o, id <NSObject> p)
void
_NS_id_retain(void *table, id <NSObject> o)
{
IF_NO_GC(RETAIN(o));
IF_NO_ARC(RETAIN(o));
return;
}

View file

@ -75,7 +75,7 @@ static NSMapTable *classMap;
object: aClass];
description = NSMapGet(classMap, aClass);
}
IF_NO_GC([description retain];)
IF_NO_ARC([description retain];)
[mapLock unlock];
return AUTORELEASE(description);

View file

@ -379,7 +379,7 @@ existingConnection(NSPort *receivePort, NSPort *sendPort)
* We don't want this connection to be destroyed by another thread
* between now and when it's returned from this function and used!
*/
IF_NO_GC([[c retain] autorelease];)
IF_NO_ARC([[c retain] autorelease];)
break;
}
}
@ -467,7 +467,7 @@ static NSLock *cached_proxies_gate = nil;
{
c = [self allocWithZone: NSDefaultMallocZone()];
c = [c initWithReceivePort: r sendPort: s];
IF_NO_GC([c autorelease];)
IF_NO_ARC([c autorelease];)
}
return c;
}
@ -1259,7 +1259,7 @@ static NSLock *cached_proxies_gate = nil;
*/
[self setRequestMode: nil];
IF_NO_GC(RETAIN(self);)
IF_NO_ARC(RETAIN(self);)
if (debug_connection)
{
@ -3522,7 +3522,7 @@ static NSLock *cached_proxies_gate = nil;
node = GSIMapNodeForKey(IlocalTargets, (GSIMapKey)(NSUInteger)target);
NSAssert(node == 0, NSInternalInconsistencyException);
IF_NO_GC([anObj retain];)
IF_NO_ARC([anObj retain];)
GSIMapAddPair(IlocalObjects, (GSIMapKey)object, (GSIMapVal)((id)anObj));
GSIMapAddPair(IlocalTargets,
(GSIMapKey)(NSUInteger)target, (GSIMapVal)((id)anObj));

View file

@ -1826,7 +1826,7 @@ failure:
{
att = [[mgr fileAttributesAtPath: path
traverseLink: YES] mutableCopy];
IF_NO_GC(AUTORELEASE(att));
IF_NO_ARC(AUTORELEASE(att));
}
/* To replace the existing file on windows, it must be writable.
@ -2083,7 +2083,7 @@ failure:
{
NSMutableDictionary *mAtt = [att mutableCopy];
IF_NO_GC(AUTORELEASE(mAtt));
IF_NO_ARC(AUTORELEASE(mAtt));
/*
* We have created a new file - so we attempt to make it's
* attributes match that of the original.

View file

@ -132,11 +132,11 @@ static NSDateFormatterBehavior _defaultBehavior = 0;
{
NSDateFormatter *o = (id)NSCopyObject(self, 0, zone);
IF_NO_GC(RETAIN(o->_dateFormat));
IF_NO_ARC(RETAIN(o->_dateFormat));
if (0 != internal)
{
GS_COPY_INTERNAL(o, zone)
IF_NO_GC(RETAIN(GSIVar(o,_locale));)
IF_NO_ARC(RETAIN(GSIVar(o,_locale));)
#if GS_USE_ICU == 1
{
UErrorCode err = U_ZERO_ERROR;

View file

@ -836,7 +836,7 @@ GS_ROOT_CLASS @interface GSDistantObjectPlaceHolder
}
/**
* Used by the garbage collection system to tidy up when a proxy is destroyed.
* Used to tidy up when a proxy is destroyed.
*/
- (void) finalize
{

View file

@ -745,7 +745,7 @@ static Class NSFileHandle_ssl_class = nil;
{
NSRunLoop *loop;
IF_NO_GC([self retain];) // Don't get destroyed during runloop
IF_NO_ARC([self retain];) // Don't get destroyed during runloop
loop = [NSRunLoop currentRunLoop];
[loop runUntilDate: [NSDate dateWithTimeIntervalSinceNow: 0.01]];
if (NO == [self sslHandshakeEstablished: &result outgoing: NO])
@ -789,7 +789,7 @@ static Class NSFileHandle_ssl_class = nil;
{
NSRunLoop *loop;
IF_NO_GC([self retain];) // Don't get destroyed during runloop
IF_NO_ARC([self retain];) // Don't get destroyed during runloop
loop = [NSRunLoop currentRunLoop];
[loop runUntilDate: [NSDate dateWithTimeIntervalSinceNow: 0.01]];
if (NO == [self sslHandshakeEstablished: &result outgoing: YES])

View file

@ -446,7 +446,7 @@ myHostName()
* with ALL the IP addresses of any interfaces on the local machine
*/
host = [[self alloc] _initWithHostEntry: 0 key: localHostName];
IF_NO_GC([host autorelease];)
IF_NO_ARC([host autorelease];)
}
else
{
@ -474,7 +474,7 @@ myHostName()
else
{
host = [[self alloc] _initWithHostEntry: h key: name];
IF_NO_GC([host autorelease];)
IF_NO_ARC([host autorelease];)
}
}
}
@ -484,7 +484,7 @@ myHostName()
}
else
{
IF_NO_GC([[host retain] autorelease];)
IF_NO_ARC([[host retain] autorelease];)
}
[_hostCacheLock unlock];
return host;
@ -559,17 +559,17 @@ myHostName()
if (0 == h)
{
host = [[self alloc] _initWithAddress: address];
IF_NO_GC([host autorelease];)
IF_NO_ARC([host autorelease];)
}
else
{
host = [[self alloc] _initWithHostEntry: h key: address];
IF_NO_GC([host autorelease];)
IF_NO_ARC([host autorelease];)
}
}
else
{
IF_NO_GC([[host retain] autorelease];)
IF_NO_ARC([[host retain] autorelease];)
}
[_hostCacheLock unlock];
return host;
@ -634,7 +634,7 @@ myHostName()
{
host = [NSHost currentHost];
}
IF_NO_GC([host retain];)
IF_NO_ARC([host retain];)
DESTROY(self);
return host;
}

View file

@ -490,7 +490,7 @@ _arg_addr(NSInvocation *inv, int index)
_get_arg(self, index, &old);
_set_arg(self, index, buffer);
IF_NO_GC(RETAIN(*(id*)buffer));
IF_NO_ARC(RETAIN(*(id*)buffer));
if (old != nil)
{
RELEASE(old);
@ -634,7 +634,7 @@ _arg_addr(NSInvocation *inv, int index)
_get_arg(self, i-1, &old);
if (old != nil)
{
IF_NO_GC(RETAIN(old));
IF_NO_ARC(RETAIN(old));
}
}
else if (*_inf[i].type == _C_CHARPTR)
@ -661,7 +661,7 @@ _arg_addr(NSInvocation *inv, int index)
{
_targetRetained = YES;
IF_NO_GC(RETAIN(_target));
IF_NO_ARC(RETAIN(_target));
}
}

View file

@ -1554,7 +1554,7 @@ cifframe_callback(ffi_cif *cif, void *retp, void **args, void *user)
* turn off key-value-observing for it.
*/
object_setClass(self, [self class]);
IF_NO_GC(AUTORELEASE(info);)
IF_NO_ARC(AUTORELEASE(info);)
[self setObservationInfo: nil];
}
if ([aPath rangeOfString:@"."].location != NSNotFound)
@ -2058,7 +2058,7 @@ triggerChangeNotificationsForDependentKey: (NSString*)dependentKey
setup();
[kvoLock lock];
info = NSMapGet(infoTable, (void*)self);
IF_NO_GC(AUTORELEASE(RETAIN((id)info));)
IF_NO_ARC(AUTORELEASE(RETAIN((id)info));)
[kvoLock unlock];
return info;
}

View file

@ -839,7 +839,7 @@ static NSMapTable *globalClassMap = 0;
unsigned count;
unsigned i;
IF_NO_GC(RETAIN(_archive);)
IF_NO_ARC(RETAIN(_archive);)
_archiverClass = [_archive objectForKey: @"$archiver"];
_version = [_archive objectForKey: @"$version"];

View file

@ -877,7 +877,7 @@ static Class runLoopClass;
DESTROY(rItems);
NSDebugMLLog(@"NSMessagePort_details",
@"got message %@ on 0x%"PRIxPTR, pm, (NSUInteger)self);
IF_NO_GC([rp retain];)
IF_NO_ARC([rp retain];)
M_UNLOCK(myLock);
NS_DURING
{
@ -1033,7 +1033,7 @@ static Class runLoopClass;
l = [runLoopClass currentRunLoop];
IF_NO_GC(RETAIN(self);)
IF_NO_ARC(RETAIN(self);)
[self _add: l];
@ -1368,10 +1368,10 @@ typedef struct {
else
{
RELEASE(theName);
IF_NO_GC([port retain];)
IF_NO_ARC([port retain];)
NSDebugMLLog(@"NSMessagePort", @"Using pre-existing port: %@", port);
}
IF_NO_GC(AUTORELEASE(port));
IF_NO_ARC(AUTORELEASE(port));
M_UNLOCK(messagePortLock);
return port;
@ -1494,7 +1494,7 @@ typedef struct {
{
if ((NSPort*) [handle recvPort] == recvPort)
{
IF_NO_GC([handle retain];)
IF_NO_ARC([handle retain];)
NSEndMapTableEnumeration(&me);
M_UNLOCK(myLock);
return AUTORELEASE(handle);
@ -1597,7 +1597,7 @@ typedef struct {
{
if ([self isValid] == YES)
{
IF_NO_GC(RETAIN(self);)
IF_NO_ARC(RETAIN(self);)
M_LOCK(myLock);
if ([self isValid] == YES)
@ -1693,7 +1693,7 @@ typedef struct {
{
M_LOCK(myLock);
handle = (GSMessageHandle*)NSMapGet(handles, (void*)(uintptr_t)desc);
IF_NO_GC(AUTORELEASE(RETAIN(handle)));
IF_NO_ARC(AUTORELEASE(RETAIN(handle)));
M_UNLOCK(myLock);
if (handle == nil)
{
@ -1732,7 +1732,7 @@ typedef struct {
- (void) removeHandle: (GSMessageHandle*)handle
{
IF_NO_GC(RETAIN(self);)
IF_NO_ARC(RETAIN(self);)
M_LOCK(myLock);
if ([handle sendPort] == self)
{
@ -1745,7 +1745,7 @@ typedef struct {
* been retained - we must therefore release this port since the
* handle no longer uses it.
*/
IF_NO_GC([self autorelease];)
IF_NO_ARC([self autorelease];)
}
handle->sendPort = nil;
}

View file

@ -278,7 +278,7 @@ static NSMapTable *portToNamesMap;
data = [GSMimeDocument encodeBase64: data];
name = [[NSString alloc] initWithData: data
encoding: NSASCIIStringEncoding];
IF_NO_GC([name autorelease];)
IF_NO_ARC([name autorelease];)
}
[serverLock lock];
if (!base_path)

View file

@ -119,18 +119,6 @@ static Class concrete = 0;
@end
/*
* Garbage collection considerations -
* The notification center is not supposed to retain any notification
* observers or notification objects. To achieve this when using garbage
* collection, we must hide all references to observers and objects.
* Within an Observation structure, this is not a problem, we simply
* allocate the structure using 'atomic' allocation to tell the gc
* system to ignore pointers inside it.
* Elsewhere, we store the pointers with a bit added, to hide them from
* the garbage collector.
*/
struct NCTbl; /* Notification Center Table structure */
/*
@ -238,11 +226,6 @@ static void obsFree(Observation *o);
* lists of Observations. This lets us avoid the overhead of creating
* and destroying map tables when we are frequently adding and removing
* notification observations.
*
* Performance is however, not the primary reason for using this
* structure - it provides a neat way to ensure that observers pointed
* to by the Observation structures are not seen as being in use by
* the garbage collection mechanism.
*/
#define CHUNKSIZE 128
#define CACHESIZE 16
@ -273,8 +256,7 @@ obsNew(NCTable *t, SEL s, id o)
/* Generally, observations are cached and we create a 'new' observation
* by retrieving from the cache or by allocating a block of observations
* in one go. This works nicely to both hide observations from the
* garbage collector (when using gcc for GC) and to provide high
* in one go. This works nicely to provide high
* performance for situations where apps add/remove lots of observers
* very frequently (poor design, but something which happens in the
* real world unfortunately).
@ -758,8 +740,6 @@ static NSNotificationCenter *default_center = nil;
* <p>The notification center does not retain observer or object. Therefore,
* you should always send removeObserver: or removeObserver:name:object: to
* the notification center before releasing these objects.<br />
* As a convenience, when built with garbage collection, you do not need to
* remove any garbage collected observer as the system will do it implicitly.
* </p>
*
* <p>NB. For MacOS-X compatibility, adding an observer multiple times will
@ -1097,9 +1077,8 @@ static NSNotificationCenter *default_center = nil;
* Lock the table of observations while we traverse it.
*
* The table of observations contains weak pointers which are zeroed when
* the observers get garbage collected. So to avoid consistency problems
* we disable gc while we copy all the observations we are interested in.
* We use scanned memory in the array in the case where there are more
* the observers get destroyed. So to avoid consistency problems
* we use scanned memory in the array in the case where there are more
* than the 64 observers we allowed room for on the stack.
*/
GSIArrayInitWithZoneAndStaticCapacity(a, _zone, 64, i);

View file

@ -512,22 +512,22 @@ static NSUInteger _defaultBehavior = NSNumberFormatterBehavior10_4;
{
NSNumberFormatter *o = (NSNumberFormatter*) NSCopyObject(self, 0, zone);
IF_NO_GC(RETAIN(o->_negativeFormat);)
IF_NO_GC(RETAIN(o->_positiveFormat);)
IF_NO_GC(RETAIN(o->_attributesForPositiveValues);)
IF_NO_GC(RETAIN(o->_attributesForNegativeValues);)
IF_NO_GC(RETAIN(o->_maximum);)
IF_NO_GC(RETAIN(o->_minimum);)
IF_NO_GC(RETAIN(o->_roundingBehavior);)
IF_NO_GC(RETAIN(o->_attributedStringForNil);)
IF_NO_GC(RETAIN(o->_attributedStringForNotANumber);)
IF_NO_GC(RETAIN(o->_attributedStringForZero);)
IF_NO_ARC(RETAIN(o->_negativeFormat);)
IF_NO_ARC(RETAIN(o->_positiveFormat);)
IF_NO_ARC(RETAIN(o->_attributesForPositiveValues);)
IF_NO_ARC(RETAIN(o->_attributesForNegativeValues);)
IF_NO_ARC(RETAIN(o->_maximum);)
IF_NO_ARC(RETAIN(o->_minimum);)
IF_NO_ARC(RETAIN(o->_roundingBehavior);)
IF_NO_ARC(RETAIN(o->_attributedStringForNil);)
IF_NO_ARC(RETAIN(o->_attributedStringForNotANumber);)
IF_NO_ARC(RETAIN(o->_attributedStringForZero);)
if (0 != internal)
{
int idx;
GS_COPY_INTERNAL(o, zone)
IF_NO_GC(
IF_NO_ARC(
[GSIVar(o,_locale) retain];
for (idx = 0; idx < MAX_SYMBOLS; ++idx)
{

View file

@ -1151,7 +1151,7 @@ static id gs_weak_load(id obj)
* instance is performed apart from setup to be an instance of
* the correct class: it is your responsibility to initialize the
* instance by calling an appropriate <code>init</code>
* method. If you are not using the garbage collector, it is
* method. If you are not using ARC, it is
* also your responsibility to make sure the returned
* instance is destroyed when you finish using it, by calling
* the <code>release</code> method to destroy the instance
@ -1204,7 +1204,7 @@ static id gs_weak_load(id obj)
* initialized instance, as would be generated by an
* <code>alloc</code> method followed by a corresponding
* <code>init...</code> method. Please note that if you are
* not using a garbage collector, this means that instances
* not using ARC, this means that instances
* generated by the <code>new...</code> methods are not
* autoreleased, that is, you are responsible for releasing
* (autoreleasing) the instances yourself. So when you use

View file

@ -388,7 +388,7 @@ static unsigned encodingVersion;
coder = [self allocWithZone: NSDefaultMallocZone()];
coder = [coder initWithReceivePort: recv sendPort: send components: comp];
IF_NO_GC(AUTORELEASE(coder);)
IF_NO_ARC(AUTORELEASE(coder);)
return coder;
}
@ -633,7 +633,7 @@ scalarSize(char type)
* order to give the appearance that it's actually a
* new object.
*/
IF_NO_GC(RETAIN(obj));
IF_NO_ARC(RETAIN(obj));
}
else
{
@ -705,7 +705,7 @@ scalarSize(char type)
* order to give the appearance that it's actually a
* new object.
*/
IF_NO_GC(RETAIN(obj));
IF_NO_ARC(RETAIN(obj));
}
else
{

View file

@ -306,7 +306,7 @@ _gnu_process_args(int argc, char *argv[], char *env[])
}
/* Getting the process name */
IF_NO_GC(RELEASE(_gnu_processName));
IF_NO_ARC(RELEASE(_gnu_processName));
_gnu_processName = [arg0 lastPathComponent];
#if defined(_WIN32)
/* On windows we remove any .exe extension for consistency with app names
@ -321,7 +321,7 @@ _gnu_process_args(int argc, char *argv[], char *env[])
}
}
#endif
IF_NO_GC(RETAIN(_gnu_processName));
IF_NO_ARC(RETAIN(_gnu_processName));
/* Copy the argument list */
#if defined(_WIN32)
@ -349,7 +349,7 @@ _gnu_process_args(int argc, char *argv[], char *env[])
}
}
IF_NO_GC(RELEASE(_gnu_arguments));
IF_NO_ARC(RELEASE(_gnu_arguments));
_gnu_arguments = [[NSArray alloc] initWithObjects: obj_argv count: added];
RELEASE(arg0);
}
@ -376,7 +376,7 @@ _gnu_process_args(int argc, char *argv[], char *env[])
obj_argv[added++] = str;
}
IF_NO_GC(RELEASE(_gnu_arguments));
IF_NO_ARC(RELEASE(_gnu_arguments));
_gnu_arguments = [[NSArray alloc] initWithObjects: obj_argv count: added];
RELEASE(arg0);
}
@ -458,11 +458,11 @@ _gnu_process_args(int argc, char *argv[], char *env[])
i++;
}
}
IF_NO_GC(RELEASE(_gnu_environment));
IF_NO_ARC(RELEASE(_gnu_environment));
_gnu_environment = [[NSDictionary alloc] initWithObjects: values
forKeys: keys];
IF_NO_GC(RELEASE(keys));
IF_NO_GC(RELEASE(values));
IF_NO_ARC(RELEASE(keys));
IF_NO_ARC(RELEASE(values));
}
[arp drain];
}

View file

@ -284,7 +284,7 @@ static inline BOOL timerInvalidated(NSTimer *t)
{
GSTimedPerformer *array[count];
IF_NO_GC(RETAIN(target));
IF_NO_ARC(RETAIN(target));
[perf getObjects: array];
while (count-- > 0)
{
@ -318,8 +318,8 @@ static inline BOOL timerInvalidated(NSTimer *t)
{
GSTimedPerformer *array[count];
IF_NO_GC(RETAIN(target));
IF_NO_GC(RETAIN(arg));
IF_NO_ARC(RETAIN(target));
IF_NO_ARC(RETAIN(arg));
[perf getObjects: array];
while (count-- > 0)
{
@ -545,7 +545,7 @@ static inline BOOL timerInvalidated(NSTimer *t)
{
[array[i] fire];
RELEASE(array[i]);
IF_NO_GC([arp emptyPool];)
IF_NO_ARC([arp emptyPool];)
}
[arp drain];
}
@ -1040,7 +1040,7 @@ updateTimer(NSTimer *t, NSDate *d, NSTimeInterval now)
GSIArrayRemoveItemAtIndexNoRelease(timers, i);
[t fire];
GSPrivateNotifyASAP(_currentMode);
IF_NO_GC([arp emptyPool];)
IF_NO_ARC([arp emptyPool];)
if (updateTimer(t, d, now) == YES)
{
/* Updated ... replace in array.

View file

@ -153,7 +153,7 @@ typedef GSString *ivars;
memSel = @selector(characterIsMember:);
defaultSkipSet = [NSCharacterSet whitespaceAndNewlineCharacterSet];
IF_NO_GC(RETAIN(defaultSkipSet));
IF_NO_ARC(RETAIN(defaultSkipSet));
NSStringClass = [NSString class];
GSCStringClass = [GSCString class];
GSUnicodeStringClass = [GSUnicodeString class];

View file

@ -681,7 +681,7 @@ deserializeFromInfo(_NSDeserializerInfo* info)
* rather than simply releasing as the key may
* be referred to by a cross-reference later.
*/
IF_NO_GC(AUTORELEASE(k);)
IF_NO_ARC(AUTORELEASE(k);)
RELEASE(o);
}
}

View file

@ -1171,7 +1171,7 @@ static Class NSMutableSet_concrete_class;
}
else
{
IF_NO_GC([other retain];) // In case it's held by us
IF_NO_ARC([other retain];) // In case it's held by us
[self removeAllObjects];
[self unionSet: other];
RELEASE(other);

View file

@ -1199,7 +1199,7 @@ static Class runLoopClass;
rId = 0;
DESTROY(rItems);
NSDebugMLLog(@"GSTcpHandle", @"got message %@ on %p", pm, self);
IF_NO_GC(RETAIN(rp);)
IF_NO_ARC(RETAIN(rp);)
M_UNLOCK(myLock);
NS_DURING
{
@ -1577,7 +1577,7 @@ static Class runLoopClass;
l = [runLoopClass currentRunLoop];
IF_NO_GC(RETAIN(self);)
IF_NO_ARC(RETAIN(self);)
[self _add: l];
@ -1703,7 +1703,7 @@ static Class tcpPortClass;
if (thePorts != 0)
{
port = (NSSocketPort*)NSMapGet(thePorts, (void*)aHost);
IF_NO_GC(AUTORELEASE(RETAIN(port)));
IF_NO_ARC(AUTORELEASE(RETAIN(port)));
}
M_UNLOCK(tcpPortLock);
return port;
@ -1925,10 +1925,10 @@ static Class tcpPortClass;
}
else
{
IF_NO_GC(RETAIN(port);)
IF_NO_ARC(RETAIN(port);)
NSDebugMLLog(@"NSPort", @"Using pre-existing port: %@", port);
}
IF_NO_GC(AUTORELEASE(port));
IF_NO_ARC(AUTORELEASE(port));
M_UNLOCK(tcpPortLock);
return port;
@ -2006,7 +2006,7 @@ static Class tcpPortClass;
{
if ((NSPort*) [handle recvPort] == recvPort)
{
IF_NO_GC(RETAIN(handle);)
IF_NO_ARC(RETAIN(handle);)
NSEndMapTableEnumeration(&me);
M_UNLOCK(myLock);
return AUTORELEASE(handle);
@ -2267,7 +2267,7 @@ static Class tcpPortClass;
{
if ([self isValid] == YES)
{
IF_NO_GC(RETAIN(self);)
IF_NO_ARC(RETAIN(self);)
M_LOCK(myLock);
if ([self isValid] == YES)
@ -2420,7 +2420,7 @@ static Class tcpPortClass;
desc = (SOCKET)NSMapGet(events, (void*)(uintptr_t)event);
#endif
handle = (GSTcpHandle*)NSMapGet(handles, (void*)(uintptr_t)desc);
IF_NO_GC(AUTORELEASE(RETAIN(handle)));
IF_NO_ARC(AUTORELEASE(RETAIN(handle)));
M_UNLOCK(myLock);
if (handle == nil)
{
@ -2473,7 +2473,7 @@ static Class tcpPortClass;
*/
- (void) removeHandle: (GSTcpHandle*)handle
{
IF_NO_GC(RETAIN(self);)
IF_NO_ARC(RETAIN(self);)
M_LOCK(myLock);
if ([handle sendPort] == self)
{
@ -2486,7 +2486,7 @@ static Class tcpPortClass;
* been retained - we must therefore release this port since the
* handle no longer uses it.
*/
IF_NO_GC(RELEASE(self);)
IF_NO_ARC(RELEASE(self);)
}
handle->sendPort = nil;
}

View file

@ -460,7 +460,7 @@ typedef enum {
if (state == GSPC_FAIL)
return;
IF_NO_GC(RETAIN(handle));
IF_NO_ARC(RETAIN(handle));
nc = [NSNotificationCenter defaultCenter];
[nc addObserver: self
selector: @selector(didConnect:)
@ -494,7 +494,7 @@ typedef enum {
msg.port = 0;
TEST_RELEASE(data);
data = [NSMutableData dataWithBytes: (void*)&msg length: sizeof(msg)];
IF_NO_GC(RETAIN(data));
IF_NO_ARC(RETAIN(data));
[self open: nil];
}
@ -507,7 +507,7 @@ typedef enum {
[name getCString: (char*)msg.name];
TEST_RELEASE(data);
data = [NSMutableData dataWithBytes: (void*)&msg length: sizeof(msg)];
IF_NO_GC(RETAIN(data));
IF_NO_ARC(RETAIN(data));
[self open: host];
}
@ -520,7 +520,7 @@ typedef enum {
msg.port = GSSwapHostI32ToBig(portNumber);
TEST_RELEASE(data);
data = [NSMutableData dataWithBytes: (void*)&msg length: sizeof(msg)];
IF_NO_GC(RETAIN(data));
IF_NO_ARC(RETAIN(data));
[self open: nil];
}
@ -540,7 +540,7 @@ typedef enum {
msg.port = GSSwapHostI32ToBig(portNumber);
TEST_RELEASE(data);
data = [NSMutableData dataWithBytes: (void*)&msg length: sizeof(msg)];
IF_NO_GC(RETAIN(data));
IF_NO_ARC(RETAIN(data));
[self open: nil];
}
@ -1210,7 +1210,7 @@ typedef enum {
NSMutableSet *known = (NSMutableSet*)NSMapGet(_portMap, port);
NSString *name;
IF_NO_GC(RETAIN(known);)
IF_NO_ARC(RETAIN(known);)
while ((name = [known anyObject]) != nil)
{
if ([self removePortForName: name] == NO)

View file

@ -149,7 +149,7 @@ GSSpellServerName(NSString *vendor, NSString *language)
- (void) setDelegate: (id)anObject
{
/* FIXME - we should not retain the delegate ! */
IF_NO_GC(RETAIN(anObject);)
IF_NO_ARC(RETAIN(anObject);)
ASSIGN(_delegate, anObject);
}

View file

@ -1949,7 +1949,7 @@ GSICUCollatorOpen(NSStringCompareOptions mask, NSLocale *locale)
length: dpos
encoding: NSASCIIStringEncoding];
NSZoneFree(NSDefaultMallocZone(), dst);
IF_NO_GC([s autorelease];)
IF_NO_ARC([s autorelease];)
}
return s;
}
@ -2072,7 +2072,7 @@ GSICUCollatorOpen(NSStringCompareOptions mask, NSLocale *locale)
length: dpos
encoding: NSASCIIStringEncoding];
NSZoneFree(NSDefaultMallocZone(), dst);
IF_NO_GC([s autorelease];)
IF_NO_ARC([s autorelease];)
}
return s;
}
@ -2126,13 +2126,13 @@ GSICUCollatorOpen(NSStringCompareOptions mask, NSLocale *locale)
NSRange complete;
NSRange found;
NSMutableArray *array;
IF_NO_GC(NSAutoreleasePool *pool; NSUInteger count;)
IF_NO_ARC(NSAutoreleasePool *pool; NSUInteger count;)
if (separator == nil)
[NSException raise: NSInvalidArgumentException format: @"separator is nil"];
array = [NSMutableArray array];
IF_NO_GC(pool = [NSAutoreleasePool new]; count = 0;)
IF_NO_ARC(pool = [NSAutoreleasePool new]; count = 0;)
search = NSMakeRange (0, [self length]);
complete = search;
found = [self rangeOfCharacterFromSet: separator];
@ -2149,11 +2149,11 @@ GSICUCollatorOpen(NSStringCompareOptions mask, NSLocale *locale)
found = [self rangeOfCharacterFromSet: separator
options: 0
range: search];
IF_NO_GC(if (0 == count % 200) [pool emptyPool];)
IF_NO_ARC(if (0 == count % 200) [pool emptyPool];)
}
// Add the last search string range
[array addObject: [self substringWithRange: search]];
IF_NO_GC([pool release];)
IF_NO_ARC([pool release];)
// FIXME: Need to make mutable array into non-mutable array?
return array;
}
@ -3681,7 +3681,7 @@ GSICUCollatorOpen(NSStringCompareOptions mask, NSLocale *locale)
}
m = [d mutableCopy];
[m appendBytes: "" length: 1];
IF_NO_GC([m autorelease];)
IF_NO_ARC([m autorelease];)
return (const char*)[m bytes];
}
@ -3769,7 +3769,7 @@ GSICUCollatorOpen(NSStringCompareOptions mask, NSLocale *locale)
allowLossyConversion: YES];
m = [d mutableCopy];
[m appendBytes: "" length: 1];
IF_NO_GC([m autorelease];)
IF_NO_ARC([m autorelease];)
return (const char*)[m bytes];
}
@ -3787,7 +3787,7 @@ GSICUCollatorOpen(NSStringCompareOptions mask, NSLocale *locale)
allowLossyConversion: NO];
m = [d mutableCopy];
[m appendBytes: "" length: 1];
IF_NO_GC([m autorelease];)
IF_NO_ARC([m autorelease];)
return (const char*)[m bytes];
}

View file

@ -850,7 +850,7 @@ pty_slave(const char* name)
NSTimer *timer = nil;
NSDate *limit = nil;
IF_NO_GC([[self retain] autorelease];)
IF_NO_ARC([[self retain] autorelease];)
while ([self isRunning])
{
/* Poll at 0.1 second intervals.
@ -923,7 +923,7 @@ pty_slave(const char* name)
- (void) _terminatedChild: (int)status reason: (NSTaskTerminationReason)reason
{
[tasksLock lock];
IF_NO_GC([[self retain] autorelease];)
IF_NO_ARC([[self retain] autorelease];)
NSMapRemove(activeTasks, (void*)(intptr_t)_taskId);
[tasksLock unlock];
_terminationStatus = status;
@ -1397,7 +1397,7 @@ GSPrivateCheckTasks()
#if defined(WAITDEBUG)
[tasksLock lock];
t = (NSTask*)NSMapGet(activeTasks, (void*)(intptr_t)result);
IF_NO_GC([[t retain] autorelease];)
IF_NO_ARC([[t retain] autorelease];)
[tasksLock unlock];
if (t != nil)
{
@ -1410,7 +1410,7 @@ GSPrivateCheckTasks()
{
[tasksLock lock];
t = (NSTask*)NSMapGet(activeTasks, (void*)(intptr_t)result);
IF_NO_GC([[t retain] autorelease];)
IF_NO_ARC([[t retain] autorelease];)
[tasksLock unlock];
if (t != nil)
{

View file

@ -393,7 +393,7 @@ static NSString *_time_zone_path(NSString *subpath, NSString *type)
{
zone = nil;
}
IF_NO_GC(RETAIN(zone));
IF_NO_ARC(RETAIN(zone));
GS_MUTEX_UNLOCK(zone_mutex);
if (zone == nil)
@ -709,7 +709,7 @@ static NSMapTable *absolutes = 0;
z = commonAbsolutes[anOffset/900 + 72];
if (z != nil)
{
IF_NO_GC(RETAIN(z));
IF_NO_ARC(RETAIN(z));
DESTROY(self);
return z;
}
@ -719,7 +719,7 @@ static NSMapTable *absolutes = 0;
z = (GSAbsTimeZone*)NSMapGet(absolutes, (void*)(uintptr_t)anOffset);
if (z != nil)
{
IF_NO_GC(RETAIN(z));
IF_NO_ARC(RETAIN(z));
DESTROY(self);
}
else
@ -1846,7 +1846,7 @@ localZoneString, [zone name], sign, s/3600, (s/60)%60);
to be in this directory, but initWithName:data:
will do this anyway and log a message if not. */
zone = [[self alloc] initWithName: name data: data];
IF_NO_GC([zone autorelease];)
IF_NO_ARC([zone autorelease];)
}
if (zone != nil)
{

View file

@ -1915,7 +1915,7 @@ static NSUInteger urlAlign;
if (c != 0)
{
handle = [[c alloc] initWithURL: self cached: shouldUseCache];
IF_NO_GC([handle autorelease];)
IF_NO_ARC([handle autorelease];)
}
}
return handle;

View file

@ -216,10 +216,10 @@ static Class NSURLHandleClass = 0;
{
id o = client;
IF_NO_GC([o retain];)
IF_NO_ARC([o retain];)
[_clients removeObjectIdenticalTo: o];
[_clients addObject: o];
IF_NO_GC([o release];)
IF_NO_ARC([o release];)
}
/**
@ -276,12 +276,12 @@ static Class NSURLHandleClass = 0;
*/
- (void) cancelLoadInBackground
{
IF_NO_GC([self retain];)
IF_NO_ARC([self retain];)
[_clients makeObjectsPerformSelector:
@selector(URLHandleResourceDidCancelLoading:)
withObject: self];
[self endLoadInBackground];
IF_NO_GC(RELEASE(self);)
IF_NO_ARC(RELEASE(self);)
}
- (void) dealloc
@ -620,7 +620,7 @@ static NSLock *fileLock = nil;
NS_DURING
{
obj = [fileCache objectForKey: path];
IF_NO_GC([[obj retain] autorelease];)
IF_NO_ARC([[obj retain] autorelease];)
}
NS_HANDLER
{
@ -715,7 +715,7 @@ static NSLock *fileLock = nil;
if (obj != nil)
{
DESTROY(self);
IF_NO_GC([obj retain];)
IF_NO_ARC([obj retain];)
}
}
NS_HANDLER

View file

@ -1676,7 +1676,7 @@ typedef struct {
{
/* Make sure no action triggered by anything else destroys us prematurely.
*/
IF_NO_GC([[self retain] autorelease];)
IF_NO_ARC([[self retain] autorelease];)
#if 0
NSLog(@"stream: %@ handleEvent: %x for: %@ (ip %p, op %p)",

View file

@ -324,7 +324,7 @@ typedef struct {
p = AUTORELEASE([GSMimeParser new]);
h = [[GSMimeHeader alloc] initWithName: @"content-displosition"
value: disp];
IF_NO_GC([h autorelease];)
IF_NO_ARC([h autorelease];)
sc = [NSScanner scannerWithString: [h value]];
if ([p scanHeaderBody: sc into: h] == YES)
{

View file

@ -903,7 +903,7 @@ scalarSize(char type)
* order to give the appearance that it's actually a
* new object.
*/
IF_NO_GC(RETAIN(obj));
IF_NO_ARC(RETAIN(obj));
}
else
{
@ -1506,7 +1506,7 @@ scalarSize(char type)
at: b];
d = [[NSData allocWithZone: zone] initWithBytesNoCopy: b
length: l];
IF_NO_GC(AUTORELEASE(d));
IF_NO_ARC(AUTORELEASE(d));
return d;
}
else

View file

@ -101,7 +101,7 @@ static NSRecursiveLock *lock = nil;
[lock lock];
transformer = [registry objectForKey: name];
IF_NO_GC([transformer retain];)
IF_NO_ARC([transformer retain];)
if (transformer == nil)
{

View file

@ -58,7 +58,7 @@ static BOOL snuggleEnd(NSString *t)
if (set == nil)
{
set = [NSCharacterSet characterSetWithCharactersInString: @"]}).,;"];
IF_NO_GC([set retain];)
IF_NO_ARC([set retain];)
}
return [set characterIsMember: [t characterAtIndex: 0]];
}
@ -70,7 +70,7 @@ static BOOL snuggleStart(NSString *t)
if (set == nil)
{
set = [NSCharacterSet characterSetWithCharactersInString: @"[{("];
IF_NO_GC([set retain];)
IF_NO_ARC([set retain];)
}
return [set characterIsMember: [t characterAtIndex: [t length] - 1]];
}
@ -1081,7 +1081,7 @@ static BOOL snuggleStart(NSString *t)
} while (r.length > 0);
if (m != nil)
{
IF_NO_GC([m autorelease];)
IF_NO_ARC([m autorelease];)
}
}

View file

@ -1303,7 +1303,7 @@ recheck:
@"unsigned",
@"volatile",
nil];
IF_NO_GC([qualifiers retain];)
IF_NO_ARC([qualifiers retain];)
keep = [NSSet setWithObjects:
@"const",
@"long",
@ -1312,7 +1312,7 @@ recheck:
@"unsigned",
@"volatile",
nil];
IF_NO_GC([keep retain];)
IF_NO_ARC([keep retain];)
}
a = [NSMutableArray array];
@ -1374,7 +1374,7 @@ recheck:
pos++;
[self skipSpaces];
}
IF_NO_GC(DESTROY(arp);)
IF_NO_ARC(DESTROY(arp);)
return nil;
}
@ -3023,7 +3023,7 @@ fail:
DESTROY(itemName);
[arp drain];
IF_NO_GC([method autorelease];)
IF_NO_ARC([method autorelease];)
return method;
fail:
@ -3733,7 +3733,7 @@ fail:
DESTROY(unitName);
DESTROY(comment);
[arp drain];
IF_NO_GC([dict autorelease];)
IF_NO_ARC([dict autorelease];)
return dict;
fail:
@ -4201,7 +4201,7 @@ fail:
pos = 0;
ASSIGN(lines, [NSArray arrayWithArray: a]);
[arp drain];
IF_NO_GC([data autorelease];)
IF_NO_ARC([data autorelease];)
}
/**

View file

@ -1056,7 +1056,7 @@ build_relocation_table_for_directory (NSString *dir)
NSMutableDictionary *relocationTable;
relocationTable = [NSMutableDictionary new];
IF_NO_GC ([relocationTable autorelease];)
IF_NO_ARC ([relocationTable autorelease];)
e = [HTMLDirectoryEnumerator alloc];
e = [[e initWithBasePath: dir] autorelease];

View file

@ -1368,7 +1368,7 @@ main(int argc, char **argv, char **env)
if (sDate == nil || [d earlierDate: sDate] == sDate)
{
sDate = d;
IF_NO_GC([[sDate retain] autorelease];)
IF_NO_ARC([[sDate retain] autorelease];)
}
}
if (verbose == YES)
@ -1396,7 +1396,7 @@ main(int argc, char **argv, char **env)
if (gDate == nil || [d laterDate: gDate] == gDate)
{
gDate = d;
IF_NO_GC([[gDate retain] autorelease];)
IF_NO_ARC([[gDate retain] autorelease];)
}
}
if (verbose == YES)
@ -1617,7 +1617,7 @@ main(int argc, char **argv, char **env)
{
attrs = [mgr fileAttributesAtPath: gsdocfile traverseLink: YES];
gDate = [attrs fileModificationDate];
IF_NO_GC([[gDate retain] autorelease];)
IF_NO_ARC([[gDate retain] autorelease];)
}
/*
@ -1721,7 +1721,7 @@ main(int argc, char **argv, char **env)
systemProjects = @"";
}
projects = [[defs dictionaryForKey: @"Projects"] mutableCopy];
IF_NO_GC([projects autorelease];)
IF_NO_ARC([projects autorelease];)
/*
* Merge any system project references.
@ -2076,10 +2076,10 @@ main(int argc, char **argv, char **env)
*/
attrs = [mgr fileAttributesAtPath: gsdocfile traverseLink: YES];
gDate = [attrs fileModificationDate];
IF_NO_GC([[gDate retain] autorelease];)
IF_NO_ARC([[gDate retain] autorelease];)
attrs = [mgr fileAttributesAtPath: htmlfile traverseLink: YES];
hDate = [attrs fileModificationDate];
IF_NO_GC([[hDate retain] autorelease];)
IF_NO_ARC([[hDate retain] autorelease];)
}
if ([mgr isReadableFileAtPath: gsdocfile] == YES)

View file

@ -47,7 +47,7 @@ convert_unicode(NSArray *args)
data = [NSData dataWithContentsOfFile: file];
myString = [[NSString alloc] initWithData: data
encoding: NSUTF8StringEncoding];
IF_NO_GC([myString autorelease];)
IF_NO_ARC([myString autorelease];)
if ([myString length] == 0)
{
myString = [[[NSString alloc] initWithData: data