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:
rfm 2009-09-12 07:37:00 +00:00
parent 88fd37ca57
commit 1a11998ecf
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,12 +117,15 @@ 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

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

@ -246,6 +246,7 @@ extern "C" {
* slower, but more portable.
*/
+ (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
@ -259,19 +260,6 @@ extern "C" {
+ (BOOL) resolveInstanceMethod: (SEL)name;
#endif
#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST)
/**
* 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
* default implementation of this returns nil, but care should be taken when
* subclassing NSObject subclasses and overriding this method that
* the superclass implementation is called if returning nil.
*
* Note: This method is only reliable when using the GNUstep runtime and code
* compiled with clang. If you require compatibility with GCC and the GCC
* 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
@ -285,6 +273,21 @@ extern "C" {
* 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
* default implementation of this returns nil, but care should be taken when
* subclassing NSObject subclasses and overriding this method that
* the superclass implementation is called if returning nil.
*
* Note: This method is only reliable when using the GNUstep runtime and code
* compiled with clang. If you require compatibility with GCC and the GCC
* runtime, you must also implement -forwardInvocation: with equivalent
* semantics. This will be considerably slower, but more portable.
*/
- (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,12 +470,19 @@ 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;
/**
* 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
@ -479,14 +490,11 @@ GS_EXPORT NSRecursiveLock *gnustep_global_lock;
* accessing the contents.
*/
- (void) endContentAccess;
/**
* Discards the contents of the object if it is not currently being edited.
*/
- (void)discardContentIfPossible;
/**
* 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;
@end

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

@ -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,22 +2014,25 @@ 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;
}
+ (BOOL)resolveInstanceMethod:(SEL)name;
{
return NO;
}
- (id)forwardingTargetForSelector:(SEL)aSelector;
{
return nil;
return class_get_version(self);
}
- (id) autoContentAccessingProxy
{
return AUTORELEASE([[GSContentAccessingProxy alloc] initWithObject: self]);
}
- (id) forwardingTargetForSelector:(SEL)aSelector;
{
return nil;
}
@end
@ -2475,20 +2478,17 @@ 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
{
[object endContentAccess];
}
- (void)dealloc
{
[object endContentAccess];
}
- (id) forwardingTargetForSelector: (SEL)aSelector
{
return object;
@ -2498,6 +2498,14 @@ GSGarbageCollectorLog(char *msg, GC_word arg)
{
[anInvocation invokeWithTarget: object];
}
- (id) initWithObject: (id)anObject
{
ASSIGN(object, anObject);
[object beginContentAccess];
return self;
}
- (NSMethodSignature*) methodSignatureForSelector: (SEL)aSelector
{
return [object methodSignatureForSelector: aSelector];