More GC removal updates

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@39611 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2016-03-26 05:10:00 +00:00
parent 7fbdf38a9c
commit c3890f7d67
5 changed files with 60 additions and 17 deletions

View file

@ -317,7 +317,8 @@ explicit/readable code.
We encourage the use of the following macros to ease retain and release
and as a convenience for managing code which should work in both a
garbage collecting and a retain counting environment.
conventional retain counting environment and one with automatic reference
counting (ARC)
@itemize @bullet
@item
ASSIGN(object,value) to assign an object variable, performing the appropriate retain/release as necessary.
@ -326,10 +327,8 @@ ASSIGNCOPY(object,value) to copy the value and assign it to the object.
@item
DESTROY(object) to release an object variable and set it to nil.
@item
CREATE_AUTORELEASE_POOL(name) to create an autorelease pool with the
specified name.
@item IF_NO_GC(X) compile the code 'X' only if GarbageCollection is not
in use.
ENTER_POOL and LEAVE_POOL to bracket statements which should be performed
inside their own auutorlease context.
@end itemize
@c ******************************************************************

View file

@ -47,17 +47,17 @@
#if __has_feature(objc_arc)
#ifndef RETAIN
#define RETAIN(object) (object)
#define RETAIN(object) (object)
#endif
#ifndef RELEASE
#define RELEASE(object)
#endif
#ifndef AUTORELEASE
#define AUTORELEASE(object) (object)
#define AUTORELEASE(object) (object)
#endif
#ifndef TEST_RETAIN
#define TEST_RETAIN(object) (object)
#define TEST_RETAIN(object) (object)
#endif
#ifndef TEST_RELEASE
#define TEST_RELEASE(object)
@ -67,17 +67,29 @@
#endif
#ifndef ASSIGN
#define ASSIGN(object,value) object = (value)
#define ASSIGN(object,value) object = (value)
#endif
#ifndef ASSIGNCOPY
#define ASSIGNCOPY(object,value) object = [(value) copy]
#endif
#ifndef DESTROY
#define DESTROY(object) object = nil
#define DESTROY(object) object = nil
#endif
#define IF_NO_GC(X)
#ifndef ENTER_POOL
#define ENTER_POOL @autoreleasepool{do{
#endif
#ifndef LEAVE_POOL
#define LEAVE_POOL }while(0);}
#endif
#ifndef DEALLOC
#define DEALLOC
#endif
#else
#ifndef RETAIN
@ -183,17 +195,45 @@ id __object = (object); (__object != nil) ? [__object autorelease] : nil; })
#define IF_NO_GC(X) X
#ifndef ENTER_POOL
/**
* ENTER_POOL creates an autorelease pool and places subsequent code
* in a do/while loop (executed only once) which can be broken out of
* to reach the point when the pool is drained.<br />
* The block must be terminated with a corresponding LEAVE_POOL.<br />
* You should not return from such a block of code (to do so could
* leak an autorelease pool and give objects a longer lifetime than
* they ought to have. If you wish to leave the block of code early,
* you may do so using a 'break' statement.
*/
#define ENTER_POOL {NSAutoreleasePool *_lARP=[NSAutoreleasePool new];do{
#endif
#ifndef LEAVE_POOL
/**
* LEAVE_POOL terminates a block of code started with ENTER_POOL.
*/
#define LEAVE_POOL }while(0);[_lARP drain];}
#endif
#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
#endif
#ifndef CREATE_AUTORELEASE_POOL
/** DEPRECATED ... use NSAutoreleasePool *X = [NSAutoreleasePool new]
/** DEPRECATED ... use ENTER_POOL and LEAVE_POOL
*/
#define CREATE_AUTORELEASE_POOL(X) \
NSAutoreleasePool *X = [NSAutoreleasePool new]
#endif
#ifndef RECREATE_AUTORELEASE_POOL
/** DEPRECATED ... use [X release]; X = [NSAutoreleasePool new]
/** DEPRECATED ... use ENTER_POOL and LEAVE_POOL
*/
#define RECREATE_AUTORELEASE_POOL(X) \
DESTROY(X);\

View file

@ -1766,7 +1766,7 @@ static Class tcpPortClass;
}
else
{
handle->recvPort = GS_GC_HIDE(self);
handle->recvPort = self;
}
NSMapInsert(handles, (void*)(uintptr_t)[handle descriptor], (void*)handle);
#if defined(_WIN32)

View file

@ -108,7 +108,7 @@ static NSString *mainFont = nil;
RELEASE(localRefs);
RELEASE(projectRefs);
RELEASE(indent);
[super dealloc];
DEALLOC
}
- (void) decIndent
@ -593,7 +593,7 @@ static NSString *mainFont = nil;
- (void) outputNode: (GSXMLNode*)node to: (NSMutableString*)buf
{
CREATE_AUTORELEASE_POOL(arp);
ENTER_POOL
GSXMLNode *children = [node firstChild];
if ([node type] == XML_ELEMENT_NODE)
@ -1091,7 +1091,7 @@ static NSString *mainFont = nil;
if (base == nil)
{
NSLog(@"No 'base' document name supplied in gsdoc element");
return;
break;
}
nextFile = [prop objectForKey: @"next"];
nextFile = [nextFile stringByAppendingPathExtension: @"html"];
@ -1961,7 +1961,7 @@ static NSString *mainFont = nil;
}
}
}
[arp drain];
LEAVE_POOL
}
/**

View file

@ -103,6 +103,10 @@ locale_alias_OBJC_FILES = locale_alias.m
xmlparse_OBJC_FILES = xmlparse.m
HTMLLinker_OBJC_FILES = HTMLLinker.m
ifeq ($(OBJC_RUNTIME_LIB), ng)
AGSHtml.m_FILE_FLAGS+= -fobjc-arc
endif
# Reset this variable (defined in config.mak) to avoid useless linkage
# against the libraries gnustep-base uses.
CONFIG_SYSTEM_LIBS :=