mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 00:30:53 +00:00
Farious fixes
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@29513 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
dfdd5d3483
commit
29b9911e0d
6 changed files with 150 additions and 25 deletions
15
ChangeLog
15
ChangeLog
|
@ -1,7 +1,18 @@
|
||||||
|
2010-02-08 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* Source/NSAttributedString.m: minor cosmetic change
|
||||||
|
* Source/GSAttributedString.m: Re-introduce proxy for -string
|
||||||
|
and comment to try to avoid it being accidentally removed again.
|
||||||
|
* Source/GSString.m: Fixups to work properly with string proxies.
|
||||||
|
* Source/NSException.m: Re-instate correct behavior and make the
|
||||||
|
comment about it more emphatic.
|
||||||
|
|
||||||
2010-02-08 Jonathan Gillaspie <jonathan.gillaspie@testplant.com>
|
2010-02-08 Jonathan Gillaspie <jonathan.gillaspie@testplant.com>
|
||||||
|
|
||||||
* Source/NSException.m
|
* Source/NSException.m
|
||||||
* Removed redundant call to _NSFoundationUncaughtExceptionHandler and added else blocks
|
* Removed redundant call to _NSFoundationUncaughtExceptionHandler
|
||||||
to allow a set uncaught exception handler to NOT exit if capable of recovering.
|
and added else blocks to allow a set uncaught exception handler
|
||||||
|
to NOT exit if capable of recovering.
|
||||||
|
|
||||||
2010-02-08 Richard Frith-Macdonald <rfm@gnu.org>
|
2010-02-08 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
|
|
@ -72,6 +72,11 @@ extern "C" {
|
||||||
|
|
||||||
//Retrieving character information
|
//Retrieving character information
|
||||||
- (NSUInteger) length;
|
- (NSUInteger) length;
|
||||||
|
/** Returns the string content of the receiver.<br />
|
||||||
|
* NB. this is actually a proxy to the internal content (which may change)
|
||||||
|
* so if you need an immutable instance yu should copy the returned value,
|
||||||
|
* not jhust retain it.
|
||||||
|
*/
|
||||||
- (NSString*) string; //Primitive method!
|
- (NSString*) string; //Primitive method!
|
||||||
|
|
||||||
//Retrieving attribute information
|
//Retrieving attribute information
|
||||||
|
|
|
@ -52,7 +52,9 @@
|
||||||
#import "Foundation/NSRange.h"
|
#import "Foundation/NSRange.h"
|
||||||
#import "Foundation/NSDebug.h"
|
#import "Foundation/NSDebug.h"
|
||||||
#import "Foundation/NSArray.h"
|
#import "Foundation/NSArray.h"
|
||||||
|
#import "Foundation/NSInvocation.h"
|
||||||
#import "Foundation/NSLock.h"
|
#import "Foundation/NSLock.h"
|
||||||
|
#import "Foundation/NSProxy.h"
|
||||||
#import "Foundation/NSThread.h"
|
#import "Foundation/NSThread.h"
|
||||||
#import "Foundation/NSNotification.h"
|
#import "Foundation/NSNotification.h"
|
||||||
#import "Foundation/NSZone.h"
|
#import "Foundation/NSZone.h"
|
||||||
|
@ -61,6 +63,103 @@
|
||||||
|
|
||||||
static NSDictionary *blank;
|
static NSDictionary *blank;
|
||||||
|
|
||||||
|
@interface GSAttributedStringProxy : NSProxy
|
||||||
|
{
|
||||||
|
NSString *string;
|
||||||
|
}
|
||||||
|
- (id) _initWithString: (NSString*)s;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation GSAttributedStringProxy
|
||||||
|
|
||||||
|
static Class NSObjectClass = nil;
|
||||||
|
static Class NSStringClass = nil;
|
||||||
|
|
||||||
|
+ (void) initialize
|
||||||
|
{
|
||||||
|
NSObjectClass = [NSObject class];
|
||||||
|
NSStringClass = [NSString class];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (Class) class
|
||||||
|
{
|
||||||
|
return NSStringClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) dealloc
|
||||||
|
{
|
||||||
|
[string release];
|
||||||
|
[super dealloc];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) forwardInvocation: (NSInvocation*)anInvocation
|
||||||
|
{
|
||||||
|
SEL aSel = [anInvocation selector];
|
||||||
|
|
||||||
|
if (YES == [NSStringClass instancesRespondToSelector: aSel])
|
||||||
|
{
|
||||||
|
[anInvocation invokeWithTarget: string];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[NSException raise: NSGenericException
|
||||||
|
format: @"NSString(instance) does not recognize %s",
|
||||||
|
aSel ? GSNameFromSelector(aSel) : "(null)"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSUInteger) hash
|
||||||
|
{
|
||||||
|
return [string hash];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id) _initWithString: (NSString*)s
|
||||||
|
{
|
||||||
|
string = [s retain];
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL) isEqual: (id)other
|
||||||
|
{
|
||||||
|
return [string isEqual: other];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL) isMemberOfClass: (Class)c
|
||||||
|
{
|
||||||
|
return (c == NSStringClass) ? YES : NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL) isKindOfClass: (Class)c
|
||||||
|
{
|
||||||
|
return (c == NSStringClass || c == NSObjectClass) ? YES : NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSMethodSignature*) methodSignatureForSelector: (SEL)aSelector
|
||||||
|
{
|
||||||
|
NSMethodSignature *sig;
|
||||||
|
|
||||||
|
if (YES == [NSStringClass instancesRespondToSelector: aSelector])
|
||||||
|
{
|
||||||
|
sig = [string methodSignatureForSelector: aSelector];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sig = [super methodSignatureForSelector: aSelector];
|
||||||
|
}
|
||||||
|
return sig;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL) respondsToSelector: (SEL)aSelector
|
||||||
|
{
|
||||||
|
if (YES == [NSStringClass instancesRespondToSelector: aSelector])
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
return [super respondsToSelector: aSelector];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
@interface GSAttributedString : NSAttributedString
|
@interface GSAttributedString : NSAttributedString
|
||||||
{
|
{
|
||||||
NSString *_textChars;
|
NSString *_textChars;
|
||||||
|
@ -79,6 +178,7 @@ static NSDictionary *blank;
|
||||||
{
|
{
|
||||||
NSMutableString *_textChars;
|
NSMutableString *_textChars;
|
||||||
NSMutableArray *_infoArray;
|
NSMutableArray *_infoArray;
|
||||||
|
NSString *_proxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) initWithString: (NSString*)aString
|
- (id) initWithString: (NSString*)aString
|
||||||
|
@ -591,7 +691,14 @@ SANITY();
|
||||||
|
|
||||||
- (NSString*) string
|
- (NSString*) string
|
||||||
{
|
{
|
||||||
return AUTORELEASE([_textChars copy]);
|
/* NB. This method is SUPPOSED to return a proxy to the mutable string!
|
||||||
|
* This is a performance feature documented ifor OSX.
|
||||||
|
*/
|
||||||
|
if (_proxy == nil)
|
||||||
|
{
|
||||||
|
_proxy = [[GSAttributedStringProxy alloc] _initWithString: _textChars];
|
||||||
|
}
|
||||||
|
return _proxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSDictionary*) attributesAtIndex: (unsigned)index
|
- (NSDictionary*) attributesAtIndex: (unsigned)index
|
||||||
|
@ -881,6 +988,7 @@ SANITY();
|
||||||
|
|
||||||
- (void) dealloc
|
- (void) dealloc
|
||||||
{
|
{
|
||||||
|
[_proxy release];
|
||||||
RELEASE(_textChars);
|
RELEASE(_textChars);
|
||||||
RELEASE(_infoArray);
|
RELEASE(_infoArray);
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
|
|
|
@ -831,11 +831,11 @@ fixBOM(unsigned char **bytes, NSUInteger*length, BOOL *owned,
|
||||||
if (string == nil)
|
if (string == nil)
|
||||||
[NSException raise: NSInvalidArgumentException
|
[NSException raise: NSInvalidArgumentException
|
||||||
format: @"-initWithString: given nil string"];
|
format: @"-initWithString: given nil string"];
|
||||||
c = GSObjCClass(string);
|
if (NO == [string isKindOfClass: NSStringClass]) // may be proxy
|
||||||
if (GSObjCIsKindOf(c, NSStringClass) == NO)
|
|
||||||
[NSException raise: NSInvalidArgumentException
|
[NSException raise: NSInvalidArgumentException
|
||||||
format: @"-initWithString: given non-string object"];
|
format: @"-initWithString: given non-string object"];
|
||||||
|
|
||||||
|
c = GSObjCClass(string);
|
||||||
length = [string length];
|
length = [string length];
|
||||||
if (GSObjCIsKindOf(c, GSCStringClass) == YES || c == NSConstantStringClass
|
if (GSObjCIsKindOf(c, GSCStringClass) == YES || c == NSConstantStringClass
|
||||||
|| (GSObjCIsKindOf(c, GSMutableStringClass) == YES
|
|| (GSObjCIsKindOf(c, GSMutableStringClass) == YES
|
||||||
|
@ -2144,7 +2144,7 @@ isEqual_c(GSStr self, id anObject)
|
||||||
}
|
}
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
else if (GSObjCIsKindOf(c, NSStringClass))
|
else if (YES == [anObject isKindOfClass: NSStringClass]) // may be proxy
|
||||||
{
|
{
|
||||||
return (*equalImp)((id)self, equalSel, anObject);
|
return (*equalImp)((id)self, equalSel, anObject);
|
||||||
}
|
}
|
||||||
|
@ -2211,7 +2211,7 @@ isEqual_u(GSStr self, id anObject)
|
||||||
}
|
}
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
else if (GSObjCIsKindOf(c, NSStringClass))
|
else if (YES == [anObject isKindOfClass: NSStringClass]) // may be proxy
|
||||||
{
|
{
|
||||||
return (*equalImp)((id)self, equalSel, anObject);
|
return (*equalImp)((id)self, equalSel, anObject);
|
||||||
}
|
}
|
||||||
|
@ -4767,7 +4767,7 @@ NSAssert(_flags.owned == 1 && _zone != 0, NSInternalInconsistencyException);
|
||||||
}
|
}
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
else if (GSObjCIsKindOf(c, NSStringClass))
|
else if (YES == [anObject isKindOfClass: NSStringClass]) // may be proxy
|
||||||
{
|
{
|
||||||
return (*equalImp)(self, equalSel, anObject);
|
return (*equalImp)(self, equalSel, anObject);
|
||||||
}
|
}
|
||||||
|
@ -4817,7 +4817,7 @@ NSAssert(_flags.owned == 1 && _zone != 0, NSInternalInconsistencyException);
|
||||||
}
|
}
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
else if (GSObjCIsKindOf(c, NSStringClass))
|
else if (YES == [anObject isKindOfClass: NSStringClass]) // may be proxy
|
||||||
{
|
{
|
||||||
return (*equalImp)(self, equalSel, anObject);
|
return (*equalImp)(self, equalSel, anObject);
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,7 +157,9 @@ static Class GSMutableAttributedStringClass;
|
||||||
[aCoder encodeObject: [self string] forKey: @"NSString"];
|
[aCoder encodeObject: [self string] forKey: @"NSString"];
|
||||||
if ([self length] > 0)
|
if ([self length] > 0)
|
||||||
{
|
{
|
||||||
NSDictionary* attrs = [self attributesAtIndex: 0 effectiveRange: NULL];
|
NSDictionary *attrs;
|
||||||
|
|
||||||
|
attrs = [self attributesAtIndex: 0 effectiveRange: NULL];
|
||||||
|
|
||||||
[aCoder encodeObject: attrs forKey: @"NSAttributes"];
|
[aCoder encodeObject: attrs forKey: @"NSAttributes"];
|
||||||
}
|
}
|
||||||
|
@ -523,7 +525,7 @@ static Class GSMutableAttributedStringClass;
|
||||||
return NO;
|
return NO;
|
||||||
|
|
||||||
length = [otherString length];
|
length = [otherString length];
|
||||||
if (length<=0)
|
if (length == 0)
|
||||||
return YES;
|
return YES;
|
||||||
|
|
||||||
ownDictionary = [self attributesAtIndex: 0
|
ownDictionary = [self attributesAtIndex: 0
|
||||||
|
|
|
@ -774,9 +774,7 @@ callUncaughtHandler(id value)
|
||||||
{
|
{
|
||||||
(*_NSUncaughtExceptionHandler)(value);
|
(*_NSUncaughtExceptionHandler)(value);
|
||||||
}
|
}
|
||||||
else {
|
_NSFoundationUncaughtExceptionHandler(value);
|
||||||
_NSFoundationUncaughtExceptionHandler(value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@implementation NSException
|
@implementation NSException
|
||||||
|
@ -924,19 +922,20 @@ callUncaughtHandler(id value)
|
||||||
*/
|
*/
|
||||||
callUncaughtHandler(self);
|
callUncaughtHandler(self);
|
||||||
|
|
||||||
/*
|
/* The uncaught exception handler which is set has not exited,
|
||||||
* The uncaught exception handler which is set has not
|
* so we MUST call the builtin handler, (normal behavior of MacOS-X).
|
||||||
* exited, so we call the builtin handler, (undocumented
|
* The standard handler is guaranteed to exit/abort, which is the
|
||||||
* behavior of MacOS-X).
|
* required behavioru for OSX compatibility.
|
||||||
* The standard handler is guaranteed to exit/abort.
|
* NB Cocoa's Exception Handling framework bypasses this behavior
|
||||||
|
* somehow ... if anyone contributes an implementation we could
|
||||||
|
* integrate it here.
|
||||||
*/
|
*/
|
||||||
//_NSFoundationUncaughtExceptionHandler(self);
|
_NSFoundationUncaughtExceptionHandler(self);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
thread->_exception_handler = handler->next;
|
thread->_exception_handler = handler->next;
|
||||||
handler->exception = self;
|
handler->exception = self;
|
||||||
longjmp(handler->jumpState, 1);
|
longjmp(handler->jumpState, 1);
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue