mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 16:30:41 +00:00
Minor usability tweak.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@18240 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
41479d85fb
commit
99ac08eca9
2 changed files with 35 additions and 3 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2003-11-30 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* Source/NSNumber.m: Raise exception if user code incorrectly tries
|
||||||
|
to deallocate a cached small number.
|
||||||
|
|
||||||
2003-11-25 Richard Frith-Macdonald <rfm@gnu.org>
|
2003-11-25 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Source/Additions/GSMime.m: fix for incremental parsing so that
|
* Source/Additions/GSMime.m: fix for incremental parsing so that
|
||||||
|
|
|
@ -41,6 +41,33 @@
|
||||||
|
|
||||||
#include "NSConcreteNumber.h"
|
#include "NSConcreteNumber.h"
|
||||||
|
|
||||||
|
@interface GSCachedBool : NSBoolNumber
|
||||||
|
@end
|
||||||
|
@interface GSCachedInt : NSIntNumber
|
||||||
|
@end
|
||||||
|
@implementation GSCachedBool
|
||||||
|
- (id) copyWithZone: (NSZone*)zone
|
||||||
|
{
|
||||||
|
return RETAIN(self);
|
||||||
|
}
|
||||||
|
- (void) dealloc
|
||||||
|
{
|
||||||
|
[NSException raise: NSGenericException
|
||||||
|
format: @"Attempt to deallocate bool number owned by cache"];
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
@implementation GSCachedInt
|
||||||
|
- (id) copyWithZone: (NSZone*)zone
|
||||||
|
{
|
||||||
|
return RETAIN(self);
|
||||||
|
}
|
||||||
|
- (void) dealloc
|
||||||
|
{
|
||||||
|
[NSException raise: NSGenericException
|
||||||
|
format: @"Attempt to deallocate int number owned by cache"];
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
@implementation NSNumber
|
@implementation NSNumber
|
||||||
|
|
||||||
static NSMapTable *numberMap;
|
static NSMapTable *numberMap;
|
||||||
|
@ -204,12 +231,12 @@ static Class doubleNumberClass;
|
||||||
/*
|
/*
|
||||||
* cache bool values.
|
* cache bool values.
|
||||||
*/
|
*/
|
||||||
boolN = (NSNumber*)NSAllocateObject(boolNumberClass, 0,
|
boolN = (NSNumber*)NSAllocateObject([GSCachedBool class], 0,
|
||||||
NSDefaultMallocZone());
|
NSDefaultMallocZone());
|
||||||
boolean = NO;
|
boolean = NO;
|
||||||
boolN = [boolN initWithBytes: &boolean objCType: NULL];
|
boolN = [boolN initWithBytes: &boolean objCType: NULL];
|
||||||
|
|
||||||
boolY = (NSNumber*)NSAllocateObject(boolNumberClass, 0,
|
boolY = (NSNumber*)NSAllocateObject([GSCachedBool class], 0,
|
||||||
NSDefaultMallocZone());
|
NSDefaultMallocZone());
|
||||||
boolean = YES;
|
boolean = YES;
|
||||||
boolY = [boolY initWithBytes: &boolean objCType: NULL];
|
boolY = [boolY initWithBytes: &boolean objCType: NULL];
|
||||||
|
@ -221,7 +248,7 @@ static Class doubleNumberClass;
|
||||||
{
|
{
|
||||||
NSNumber *num;
|
NSNumber *num;
|
||||||
|
|
||||||
num = (NSNumber*)NSAllocateObject(intNumberClass, 0,
|
num = (NSNumber*)NSAllocateObject([GSCachedInt class], 0,
|
||||||
NSDefaultMallocZone());
|
NSDefaultMallocZone());
|
||||||
num = [num initWithBytes: &integer objCType: NULL];
|
num = [num initWithBytes: &integer objCType: NULL];
|
||||||
smallIntegers[integer + GS_SMALL] = num;
|
smallIntegers[integer + GS_SMALL] = num;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue