mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
Make NSNumber more like OSX ... retain for copy, and return YES/NO as BOOL
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@29676 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
42143bb921
commit
012fa8e513
5 changed files with 27 additions and 114 deletions
|
@ -1,3 +1,11 @@
|
|||
2010-02-19 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSConcreteNumber.h: Remove unused file
|
||||
* Source/NSNumberMethods.h:
|
||||
* Source/NSNumber.m:
|
||||
* Source/GSNumberTypes.h:
|
||||
Updates to match OSX behavior.
|
||||
|
||||
2010-02-19 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* configure.ac: Add check for ObjC2 support in runtime.
|
||||
|
|
|
@ -15,7 +15,6 @@ INTEGER_MACRO(signed char, char, Char)
|
|||
INTEGER_MACRO(int, int, Int)
|
||||
INTEGER_MACRO(short, short, Short)
|
||||
INTEGER_MACRO(long, long, Long)
|
||||
INTEGER_MACRO(BOOL, bool, Bool)
|
||||
INTEGER_MACRO(NSInteger, integer, Integer)
|
||||
INTEGER_MACRO(NSUInteger, unsignedInteger, UnsignedInteger)
|
||||
INTEGER_MACRO(long long, longLong, LongLong)
|
||||
|
|
|
@ -1,105 +0,0 @@
|
|||
/* NSConcreteNumber - Interface for Concrete NSNumber classes
|
||||
|
||||
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Adam Fedor <fedor@boulder.colorado.edu>
|
||||
Date: Mar 1995
|
||||
|
||||
This file is part of the GNUstep Base Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
#import "Foundation/NSValue.h"
|
||||
|
||||
@interface NSBoolNumber : NSNumber
|
||||
{
|
||||
BOOL data;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface NSUCharNumber : NSNumber
|
||||
{
|
||||
unsigned char data;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface NSCharNumber : NSNumber
|
||||
{
|
||||
signed char data;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface NSUShortNumber : NSNumber
|
||||
{
|
||||
unsigned short data;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface NSShortNumber : NSNumber
|
||||
{
|
||||
signed short data;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface NSUIntNumber : NSNumber
|
||||
{
|
||||
unsigned int data;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface NSIntNumber : NSNumber
|
||||
{
|
||||
signed int data;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface NSULongNumber : NSNumber
|
||||
{
|
||||
unsigned long data;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface NSLongNumber : NSNumber
|
||||
{
|
||||
signed long data;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface NSULongLongNumber : NSNumber
|
||||
{
|
||||
unsigned long long data;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface NSLongLongNumber : NSNumber
|
||||
{
|
||||
signed long long data;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface NSFloatNumber : NSNumber
|
||||
{
|
||||
float data;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface NSDoubleNumber : NSNumber
|
||||
{
|
||||
double data;
|
||||
}
|
||||
@end
|
||||
|
|
@ -400,6 +400,12 @@ static Class NSDoubleNumberClass;
|
|||
|
||||
#include "GSNumberTypes.h"
|
||||
|
||||
- (id) initWithBool: (BOOL)aValue
|
||||
{
|
||||
[self release];
|
||||
return [[NSNumberClass numberWithBool: aValue] retain];
|
||||
}
|
||||
|
||||
/*
|
||||
* Macro for checking whether this value is the same as one of the singleton
|
||||
* instances.
|
||||
|
@ -596,14 +602,8 @@ if (aValue >= -1 && aValue <= 12)\
|
|||
|
||||
- (id) copyWithZone: (NSZone *) aZone
|
||||
{
|
||||
if (NSShouldRetainWithZone (self, aZone))
|
||||
{
|
||||
return RETAIN (self);
|
||||
}
|
||||
else
|
||||
{
|
||||
return NSCopyObject (self, 0, aZone);
|
||||
}
|
||||
// OSX just returns the receive with no copy.
|
||||
return RETAIN (self);
|
||||
}
|
||||
|
||||
- (id) initWithCoder: (NSCoder *) coder
|
||||
|
@ -643,6 +643,13 @@ if (aValue >= -1 && aValue <= 12)\
|
|||
}
|
||||
|
||||
#include "GSNumberTypes.h"
|
||||
|
||||
- (BOOL) boolValue
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (NSDecimal) decimalValue
|
||||
{
|
||||
NSDecimalNumber *dn;
|
||||
|
|
|
@ -4,6 +4,10 @@
|
|||
return (type)VALUE;\
|
||||
}
|
||||
#include "GSNumberTypes.h"
|
||||
- (BOOL) boolValue
|
||||
{
|
||||
return (VALUE == 0) ? NO : YES;
|
||||
}
|
||||
- (const char *) objCType
|
||||
{
|
||||
return @encode(typeof(VALUE));
|
||||
|
|
Loading…
Reference in a new issue