Index: src/OFNumber.h ================================================================== --- src/OFNumber.h +++ src/OFNumber.h @@ -102,29 +102,29 @@ /** * \param uchar An unsigned char which the OFNumber should contain * \return A new autoreleased OFNumber */ -+ numberWithUChar: (unsigned char)uchar; ++ numberWithUnsignedChar: (unsigned char)uchar; /** * \param ushort An unsigned short which the OFNumber should contain * \return A new autoreleased OFNumber */ -+ numberWithUShort: (unsigned short)ushort; ++ numberWithUnsignedShort: (unsigned short)ushort; /** * \param uint An unsigned int which the OFNumber should contain * \return A new autoreleased OFNumber */ -+ numberWithUInt: (unsigned int)uint; ++ numberWithUnsignedInt: (unsigned int)uint; /** * \param ulong An unsigned long which the OFNumber should contain * \return A new autoreleased OFNumber */ -+ numberWithULong: (unsigned long)ulong; ++ numberWithUnsignedLong: (unsigned long)ulong; /** * \param int8 An int8_t which the OFNumber should contain * \return A new autoreleased OFNumber */ @@ -262,35 +262,35 @@ * Initializes an already allocated OFNumber with the specified unsigned char. * * \param uchar An unsigned char which the OFNumber should contain * \return An initialized OFNumber */ -- initWithUChar: (unsigned char)uchar; +- initWithUnsignedChar: (unsigned char)uchar; /** * Initializes an already allocated OFNumber with the specified unsigned short. * * \param ushort An unsigned short which the OFNumber should contain * \return An initialized OFNumber */ -- initWithUShort: (unsigned short)ushort; +- initWithUnsignedShort: (unsigned short)ushort; /** * Initializes an already allocated OFNumber with the specified unsigned int . * * \param uint An unsigned int which the OFNumber should contain * \return An initialized OFNumber */ -- initWithUInt: (unsigned int)uint; +- initWithUnsignedInt: (unsigned int)uint; /** * Initializes an already allocated OFNumber with the specified unsigned long. * * \param ulong An unsigned long which the OFNumber should contain * \return An initialized OFNumber */ -- initWithULong: (unsigned long)ulong; +- initWithUnsignedLong: (unsigned long)ulong; /** * Initializes an already allocated OFNumber with the specified int8_t. * * \param int8 An int8_t which the OFNumber should contain @@ -433,131 +433,131 @@ - (enum of_number_type)type; /** * \return The OFNumber as a char */ -- (char)asChar; +- (char)charValue; /** * \return The OFNumber as a short */ -- (short)asShort; +- (short)shortValue; /** * \return The OFNumber as an int */ -- (int)asInt; +- (int)intValue; /** * \return The OFNumber as a long */ -- (long)asLong; +- (long)longValue; /** * \return The OFNumber as an unsigned char */ -- (unsigned char)asUChar; +- (unsigned char)unsignedCharValue; /** * \return The OFNumber as an unsigned short */ -- (unsigned short)asUShort; +- (unsigned short)unsignedShortValue; /** * \return The OFNumber as an unsigned int */ -- (unsigned int)asUInt; +- (unsigned int)unsignedIntValue; /** * \return The OFNumber as an unsigned long */ -- (unsigned long)asULong; +- (unsigned long)unsignedLongValue; /** * \return The OFNumber as an int8_t */ -- (int8_t)asInt8; +- (int8_t)int8Value; /** * \return The OFNumber as an int16_t */ -- (int16_t)asInt16; +- (int16_t)int16Value; /** * \return The OFNumber as an int32_t */ -- (int32_t)asInt32; +- (int32_t)int32Value; /** * \return The OFNumber as an int64_t */ -- (int64_t)asInt64; +- (int64_t)int64Value; /** * \return The OFNumber as an uint8_t */ -- (uint8_t)asUInt8; +- (uint8_t)uInt8Value; /** * \return The OFNumber as an uint16_t */ -- (uint16_t)asUInt16; +- (uint16_t)uInt16Value; /** * \return The OFNumber as an uint32_t */ -- (uint32_t)asUInt32; +- (uint32_t)uInt32Value; /** * \return The OFNumber as an uint64_t */ -- (uint64_t)asUInt64; +- (uint64_t)uInt64Value; /** * \return The OFNumber as a size_t */ -- (size_t)asSize; +- (size_t)sizeValue; /** * \return The OFNumber as an ssize_t */ -- (ssize_t)asSSize; +- (ssize_t)sSizeValue; /** * \return The OFNumber as an intmax_t */ -- (intmax_t)asIntMax; +- (intmax_t)intMaxValue; /** * \return The OFNumber as an uintmax_t */ -- (uintmax_t)asUIntMax; +- (uintmax_t)uIntMaxValue; /** * \return The OFNumber as a ptrdiff_t */ -- (ptrdiff_t)asPtrDiff; +- (ptrdiff_t)ptrDiffValue; /** * \return The OFNumber as an intptr_t */ -- (intptr_t)asIntPtr; +- (intptr_t)intPtrValue; /** * \return The OFNumber as an uintptr_t */ -- (uintptr_t)asUIntPtr; +- (uintptr_t)uIntPtrValue; /** * \return The OFNumber as a float */ -- (float)asFloat; +- (float)floatValue; /** * \return The OFNumber as a double */ -- (double)asDouble; +- (double)doubleValue; /** * \param num The OFNumber to add * \return A new autoreleased OFNumber added with the specified OFNumber */ Index: src/OFNumber.m ================================================================== --- src/OFNumber.m +++ src/OFNumber.m @@ -72,157 +72,157 @@ } #define CALCULATE(o, n) \ switch (type) { \ case OF_NUMBER_CHAR: \ return [OFNumber numberWithChar: \ - value.char_ o [n asChar]]; \ + value.char_ o [n charValue]]; \ case OF_NUMBER_SHORT: \ return [OFNumber numberWithShort: \ - value.short_ o [n asShort]]; \ + value.short_ o [n shortValue]]; \ case OF_NUMBER_INT: \ return [OFNumber numberWithInt: \ - value.int_ o [n asInt]]; \ + value.int_ o [n intValue]]; \ case OF_NUMBER_LONG: \ return [OFNumber numberWithLong: \ - value.long_ o [n asLong]]; \ + value.long_ o [n longValue]]; \ case OF_NUMBER_UCHAR: \ - return [OFNumber numberWithUChar: \ - value.uchar o [n asUChar]]; \ + return [OFNumber numberWithUnsignedChar: \ + value.uchar o [n unsignedCharValue]]; \ case OF_NUMBER_USHORT: \ - return [OFNumber numberWithUShort: \ - value.ushort o [n asUShort]]; \ + return [OFNumber numberWithUnsignedShort: \ + value.ushort o [n unsignedShortValue]]; \ case OF_NUMBER_UINT: \ - return [OFNumber numberWithUInt: \ - value.uint o [n asUInt]]; \ + return [OFNumber numberWithUnsignedInt: \ + value.uint o [n unsignedIntValue]]; \ case OF_NUMBER_ULONG: \ - return [OFNumber numberWithULong: \ - value.ulong o [n asULong]]; \ + return [OFNumber numberWithUnsignedLong: \ + value.ulong o [n unsignedLongValue]]; \ case OF_NUMBER_INT8: \ return [OFNumber numberWithInt8: \ - value.int8 o [n asInt8]]; \ + value.int8 o [n int8Value]]; \ case OF_NUMBER_INT16: \ return [OFNumber numberWithInt16: \ - value.int16 o [n asInt16]]; \ + value.int16 o [n int16Value]]; \ case OF_NUMBER_INT32: \ return [OFNumber numberWithInt32: \ - value.int32 o [n asInt32]]; \ + value.int32 o [n int32Value]]; \ case OF_NUMBER_INT64: \ return [OFNumber numberWithInt64: \ - value.int64 o [n asInt64]]; \ + value.int64 o [n int64Value]]; \ case OF_NUMBER_UINT8: \ return [OFNumber numberWithUInt8: \ - value.uint8 o [n asUInt8]]; \ + value.uint8 o [n uInt8Value]]; \ case OF_NUMBER_UINT16: \ return [OFNumber numberWithUInt16: \ - value.uint16 o [n asUInt16]]; \ + value.uint16 o [n uInt16Value]]; \ case OF_NUMBER_UINT32: \ return [OFNumber numberWithUInt32: \ - value.uint32 o [n asUInt32]]; \ + value.uint32 o [n uInt32Value]]; \ case OF_NUMBER_UINT64: \ return [OFNumber numberWithUInt64: \ - value.uint64 o [n asUInt64]]; \ + value.uint64 o [n uInt64Value]]; \ case OF_NUMBER_SIZE: \ return [OFNumber numberWithSize: \ - value.size o [n asSize]]; \ + value.size o [n sizeValue]]; \ case OF_NUMBER_SSIZE: \ return [OFNumber numberWithSSize: \ - value.ssize o [n asSSize]]; \ + value.ssize o [n sSizeValue]]; \ case OF_NUMBER_INTMAX: \ return [OFNumber numberWithIntMax: \ - value.intmax o [n asIntMax]]; \ + value.intmax o [n intMaxValue]]; \ case OF_NUMBER_UINTMAX: \ return [OFNumber numberWithUIntMax: \ - value.uintmax o [n asUIntMax]]; \ + value.uintmax o [n uIntMaxValue]]; \ case OF_NUMBER_PTRDIFF: \ return [OFNumber numberWithPtrDiff: \ - value.ptrdiff o [n asPtrDiff]]; \ + value.ptrdiff o [n ptrDiffValue]]; \ case OF_NUMBER_INTPTR: \ return [OFNumber numberWithIntPtr: \ - value.intptr o [n asIntPtr]]; \ + value.intptr o [n intPtrValue]]; \ case OF_NUMBER_UINTPTR: \ return [OFNumber numberWithUIntPtr: \ - value.uintptr o [n asUIntPtr]]; \ + value.uintptr o [n uIntPtrValue]]; \ case OF_NUMBER_FLOAT: \ return [OFNumber numberWithFloat: \ - value.float_ o [n asFloat]]; \ + value.float_ o [n floatValue]]; \ case OF_NUMBER_DOUBLE: \ return [OFNumber numberWithDouble: \ - value.double_ o [n asDouble]]; \ + value.double_ o [n doubleValue]]; \ default: \ @throw [OFInvalidFormatException newWithClass: isa]; \ } #define CALCULATE2(o, n) \ switch (type) { \ case OF_NUMBER_CHAR: \ return [OFNumber numberWithChar: \ - value.char_ o [n asChar]]; \ + value.char_ o [n charValue]]; \ case OF_NUMBER_SHORT: \ return [OFNumber numberWithShort: \ - value.short_ o [n asShort]]; \ + value.short_ o [n shortValue]]; \ case OF_NUMBER_INT: \ return [OFNumber numberWithInt: \ - value.int_ o [n asInt]]; \ + value.int_ o [n intValue]]; \ case OF_NUMBER_LONG: \ return [OFNumber numberWithLong: \ - value.long_ o [n asLong]]; \ + value.long_ o [n longValue]]; \ case OF_NUMBER_UCHAR: \ - return [OFNumber numberWithUChar: \ - value.uchar o [n asUChar]]; \ + return [OFNumber numberWithUnsignedChar: \ + value.uchar o [n unsignedCharValue]]; \ case OF_NUMBER_USHORT: \ - return [OFNumber numberWithUShort: \ - value.ushort o [n asUShort]]; \ + return [OFNumber numberWithUnsignedShort: \ + value.ushort o [n unsignedShortValue]]; \ case OF_NUMBER_UINT: \ - return [OFNumber numberWithUInt: \ - value.uint o [n asUInt]]; \ + return [OFNumber numberWithUnsignedInt: \ + value.uint o [n unsignedIntValue]]; \ case OF_NUMBER_ULONG: \ - return [OFNumber numberWithULong: \ - value.ulong o [n asULong]]; \ + return [OFNumber numberWithUnsignedLong: \ + value.ulong o [n unsignedLongValue]]; \ case OF_NUMBER_INT8: \ return [OFNumber numberWithInt8: \ - value.int8 o [n asInt8]]; \ + value.int8 o [n int8Value]]; \ case OF_NUMBER_INT16: \ return [OFNumber numberWithInt16: \ - value.int16 o [n asInt16]]; \ + value.int16 o [n int16Value]]; \ case OF_NUMBER_INT32: \ return [OFNumber numberWithInt32: \ - value.int32 o [n asInt32]]; \ + value.int32 o [n int32Value]]; \ case OF_NUMBER_INT64: \ return [OFNumber numberWithInt64: \ - value.int64 o [n asInt64]]; \ + value.int64 o [n int64Value]]; \ case OF_NUMBER_UINT8: \ return [OFNumber numberWithUInt8: \ - value.uint8 o [n asUInt8]]; \ + value.uint8 o [n uInt8Value]]; \ case OF_NUMBER_UINT16: \ return [OFNumber numberWithUInt16: \ - value.uint16 o [n asUInt16]]; \ + value.uint16 o [n uInt16Value]]; \ case OF_NUMBER_UINT32: \ return [OFNumber numberWithUInt32: \ - value.uint32 o [n asUInt32]]; \ + value.uint32 o [n uInt32Value]]; \ case OF_NUMBER_UINT64: \ return [OFNumber numberWithUInt64: \ - value.uint64 o [n asUInt64]]; \ + value.uint64 o [n uInt64Value]]; \ case OF_NUMBER_SIZE: \ return [OFNumber numberWithSize: \ - value.size o [n asSize]]; \ + value.size o [n sizeValue]]; \ case OF_NUMBER_SSIZE: \ return [OFNumber numberWithSSize: \ - value.ssize o [n asSSize]]; \ + value.ssize o [n sSizeValue]]; \ case OF_NUMBER_INTMAX: \ return [OFNumber numberWithIntMax: \ - value.intmax o [n asIntMax]]; \ + value.intmax o [n intMaxValue]]; \ case OF_NUMBER_UINTMAX: \ return [OFNumber numberWithUIntMax: \ - value.uintmax o [n asUIntMax]]; \ + value.uintmax o [n uIntMaxValue]]; \ case OF_NUMBER_PTRDIFF: \ return [OFNumber numberWithPtrDiff: \ - value.ptrdiff o [n asPtrDiff]]; \ + value.ptrdiff o [n ptrDiffValue]]; \ case OF_NUMBER_INTPTR: \ return [OFNumber numberWithIntPtr: \ - value.intptr o [n asIntPtr]]; \ + value.intptr o [n intPtrValue]]; \ case OF_NUMBER_UINTPTR: \ return [OFNumber numberWithUIntPtr: \ - value.uintptr o [n asUIntPtr]]; \ + value.uintptr o [n uIntPtrValue]]; \ case OF_NUMBER_FLOAT: \ case OF_NUMBER_DOUBLE: \ @throw [OFNotImplementedException newWithClass: isa \ selector: _cmd]; \ default: \ @@ -237,17 +237,20 @@ case OF_NUMBER_INT: \ return [OFNumber numberWithInt: value.int_ o]; \ case OF_NUMBER_LONG: \ return [OFNumber numberWithLong: value.long_ o]; \ case OF_NUMBER_UCHAR: \ - return [OFNumber numberWithUChar: value.uchar o]; \ + return [OFNumber numberWithUnsignedChar: \ + value.uchar o]; \ case OF_NUMBER_USHORT: \ - return [OFNumber numberWithUShort: value.ushort o]; \ + return [OFNumber numberWithUnsignedShort: \ + value.ushort o]; \ case OF_NUMBER_UINT: \ - return [OFNumber numberWithUInt: value.uint o]; \ + return [OFNumber numberWithUnsignedInt: value.uint o]; \ case OF_NUMBER_ULONG: \ - return [OFNumber numberWithULong: value.ulong o]; \ + return [OFNumber numberWithUnsignedLong: \ + value.ulong o]; \ case OF_NUMBER_INT8: \ return [OFNumber numberWithInt8: value.int8 o]; \ case OF_NUMBER_INT16: \ return [OFNumber numberWithInt16: value.int16 o]; \ case OF_NUMBER_INT32: \ @@ -303,28 +306,28 @@ + numberWithLong: (long)long_ { return [[[self alloc] initWithLong: long_] autorelease]; } -+ numberWithUChar: (unsigned char)uchar -{ - return [[[self alloc] initWithUChar: uchar] autorelease]; -} - -+ numberWithUShort: (unsigned short)ushort -{ - return [[[self alloc] initWithUShort: ushort] autorelease]; -} - -+ numberWithUInt: (unsigned int)uint -{ - return [[[self alloc] initWithUInt: uint] autorelease]; -} - -+ numberWithULong: (unsigned long)ulong -{ - return [[[self alloc] initWithULong: ulong] autorelease]; ++ numberWithUnsignedChar: (unsigned char)uchar +{ + return [[[self alloc] initWithUnsignedChar: uchar] autorelease]; +} + ++ numberWithUnsignedShort: (unsigned short)ushort +{ + return [[[self alloc] initWithUnsignedShort: ushort] autorelease]; +} + ++ numberWithUnsignedInt: (unsigned int)uint +{ + return [[[self alloc] initWithUnsignedInt: uint] autorelease]; +} + ++ numberWithUnsignedLong: (unsigned long)ulong +{ + return [[[self alloc] initWithUnsignedLong: ulong] autorelease]; } + numberWithInt8: (int8_t)int8 { return [[[self alloc] initWithInt8: int8] autorelease]; @@ -454,41 +457,41 @@ type = OF_NUMBER_LONG; return self; } -- initWithUChar: (unsigned char)uchar +- initWithUnsignedChar: (unsigned char)uchar { self = [super init]; value.uchar = uchar; type = OF_NUMBER_UCHAR; return self; } -- initWithUShort: (unsigned short)ushort +- initWithUnsignedShort: (unsigned short)ushort { self = [super init]; value.ushort = ushort; type = OF_NUMBER_USHORT; return self; } -- initWithUInt: (unsigned int)uint +- initWithUnsignedInt: (unsigned int)uint { self = [super init]; value.uint = uint; type = OF_NUMBER_UINT; return self; } -- initWithULong: (unsigned long)ulong +- initWithUnsignedLong: (unsigned long)ulong { self = [super init]; value.ulong = ulong; type = OF_NUMBER_ULONG; @@ -669,131 +672,131 @@ - (enum of_number_type)type { return type; } -- (char)asChar +- (char)charValue { RETURN_AS(char) } -- (short)asShort +- (short)shortValue { RETURN_AS(short) } -- (int)asInt +- (int)intValue { RETURN_AS(int) } -- (long)asLong +- (long)longValue { RETURN_AS(long) } -- (unsigned char)asUChar +- (unsigned char)unsignedCharValue { RETURN_AS(unsigned char) } -- (unsigned short)asUShort +- (unsigned short)unsignedShortValue { RETURN_AS(unsigned short) } -- (unsigned int)asUInt +- (unsigned int)unsignedIntValue { RETURN_AS(unsigned int) } -- (unsigned long)asULong +- (unsigned long)unsignedLongValue { RETURN_AS(unsigned long) } -- (int8_t)asInt8 +- (int8_t)int8Value { RETURN_AS(int8_t) } -- (int16_t)asInt16 +- (int16_t)int16Value { RETURN_AS(int16_t) } -- (int32_t)asInt32 +- (int32_t)int32Value { RETURN_AS(int32_t) } -- (int64_t)asInt64 +- (int64_t)int64Value { RETURN_AS(int64_t) } -- (uint8_t)asUInt8 +- (uint8_t)uInt8Value { RETURN_AS(uint8_t) } -- (uint16_t)asUInt16 +- (uint16_t)uInt16Value { RETURN_AS(uint16_t) } -- (uint32_t)asUInt32 +- (uint32_t)uInt32Value { RETURN_AS(uint32_t) } -- (uint64_t)asUInt64 +- (uint64_t)uInt64Value { RETURN_AS(uint64_t) } -- (size_t)asSize +- (size_t)sizeValue { RETURN_AS(size_t) } -- (ssize_t)asSSize +- (ssize_t)sSizeValue { RETURN_AS(ssize_t) } -- (intmax_t)asIntMax +- (intmax_t)intMaxValue { RETURN_AS(intmax_t) } -- (uintmax_t)asUIntMax +- (uintmax_t)uIntMaxValue { RETURN_AS(uintmax_t) } -- (ptrdiff_t)asPtrDiff +- (ptrdiff_t)ptrDiffValue { RETURN_AS(ptrdiff_t) } -- (intptr_t)asIntPtr +- (intptr_t)intPtrValue { RETURN_AS(intptr_t) } -- (uintptr_t)asUIntPtr +- (uintptr_t)uIntPtrValue { RETURN_AS(uintptr_t) } -- (float)asFloat +- (float)floatValue { RETURN_AS(float) } -- (double)asDouble +- (double)doubleValue { RETURN_AS(double) } - (BOOL)isEqual: (OFObject*)obj @@ -810,11 +813,11 @@ case OF_NUMBER_INT16: case OF_NUMBER_INT32: case OF_NUMBER_INT64: case OF_NUMBER_INTMAX: case OF_NUMBER_PTRDIFF: - return ([(OFNumber*)obj asIntMax] == [self asIntMax] + return ([(OFNumber*)obj intMaxValue] == [self intMaxValue] ? YES : NO); case OF_NUMBER_SSIZE: case OF_NUMBER_UCHAR: case OF_NUMBER_USHORT: case OF_NUMBER_UINT: @@ -825,15 +828,15 @@ case OF_NUMBER_UINT64: case OF_NUMBER_SIZE: case OF_NUMBER_UINTMAX: case OF_NUMBER_INTPTR: case OF_NUMBER_UINTPTR: - return ([(OFNumber*)obj asUIntMax] == [self asUIntMax] + return ([(OFNumber*)obj uIntMaxValue] == [self uIntMaxValue] ? YES : NO); case OF_NUMBER_FLOAT: case OF_NUMBER_DOUBLE: - return ([(OFNumber*)obj asDouble] == [self asDouble] + return ([(OFNumber*)obj doubleValue] == [self doubleValue] ? YES : NO); default: @throw [OFInvalidArgumentException newWithClass: isa selector: _cmd]; } @@ -858,11 +861,11 @@ OF_HASH_ADD(hash, ((char*)&value.double_)[i]); OF_HASH_FINALIZE(hash); return hash; default: - return [self asUInt32]; + return [self uInt32Value]; } } - (OFNumber*)numberByAdding: (OFNumber*)num { Index: tests/OFNumberTests.m ================================================================== --- tests/OFNumberTests.m +++ tests/OFNumberTests.m @@ -31,26 +31,26 @@ TEST(@"-[isEqual:]", [num isEqual: [OFNumber numberWithUInt32: 123456789]]) TEST(@"-[hash]", [num hash] == 123456789) - TEST(@"-[asDouble]", [num asDouble] == 123456789.L) + TEST(@"-[asDouble]", [num doubleValue] == 123456789.L) TEST(@"-[numberByDecreasing]", [[num numberByDecreasing] isEqual: [OFNumber numberWithInt32: 123456788]]) TEST(@"-[numberByDividingBy:]", - [[num numberByDividingBy: [OFNumber numberWithInt: 2]] asInt] == + [[num numberByDividingBy: [OFNumber numberWithInt: 2]] intValue] == 61728394) TEST(@"-[numberByXORing:]", - [[num numberByXORing: [OFNumber numberWithInt: 123456831]] asInt] == - 42) + [[num numberByXORing: [OFNumber numberWithInt: 123456831]] + intValue] == 42) TEST(@"-[numberByShiftingRightBy:]", [[num numberByShiftingRightBy: [OFNumber numberWithInt: 8]] - asInt] == 482253) + intValue] == 482253) [pool drain]; } @end