Cleanups and minor bugfixes for new code.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@28665 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2009-09-12 07:37:00 +00:00
parent bed83a2f29
commit 640ae938c6
27 changed files with 156 additions and 92 deletions

View file

@ -1,3 +1,37 @@
2009-09-12 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSCalendarDate.m: Add optional diagnostics to detect system
time changes and warn about them.
* Source/NSException.m: Clean up to match coding standards.
Fix uninitialised variable bug.
* Source/NSObject.m: clean up and fix missing dealloc.
* Headers/Foundation/NSURLCredential.h:
* Headers/Foundation/NSHTTPCookieStorage.h:
* Headers/Foundation/NSException.h:
* Headers/Foundation/NSValueTransformer.h:
* Headers/Foundation/NSURLAuthenticationChallenge.h:
* Headers/Foundation/NSObject.h:
* Headers/Foundation/NSString.h:
* Headers/Foundation/NSStream.h:
* Headers/Foundation/NSThread.h:
* Headers/Foundation/NSHTTPCookie.h:
* Headers/Foundation/NSURLError.h:
* Headers/Foundation/NSURLProtectionSpace.h:
* Headers/Foundation/NSURLDownload.h:
* Headers/Foundation/NSKeyValueObserving.h:
* Headers/Foundation/NSURLRequest.h:
* Headers/Foundation/NSURLCredentialStorage.h:
* Headers/Foundation/NSInvocation.h:
* Headers/Foundation/NSURLResponse.h:
* Headers/Foundation/NSURLConnection.h:
* Headers/Foundation/NSIndexPath.h:
* Headers/Foundation/NSURLProtocol.h:
* Headers/Foundation/NSURLCache.h:
* Headers/Additions/GNUstepBase/GSVersionMacros.h:
Fix up errors in version of feature addition to GNUstep. Some
GNUstep version constants had leading zeros so they were interpreted
as octal rather than decimal.
2009-09-11 David Chisnall <csdavec@swan.ac.uk>
* Source/NSException.m:
@ -16,7 +50,8 @@
Added implementations of the hooks provided by the new runtime. This
brings NSObject up to feature-parity with the OS X 10.5 implementation
when using the new runtime and up to feature-parity with the 10.6
implementation if you are using the new runtime and compiling with clang.
implementation if you are using the new runtime and compiling with
clang.
Also removes the objc_mutex_wibble stuff from NSObject in favour of just
using NSLocks (which, with the new implementation, are now faster than

View file

@ -29,7 +29,7 @@
* Check consistency of definitions for system compatibility.
*/
#if defined(STRICT_OPENSTEP)
#define GS_OPENSTEP_V 010000
#define GS_OPENSTEP_V 10000
#define NO_GNUSTEP 1
#elif defined(STRICT_MACOS_X)
#define GS_OPENSTEP_V 100000

View file

@ -117,19 +117,22 @@ extern "C" {
format: (NSString*)format
arguments: (va_list)argList;
#if OS_API_VERSION(100500,GS_API_LATEST) && GS_API_VERSION(011501,GS_API_LATEST)
#if OS_API_VERSION(100500,GS_API_LATEST) && GS_API_VERSION( 11501,GS_API_LATEST)
/** Returns an array of the call stack return addresses at the point when
* the exception was raised. Re-raising the exception does not change
* this value.
*/
- (NSArray*) callStackReturnAddresses;
#endif
#if OS_API_VERSION(100600,GS_API_LATEST) && GS_API_VERSION( 11903,GS_API_LATEST)
/**
* Returns an array of the symbolic names of the call stack return addresses.
* Note that, on some platforms, symbols are only exported in
* position-independent code and so these may only return numeric addresses for
* code in static libraries or the main application.
*/
- (NSArray *)callStackSymbols;
- (NSArray*) callStackSymbols;
#endif
/**

View file

@ -26,7 +26,7 @@
#define __NSHTTPCookie_h_GNUSTEP_BASE_INCLUDE
#import <GNUstepBase/GSVersionMacros.h>
#if OS_API_VERSION(100200,GS_API_LATEST) && GS_API_VERSION(011300,GS_API_LATEST)
#if OS_API_VERSION(100200,GS_API_LATEST) && GS_API_VERSION( 11300,GS_API_LATEST)
#import <Foundation/NSObject.h>

View file

@ -26,7 +26,7 @@
#define __NSHTTPCookieStorage_h_GNUSTEP_BASE_INCLUDE
#import <GNUstepBase/GSVersionMacros.h>
#if OS_API_VERSION(100200,GS_API_LATEST) && GS_API_VERSION(011300,GS_API_LATEST)
#if OS_API_VERSION(100200,GS_API_LATEST) && GS_API_VERSION( 11300,GS_API_LATEST)
#import <Foundation/NSObject.h>

View file

@ -35,7 +35,7 @@
extern "C" {
#endif
#if OS_API_VERSION(100400,GS_API_LATEST) && GS_API_VERSION(010200,GS_API_LATEST)
#if OS_API_VERSION(100400,GS_API_LATEST) && GS_API_VERSION( 10200,GS_API_LATEST)
/**
* Instances of this class represent a series of indexes into a hierarchy

View file

@ -77,7 +77,7 @@ extern "C" {
- (BOOL) argumentsRetained;
- (void) retainArguments;
#if OS_API_VERSION(GS_API_NONE,GS_API_NONE) && GS_API_VERSION(011101,GS_API_LATEST)
#if OS_API_VERSION(GS_API_NONE,GS_API_NONE) && GS_API_VERSION( 11101,GS_API_LATEST)
- (BOOL) targetRetained;
- (void) retainArgumentsIncludingTarget: (BOOL)retainTargetFlag;
#endif

View file

@ -26,7 +26,7 @@
#define __NSKeyValueObserving_h_GNUSTEP_BASE_INCLUDE
#import <GNUstepBase/GSVersionMacros.h>
#if OS_API_VERSION(100300,GS_API_LATEST) && GS_API_VERSION(010200,GS_API_LATEST)
#if OS_API_VERSION(100300,GS_API_LATEST) && GS_API_VERSION( 10200,GS_API_LATEST)
#import <Foundation/NSObject.h>
#import <Foundation/NSArray.h>

View file

@ -245,7 +245,8 @@ extern "C" {
* -forwardInvocation: with equivalent semantics. This will be considerably
* slower, but more portable.
*/
+ (BOOL)resolveClassMethod:(SEL)name;
+ (BOOL) resolveClassMethod: (SEL)name;
/**
* This method will be called when attempting to send a message an instance
* that does not understand it. The class may install a new method for the
@ -256,9 +257,23 @@ extern "C" {
* -forwardInvocation: with equivalent semantics. This will be considerably
* slower, but more portable.
*/
+ (BOOL)resolveInstanceMethod:(SEL)name;
+ (BOOL) resolveInstanceMethod: (SEL)name;
#endif
#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST)
/**
* Returns an auto-accessing proxy for the given object. This proxy sends a
* -beginContentAccess message to the receiver when it is created and an
* -endContentAccess message when it is destroyed. This prevents an object
* that implements the NSDiscardableContent protocol from having its contents
* discarded for as long as the proxy exists.
*
* On systems using the GNUstep runtime, messages send to the proxy will be
* slightly slower than direct messages. With the GCC runtime, they will be
* approximately two orders of magnitude slower. The GNUstep runtime,
* therefore, is strongly recommended for code calling this method.
*/
- (id) autoContentAccessingProxy;
/**
* If an object does not understand a message, it may delegate it to another
* object. Returning nil indicates that forwarding should not take place. The
@ -271,20 +286,8 @@ extern "C" {
* runtime, you must also implement -forwardInvocation: with equivalent
* semantics. This will be considerably slower, but more portable.
*/
- (id)forwardingTargetForSelector:(SEL)aSelector;
/**
* Returns an auto-accessing proxy for the given object. This proxy sends a
* -beginContentAccess message to the receiver when it is created and an
* -endContentAccess message when it is destroyed. This prevents an object
* that implements the NSDiscardableContent protocol from having its contents
* discarded for as long as the proxy exists.
*
* On systems using the GNUstep runtime, messages send to the proxy will be
* slightly slower than direct messages. With the GCC runtime, they will be
* approximately two orders of magnitude slower. The GNUstep runtime,
* therefore, is strongly recommended for code calling this method.
*/
- (id)autoContentAccessingProxy;
- (id) forwardingTargetForSelector: (SEL)aSelector;
#endif
@end
@ -459,6 +462,7 @@ GS_EXPORT NSRecursiveLock *gnustep_global_lock;
afterDelay: (NSTimeInterval)seconds
inModes: (NSArray*)modes;
@end
#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST)
/**
* The NSDiscardableContent protocol is used by objects which encapsulate data
@ -466,29 +470,33 @@ GS_EXPORT NSRecursiveLock *gnustep_global_lock;
* constraints are typically, but not always, related memory.
*/
@protocol NSDiscardableContent
/**
* This method is called before any access to the object. It returns YES if
* the object's content is still valid. The caller must call -endContentAccess
* once for every call to -beginContentAccess;
*/
- (BOOL)beginContentAccess;
- (BOOL) beginContentAccess;
/**
* Discards the contents of the object if it is not currently being edited.
*/
- (void) discardContentIfPossible;
/**
* This method indicates that the caller has finished accessing the contents of
* the object adopting this protocol. Every call to -beginContentAccess must
* be be paired with a call to this method after the caller has finished
* accessing the contents.
*/
- (void)endContentAccess;
/**
* Discards the contents of the object if it is not currently being edited.
*/
- (void)discardContentIfPossible;
- (void) endContentAccess;
/**
* Returns YES if the contents of the object have been discarded, either via a
* call to -discardContentIfPossible while the object is not in use, or by some
* implementation-dependent mechanism.
* implementation dependent mechanism.
*/
- (BOOL)isContentDiscarded;
- (BOOL) isContentDiscarded;
@end
#endif
#if defined(__cplusplus)

View file

@ -25,7 +25,7 @@
#define __NSStream_h_GNUSTEP_BASE_INCLUDE
#import <GNUstepBase/GSVersionMacros.h>
#if OS_API_VERSION(100400,GS_API_LATEST) && GS_API_VERSION(010200,GS_API_LATEST)
#if OS_API_VERSION(100400,GS_API_LATEST) && GS_API_VERSION( 10200,GS_API_LATEST)
#import <Foundation/NSObject.h>

View file

@ -252,7 +252,7 @@ typedef NSUInteger NSStringEncodingConversionOptions;
+ (id) string;
+ (id) stringWithCharacters: (const unichar*)chars
length: (NSUInteger)length;
#if OS_API_VERSION(100400,GS_API_LATEST) && GS_API_VERSION(010200,GS_API_LATEST)
#if OS_API_VERSION(100400,GS_API_LATEST) && GS_API_VERSION( 10200,GS_API_LATEST)
+ (id) stringWithCString: (const char*)byteString
encoding: (NSStringEncoding)encoding;
#endif
@ -264,7 +264,7 @@ typedef NSUInteger NSStringEncodingConversionOptions;
// Initializing Newly Allocated Strings
- (id) init;
#if OS_API_VERSION(100400,GS_API_LATEST) && GS_API_VERSION(010200,GS_API_LATEST)
#if OS_API_VERSION(100400,GS_API_LATEST) && GS_API_VERSION( 10200,GS_API_LATEST)
- (id) initWithBytes: (const void*)bytes
length: (NSUInteger)length
encoding: (NSStringEncoding)encoding;
@ -367,7 +367,7 @@ typedef NSUInteger NSStringEncodingConversionOptions;
- (const char*) cString;
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
#if OS_API_VERSION(100400,GS_API_LATEST) && GS_API_VERSION(010200,GS_API_LATEST)
#if OS_API_VERSION(100400,GS_API_LATEST) && GS_API_VERSION( 10200,GS_API_LATEST)
- (const char*) cStringUsingEncoding: (NSStringEncoding)encoding;
- (BOOL) getCString: (char*)buffer
maxLength: (NSUInteger)maxLength

View file

@ -114,13 +114,13 @@ extern "C" {
- (NSMutableDictionary*) threadDictionary;
#if OS_API_VERSION(MAC_OS_X_VERSION_10_2,GS_API_LATEST) \
&& GS_API_VERSION(010200,GS_API_LATEST)
&& GS_API_VERSION( 10200,GS_API_LATEST)
+ (void) setThreadPriority: (double)pri;
+ (double) threadPriority;
#endif
#if OS_API_VERSION(MAC_OS_X_VERSION_10_5,GS_API_LATEST) \
&& GS_API_VERSION(011501,GS_API_LATEST)
&& GS_API_VERSION( 11501,GS_API_LATEST)
/** Returns an array of the call stack return addresses.
*/

View file

@ -26,7 +26,7 @@
#define __NSURLAuthenticationChallenge_h_GNUSTEP_BASE_INCLUDE
#import <GNUstepBase/GSVersionMacros.h>
#if OS_API_VERSION(100200,GS_API_LATEST) && GS_API_VERSION(011300,GS_API_LATEST)
#if OS_API_VERSION(100200,GS_API_LATEST) && GS_API_VERSION( 11300,GS_API_LATEST)
#import <Foundation/NSObject.h>

View file

@ -26,7 +26,7 @@
#define __NSURLCache_h_GNUSTEP_BASE_INCLUDE
#import <GNUstepBase/GSVersionMacros.h>
#if OS_API_VERSION(100200,GS_API_LATEST) && GS_API_VERSION(011300,GS_API_LATEST)
#if OS_API_VERSION(100200,GS_API_LATEST) && GS_API_VERSION( 11300,GS_API_LATEST)
#import <Foundation/NSObject.h>

View file

@ -26,7 +26,7 @@
#define __NSURLConnection_h_GNUSTEP_BASE_INCLUDE
#import <GNUstepBase/GSVersionMacros.h>
#if OS_API_VERSION(100200,GS_API_LATEST) && GS_API_VERSION(011300,GS_API_LATEST)
#if OS_API_VERSION(100200,GS_API_LATEST) && GS_API_VERSION( 11300,GS_API_LATEST)
#import <Foundation/NSObject.h>

View file

@ -26,7 +26,7 @@
#define __NSURLCredential_h_GNUSTEP_BASE_INCLUDE
#import <GNUstepBase/GSVersionMacros.h>
#if OS_API_VERSION(100200,GS_API_LATEST) && GS_API_VERSION(011300,GS_API_LATEST)
#if OS_API_VERSION(100200,GS_API_LATEST) && GS_API_VERSION( 11300,GS_API_LATEST)
#import <Foundation/NSObject.h>

View file

@ -26,7 +26,7 @@
#define __NSURLCredentialStorage_h_GNUSTEP_BASE_INCLUDE
#import <GNUstepBase/GSVersionMacros.h>
#if OS_API_VERSION(100200,GS_API_LATEST) && GS_API_VERSION(011300,GS_API_LATEST)
#if OS_API_VERSION(100200,GS_API_LATEST) && GS_API_VERSION( 11300,GS_API_LATEST)
#import <Foundation/NSObject.h>

View file

@ -26,7 +26,7 @@
#define __NSURLDownload_h_GNUSTEP_BASE_INCLUDE
#import <GNUstepBase/GSVersionMacros.h>
#if OS_API_VERSION(100200,GS_API_LATEST) && GS_API_VERSION(011300,GS_API_LATEST)
#if OS_API_VERSION(100200,GS_API_LATEST) && GS_API_VERSION( 11300,GS_API_LATEST)
#import <Foundation/NSObject.h>

View file

@ -26,7 +26,7 @@
#define __NSURLError_h_GNUSTEP_BASE_INCLUDE
#import <GNUstepBase/GSVersionMacros.h>
#if OS_API_VERSION(100200,GS_API_LATEST) && GS_API_VERSION(011300,GS_API_LATEST)
#if OS_API_VERSION(100200,GS_API_LATEST) && GS_API_VERSION( 11300,GS_API_LATEST)
#import <Foundation/NSObject.h>

View file

@ -26,7 +26,7 @@
#define __NSURLProtectionSpace_h_GNUSTEP_BASE_INCLUDE
#import <GNUstepBase/GSVersionMacros.h>
#if OS_API_VERSION(100200,GS_API_LATEST) && GS_API_VERSION(011300,GS_API_LATEST)
#if OS_API_VERSION(100200,GS_API_LATEST) && GS_API_VERSION( 11300,GS_API_LATEST)
#import <Foundation/NSObject.h>

View file

@ -26,7 +26,7 @@
#define __NSURLProtocol_h_GNUSTEP_BASE_INCLUDE
#import <GNUstepBase/GSVersionMacros.h>
#if OS_API_VERSION(100200,GS_API_LATEST) && GS_API_VERSION(011300,GS_API_LATEST)
#if OS_API_VERSION(100200,GS_API_LATEST) && GS_API_VERSION( 11300,GS_API_LATEST)
#import <Foundation/NSObject.h>

View file

@ -26,7 +26,7 @@
#define __NSURLRequest_h_GNUSTEP_BASE_INCLUDE
#import <GNUstepBase/GSVersionMacros.h>
#if OS_API_VERSION(100200,GS_API_LATEST) && GS_API_VERSION(011300,GS_API_LATEST)
#if OS_API_VERSION(100200,GS_API_LATEST) && GS_API_VERSION( 11300,GS_API_LATEST)
#import <Foundation/NSObject.h>

View file

@ -26,7 +26,7 @@
#define __NSURLResponse_h_GNUSTEP_BASE_INCLUDE
#import <GNUstepBase/GSVersionMacros.h>
#if OS_API_VERSION(100200,GS_API_LATEST) && GS_API_VERSION(011300,GS_API_LATEST)
#if OS_API_VERSION(100200,GS_API_LATEST) && GS_API_VERSION( 11300,GS_API_LATEST)
#import <Foundation/NSObject.h>

View file

@ -27,7 +27,7 @@
#define __NSValueTransformer_h_GNUSTEP_BASE_INCLUDE
#import <GNUstepBase/GSVersionMacros.h>
#if OS_API_VERSION(100300,GS_API_LATEST) && GS_API_VERSION(010200,GS_API_LATEST)
#if OS_API_VERSION(100300,GS_API_LATEST) && GS_API_VERSION( 10200,GS_API_LATEST)
#import <Foundation/NSObject.h>

View file

@ -289,26 +289,36 @@ GSBreakTime(NSTimeInterval when, int *year, int *month, int *day,
NSTimeInterval
GSTimeNow(void)
{
NSTimeInterval t;
#if !defined(__MINGW32__)
NSTimeInterval interval;
struct timeval tp;
gettimeofday (&tp, NULL);
interval = -NSTimeIntervalSince1970;
interval += tp.tv_sec;
interval += (double)tp.tv_usec / 1000000.0;
return interval;
t = (NSTimeInterval)tp.tv_sec - NSTimeIntervalSince1970;
t += (NSTimeInterval)tp.tv_usec / (NSTimeInterval)1000000.0;
#else
SYSTEMTIME sys_time;
NSTimeInterval t;
/*
* Get current GMT time, convert to NSTimeInterval since reference date,
*/
GetSystemTime(&sys_time);
t = GSTime(sys_time.wDay, sys_time.wMonth, sys_time.wYear, sys_time.wHour,
sys_time.wMinute, sys_time.wSecond, sys_time.wMilliseconds);
return t;
#endif /* __MINGW32__ */
#if defined(DEBUG)
{
static NSTimeInterval old = 0.0;
if (t < old)
{
fprintf(stderr, "WARNING: system time changed by %g seconds\n",
t - old);
}
old = t;
}
#endif
return t;
}
/**

View file

@ -96,7 +96,7 @@ Class GSStackTraceClass;
{
NSMutableString *trace = [NSMutableString string];
NSEnumerator *e = [[self symbols] objectEnumerator];
int i;
int i = 0;
id obj;
while ((obj = [e nextObject]))

View file

@ -117,9 +117,9 @@ static Class NSConstantStringClass;
@interface GSContentAccessingProxy : NSProxy
{
NSObject<NSDiscardableContent> *object;
NSObject<NSDiscardableContent> *object;
}
- (id)initWithObject: (id)anObject;
- (id) initWithObject: (id)anObject;
@end
/*
@ -1991,14 +1991,14 @@ GSGarbageCollectorLog(char *msg, GC_word arg)
return self;
}
/**
* Returns the version number of the receiving class. This will default to
* a number assigned by the Objective C compiler if [NSObject -setVersion] has
* not been called.
*/
+ (NSInteger) version
+ (BOOL) resolveClassMethod: (SEL)name
{
return class_get_version(self);
return NO;
}
+ (BOOL) resolveInstanceMethod: (SEL)name;
{
return NO;
}
/**
@ -2014,21 +2014,24 @@ GSGarbageCollectorLog(char *msg, GC_word arg)
return self;
}
+ (BOOL)resolveClassMethod:(SEL)name
/**
* Returns the version number of the receiving class. This will default to
* a number assigned by the Objective C compiler if [NSObject -setVersion] has
* not been called.
*/
+ (NSInteger) version
{
return NO;
return class_get_version(self);
}
+ (BOOL)resolveInstanceMethod:(SEL)name;
- (id) autoContentAccessingProxy
{
return NO;
return AUTORELEASE([[GSContentAccessingProxy alloc] initWithObject: self]);
}
- (id)forwardingTargetForSelector:(SEL)aSelector;
- (id) forwardingTargetForSelector:(SEL)aSelector;
{
return nil;
}
- (id)autoContentAccessingProxy
{
return AUTORELEASE([[GSContentAccessingProxy alloc] initWithObject: self]);
return nil;
}
@end
@ -2475,31 +2478,36 @@ GSGarbageCollectorLog(char *msg, GC_word arg)
@end
@implementation GSContentAccessingProxy
- (id)initWithObject: (id)anObject
- (void) dealloc
{
ASSIGN(object, anObject);
[object beginContentAccess];
return self;
[object endContentAccess];
[super dealloc];
}
- (void)finalize
- (void) finalize
{
[object endContentAccess];
[object endContentAccess];
}
- (void)dealloc
- (id) forwardingTargetForSelector: (SEL)aSelector
{
[object endContentAccess];
}
- (id)forwardingTargetForSelector: (SEL)aSelector
{
return object;
return object;
}
/* Support for legacy runtimes... */
- (void) forwardInvocation: (NSInvocation*)anInvocation
{
[anInvocation invokeWithTarget: object];
[anInvocation invokeWithTarget: object];
}
- (id) initWithObject: (id)anObject
{
ASSIGN(object, anObject);
[object beginContentAccess];
return self;
}
- (NSMethodSignature*) methodSignatureForSelector: (SEL)aSelector
{
return [object methodSignatureForSelector: aSelector];
return [object methodSignatureForSelector: aSelector];
}
@end