1995-08-30 21:32:11 +00:00
|
|
|
# line 1 "NSConcreteNumber.m" /* So gdb knows which file we are in */
|
1995-04-03 20:49:14 +00:00
|
|
|
/* NSConcreteNumber - Object encapsulation of numbers
|
|
|
|
|
2000-03-23 18:57:43 +00:00
|
|
|
Copyright (C) 1993, 1994, 1996, 2000 Free Software Foundation, Inc.
|
1995-04-03 20:49:14 +00:00
|
|
|
|
|
|
|
Written by: Adam Fedor <fedor@boulder.colorado.edu>
|
|
|
|
Date: Mar 1995
|
2000-03-23 18:57:43 +00:00
|
|
|
Rewrite: Richard Frith-Macdonald <rfm@gnu.org>
|
|
|
|
Date: Mar 2000
|
1995-04-03 20:49:14 +00:00
|
|
|
|
1996-05-12 00:56:10 +00:00
|
|
|
This file is part of the GNUstep Base Library.
|
1995-04-03 20:49:14 +00:00
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Library 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 Library General Public
|
|
|
|
License along with this library; if not, write to the Free
|
1999-09-09 02:56:20 +00:00
|
|
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
1995-04-03 20:49:14 +00:00
|
|
|
*/
|
|
|
|
|
1997-11-06 00:51:23 +00:00
|
|
|
#include <config.h>
|
2000-06-14 04:03:56 +00:00
|
|
|
#include <base/preface.h>
|
2000-06-22 03:15:27 +00:00
|
|
|
#include <Foundation/NSObjCRuntime.h>
|
2000-03-19 21:40:06 +00:00
|
|
|
#include <GSConfig.h>
|
1995-04-17 21:13:20 +00:00
|
|
|
#include <Foundation/NSConcreteNumber.h>
|
|
|
|
#include <Foundation/NSString.h>
|
|
|
|
#include <Foundation/NSException.h>
|
|
|
|
#include <Foundation/NSCoder.h>
|
1998-12-18 17:05:44 +00:00
|
|
|
#include <Foundation/NSPortCoder.h>
|
2000-03-19 21:40:06 +00:00
|
|
|
#include <Foundation/NSCoder.h>
|
1995-04-03 20:49:14 +00:00
|
|
|
|
|
|
|
/* This file should be run through a preprocessor with the macro TYPE_ORDER
|
|
|
|
defined to a number from 0 to 12 cooresponding to each number type */
|
|
|
|
#if TYPE_ORDER == 0
|
|
|
|
# define NumberTemplate NSBoolNumber
|
1998-12-07 19:45:08 +00:00
|
|
|
# define TYPE_FORMAT @"%u"
|
2000-03-23 18:57:43 +00:00
|
|
|
# define TYPE_TYPE BOOL
|
1995-04-03 20:49:14 +00:00
|
|
|
#elif TYPE_ORDER == 1
|
|
|
|
# define NumberTemplate NSCharNumber
|
|
|
|
# define TYPE_FORMAT @"%c"
|
2000-08-07 22:00:31 +00:00
|
|
|
# define TYPE_TYPE signed char
|
2000-03-19 20:57:09 +00:00
|
|
|
#elif TYPE_ORDER == 2
|
|
|
|
# define NumberTemplate NSUCharNumber
|
|
|
|
# define TYPE_FORMAT @"%c"
|
2000-03-23 18:57:43 +00:00
|
|
|
# define TYPE_TYPE unsigned char
|
1995-04-03 20:49:14 +00:00
|
|
|
#elif TYPE_ORDER == 3
|
|
|
|
# define NumberTemplate NSShortNumber
|
|
|
|
# define TYPE_FORMAT @"%hd"
|
2000-08-07 22:00:31 +00:00
|
|
|
# define TYPE_TYPE signed short
|
2000-03-19 20:57:09 +00:00
|
|
|
#elif TYPE_ORDER == 4
|
|
|
|
# define NumberTemplate NSUShortNumber
|
|
|
|
# define TYPE_FORMAT @"%hu"
|
2000-03-23 18:57:43 +00:00
|
|
|
# define TYPE_TYPE unsigned short
|
1995-04-03 20:49:14 +00:00
|
|
|
#elif TYPE_ORDER == 5
|
|
|
|
# define NumberTemplate NSIntNumber
|
|
|
|
# define TYPE_FORMAT @"%d"
|
2000-08-07 22:00:31 +00:00
|
|
|
# define TYPE_TYPE signed int
|
2000-03-19 20:57:09 +00:00
|
|
|
#elif TYPE_ORDER == 6
|
|
|
|
# define NumberTemplate NSUIntNumber
|
|
|
|
# define TYPE_FORMAT @"%u"
|
2000-03-23 18:57:43 +00:00
|
|
|
# define TYPE_TYPE unsigned int
|
1995-04-03 20:49:14 +00:00
|
|
|
#elif TYPE_ORDER == 7
|
|
|
|
# define NumberTemplate NSLongNumber
|
|
|
|
# define TYPE_FORMAT @"%ld"
|
2000-08-07 22:00:31 +00:00
|
|
|
# define TYPE_TYPE signed long
|
2000-03-19 20:57:09 +00:00
|
|
|
#elif TYPE_ORDER == 8
|
|
|
|
# define NumberTemplate NSULongNumber
|
|
|
|
# define TYPE_FORMAT @"%lu"
|
2000-03-23 18:57:43 +00:00
|
|
|
# define TYPE_TYPE unsigned long
|
1995-04-03 20:49:14 +00:00
|
|
|
#elif TYPE_ORDER == 9
|
|
|
|
# define NumberTemplate NSLongLongNumber
|
|
|
|
# define TYPE_FORMAT @"%lld"
|
2000-08-07 22:00:31 +00:00
|
|
|
# define TYPE_TYPE signed long long
|
2000-03-19 20:57:09 +00:00
|
|
|
#elif TYPE_ORDER == 10
|
|
|
|
# define NumberTemplate NSULongLongNumber
|
|
|
|
# define TYPE_FORMAT @"%llu"
|
2000-03-23 18:57:43 +00:00
|
|
|
# define TYPE_TYPE unsigned long long
|
1995-04-03 20:49:14 +00:00
|
|
|
#elif TYPE_ORDER == 11
|
|
|
|
# define NumberTemplate NSFloatNumber
|
2001-02-26 10:32:22 +00:00
|
|
|
# define TYPE_FORMAT @"%0.7f"
|
2000-03-23 18:57:43 +00:00
|
|
|
# define TYPE_TYPE float
|
1995-04-03 20:49:14 +00:00
|
|
|
#elif TYPE_ORDER == 12
|
|
|
|
# define NumberTemplate NSDoubleNumber
|
2001-02-26 10:32:22 +00:00
|
|
|
# define TYPE_FORMAT @"%0.16g"
|
2000-03-23 18:57:43 +00:00
|
|
|
# define TYPE_TYPE double
|
1995-04-03 20:49:14 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
@implementation NumberTemplate
|
|
|
|
|
2000-03-19 20:57:09 +00:00
|
|
|
- (id) initWithBytes: (const void*)value objCType: (const char*)type
|
1995-04-03 20:49:14 +00:00
|
|
|
{
|
1999-06-25 05:57:30 +00:00
|
|
|
typedef __typeof__(data) _dt;
|
2000-03-19 20:57:09 +00:00
|
|
|
data = *(_dt*)value;
|
1999-06-14 09:07:52 +00:00
|
|
|
return self;
|
1995-04-03 20:49:14 +00:00
|
|
|
}
|
|
|
|
|
2000-03-19 20:57:09 +00:00
|
|
|
/*
|
|
|
|
* Because of the rule that two numbers which are the same according to
|
|
|
|
* [-isEqual: ] must generate the same hash, we must generate the hash
|
|
|
|
* from the most general representation of the number.
|
|
|
|
* NB. Don't change this without changing the matching function in
|
|
|
|
* NSNumber.m
|
|
|
|
*/
|
|
|
|
- (unsigned) hash
|
|
|
|
{
|
|
|
|
union {
|
|
|
|
double d;
|
|
|
|
unsigned char c[sizeof(double)];
|
|
|
|
} val;
|
|
|
|
unsigned hash = 0;
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If possible use a cached hash value for small integers.
|
|
|
|
*/
|
|
|
|
#if TYPE_ORDER < 11
|
|
|
|
#if (TYPE_ORDER & 1)
|
|
|
|
if (data <= GS_SMALL && data >= -GS_SMALL)
|
|
|
|
#else
|
|
|
|
if (data <= GS_SMALL)
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
return GSSmallHash((int)data);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
val.d = [self doubleValue];
|
|
|
|
for (i = 0; i < sizeof(double); i++)
|
|
|
|
{
|
|
|
|
hash += val.c[i];
|
|
|
|
}
|
|
|
|
return hash;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) boolValue
|
1995-04-03 20:49:14 +00:00
|
|
|
{
|
2000-03-23 18:57:43 +00:00
|
|
|
return (BOOL)data;
|
1995-04-03 20:49:14 +00:00
|
|
|
}
|
|
|
|
|
2000-08-07 22:00:31 +00:00
|
|
|
- (signed char) charValue
|
1995-04-03 20:49:14 +00:00
|
|
|
{
|
2000-08-07 22:00:31 +00:00
|
|
|
return (signed char)data;
|
1995-04-03 20:49:14 +00:00
|
|
|
}
|
|
|
|
|
2000-03-19 20:57:09 +00:00
|
|
|
- (double) doubleValue
|
1995-04-03 20:49:14 +00:00
|
|
|
{
|
2000-03-23 18:57:43 +00:00
|
|
|
return (double)data;
|
1995-04-03 20:49:14 +00:00
|
|
|
}
|
|
|
|
|
2000-03-19 20:57:09 +00:00
|
|
|
- (float) floatValue
|
1995-04-03 20:49:14 +00:00
|
|
|
{
|
2000-03-23 18:57:43 +00:00
|
|
|
return (float)data;
|
1995-04-03 20:49:14 +00:00
|
|
|
}
|
|
|
|
|
2000-08-07 22:00:31 +00:00
|
|
|
- (signed int) intValue
|
1995-04-03 20:49:14 +00:00
|
|
|
{
|
2000-08-07 22:00:31 +00:00
|
|
|
return (signed int)data;
|
1995-04-03 20:49:14 +00:00
|
|
|
}
|
|
|
|
|
2000-08-07 22:00:31 +00:00
|
|
|
- (signed long long) longLongValue
|
1995-04-03 20:49:14 +00:00
|
|
|
{
|
2000-08-07 22:00:31 +00:00
|
|
|
return (signed long long)data;
|
1995-04-03 20:49:14 +00:00
|
|
|
}
|
|
|
|
|
2000-08-07 22:00:31 +00:00
|
|
|
- (signed long) longValue
|
1995-04-03 20:49:14 +00:00
|
|
|
{
|
2000-08-07 22:00:31 +00:00
|
|
|
return (signed long)data;
|
1995-04-03 20:49:14 +00:00
|
|
|
}
|
|
|
|
|
2000-08-07 22:00:31 +00:00
|
|
|
- (signed short) shortValue
|
1995-04-03 20:49:14 +00:00
|
|
|
{
|
2000-08-07 22:00:31 +00:00
|
|
|
return (signed short)data;
|
1995-04-03 20:49:14 +00:00
|
|
|
}
|
|
|
|
|
2000-03-19 20:57:09 +00:00
|
|
|
- (unsigned char) unsignedCharValue
|
1995-04-03 20:49:14 +00:00
|
|
|
{
|
2000-03-23 18:57:43 +00:00
|
|
|
return (unsigned char)data;
|
1995-04-03 20:49:14 +00:00
|
|
|
}
|
|
|
|
|
2000-03-19 20:57:09 +00:00
|
|
|
- (unsigned int) unsignedIntValue
|
1995-04-03 20:49:14 +00:00
|
|
|
{
|
2000-03-23 18:57:43 +00:00
|
|
|
return (unsigned int)data;
|
1995-04-03 20:49:14 +00:00
|
|
|
}
|
|
|
|
|
2000-03-19 20:57:09 +00:00
|
|
|
- (unsigned long long) unsignedLongLongValue
|
1995-04-03 20:49:14 +00:00
|
|
|
{
|
2000-03-23 18:57:43 +00:00
|
|
|
return (unsigned long long)data;
|
1995-04-03 20:49:14 +00:00
|
|
|
}
|
|
|
|
|
2000-03-19 20:57:09 +00:00
|
|
|
- (unsigned long) unsignedLongValue
|
1995-04-03 20:49:14 +00:00
|
|
|
{
|
2000-03-23 18:57:43 +00:00
|
|
|
return (unsigned long)data;
|
1995-04-03 20:49:14 +00:00
|
|
|
}
|
|
|
|
|
2000-03-19 20:57:09 +00:00
|
|
|
- (unsigned short) unsignedShortValue
|
1995-04-03 20:49:14 +00:00
|
|
|
{
|
2000-03-23 18:57:43 +00:00
|
|
|
return (unsigned short)data;
|
1995-04-03 20:49:14 +00:00
|
|
|
}
|
|
|
|
|
2000-03-19 20:57:09 +00:00
|
|
|
- (NSComparisonResult) compare: (NSNumber*)other
|
1995-04-03 20:49:14 +00:00
|
|
|
{
|
2000-03-19 20:57:09 +00:00
|
|
|
if (other == self)
|
|
|
|
{
|
|
|
|
return NSOrderedSame;
|
|
|
|
}
|
2000-08-07 22:00:31 +00:00
|
|
|
else if (other == nil)
|
1999-06-14 09:07:52 +00:00
|
|
|
{
|
2000-08-07 22:00:31 +00:00
|
|
|
[NSException raise: NSInvalidArgumentException
|
|
|
|
format: @"nil argument for compare:"];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GSNumberInfo *info = GSNumberInfoFromObject(other);
|
2000-03-23 18:57:43 +00:00
|
|
|
|
2000-08-07 22:00:31 +00:00
|
|
|
switch (info->typeLevel)
|
2000-03-23 18:57:43 +00:00
|
|
|
{
|
2000-08-07 22:00:31 +00:00
|
|
|
case 0:
|
|
|
|
{
|
|
|
|
BOOL oData;
|
|
|
|
|
|
|
|
(*(info->getValue))(other, @selector(getValue:), (void*)&oData);
|
|
|
|
if (data == oData)
|
|
|
|
return NSOrderedSame;
|
|
|
|
else if (data < oData)
|
|
|
|
return NSOrderedAscending;
|
|
|
|
else
|
|
|
|
return NSOrderedDescending;
|
|
|
|
}
|
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
signed char oData;
|
|
|
|
|
|
|
|
(*(info->getValue))(other, @selector(getValue:), (void*)&oData);
|
|
|
|
if (data == oData)
|
|
|
|
return NSOrderedSame;
|
|
|
|
else if (data < oData)
|
|
|
|
return NSOrderedAscending;
|
|
|
|
else
|
|
|
|
return NSOrderedDescending;
|
|
|
|
}
|
|
|
|
case 2:
|
|
|
|
{
|
|
|
|
unsigned char oData;
|
|
|
|
|
|
|
|
(*(info->getValue))(other, @selector(getValue:), (void*)&oData);
|
|
|
|
if (data == oData)
|
|
|
|
return NSOrderedSame;
|
|
|
|
else if (data < oData)
|
|
|
|
return NSOrderedAscending;
|
|
|
|
else
|
|
|
|
return NSOrderedDescending;
|
|
|
|
}
|
|
|
|
case 3:
|
|
|
|
{
|
|
|
|
signed short oData;
|
|
|
|
|
|
|
|
(*(info->getValue))(other, @selector(getValue:), (void*)&oData);
|
|
|
|
if (data == oData)
|
|
|
|
return NSOrderedSame;
|
|
|
|
else if (data < oData)
|
|
|
|
return NSOrderedAscending;
|
|
|
|
else
|
|
|
|
return NSOrderedDescending;
|
|
|
|
}
|
|
|
|
case 4:
|
|
|
|
{
|
|
|
|
unsigned short oData;
|
|
|
|
|
|
|
|
(*(info->getValue))(other, @selector(getValue:), (void*)&oData);
|
|
|
|
if (data == oData)
|
|
|
|
return NSOrderedSame;
|
|
|
|
else if (data < oData)
|
|
|
|
return NSOrderedAscending;
|
|
|
|
else
|
|
|
|
return NSOrderedDescending;
|
|
|
|
}
|
|
|
|
case 5:
|
|
|
|
{
|
|
|
|
signed int oData;
|
|
|
|
|
|
|
|
(*(info->getValue))(other, @selector(getValue:), (void*)&oData);
|
|
|
|
if (data == oData)
|
|
|
|
return NSOrderedSame;
|
|
|
|
else if (data < oData)
|
|
|
|
return NSOrderedAscending;
|
|
|
|
else
|
|
|
|
return NSOrderedDescending;
|
|
|
|
}
|
|
|
|
case 6:
|
|
|
|
{
|
|
|
|
unsigned int oData;
|
|
|
|
|
|
|
|
(*(info->getValue))(other, @selector(getValue:), (void*)&oData);
|
|
|
|
if (data == oData)
|
|
|
|
return NSOrderedSame;
|
|
|
|
else if (data < oData)
|
|
|
|
return NSOrderedAscending;
|
|
|
|
else
|
|
|
|
return NSOrderedDescending;
|
|
|
|
}
|
|
|
|
case 7:
|
|
|
|
{
|
|
|
|
signed long oData;
|
|
|
|
|
|
|
|
(*(info->getValue))(other, @selector(getValue:), (void*)&oData);
|
|
|
|
if (data == oData)
|
|
|
|
return NSOrderedSame;
|
|
|
|
else if (data < oData)
|
|
|
|
return NSOrderedAscending;
|
|
|
|
else
|
|
|
|
return NSOrderedDescending;
|
|
|
|
}
|
|
|
|
case 8:
|
|
|
|
{
|
|
|
|
unsigned long oData;
|
|
|
|
|
|
|
|
(*(info->getValue))(other, @selector(getValue:), (void*)&oData);
|
|
|
|
if (data == oData)
|
|
|
|
return NSOrderedSame;
|
|
|
|
else if (data < oData)
|
|
|
|
return NSOrderedAscending;
|
|
|
|
else
|
|
|
|
return NSOrderedDescending;
|
|
|
|
}
|
|
|
|
case 9:
|
|
|
|
{
|
|
|
|
signed long long oData;
|
|
|
|
|
|
|
|
(*(info->getValue))(other, @selector(getValue:), (void*)&oData);
|
|
|
|
if (data == oData)
|
|
|
|
return NSOrderedSame;
|
|
|
|
else if (data < oData)
|
|
|
|
return NSOrderedAscending;
|
|
|
|
else
|
|
|
|
return NSOrderedDescending;
|
|
|
|
}
|
|
|
|
case 10:
|
|
|
|
{
|
|
|
|
unsigned long long oData;
|
|
|
|
|
|
|
|
(*(info->getValue))(other, @selector(getValue:), (void*)&oData);
|
|
|
|
if (data == oData)
|
|
|
|
return NSOrderedSame;
|
|
|
|
else if (data < oData)
|
|
|
|
return NSOrderedAscending;
|
|
|
|
else
|
|
|
|
return NSOrderedDescending;
|
|
|
|
}
|
|
|
|
case 11:
|
|
|
|
{
|
|
|
|
float oData;
|
|
|
|
|
|
|
|
(*(info->getValue))(other, @selector(getValue:), (void*)&oData);
|
|
|
|
if (data == oData)
|
|
|
|
return NSOrderedSame;
|
|
|
|
else if (data < oData)
|
|
|
|
return NSOrderedAscending;
|
|
|
|
else
|
|
|
|
return NSOrderedDescending;
|
|
|
|
}
|
|
|
|
case 12:
|
|
|
|
{
|
|
|
|
double oData;
|
|
|
|
|
|
|
|
(*(info->getValue))(other, @selector(getValue:), (void*)&oData);
|
|
|
|
if (data == oData)
|
|
|
|
return NSOrderedSame;
|
|
|
|
else if (data < oData)
|
|
|
|
return NSOrderedAscending;
|
|
|
|
else
|
|
|
|
return NSOrderedDescending;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
[NSException raise: NSInvalidArgumentException
|
|
|
|
format: @"number type value for comparison"];
|
2000-03-23 18:57:43 +00:00
|
|
|
return NSOrderedSame;
|
|
|
|
}
|
1998-02-05 22:06:20 +00:00
|
|
|
}
|
2000-08-07 22:00:31 +00:00
|
|
|
return 0; /* Quiet warnings */
|
1998-02-05 22:06:20 +00:00
|
|
|
}
|
|
|
|
|
2000-03-19 20:57:09 +00:00
|
|
|
- (NSString*) descriptionWithLocale: (NSDictionary*)locale
|
1998-02-05 22:06:20 +00:00
|
|
|
{
|
1998-12-07 19:45:08 +00:00
|
|
|
#if TYPE_ORDER == 0
|
1999-06-14 09:07:52 +00:00
|
|
|
return (data) ? @"YES" : @"NO";
|
1998-12-07 19:45:08 +00:00
|
|
|
#else
|
1999-06-14 09:07:52 +00:00
|
|
|
return [NSString stringWithFormat: TYPE_FORMAT, data];
|
1998-12-07 19:45:08 +00:00
|
|
|
#endif
|
1995-04-03 20:49:14 +00:00
|
|
|
}
|
|
|
|
|
2000-03-23 18:57:43 +00:00
|
|
|
- (id) copy
|
|
|
|
{
|
|
|
|
if (NSShouldRetainWithZone(self, NSDefaultMallocZone()))
|
|
|
|
return RETAIN(self);
|
|
|
|
else
|
|
|
|
return NSCopyObject(self, 0, NSDefaultMallocZone());
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id) copyWithZone: (NSZone*)zone
|
|
|
|
{
|
|
|
|
if (NSShouldRetainWithZone(self, zone))
|
|
|
|
return RETAIN(self);
|
|
|
|
else
|
|
|
|
return NSCopyObject(self, 0, zone);
|
|
|
|
}
|
|
|
|
|
1995-04-03 20:49:14 +00:00
|
|
|
// Override these from NSValue
|
2000-03-19 20:57:09 +00:00
|
|
|
- (void) getValue: (void*)value
|
1995-04-03 20:49:14 +00:00
|
|
|
{
|
2000-03-19 20:57:09 +00:00
|
|
|
if (value == 0)
|
1999-06-14 09:07:52 +00:00
|
|
|
{
|
|
|
|
[NSException raise: NSInvalidArgumentException
|
2000-03-23 18:57:43 +00:00
|
|
|
format: @"Cannot copy value into NULL pointer"];
|
1999-06-14 09:07:52 +00:00
|
|
|
/* NOT REACHED */
|
1995-04-03 20:49:14 +00:00
|
|
|
}
|
2000-03-23 18:57:43 +00:00
|
|
|
memcpy(value, &data, objc_sizeof_type(@encode(TYPE_TYPE)));
|
1995-04-03 20:49:14 +00:00
|
|
|
}
|
|
|
|
|
2000-03-19 20:57:09 +00:00
|
|
|
- (const char*) objCType
|
1995-04-03 20:49:14 +00:00
|
|
|
{
|
2000-03-23 18:57:43 +00:00
|
|
|
return @encode(TYPE_TYPE);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id) nonretainedObjectValue
|
|
|
|
{
|
|
|
|
return (id)(void*)&data;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void*) pointerValue
|
|
|
|
{
|
|
|
|
return (void*)&data;
|
1996-02-22 16:06:34 +00:00
|
|
|
}
|
|
|
|
|
1995-04-03 20:49:14 +00:00
|
|
|
// NSCoding
|
1998-12-18 17:05:44 +00:00
|
|
|
|
2000-10-16 12:35:42 +00:00
|
|
|
/*
|
|
|
|
* Exact mirror of NSNumber abstract class coding method.
|
|
|
|
*/
|
2000-03-23 18:57:43 +00:00
|
|
|
- (void) encodeWithCoder: (NSCoder*)coder
|
1995-04-03 20:49:14 +00:00
|
|
|
{
|
2000-10-16 12:35:42 +00:00
|
|
|
const char *t = @encode(TYPE_TYPE);
|
|
|
|
|
|
|
|
[coder encodeValueOfObjCType: @encode(char) at: t];
|
|
|
|
[coder encodeValueOfObjCType: t at: &data];
|
1996-02-22 16:06:34 +00:00
|
|
|
}
|
|
|
|
|
2000-10-16 12:35:42 +00:00
|
|
|
/*
|
|
|
|
* NSNumber objects should have been encoded with their class set to the
|
|
|
|
* abstract class. If they haven't then we must be encoding from an old
|
|
|
|
* archive, so we must implement the old initWithCoder: method.
|
|
|
|
*/
|
2000-03-23 18:57:43 +00:00
|
|
|
- (id) initWithCoder: (NSCoder*)coder
|
1996-02-22 16:06:34 +00:00
|
|
|
{
|
2000-03-23 18:57:43 +00:00
|
|
|
[coder decodeValueOfObjCType: @encode(TYPE_TYPE) at: &data];
|
1996-02-22 16:06:34 +00:00
|
|
|
return self;
|
1995-04-03 20:49:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
|
|
|