Index: src/OFNumber.h ================================================================== --- src/OFNumber.h +++ src/OFNumber.h @@ -42,33 +42,37 @@ OF_NUMBER_USHORT = 0x03, /*! unsigned int */ OF_NUMBER_UINT = 0x04, /*! unsigned long */ OF_NUMBER_ULONG = 0x05, + /*! unsigned long long */ + OF_NUMBER_ULONGLONG = 0x06, /*! size_t */ - OF_NUMBER_SIZE = 0x06, + OF_NUMBER_SIZE = 0x07, /*! uint8_t */ - OF_NUMBER_UINT8 = 0x07, + OF_NUMBER_UINT8 = 0x08, /*! uint16_t */ - OF_NUMBER_UINT16 = 0x08, + OF_NUMBER_UINT16 = 0x09, /*! uint32_t */ - OF_NUMBER_UINT32 = 0x09, + OF_NUMBER_UINT32 = 0x0A, /*! uint64_t */ - OF_NUMBER_UINT64 = 0x0A, + OF_NUMBER_UINT64 = 0x0B, /*! uintptr_t */ - OF_NUMBER_UINTPTR = 0x0B, + OF_NUMBER_UINTPTR = 0x0C, /*! uintmax_t */ - OF_NUMBER_UINTMAX = 0x0C, + OF_NUMBER_UINTMAX = 0x0D, OF_NUMBER_SIGNED = 0x10, /*! signed char */ OF_NUMBER_CHAR = OF_NUMBER_UCHAR | OF_NUMBER_SIGNED, /*! signed short */ OF_NUMBER_SHORT = OF_NUMBER_USHORT | OF_NUMBER_SIGNED, /*! signed int */ OF_NUMBER_INT = OF_NUMBER_UINT | OF_NUMBER_SIGNED, /*! signed long */ OF_NUMBER_LONG = OF_NUMBER_ULONG | OF_NUMBER_SIGNED, + /*! signed long long */ + OF_NUMBER_LONGLONG = OF_NUMBER_ULONGLONG | OF_NUMBER_SIGNED, /*! int8_t */ OF_NUMBER_INT8 = OF_NUMBER_UINT8 | OF_NUMBER_SIGNED, /*! int16_t */ OF_NUMBER_INT16 = OF_NUMBER_UINT16 | OF_NUMBER_SIGNED, /*! int32_t */ @@ -78,13 +82,13 @@ /*! ssize_t */ OF_NUMBER_SSIZE = OF_NUMBER_SIZE | OF_NUMBER_SIGNED, /*! intmax_t */ OF_NUMBER_INTMAX = OF_NUMBER_UINTMAX | OF_NUMBER_SIGNED, /*! ptrdiff_t */ - OF_NUMBER_PTRDIFF = 0x0D | OF_NUMBER_SIGNED, + OF_NUMBER_PTRDIFF = 0x0E | OF_NUMBER_SIGNED, /*! intptr_t */ - OF_NUMBER_INTPTR = 0x0E | OF_NUMBER_SIGNED, + OF_NUMBER_INTPTR = 0x0F | OF_NUMBER_SIGNED, /*! float */ OF_NUMBER_FLOAT = 0x20, /*! double */ OF_NUMBER_DOUBLE = 0x40 | OF_NUMBER_FLOAT, } of_number_type_t; @@ -94,36 +98,38 @@ */ @interface OFNumber: OFObject { union of_number_value { - BOOL bool_; - signed char schar; - signed short sshort; - signed int sint; - signed long slong; - unsigned char uchar; - unsigned short ushort; - unsigned int uint; - unsigned long ulong; - int8_t int8; - int16_t int16; - int32_t int32; - int64_t int64; - uint8_t uint8; - uint16_t uint16; - uint32_t uint32; - uint64_t uint64; - size_t size; - ssize_t ssize; - intmax_t intmax; - uintmax_t uintmax; - ptrdiff_t ptrdiff; - intptr_t intptr; - uintptr_t uintptr; - float float_; - double double_; + BOOL bool_; + signed char schar; + signed short sshort; + signed int sint; + signed long slong; + signed long long slonglong; + unsigned char uchar; + unsigned short ushort; + unsigned int uint; + unsigned long ulong; + unsigned long long ulonglong; + int8_t int8; + int16_t int16; + int32_t int32; + int64_t int64; + uint8_t uint8; + uint16_t uint16; + uint32_t uint32; + uint64_t uint64; + size_t size; + ssize_t ssize; + intmax_t intmax; + uintmax_t uintmax; + ptrdiff_t ptrdiff; + intptr_t intptr; + uintptr_t uintptr; + float float_; + double double_; } _value; of_number_type_t _type; } #ifdef OF_HAVE_PROPERTIES @@ -168,10 +174,18 @@ * @param slong A signed long which the OFNumber should contain * @return A new autoreleased OFNumber */ + (instancetype)numberWithLong: (signed long)slong; +/*! + * @brief Creates a new OFNumber with the specified signed long long. + * + * @param slonglong A signed long long which the OFNumber should contain + * @return A new autoreleased OFNumber + */ ++ (instancetype)numberWithLongLong: (signed long long)slonglong; + /*! * @brief Creates a new OFNumber with the specified unsigned char. * * @param uchar An unsigned char which the OFNumber should contain * @return A new autoreleased OFNumber @@ -200,10 +214,18 @@ * @param ulong An unsigned long which the OFNumber should contain * @return A new autoreleased OFNumber */ + (instancetype)numberWithUnsignedLong: (unsigned long)ulong; +/*! + * @brief Creates a new OFNumber with the specified unsigned long long. + * + * @param ulonglong An unsigned long long which the OFNumber should contain + * @return A new autoreleased OFNumber + */ ++ (instancetype)numberWithUnsignedLongLong: (unsigned long long)ulonglong; + /*! * @brief Creates a new OFNumber with the specified int8_t. * * @param int8 An int8_t which the OFNumber should contain * @return A new autoreleased OFNumber @@ -380,10 +402,19 @@ * @param slong A signed long which the OFNumber should contain * @return An initialized OFNumber */ - initWithLong: (signed long)slong; +/*! + * @brief Initializes an already allocated OFNumber with the specified signed + * long long. + * + * @param slonglong A signed long long which the OFNumber should contain + * @return An initialized OFNumber + */ +- initWithLongLong: (signed long long)slonglong; + /*! * @brief Initializes an already allocated OFNumber with the specified unsigned * char. * * @param uchar An unsigned char which the OFNumber should contain @@ -416,10 +447,19 @@ * @param ulong An unsigned long which the OFNumber should contain * @return An initialized OFNumber */ - initWithUnsignedLong: (unsigned long)ulong; +/*! + * @brief Initializes an already allocated OFNumber with the specified unsigned + * long long. + * + * @param ulonglong An unsigned long long which the OFNumber should contain + * @return An initialized OFNumber + */ +- initWithUnsignedLongLong: (unsigned long long)ulonglong; + /*! * @brief Initializes an already allocated OFNumber with the specified int8_t. * * @param int8 An int8_t which the OFNumber should contain * @return An initialized OFNumber @@ -579,28 +619,35 @@ - (signed char)charValue; /*! * @brief Returns the OFNumber as a signed short. * - * @return The OFNumber as a short + * @return The OFNumber as a signed short */ - (signed short)shortValue; /*! * @brief Returns the OFNumber as a signed int. * - * @return The OFNumber as an int + * @return The OFNumber as a signed int */ - (signed int)intValue; /*! * @brief Returns the OFNumber as a signed long. * - * @return The OFNumber as a long + * @return The OFNumber as a signed long */ - (signed long)longValue; +/*! + * @brief Returns the OFNumber as a signed long long. + * + * @return The OFNumber as a signed long long + */ +- (signed long long)longLongValue; + /*! * @brief Returns the OFNumber as an unsigned char. * * @return The OFNumber as an unsigned char */ @@ -625,10 +672,17 @@ * * @return The OFNumber as an unsigned long */ - (unsigned long)unsignedLongValue; +/*! + * @brief Returns the OFNumber as an unsigned long long. + * + * @return The OFNumber as an unsigned long long + */ +- (unsigned long long)unsignedLongLongValue; + /*! * @brief Returns the OFNumber as an int8_t. * * @return The OFNumber as an int8_t */ Index: src/OFNumber.m ================================================================== --- src/OFNumber.m +++ src/OFNumber.m @@ -43,18 +43,22 @@ return (t)_value.sshort; \ case OF_NUMBER_INT: \ return (t)_value.sint; \ case OF_NUMBER_LONG: \ return (t)_value.slong; \ + case OF_NUMBER_LONGLONG: \ + return (t)_value.slonglong; \ case OF_NUMBER_UCHAR: \ return (t)_value.uchar; \ case OF_NUMBER_USHORT: \ return (t)_value.ushort; \ case OF_NUMBER_UINT: \ return (t)_value.uint; \ case OF_NUMBER_ULONG: \ return (t)_value.ulong; \ + case OF_NUMBER_ULONGLONG: \ + return (t)_value.ulonglong; \ case OF_NUMBER_INT8: \ return (t)_value.int8; \ case OF_NUMBER_INT16: \ return (t)_value.int16; \ case OF_NUMBER_INT32: \ @@ -106,10 +110,13 @@ return [OFNumber numberWithInt: \ _value.sint o [n intValue]]; \ case OF_NUMBER_LONG: \ return [OFNumber numberWithLong: \ _value.slong o [n longValue]]; \ + case OF_NUMBER_LONGLONG: \ + return [OFNumber numberWithLongLong: \ + _value.slonglong o [n longLongValue]]; \ case OF_NUMBER_UCHAR: \ return [OFNumber numberWithUnsignedChar: \ _value.uchar o [n unsignedCharValue]]; \ case OF_NUMBER_USHORT: \ return [OFNumber numberWithUnsignedShort: \ @@ -118,10 +125,13 @@ return [OFNumber numberWithUnsignedInt: \ _value.uint o [n unsignedIntValue]]; \ case OF_NUMBER_ULONG: \ return [OFNumber numberWithUnsignedLong: \ _value.ulong o [n unsignedLongValue]]; \ + case OF_NUMBER_ULONGLONG: \ + return [OFNumber numberWithUnsignedLongLong: \ + _value.ulonglong o [n unsignedLongLongValue]]; \ case OF_NUMBER_INT8: \ return [OFNumber numberWithInt8: \ _value.int8 o [n int8Value]]; \ case OF_NUMBER_INT16: \ return [OFNumber numberWithInt16: \ @@ -190,10 +200,13 @@ return [OFNumber numberWithInt: \ _value.sint o [n intValue]]; \ case OF_NUMBER_LONG: \ return [OFNumber numberWithLong: \ _value.slong o [n longValue]]; \ + case OF_NUMBER_LONGLONG: \ + return [OFNumber numberWithLongLong: \ + _value.slonglong o [n longLongValue]]; \ case OF_NUMBER_UCHAR: \ return [OFNumber numberWithUnsignedChar: \ _value.uchar o [n unsignedCharValue]]; \ case OF_NUMBER_USHORT: \ return [OFNumber numberWithUnsignedShort: \ @@ -202,10 +215,13 @@ return [OFNumber numberWithUnsignedInt: \ _value.uint o [n unsignedIntValue]]; \ case OF_NUMBER_ULONG: \ return [OFNumber numberWithUnsignedLong: \ _value.ulong o [n unsignedLongValue]]; \ + case OF_NUMBER_ULONGLONG: \ + return [OFNumber numberWithUnsignedLongLong: \ + _value.ulonglong o [n unsignedLongLongValue]]; \ case OF_NUMBER_INT8: \ return [OFNumber numberWithInt8: \ _value.int8 o [n int8Value]]; \ case OF_NUMBER_INT16: \ return [OFNumber numberWithInt16: \ @@ -268,10 +284,13 @@ return [OFNumber numberWithShort: _value.sshort o]; \ case OF_NUMBER_INT: \ return [OFNumber numberWithInt: _value.sint o]; \ case OF_NUMBER_LONG: \ return [OFNumber numberWithLong: _value.slong o]; \ + case OF_NUMBER_LONGLONG: \ + return [OFNumber numberWithLongLong: \ + _value.slonglong o]; \ case OF_NUMBER_UCHAR: \ return [OFNumber numberWithUnsignedChar: \ _value.uchar o]; \ case OF_NUMBER_USHORT: \ return [OFNumber numberWithUnsignedShort: \ @@ -278,11 +297,14 @@ _value.ushort o]; \ case OF_NUMBER_UINT: \ return [OFNumber numberWithUnsignedInt: _value.uint o]; \ case OF_NUMBER_ULONG: \ return [OFNumber numberWithUnsignedLong: \ - _value.ulong o]; \ + _value.ulong o]; \ + case OF_NUMBER_ULONGLONG: \ + return [OFNumber numberWithUnsignedLongLong: \ + _value.ulonglong 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: \ @@ -343,10 +365,15 @@ + (instancetype)numberWithLong: (signed long)slong { return [[[self alloc] initWithLong: slong] autorelease]; } + ++ (instancetype)numberWithLongLong: (signed long long)slonglong +{ + return [[[self alloc] initWithLongLong: slonglong] autorelease]; +} + (instancetype)numberWithUnsignedChar: (unsigned char)uchar { return [[[self alloc] initWithUnsignedChar: uchar] autorelease]; } @@ -363,10 +390,15 @@ + (instancetype)numberWithUnsignedLong: (unsigned long)ulong { return [[[self alloc] initWithUnsignedLong: ulong] autorelease]; } + ++ (instancetype)numberWithUnsignedLongLong: (unsigned long long)ulonglong +{ + return [[[self alloc] initWithUnsignedLongLong: ulonglong] autorelease]; +} + (instancetype)numberWithInt8: (int8_t)int8 { return [[[self alloc] initWithInt8: int8] autorelease]; } @@ -510,10 +542,20 @@ _value.slong = slong; _type = OF_NUMBER_LONG; return self; } + +- initWithLongLong: (signed long long)slonglong +{ + self = [super init]; + + _value.slonglong = slonglong; + _type = OF_NUMBER_LONGLONG; + + return self; +} - initWithUnsignedChar: (unsigned char)uchar { self = [super init]; @@ -548,10 +590,20 @@ self = [super init]; _value.ulong = ulong; _type = OF_NUMBER_ULONG; + return self; +} + +- initWithUnsignedLongLong: (unsigned long long)ulonglong +{ + self = [super init]; + + _value.ulonglong = ulonglong; + _type = OF_NUMBER_ULONGLONG; + return self; } - initWithInt8: (int8_t)int8 { @@ -810,18 +862,22 @@ return !!_value.sshort; case OF_NUMBER_INT: return !!_value.sint; case OF_NUMBER_LONG: return !!_value.slong; + case OF_NUMBER_LONGLONG: + return !!_value.slonglong; case OF_NUMBER_UCHAR: return !!_value.uchar; case OF_NUMBER_USHORT: return !!_value.ushort; case OF_NUMBER_UINT: return !!_value.uint; case OF_NUMBER_ULONG: return !!_value.ulong; + case OF_NUMBER_ULONGLONG: + return !!_value.ulonglong; case OF_NUMBER_INT8: return !!_value.int8; case OF_NUMBER_INT16: return !!_value.int16; case OF_NUMBER_INT32: @@ -877,10 +933,15 @@ - (signed long)longValue { RETURN_AS(signed long) } + +- (signed long long)longLongValue +{ + RETURN_AS(signed long long) +} - (unsigned char)unsignedCharValue { RETURN_AS(unsigned char) } @@ -897,10 +958,15 @@ - (unsigned long)unsignedLongValue { RETURN_AS(unsigned long) } + +- (unsigned long long)unsignedLongLongValue +{ + RETURN_AS(unsigned long long) +} - (int8_t)int8Value { RETURN_AS(int8_t) } @@ -1179,10 +1245,13 @@ return [OFNumber numberWithInt: _value.sint % [number intValue]]; case OF_NUMBER_LONG: return [OFNumber numberWithLong: _value.slong % [number longValue]]; + case OF_NUMBER_LONGLONG: + return [OFNumber numberWithLongLong: + _value.slonglong % [number longLongValue]]; case OF_NUMBER_UCHAR: return [OFNumber numberWithUnsignedChar: _value.uchar % [number unsignedCharValue]]; case OF_NUMBER_USHORT: return [OFNumber numberWithUnsignedShort: @@ -1191,10 +1260,13 @@ return [OFNumber numberWithUnsignedInt: _value.uint % [number unsignedIntValue]]; case OF_NUMBER_ULONG: return [OFNumber numberWithUnsignedLong: _value.ulong % [number unsignedLongValue]]; + case OF_NUMBER_ULONGLONG: + return [OFNumber numberWithUnsignedLongLong: + _value.ulonglong % [number unsignedLongLongValue]]; case OF_NUMBER_INT8: return [OFNumber numberWithInt8: _value.int8 % [number int8Value]]; case OF_NUMBER_INT16: return [OFNumber numberWithInt16: @@ -1264,10 +1336,11 @@ return (_value.bool_ ? @"YES" : @"NO"); case OF_NUMBER_UCHAR: case OF_NUMBER_USHORT: case OF_NUMBER_UINT: case OF_NUMBER_ULONG: + case OF_NUMBER_ULONGLONG: case OF_NUMBER_UINT8: case OF_NUMBER_UINT16: case OF_NUMBER_UINT32: case OF_NUMBER_UINT64: case OF_NUMBER_SIZE: @@ -1276,10 +1349,11 @@ return [OFString stringWithFormat: @"%ju", [self uIntMaxValue]]; case OF_NUMBER_CHAR: case OF_NUMBER_SHORT: case OF_NUMBER_INT: case OF_NUMBER_LONG: + case OF_NUMBER_LONGLONG: case OF_NUMBER_INT8: case OF_NUMBER_INT16: case OF_NUMBER_INT32: case OF_NUMBER_INT64: case OF_NUMBER_SSIZE: @@ -1328,10 +1402,11 @@ break; case OF_NUMBER_UCHAR: case OF_NUMBER_USHORT: case OF_NUMBER_UINT: case OF_NUMBER_ULONG: + case OF_NUMBER_ULONGLONG: case OF_NUMBER_UINT8: case OF_NUMBER_UINT16: case OF_NUMBER_UINT32: case OF_NUMBER_UINT64: case OF_NUMBER_SIZE: @@ -1342,10 +1417,11 @@ break; case OF_NUMBER_CHAR: case OF_NUMBER_SHORT: case OF_NUMBER_INT: case OF_NUMBER_LONG: + case OF_NUMBER_LONGLONG: case OF_NUMBER_INT8: case OF_NUMBER_INT16: case OF_NUMBER_INT32: case OF_NUMBER_INT64: case OF_NUMBER_SSIZE: