@@ -65,18 +65,10 @@ SINGLETON(unsignedCharZeroNumber, initWithUnsignedChar:, 0) SINGLETON(unsignedShortZeroNumber, initWithUnsignedShort:, 0) SINGLETON(unsignedIntZeroNumber, initWithUnsignedInt:, 0) SINGLETON(unsignedLongZeroNumber, initWithUnsignedLong:, 0) SINGLETON(unsignedLongLongZeroNumber, initWithUnsignedLongLong:, 0) -SINGLETON(int8ZeroNumber, initWithInt8:, 0) -SINGLETON(int16ZeroNumber, initWithInt16:, 0) -SINGLETON(int32ZeroNumber, initWithInt32:, 0) -SINGLETON(int64ZeroNumber, initWithInt64:, 0) -SINGLETON(uInt8ZeroNumber, initWithUInt8:, 0) -SINGLETON(uInt16ZeroNumber, initWithUInt16:, 0) -SINGLETON(uInt32ZeroNumber, initWithUInt32:, 0) -SINGLETON(uInt64ZeroNumber, initWithUInt64:, 0) SINGLETON(floatZeroNumber, initWithFloat:, 0) SINGLETON(doubleZeroNumber, initWithDouble:, 0) #undef SINGLETON @implementation OFNumberPlaceholder @@ -201,118 +193,10 @@ } return (id)[[OFNumber of_alloc] initWithUnsignedLongLong: value]; } -- (instancetype)initWithInt8: (int8_t)value -{ - if (value == 0) { - static of_once_t once = OF_ONCE_INIT; - of_once(&once, int8ZeroNumberInit); - return (id)int8ZeroNumber; - } - - return (id)[[OFNumber of_alloc] initWithInt8: value]; -} - -- (instancetype)initWithInt16: (int16_t)value -{ - if (value == 0) { - static of_once_t once = OF_ONCE_INIT; - of_once(&once, int16ZeroNumberInit); - return (id)int16ZeroNumber; - } - - return (id)[[OFNumber of_alloc] initWithInt16: value]; -} - -- (instancetype)initWithInt32: (int32_t)value -{ - if (value == 0) { - static of_once_t once = OF_ONCE_INIT; - of_once(&once, int32ZeroNumberInit); - return (id)int32ZeroNumber; - } - - return (id)[[OFNumber of_alloc] initWithInt32: value]; -} - -- (instancetype)initWithInt64: (int64_t)value -{ - if (value == 0) { - static of_once_t once = OF_ONCE_INIT; - of_once(&once, int64ZeroNumberInit); - return (id)int64ZeroNumber; - } - - return (id)[[OFNumber of_alloc] initWithInt64: value]; -} - -- (instancetype)initWithUInt8: (uint8_t)value -{ - if (value == 0) { - static of_once_t once = OF_ONCE_INIT; - of_once(&once, uInt8ZeroNumberInit); - return (id)uInt8ZeroNumber; - } - - return (id)[[OFNumber of_alloc] initWithUInt8: value]; -} - -- (instancetype)initWithUInt16: (uint16_t)value -{ - if (value == 0) { - static of_once_t once = OF_ONCE_INIT; - of_once(&once, uInt16ZeroNumberInit); - return (id)uInt16ZeroNumber; - } - - return (id)[[OFNumber of_alloc] initWithUInt16: value]; -} - -- (instancetype)initWithUInt32: (uint32_t)value -{ - if (value == 0) { - static of_once_t once = OF_ONCE_INIT; - of_once(&once, uInt32ZeroNumberInit); - return (id)uInt32ZeroNumber; - } - - return (id)[[OFNumber of_alloc] initWithUInt32: value]; -} - -- (instancetype)initWithUInt64: (uint64_t)value -{ - if (value == 0) { - static of_once_t once = OF_ONCE_INIT; - of_once(&once, uInt64ZeroNumberInit); - return (id)uInt64ZeroNumber; - } - - return (id)[[OFNumber of_alloc] initWithUInt64: value]; -} - -- (instancetype)initWithSize: (size_t)value -{ - return (id)[[OFNumber of_alloc] initWithSize: value]; -} - -- (instancetype)initWithPtrDiff: (ptrdiff_t)value -{ - return (id)[[OFNumber of_alloc] initWithPtrDiff: value]; -} - -- (instancetype)initWithIntPtr: (intptr_t)value -{ - return (id)[[OFNumber of_alloc] initWithIntPtr: value]; -} - -- (instancetype)initWithUIntPtr: (uintptr_t)value -{ - return (id)[[OFNumber of_alloc] initWithUIntPtr: value]; -} - - (instancetype)initWithFloat: (float)value { if (value == 0) { static of_once_t once = OF_ONCE_INIT; of_once(&once, floatZeroNumberInit); @@ -433,70 +317,10 @@ + (instancetype)numberWithUnsignedLongLong: (unsigned long long)value { return [[[self alloc] initWithUnsignedLongLong: value] autorelease]; } -+ (instancetype)numberWithInt8: (int8_t)value -{ - return [[[self alloc] initWithInt8: value] autorelease]; -} - -+ (instancetype)numberWithInt16: (int16_t)value -{ - return [[[self alloc] initWithInt16: value] autorelease]; -} - -+ (instancetype)numberWithInt32: (int32_t)value -{ - return [[[self alloc] initWithInt32: value] autorelease]; -} - -+ (instancetype)numberWithInt64: (int64_t)value -{ - return [[[self alloc] initWithInt64: value] autorelease]; -} - -+ (instancetype)numberWithUInt8: (uint8_t)value -{ - return [[[self alloc] initWithUInt8: value] autorelease]; -} - -+ (instancetype)numberWithUInt16: (uint16_t)value -{ - return [[[self alloc] initWithUInt16: value] autorelease]; -} - -+ (instancetype)numberWithUInt32: (uint32_t)value -{ - return [[[self alloc] initWithUInt32: value] autorelease]; -} - -+ (instancetype)numberWithUInt64: (uint64_t)value -{ - return [[[self alloc] initWithUInt64: value] autorelease]; -} - -+ (instancetype)numberWithSize: (size_t)value -{ - return [[[self alloc] initWithSize: value] autorelease]; -} - -+ (instancetype)numberWithPtrDiff: (ptrdiff_t)value -{ - return [[[self alloc] initWithPtrDiff: value] autorelease]; -} - -+ (instancetype)numberWithIntPtr: (intptr_t)value -{ - return [[[self alloc] initWithIntPtr: value] autorelease]; -} - -+ (instancetype)numberWithUIntPtr: (uintptr_t)value -{ - return [[[self alloc] initWithUIntPtr: value] autorelease]; -} - + (instancetype)numberWithFloat: (float)value { return [[[self alloc] initWithFloat: value] autorelease]; } @@ -626,109 +450,10 @@ _value.unsigned_ = value; _type = OF_NUMBER_TYPE_UNSIGNED; _typeEncoding = @encode(unsigned long long); - return self; -} - -- (instancetype)initWithInt8: (int8_t)value -{ - self = [super init]; - - _value.signed_ = value; - _type = OF_NUMBER_TYPE_SIGNED; - _typeEncoding = @encode(int8_t); - - return self; -} - -- (instancetype)initWithInt16: (int16_t)value -{ - self = [super init]; - - _value.signed_ = value; - _type = OF_NUMBER_TYPE_SIGNED; - _typeEncoding = @encode(int16_t); - - return self; -} - -- (instancetype)initWithInt32: (int32_t)value -{ - self = [super init]; - - _value.signed_ = value; - _type = OF_NUMBER_TYPE_SIGNED; - _typeEncoding = @encode(int32_t); - - return self; -} - -- (instancetype)initWithInt64: (int64_t)value -{ - self = [super init]; - - _value.signed_ = value; - _type = OF_NUMBER_TYPE_SIGNED; - _typeEncoding = @encode(int64_t); - - return self; -} - -- (instancetype)initWithUInt8: (uint8_t)value -{ - self = [super init]; - - _value.unsigned_ = value; - _type = OF_NUMBER_TYPE_UNSIGNED; - _typeEncoding = @encode(uint8_t); - - return self; -} - -- (instancetype)initWithUInt16: (uint16_t)value -{ - self = [super init]; - - _value.unsigned_ = value; - _type = OF_NUMBER_TYPE_UNSIGNED; - _typeEncoding = @encode(uint16_t); - - return self; -} - -- (instancetype)initWithUInt32: (uint32_t)value -{ - self = [super init]; - - _value.unsigned_ = value; - _type = OF_NUMBER_TYPE_UNSIGNED; - _typeEncoding = @encode(uint32_t); - - return self; -} - -- (instancetype)initWithUInt64: (uint64_t)value -{ - self = [super init]; - - _value.unsigned_ = value; - _type = OF_NUMBER_TYPE_UNSIGNED; - _typeEncoding = @encode(uint64_t); - - return self; -} - -- (instancetype)initWithSize: (size_t)value -{ - self = [super init]; - - _value.unsigned_ = value; - _type = OF_NUMBER_TYPE_UNSIGNED; - _typeEncoding = @encode(size_t); - return self; } - (instancetype)initWithPtrDiff: (ptrdiff_t)value { @@ -935,70 +660,10 @@ - (unsigned long long)unsignedLongLongValue { RETURN_AS(unsigned long long) } -- (int8_t)int8Value -{ - RETURN_AS(int8_t) -} - -- (int16_t)int16Value -{ - RETURN_AS(int16_t) -} - -- (int32_t)int32Value -{ - RETURN_AS(int32_t) -} - -- (int64_t)int64Value -{ - RETURN_AS(int64_t) -} - -- (uint8_t)uInt8Value -{ - RETURN_AS(uint8_t) -} - -- (uint16_t)uInt16Value -{ - RETURN_AS(uint16_t) -} - -- (uint32_t)uInt32Value -{ - RETURN_AS(uint32_t) -} - -- (uint64_t)uInt64Value -{ - RETURN_AS(uint64_t) -} - -- (size_t)sizeValue -{ - RETURN_AS(size_t) -} - -- (ptrdiff_t)ptrDiffValue -{ - RETURN_AS(ptrdiff_t) -} - -- (intptr_t)intPtrValue -{ - RETURN_AS(intptr_t) -} - -- (uintptr_t)uIntPtrValue -{ - RETURN_AS(uintptr_t) -} - - (float)floatValue { RETURN_AS(float) }