NSDecimalNumberPlaceholder implementation to allow construction of NSDecimalNumber instances in nib files. Will do some additional testing to make certain this implementation is correct.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@23108 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Gregory John Casamento 2006-06-25 16:42:38 +00:00
parent 7f2a813414
commit 7069a80090
2 changed files with 49 additions and 0 deletions

View file

@ -1,3 +1,9 @@
2006-06-25 12:40 Gregory John Casamento <greg_casamento@yahoo.com>
* Source/GSNibCompatibility.m: Added NSDecimalNumberPlaceholder
class implementation to decode NSDecimalNumber instances in
nib files.
2006-06-25 00:26 Gregory John Casamento <greg_casamento@yahoo.com>
* Source/GSNibCompatibility.m: in -[NSIBObjectData

View file

@ -32,8 +32,10 @@
#include <Foundation/NSArchiver.h>
#include <Foundation/NSArray.h>
#include <Foundation/NSBundle.h>
#include <Foundation/NSByteOrder.h>
#include <Foundation/NSCoder.h>
#include <Foundation/NSData.h>
#include <Foundation/NSDecimalNumber.h>
#include <Foundation/NSDictionary.h>
#include <Foundation/NSDebug.h>
#include <Foundation/NSEnumerator.h>
@ -1339,3 +1341,44 @@ static BOOL _isInInterfaceBuilder = NO;
@implementation NSIBHelpConnector
@end
@interface NSDecimalNumberPlaceholder : NSObject
@end
@implementation NSDecimalNumberPlaceholder
- (id) initWithCoder: (NSCoder *)coder
{
NSDecimalNumber *dn = nil;
if([coder allowsKeyedCoding])
{
unsigned int len = 0;
// BOOL compact = [coder decodeBoolForKey: @"NS.compact"];
short exponent = (short)[coder decodeIntForKey: @"NS.exponent"];
// int length = [coder decodeIntForKey: @"NS.length"];
NSByteOrder bo = [coder decodeIntForKey: @"NS.mantissa.bo"];
BOOL negative = [coder decodeBoolForKey: @"NS.negative"];
void *mantissaBytes = (void *)[coder decodeBytesForKey: @"NS.mantissa" returnedLength: &len];
unsigned long long unswapped = 0;
unsigned long long mantissa = 0;
memcpy((void *)&unswapped, (void *)mantissaBytes, sizeof(unsigned long long));
switch(bo)
{
case NS_BigEndian:
mantissa = NSSwapBigLongLongToHost(unswapped);
break;
case NS_LittleEndian:
mantissa = NSSwapLittleLongLongToHost(unswapped);
break;
default:
break;
}
dn = [[NSDecimalNumber alloc] initWithMantissa: mantissa
exponent: exponent
isNegative: negative];
}
return dn;
}
@end