mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 08:41:03 +00:00
Add change checking and NSInteger methods
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@30852 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
ae394881bf
commit
9b72ce7cd0
3 changed files with 44 additions and 34 deletions
|
@ -492,48 +492,45 @@ static NSMapTable *globalClassMap = 0;
|
|||
|
||||
- (int) decodeIntForKey: (NSString*)aKey
|
||||
{
|
||||
NSString *oldKey = aKey;
|
||||
GETVAL
|
||||
if (o != nil)
|
||||
{
|
||||
if ([o isKindOfClass: [NSNumber class]] == YES)
|
||||
{
|
||||
long long l = [o longLongValue];
|
||||
int64_t i = [self decodeInt64ForKey: aKey];
|
||||
|
||||
return l;
|
||||
}
|
||||
else
|
||||
{
|
||||
[NSException raise: NSInvalidUnarchiveOperationException
|
||||
format: @"[%@ +%@]: value for key(%@) is '%@'",
|
||||
NSStringFromClass([self class]), NSStringFromSelector(_cmd),
|
||||
oldKey, o];
|
||||
}
|
||||
#if (INT_MAX < INT64_MAX)
|
||||
if (i > INT_MAX || i < INT_MIN)
|
||||
{
|
||||
[NSException raise: NSRangeException
|
||||
format: @"[%@ +%@]: value for key(%@) is out of range",
|
||||
NSStringFromClass([self class]), NSStringFromSelector(_cmd), aKey];
|
||||
}
|
||||
return 0;
|
||||
#endif
|
||||
return (int)i;
|
||||
}
|
||||
|
||||
- (int) decodeIntegerForKey: (NSString*)aKey
|
||||
{
|
||||
int64_t i = [self decodeInt64ForKey: aKey];
|
||||
|
||||
#if (INTPTR_MAX < INT64_MAX)
|
||||
if (i > INTPTR_MAX || i < INTPTR_MIN)
|
||||
{
|
||||
[NSException raise: NSRangeException
|
||||
format: @"[%@ +%@]: value for key(%@) is out of range",
|
||||
NSStringFromClass([self class]), NSStringFromSelector(_cmd), aKey];
|
||||
}
|
||||
#endif
|
||||
return (NSInteger)i;
|
||||
}
|
||||
|
||||
- (int32_t) decodeInt32ForKey: (NSString*)aKey
|
||||
{
|
||||
NSString *oldKey = aKey;
|
||||
GETVAL
|
||||
if (o != nil)
|
||||
{
|
||||
if ([o isKindOfClass: [NSNumber class]] == YES)
|
||||
{
|
||||
long long l = [o longLongValue];
|
||||
int64_t i = [self decodeInt64ForKey: aKey];
|
||||
|
||||
return l;
|
||||
}
|
||||
else
|
||||
{
|
||||
[NSException raise: NSInvalidUnarchiveOperationException
|
||||
format: @"[%@ +%@]: value for key(%@) is '%@'",
|
||||
NSStringFromClass([self class]), NSStringFromSelector(_cmd),
|
||||
oldKey, o];
|
||||
}
|
||||
if (i > INT32_MAX || i < INT32_MIN)
|
||||
{
|
||||
[NSException raise: NSRangeException
|
||||
format: @"[%@ +%@]: value for key(%@) is out of range",
|
||||
NSStringFromClass([self class]), NSStringFromSelector(_cmd), aKey];
|
||||
}
|
||||
return 0;
|
||||
return (int32_t)i;
|
||||
}
|
||||
|
||||
- (int64_t) decodeInt64ForKey: (NSString*)aKey
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue