From f77f9b1f3591368b33b1d2cf9272a7e37e4ed481 Mon Sep 17 00:00:00 2001 From: theraven Date: Sun, 31 Jul 2011 15:31:39 +0000 Subject: [PATCH] Cleanup: - (void)release; to - (oneway void)release; so everything implementing -release actually implements the one declared in the NSObject protocol. Start marking things that are unavailable in ARC mode as unavailable in ARC mode. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@33660 72102866-910b-0410-8b05-ffd578937521 --- Headers/Foundation/NSAutoreleasePool.h | 3 ++- Headers/Foundation/NSException.h | 2 ++ Headers/Foundation/NSObjCRuntime.h | 9 +++++++++ Headers/Foundation/NSObject.h | 12 ++++-------- Source/GSArray.m | 2 +- Source/GSBlocks.m | 2 +- Source/GSString.m | 2 +- Source/NSBundle.m | 2 +- Source/NSConnection.m | 2 +- Source/NSDate.m | 2 +- Source/NSIndexPath.m | 2 +- Source/NSMessagePort.m | 2 +- Source/NSNull.m | 2 +- Source/NSNumber.m | 2 +- Source/NSPort.m | 2 +- Source/NSSocketPort.m | 2 +- Source/NSTimeZone.m | 4 ++-- Source/NSURLProtocol.m | 2 +- Source/NSValue.m | 2 +- 19 files changed, 33 insertions(+), 25 deletions(-) diff --git a/Headers/Foundation/NSAutoreleasePool.h b/Headers/Foundation/NSAutoreleasePool.h index 43deacd02..5a8784a92 100644 --- a/Headers/Foundation/NSAutoreleasePool.h +++ b/Headers/Foundation/NSAutoreleasePool.h @@ -178,9 +178,10 @@ typedef struct autorelease_array_list * * */ +NS_AUTOMATED_REFCOUNT_UNAVAILABLE @interface NSAutoreleasePool : NSObject { -#if GS_EXPOSE(NSAutoreleasePool) +#if GS_EXPOSE(NSAutoreleasePool) && !__has_feature(objc_arc) /* For re-setting the current pool when we are dealloc'ed. */ NSAutoreleasePool *_parent; /* This pointer to our child pool is necessary for co-existing diff --git a/Headers/Foundation/NSException.h b/Headers/Foundation/NSException.h index 830b12584..dd5e09ae4 100644 --- a/Headers/Foundation/NSException.h +++ b/Headers/Foundation/NSException.h @@ -35,6 +35,8 @@ #if defined(_NATIVE_OBJC_EXCEPTIONS) #define USER_NATIVE_OBJC_EXCEPTIONS 1 +#elif __has_feature(objc_exceptions) +#define USER_NATIVE_OBJC_EXCEPTIONS 1 #else #define USER_NATIVE_OBJC_EXCEPTIONS 0 #endif diff --git a/Headers/Foundation/NSObjCRuntime.h b/Headers/Foundation/NSObjCRuntime.h index 01cbb742c..05b894426 100644 --- a/Headers/Foundation/NSObjCRuntime.h +++ b/Headers/Foundation/NSObjCRuntime.h @@ -62,6 +62,15 @@ typedef float CGFloat; #define NSINTEGER_DEFINED 1 #define CGFLOAT_DEFINED 1 +#ifndef NS_AUTOMATED_REFCOUNT_UNAVAILABLE +# if __has_feature(objc_arc) +# define NS_AUTOMATED_REFCOUNT_UNAVAILABLE \ + __attribute__((unavailable("Not available with automatic reference counting"))) +# else +# define NS_AUTOMATED_REFCOUNT_UNAVAILABLE +# endif +#endif + #if defined(__cplusplus) extern "C" { diff --git a/Headers/Foundation/NSObject.h b/Headers/Foundation/NSObject.h index f7f4fd341..c7433310f 100644 --- a/Headers/Foundation/NSObject.h +++ b/Headers/Foundation/NSObject.h @@ -80,10 +80,10 @@ extern "C" { - (BOOL) respondsToSelector: (SEL)aSelector; /** See [NSObject-conformsToProtocol:] */ - (BOOL) conformsToProtocol: (Protocol*)aProtocol; -- (id) retain; /** See [NSObject-retain] */ -- (id) autorelease /** See [NSObject-autorelease] */; -- (oneway void) release; /** See [NSObject-release] */ -- (NSUInteger) retainCount; /** See [NSObject-retainCount] */ +- (id) retain NS_AUTOMATED_REFCOUNT_UNAVAILABLE; /** See [NSObject-retain] */ +- (id) autorelease NS_AUTOMATED_REFCOUNT_UNAVAILABLE /** See [NSObject-autorelease] */; +- (oneway void) release NS_AUTOMATED_REFCOUNT_UNAVAILABLE; /** See [NSObject-release] */ +- (NSUInteger) retainCount NS_AUTOMATED_REFCOUNT_UNAVAILABLE; /** See [NSObject-retainCount] */ - (NSZone*) zone; /** See [NSObject-zone] */ - (NSString*) description; /** See [NSObject-description] */ @end @@ -243,7 +243,6 @@ extern "C" { + (Class) superclass; + (NSInteger) version; -- (id) autorelease; - (id) awakeAfterUsingCoder: (NSCoder*)aDecoder; - (Class) class; - (Class) classForArchiver; @@ -269,12 +268,9 @@ extern "C" { - (id) performSelector: (SEL)aSelector withObject: (id)object1 withObject: (id)object2; -- (oneway void) release; - (id) replacementObjectForArchiver: (NSArchiver*)anArchiver; - (id) replacementObjectForCoder: (NSCoder*)anEncoder; - (BOOL) respondsToSelector: (SEL)aSelector; -- (id) retain; -- (NSUInteger) retainCount; - (id) self; - (Class) superclass; - (NSZone*) zone; diff --git a/Source/GSArray.m b/Source/GSArray.m index 5f25a0cb4..fd4ef70f1 100644 --- a/Source/GSArray.m +++ b/Source/GSArray.m @@ -1177,7 +1177,7 @@ static Class GSInlineArrayClass; return 0; } -- (void) release +- (oneway void) release { return; // placeholders never get released. } diff --git a/Source/GSBlocks.m b/Source/GSBlocks.m index 246606180..09da221b9 100644 --- a/Source/GSBlocks.m +++ b/Source/GSBlocks.m @@ -76,7 +76,7 @@ void _Block_release(void *); return _Block_copy(self); } -- (void) release +- (oneway void) release { _Block_release(self); } diff --git a/Source/GSString.m b/Source/GSString.m index 2956c3907..edd0a85ad 100644 --- a/Source/GSString.m +++ b/Source/GSString.m @@ -891,7 +891,7 @@ fixBOM(unsigned char **bytes, NSUInteger*length, BOOL *owned, return 0; } -- (void) release +- (oneway void) release { return; // placeholders never get released. } diff --git a/Source/NSBundle.m b/Source/NSBundle.m index 16fce20ea..c2ae6f469 100644 --- a/Source/NSBundle.m +++ b/Source/NSBundle.m @@ -1700,7 +1700,7 @@ IF_NO_GC( return YES; } -- (void) release +- (oneway void) release { /* We lock during release so that other threads can't grab the * object between us checking the reference count and deallocating. diff --git a/Source/NSConnection.m b/Source/NSConnection.m index a7bd76123..7a90e773d 100644 --- a/Source/NSConnection.m +++ b/Source/NSConnection.m @@ -1493,7 +1493,7 @@ static NSLock *cached_proxies_gate = nil; return result; } -- (void) release +- (oneway void) release { /* We lock the connection table while checking, to prevent * another thread from grabbing this connection while we are diff --git a/Source/NSDate.m b/Source/NSDate.m index 4ac5cbb9b..4d7769859 100644 --- a/Source/NSDate.m +++ b/Source/NSDate.m @@ -1518,7 +1518,7 @@ otherTime(NSDate* other) return self; } -- (void) release +- (oneway void) release { } diff --git a/Source/NSIndexPath.m b/Source/NSIndexPath.m index aa22124bc..80cd2bee4 100644 --- a/Source/NSIndexPath.m +++ b/Source/NSIndexPath.m @@ -428,7 +428,7 @@ static NSIndexPath *dummy = nil; return _length; } -- (void) release +- (oneway void) release { if (self != empty) { diff --git a/Source/NSMessagePort.m b/Source/NSMessagePort.m index e1522ebd7..48cdb5665 100644 --- a/Source/NSMessagePort.m +++ b/Source/NSMessagePort.m @@ -1696,7 +1696,7 @@ typedef struct { } } -- (void) release +- (oneway void) release { M_LOCK(messagePortLock); if (NSDecrementExtraRefCountWasZero(self)) diff --git a/Source/NSNull.m b/Source/NSNull.m index 56d6eac02..bebd741d8 100644 --- a/Source/NSNull.m +++ b/Source/NSNull.m @@ -104,7 +104,7 @@ static NSNull *null = 0; return NO; } -- (void) release +- (oneway void) release { } diff --git a/Source/NSNumber.m b/Source/NSNumber.m index 70b97d299..725da4d40 100644 --- a/Source/NSNumber.m +++ b/Source/NSNumber.m @@ -378,7 +378,7 @@ static BOOL useSmallInt; } - (id)retain { return self; } - (id)autorelease { return self; } -- (void)release { } +- (oneway void)release { } @end #endif diff --git a/Source/NSPort.m b/Source/NSPort.m index a82253db8..427e8dc78 100644 --- a/Source/NSPort.m +++ b/Source/NSPort.m @@ -184,7 +184,7 @@ static Class NSPort_concrete_class; return [super autorelease]; } -- (void) release +- (oneway void) release { if (_is_valid && [self retainCount] == 1) { diff --git a/Source/NSSocketPort.m b/Source/NSSocketPort.m index 07c6f9848..41693ae9f 100644 --- a/Source/NSSocketPort.m +++ b/Source/NSSocketPort.m @@ -2214,7 +2214,7 @@ static Class tcpPortClass; } } -- (void) release +- (oneway void) release { M_LOCK(tcpPortLock); if (NSDecrementExtraRefCountWasZero(self)) diff --git a/Source/NSTimeZone.m b/Source/NSTimeZone.m index 962b26656..b13a37ab6 100644 --- a/Source/NSTimeZone.m +++ b/Source/NSTimeZone.m @@ -560,7 +560,7 @@ static NSString *_time_zone_path(NSString *subpath, NSString *type) return (GSPlaceholderTimeZone*)zone; } -- (void) release +- (oneway void) release { return; // placeholders never get released. } @@ -620,7 +620,7 @@ static NSString *_time_zone_path(NSString *subpath, NSString *type) return [[NSTimeZoneClass defaultTimeZone] name]; } -- (void) release +- (oneway void) release { } diff --git a/Source/NSURLProtocol.m b/Source/NSURLProtocol.m index 894c7a137..5e531633f 100644 --- a/Source/NSURLProtocol.m +++ b/Source/NSURLProtocol.m @@ -299,7 +299,7 @@ static NSURLProtocol *placeholder = nil; } [super dealloc]; } -- (void) release +- (oneway void) release { /* In a multi-threaded environment we could have two threads release the * class at the same time ... causing -dealloc to be called twice at the diff --git a/Source/NSValue.m b/Source/NSValue.m index 18f1e9dd1..e1b90d750 100644 --- a/Source/NSValue.m +++ b/Source/NSValue.m @@ -700,7 +700,7 @@ static NSLock *placeholderLock; return 0; } -- (void) release +- (oneway void) release { return; // placeholders never get released. }