Index: src/OFASN1Enumerated.h ================================================================== --- src/OFASN1Enumerated.h +++ src/OFASN1Enumerated.h @@ -24,37 +24,36 @@ * @brief An ASN.1 Enumerated. */ OF_SUBCLASSING_RESTRICTED @interface OFASN1Enumerated: OFObject { - intmax_t _integerValue; + long long _longLongValue; } /*! * @brief The integer value. */ -@property (readonly, nonatomic) intmax_t integerValue; +@property (readonly, nonatomic) long long longLongValue; /*! * @brief Creates an ASN.1 Enumerated with the specified integer value. * - * @param integerValue The integer value of the Enumerated + * @param value The `long long` value of the Enumerated * @return A new, autoreleased OFASN1Enumerated */ -+ (instancetype)enumeratedWithIntegerValue: (intmax_t)integerValue; ++ (instancetype)enumeratedWithLongLong: (long long)value; - (instancetype)init OF_UNAVAILABLE; /*! * @brief Initializes an already allocated ASN.1 Enumerated with the specified * integer value. * - * @param integerValue The integer value of the Enumerated + * @param value The `long long` value of the Enumerated * @return An initialized OFASN1Enumerated */ -- (instancetype)initWithIntegerValue: (intmax_t)integerValue - OF_DESIGNATED_INITIALIZER; +- (instancetype)initWithLongLong: (long long)value OF_DESIGNATED_INITIALIZER; /*! * @brief Initializes an already allocated ASN.1 Enumerated with the specified * arguments. * Index: src/OFASN1Enumerated.m ================================================================== --- src/OFASN1Enumerated.m +++ src/OFASN1Enumerated.m @@ -21,53 +21,53 @@ #import "OFData.h" #import "OFString.h" #import "OFInvalidArgumentException.h" -extern intmax_t of_asn1_der_integer_parse(const unsigned char *buffer, +extern long long of_asn1_der_integer_parse(const unsigned char *buffer, size_t length); @implementation OFASN1Enumerated -@synthesize integerValue = _integerValue; +@synthesize longLongValue = _longLongValue; -+ (instancetype)enumeratedWithIntegerValue: (intmax_t)integerValue ++ (instancetype)enumeratedWithLongLong: (long long)value { - return [[[self alloc] initWithIntegerValue: integerValue] autorelease]; + return [[[self alloc] initWithLongLong: value] autorelease]; } -- (instancetype)initWithIntegerValue: (intmax_t)integerValue +- (instancetype)initWithLongLong: (long long)value { self = [super init]; - _integerValue = integerValue; + _longLongValue = value; return self; } - (instancetype)initWithTagClass: (of_asn1_tag_class_t)tagClass tagNumber: (of_asn1_tag_number_t)tagNumber constructed: (bool)constructed DEREncodedContents: (OFData *)DEREncodedContents { - intmax_t integerValue; + long long value; @try { if (tagClass != OF_ASN1_TAG_CLASS_UNIVERSAL || tagNumber != OF_ASN1_TAG_NUMBER_ENUMERATED || constructed) @throw [OFInvalidArgumentException exception]; if (DEREncodedContents.itemSize != 1) @throw [OFInvalidArgumentException exception]; - integerValue = of_asn1_der_integer_parse( + value = of_asn1_der_integer_parse( DEREncodedContents.items, DEREncodedContents.count); } @catch (id e) { [self release]; @throw e; } - return [self initWithIntegerValue: integerValue]; + return [self initWithLongLong: value]; } - (instancetype)init { OF_INVALID_INIT_METHOD @@ -83,22 +83,22 @@ if (![object isKindOfClass: [OFASN1Enumerated class]]) return false; enumerated = object; - if (enumerated->_integerValue != _integerValue) + if (enumerated->_longLongValue != _longLongValue) return false; return true; } - (uint32_t)hash { - return (uint32_t)_integerValue; + return (uint32_t)_longLongValue; } - (OFString *)description { - return [OFString stringWithFormat: @"", - _integerValue]; + return [OFString stringWithFormat: @"", + _longLongValue]; } @end Index: src/OFASN1Integer.h ================================================================== --- src/OFASN1Integer.h +++ src/OFASN1Integer.h @@ -24,37 +24,36 @@ * @brief An ASN.1 Integer. */ OF_SUBCLASSING_RESTRICTED @interface OFASN1Integer: OFObject { - intmax_t _integerValue; + long long _longLongValue; } /*! * @brief The Integer value. */ -@property (readonly, nonatomic) intmax_t integerValue; +@property (readonly, nonatomic) long long longLongValue; /*! * @brief Creates an ASN.1 Integer with the specified integer value. * - * @param integerValue The integer value of the Integer + * @param value The `long long` value of the Integer * @return A new, autoreleased OFASN1Integer */ -+ (instancetype)integerWithIntegerValue: (intmax_t)integerValue; ++ (instancetype)integerWithLongLong: (long long)value; - (instancetype)init OF_UNAVAILABLE; /*! * @brief Initializes an already allocated ASN.1 Integer with the specified * integer value. * - * @param integerValue The integer value of the Integer + * @param value The `long long` value of the Integer * @return An initialized OFASN1Integer */ -- (instancetype)initWithIntegerValue: (intmax_t)integerValue - OF_DESIGNATED_INITIALIZER; +- (instancetype)initWithLongLong: (long long)value OF_DESIGNATED_INITIALIZER; /*! * @brief Initializes an already allocated ASN.1 Integer with the specified * arguments. * Index: src/OFASN1Integer.m ================================================================== --- src/OFASN1Integer.m +++ src/OFASN1Integer.m @@ -23,73 +23,73 @@ #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFOutOfRangeException.h" -intmax_t +long long of_asn1_der_integer_parse(const unsigned char *buffer, size_t length) { - uintmax_t value = 0; + unsigned long long value = 0; /* TODO: Support for big numbers */ - if (length > sizeof(uintmax_t) && - (length != sizeof(uintmax_t) + 1 || buffer[0] != 0)) + if (length > sizeof(unsigned long long) && + (length != sizeof(unsigned long long) + 1 || buffer[0] != 0)) @throw [OFOutOfRangeException exception]; if (length >= 2 && ((buffer[0] == 0 && !(buffer[1] & 0x80)) || (buffer[0] == 0xFF && buffer[1] & 0x80))) @throw [OFInvalidFormatException exception]; if (length >= 1 && buffer[0] & 0x80) - value = ~(uintmax_t)0; + value = ~0ull; while (length--) value = (value << 8) | *buffer++; return value; } @implementation OFASN1Integer -@synthesize integerValue = _integerValue; +@synthesize longLongValue = _longLongValue; -+ (instancetype)integerWithIntegerValue: (intmax_t)integerValue ++ (instancetype)integerWithLongLong: (long long)value { - return [[[self alloc] initWithIntegerValue: integerValue] autorelease]; + return [[[self alloc] initWithLongLong: value] autorelease]; } -- (instancetype)initWithIntegerValue: (intmax_t)integerValue +- (instancetype)initWithLongLong: (long long)value { self = [super init]; - _integerValue = integerValue; + _longLongValue = value; return self; } - (instancetype)initWithTagClass: (of_asn1_tag_class_t)tagClass tagNumber: (of_asn1_tag_number_t)tagNumber constructed: (bool)constructed DEREncodedContents: (OFData *)DEREncodedContents { - intmax_t integerValue; + long long value; @try { if (tagClass != OF_ASN1_TAG_CLASS_UNIVERSAL || tagNumber != OF_ASN1_TAG_NUMBER_INTEGER || constructed) @throw [OFInvalidArgumentException exception]; if (DEREncodedContents.itemSize != 1) @throw [OFInvalidArgumentException exception]; - integerValue = of_asn1_der_integer_parse( + value = of_asn1_der_integer_parse( DEREncodedContents.items, DEREncodedContents.count); } @catch (id e) { [self release]; @throw e; } - return [self initWithIntegerValue: integerValue]; + return [self initWithLongLong: value]; } - (instancetype)init { OF_INVALID_INIT_METHOD @@ -105,22 +105,22 @@ if (![object isKindOfClass: [OFASN1Integer class]]) return false; integer = object; - if (integer->_integerValue != _integerValue) + if (integer->_longLongValue != _longLongValue) return false; return true; } - (uint32_t)hash { - return (uint32_t)_integerValue; + return (uint32_t)_longLongValue; } - (OFString *)description { - return [OFString stringWithFormat: @"", - _integerValue]; + return [OFString stringWithFormat: @"", + _longLongValue]; } @end Index: src/OFASN1ObjectIdentifier.m ================================================================== --- src/OFASN1ObjectIdentifier.m +++ src/OFASN1ObjectIdentifier.m @@ -44,11 +44,11 @@ @try { if (subidentifiers.count < 1) @throw [OFInvalidFormatException exception]; - switch ([[subidentifiers objectAtIndex: 0] intMaxValue]) { + switch ([[subidentifiers objectAtIndex: 0] longLongValue]) { case 0: case 1: case 2: break; default: @@ -73,11 +73,11 @@ OFMutableArray OF_GENERIC(OFNumber *) *subidentifiers; @try { const unsigned char *items = DEREncodedContents.items; size_t count = DEREncodedContents.count; - uintmax_t value = 0; + unsigned long long value = 0; uint_fast8_t bits = 0; if (tagClass != OF_ASN1_TAG_CLASS_UNIVERSAL || tagNumber != OF_ASN1_TAG_NUMBER_OBJECT_IDENTIFIER || constructed) @@ -93,33 +93,33 @@ @throw [OFInvalidFormatException exception]; value = (value << 7) | (items[i] & 0x7F); bits += 7; - if (bits > sizeof(uintmax_t) * 8) + if (bits > sizeof(unsigned long long) * 8) @throw [OFOutOfRangeException exception]; if (items[i] & 0x80) continue; if (subidentifiers.count == 0) { if (value < 40) [subidentifiers addObject: - [OFNumber numberWithUIntMax: 0]]; + [OFNumber numberWithInt: 0]]; else if (value < 80) { [subidentifiers addObject: - [OFNumber numberWithUIntMax: 1]]; + [OFNumber numberWithInt: 1]]; value -= 40; } else { [subidentifiers addObject: - [OFNumber numberWithUIntMax: 2]]; + [OFNumber numberWithInt: 2]]; value -= 80; } } [subidentifiers addObject: - [OFNumber numberWithUIntMax: value]]; + [OFNumber numberWithUnsignedLongLong: value]]; value = 0; bits = 0; } Index: src/OFData.m ================================================================== --- src/OFData.m +++ src/OFData.m @@ -182,19 +182,19 @@ #ifdef OF_HAVE_FILES - (instancetype)initWithContentsOfFile: (OFString *)path { char *buffer = NULL; - uintmax_t size; + unsigned long long size; @try { OFFile *file; size = [[OFFileManager defaultManager] attributesOfItemAtPath: path].fileSize; -# if UINTMAX_MAX > SIZE_MAX +# if ULLONG_MAX > SIZE_MAX if (size > SIZE_MAX) @throw [OFOutOfRangeException exception]; # endif if ((buffer = malloc((size_t)size)) == NULL) Index: src/OFFileManager.h ================================================================== --- src/OFFileManager.h +++ src/OFFileManager.h @@ -576,11 +576,11 @@ /*! * @brief The @ref of_file_attribute_key_size key from the dictionary. * * Raises an @ref OFUndefinedKeyException if the key is missing. */ -@property (readonly, nonatomic) uintmax_t fileSize; +@property (readonly, nonatomic) unsigned long long fileSize; /*! * @brief The @ref of_file_attribute_key_type key from the dictionary. * * Raises an @ref OFUndefinedKeyException if the key is missing. Index: src/OFFileManager.m ================================================================== --- src/OFFileManager.m +++ src/OFFileManager.m @@ -936,14 +936,14 @@ return OF_RETAIN_COUNT_MAX; } @end @implementation OFDictionary (FileAttributes) -- (uintmax_t)fileSize +- (unsigned long long)fileSize { return [attributeForKeyOrException(self, of_file_attribute_key_size) - uIntMaxValue]; + unsignedLongLongValue]; } - (of_file_type_t)fileType { return attributeForKeyOrException(self, of_file_attribute_key_type); Index: src/OFFileURLHandler.m ================================================================== --- src/OFFileURLHandler.m +++ src/OFFileURLHandler.m @@ -618,11 +618,11 @@ errNo: errno]; if (s.st_size < 0) @throw [OFOutOfRangeException exception]; - [ret setObject: [NSNumber numberWithUIntMax: s.st_size] + [ret setObject: [NSNumber numberWithUnsignedLongLong: s.st_size] forKey: of_file_attribute_key_size]; setTypeAttribute(ret, &s); [ret setObject: [NSNumber numberWithUInt16: s.st_mode & 07777] Index: src/OFLocale.m ================================================================== --- src/OFLocale.m +++ src/OFLocale.m @@ -213,12 +213,13 @@ compare: second] != OF_ORDERED_ASCENDING]; else if ([token isEqual: @"+"]) var = [OFNumber numberWithDouble: [first doubleValue] + [second doubleValue]]; else if ([token isEqual: @"%"]) - var = [OFNumber numberWithIntMax: - [first intMaxValue] % [second intMaxValue]]; + var = [OFNumber numberWithLongLong: + [first longLongValue] % + [second longLongValue]]; else if ([token isEqual: @"&&"]) var = [OFNumber numberWithBool: [first boolValue] && [second boolValue]]; else if ([token isEqual: @"||"]) var = [OFNumber numberWithBool: @@ -236,11 +237,12 @@ if ([token isEqual: @"!"]) var = [OFNumber numberWithBool: ![first boolValue]]; else if ([token isEqual: @"is_real"]) var = [OFNumber numberWithBool: - [first doubleValue] != [first intMaxValue]]; + ([first doubleValue] != + [first longLongValue])]; else OF_ENSURE(0); [stack replaceObjectAtIndex: stackSize - 1 withObject: var]; Index: src/OFNumber.h ================================================================== --- src/OFNumber.h +++ src/OFNumber.h @@ -47,13 +47,13 @@ #endif @interface OFNumber: OFValue { union of_number_value { - double float_; - intmax_t signed_; - uintmax_t unsigned_; + double float_; + long long signed_; + unsigned long long unsigned_; } _value; enum of_number_type { OF_NUMBER_TYPE_FLOAT = 1, OF_NUMBER_TYPE_SIGNED, OF_NUMBER_TYPE_UNSIGNED @@ -164,20 +164,10 @@ /*! * @brief The OFNumber as an `ssize_t`. */ @property (readonly, nonatomic) ssize_t sSizeValue; -/*! - * @brief The OFNumber as an `intmax_t`. - */ -@property (readonly, nonatomic) intmax_t intMaxValue; - -/*! - * @brief The OFNumber as a `uintmax_t`. - */ -@property (readonly, nonatomic) uintmax_t uIntMaxValue; - /*! * @brief The OFNumber as a `ptrdiff_t`. */ @property (readonly, nonatomic) ptrdiff_t ptrDiffValue; @@ -218,230 +208,214 @@ #endif /*! * @brief Creates a new OFNumber with the specified `bool`. * - * @param bool_ A `bool` which the OFNumber should contain + * @param value The `bool` value which the OFNumber should contain * @return A new autoreleased OFNumber */ -+ (instancetype)numberWithBool: (bool)bool_; ++ (instancetype)numberWithBool: (bool)value; /*! * @brief Creates a new OFNumber with the specified `signed char`. * - * @param sChar A `signed char` which the OFNumber should contain + * @param value The `signed char` value which the OFNumber should contain * @return A new autoreleased OFNumber */ -+ (instancetype)numberWithChar: (signed char)sChar; ++ (instancetype)numberWithChar: (signed char)value; /*! * @brief Creates a new OFNumber with the specified `short`. * - * @param sShort A `short` which the OFNumber should contain + * @param value The `short` value which the OFNumber should contain * @return A new autoreleased OFNumber */ -+ (instancetype)numberWithShort: (short)sShort; ++ (instancetype)numberWithShort: (short)value; /*! * @brief Creates a new OFNumber with the specified `int`. * - * @param sInt An `int` which the OFNumber should contain + * @param value The `int` value which the OFNumber should contain * @return A new autoreleased OFNumber */ -+ (instancetype)numberWithInt: (int)sInt; ++ (instancetype)numberWithInt: (int)value; /*! * @brief Creates a new OFNumber with the specified `long`. * - * @param sLong A `long` which the OFNumber should contain + * @param value The `long` value which the OFNumber should contain * @return A new autoreleased OFNumber */ -+ (instancetype)numberWithLong: (long)sLong; ++ (instancetype)numberWithLong: (long)value; /*! * @brief Creates a new OFNumber with the specified `long long`. * - * @param sLongLong A `long long` which the OFNumber should contain + * @param value The `long long` value which the OFNumber should contain * @return A new autoreleased OFNumber */ -+ (instancetype)numberWithLongLong: (long long)sLongLong; ++ (instancetype)numberWithLongLong: (long long)value; /*! * @brief Creates a new OFNumber with the specified `unsigned char`. * - * @param uChar An `unsigned char` which the OFNumber should contain + * @param value The `unsigned char` value which the OFNumber should contain * @return A new autoreleased OFNumber */ -+ (instancetype)numberWithUnsignedChar: (unsigned char)uChar; ++ (instancetype)numberWithUnsignedChar: (unsigned char)value; /*! * @brief Creates a new OFNumber with the specified `unsigned short`. * - * @param uShort An `unsigned short` which the OFNumber should contain + * @param value The `unsigned short` value which the OFNumber should contain * @return A new autoreleased OFNumber */ -+ (instancetype)numberWithUnsignedShort: (unsigned short)uShort; ++ (instancetype)numberWithUnsignedShort: (unsigned short)value; /*! * @brief Creates a new OFNumber with the specified `unsigned int`. * - * @param uInt An `unsigned int` which the OFNumber should contain + * @param value The `unsigned int` value which the OFNumber should contain * @return A new autoreleased OFNumber */ -+ (instancetype)numberWithUnsignedInt: (unsigned int)uInt; ++ (instancetype)numberWithUnsignedInt: (unsigned int)value; /*! * @brief Creates a new OFNumber with the specified `unsigned long`. * - * @param uLong An `unsigned long` which the OFNumber should contain + * @param value The `unsigned long` value which the OFNumber should contain * @return A new autoreleased OFNumber */ -+ (instancetype)numberWithUnsignedLong: (unsigned long)uLong; ++ (instancetype)numberWithUnsignedLong: (unsigned long)value; /*! * @brief Creates a new OFNumber with the specified `unsigned long long`. * - * @param uLongLong An `unsigned long long` which the OFNumber should contain + * @param value The `unsigned long long` value which the OFNumber should contain * @return A new autoreleased OFNumber */ -+ (instancetype)numberWithUnsignedLongLong: (unsigned long long)uLongLong; ++ (instancetype)numberWithUnsignedLongLong: (unsigned long long)value; /*! * @brief Creates a new OFNumber with the specified `int8_t`. * - * @param int8 An `int8_t` which the OFNumber should contain + * @param value The `int8_t` value which the OFNumber should contain * @return A new autoreleased OFNumber */ -+ (instancetype)numberWithInt8: (int8_t)int8; ++ (instancetype)numberWithInt8: (int8_t)value; /*! * @brief Creates a new OFNumber with the specified `int16_t`. * - * @param int16 An `int16_t` which the OFNumber should contain + * @param value The `int16_t` value which the OFNumber should contain * @return A new autoreleased OFNumber */ -+ (instancetype)numberWithInt16: (int16_t)int16; ++ (instancetype)numberWithInt16: (int16_t)value; /*! * @brief Creates a new OFNumber with the specified `int32_t`. * - * @param int32 An `int32_t` which the OFNumber should contain + * @param value The `int32_t` value which the OFNumber should contain * @return A new autoreleased OFNumber */ -+ (instancetype)numberWithInt32: (int32_t)int32; ++ (instancetype)numberWithInt32: (int32_t)value; /*! * @brief Creates a new OFNumber with the specified `int64_t`. * - * @param int64 An `int64_t` which the OFNumber should contain + * @param value The `int64_t` value which the OFNumber should contain * @return A new autoreleased OFNumber */ -+ (instancetype)numberWithInt64: (int64_t)int64; ++ (instancetype)numberWithInt64: (int64_t)value; /*! * @brief Creates a new OFNumber with the specified `uint8_t`. * - * @param uInt8 A `uint8_t` which the OFNumber should contain + * @param value The `uint8_t` value which the OFNumber should contain * @return A new autoreleased OFNumber */ -+ (instancetype)numberWithUInt8: (uint8_t)uInt8; ++ (instancetype)numberWithUInt8: (uint8_t)value; /*! * @brief Creates a new OFNumber with the specified `uint16_t`. * - * @param uInt16 A `uint16_t` which the OFNumber should contain + * @param value The `uint16_t` value which the OFNumber should contain * @return A new autoreleased OFNumber */ -+ (instancetype)numberWithUInt16: (uint16_t)uInt16; ++ (instancetype)numberWithUInt16: (uint16_t)value; /*! * @brief Creates a new OFNumber with the specified `uint32_t`. * - * @param uInt32 A `uint32_t` which the OFNumber should contain + * @param value The `uint32_t` value which the OFNumber should contain * @return A new autoreleased OFNumber */ -+ (instancetype)numberWithUInt32: (uint32_t)uInt32; ++ (instancetype)numberWithUInt32: (uint32_t)value; /*! * @brief Creates a new OFNumber with the specified `uint64_t`. * - * @param uInt64 A `uint64_t` which the OFNumber should contain + * @param value The `uint64_t` value which the OFNumber should contain * @return A new autoreleased OFNumber */ -+ (instancetype)numberWithUInt64: (uint64_t)uInt64; ++ (instancetype)numberWithUInt64: (uint64_t)value; /*! * @brief Creates a new OFNumber with the specified `size_t`. * - * @param size A `size_t` which the OFNumber should contain + * @param value The `size_t` value which the OFNumber should contain * @return A new autoreleased OFNumber */ -+ (instancetype)numberWithSize: (size_t)size; ++ (instancetype)numberWithSize: (size_t)value; /*! * @brief Creates a new OFNumber with the specified `ssize_t`. * - * @param sSize An `ssize_t` which the OFNumber should contain - * @return A new autoreleased OFNumber - */ -+ (instancetype)numberWithSSize: (ssize_t)sSize; - -/*! - * @brief Creates a new OFNumber with the specified `intmax_t`. - * - * @param intMax An `intmax_t` which the OFNumber should contain - * @return A new autoreleased OFNumber - */ -+ (instancetype)numberWithIntMax: (intmax_t)intMax; - -/*! - * @brief Creates a new OFNumber with the specified `uintmax_t`. - * - * @param uIntMax A `uintmax_t` which the OFNumber should contain - * @return A new autoreleased OFNumber - */ -+ (instancetype)numberWithUIntMax: (uintmax_t)uIntMax; + * @param value The `ssize_t` value which the OFNumber should contain + * @return A new autoreleased OFNumber + */ ++ (instancetype)numberWithSSize: (ssize_t)value; /*! * @brief Creates a new OFNumber with the specified `ptrdiff_t`. * - * @param ptrDiff A `ptrdiff_t` which the OFNumber should contain + * @param value The `ptrdiff_t` value which the OFNumber should contain * @return A new autoreleased OFNumber */ -+ (instancetype)numberWithPtrDiff: (ptrdiff_t)ptrDiff; ++ (instancetype)numberWithPtrDiff: (ptrdiff_t)value; /*! * @brief Creates a new OFNumber with the specified `intptr_t`. * - * @param intPtr An `intptr_t` which the OFNumber should contain + * @param value The `intptr_t` value which the OFNumber should contain * @return A new autoreleased OFNumber */ -+ (instancetype)numberWithIntPtr: (intptr_t)intPtr; ++ (instancetype)numberWithIntPtr: (intptr_t)value; /*! * @brief Creates a new OFNumber with the specified `uintptr_t`. * - * @param uIntPtr A `uintptr_t` which the OFNumber should contain + * @param value The `uintptr_t` value which the OFNumber should contain * @return A new autoreleased OFNumber */ -+ (instancetype)numberWithUIntPtr: (uintptr_t)uIntPtr; ++ (instancetype)numberWithUIntPtr: (uintptr_t)value; /*! * @brief Creates a new OFNumber with the specified `float`. * - * @param float_ A `float` which the OFNumber should contain + * @param value The `float` value which the OFNumber should contain * @return A new autoreleased OFNumber */ -+ (instancetype)numberWithFloat: (float)float_; ++ (instancetype)numberWithFloat: (float)value; /*! * @brief Creates a new OFNumber with the specified `double`. * - * @param double_ A `double` which the OFNumber should contain + * @param value The `double` value which the OFNumber should contain * @return A new autoreleased OFNumber */ -+ (instancetype)numberWithDouble: (double)double_; ++ (instancetype)numberWithDouble: (double)value; - (instancetype)init OF_UNAVAILABLE; #ifdef OF_HAVE_UNAVAILABLE - (instancetype)initWithBytes: (const void *)bytes objCType: (const char *)objCType OF_UNAVAILABLE; @@ -454,253 +428,235 @@ #endif /*! * @brief Initializes an already allocated OFNumber with the specified `bool`. * - * @param bool_ A `bool` which the OFNumber should contain + * @param value The `bool` value which the OFNumber should contain * @return An initialized OFNumber */ -- (instancetype)initWithBool: (bool)bool_; +- (instancetype)initWithBool: (bool)value; /*! * @brief Initializes an already allocated OFNumber with the specified * `signed char`. * - * @param sChar A `signed char` which the OFNumber should contain + * @param value The `signed char` value which the OFNumber should contain * @return An initialized OFNumber */ -- (instancetype)initWithChar: (signed char)sChar; +- (instancetype)initWithChar: (signed char)value; /*! * @brief Initializes an already allocated OFNumber with the specified `short`. * - * @param sShort A `short` which the OFNumber should contain + * @param value The `short` value which the OFNumber should contain * @return An initialized OFNumber */ -- (instancetype)initWithShort: (short)sShort; +- (instancetype)initWithShort: (short)value; /*! * @brief Initializes an already allocated OFNumber with the specified `int`. * - * @param sInt An `int` which the OFNumber should contain + * @param value The `int` value which the OFNumber should contain * @return An initialized OFNumber */ -- (instancetype)initWithInt: (int)sInt; +- (instancetype)initWithInt: (int)value; /*! * @brief Initializes an already allocated OFNumber with the specified `long`. * - * @param sLong A `long` which the OFNumber should contain + * @param value The `long` value which the OFNumber should contain * @return An initialized OFNumber */ -- (instancetype)initWithLong: (long)sLong; +- (instancetype)initWithLong: (long)value; /*! * @brief Initializes an already allocated OFNumber with the specified * `long long`. * - * @param sLongLong A `long long` which the OFNumber should contain + * @param value The `long long` value which the OFNumber should contain * @return An initialized OFNumber */ -- (instancetype)initWithLongLong: (long long)sLongLong; +- (instancetype)initWithLongLong: (long long)value; /*! * @brief Initializes an already allocated OFNumber with the specified * `unsigned char`. * - * @param uChar An `unsigned char` which the OFNumber should contain + * @param value The `unsigned char` value which the OFNumber should contain * @return An initialized OFNumber */ -- (instancetype)initWithUnsignedChar: (unsigned char)uChar; +- (instancetype)initWithUnsignedChar: (unsigned char)value; /*! * @brief Initializes an already allocated OFNumber with the specified * `unsigned short`. * - * @param uShort An `unsigned short` which the OFNumber should contain + * @param value The `unsigned short` value which the OFNumber should contain * @return An initialized OFNumber */ -- (instancetype)initWithUnsignedShort: (unsigned short)uShort; +- (instancetype)initWithUnsignedShort: (unsigned short)value; /*! * @brief Initializes an already allocated OFNumber with the specified * `unsigned int`. * - * @param uInt An `unsigned int` which the OFNumber should contain + * @param value The `unsigned int` value which the OFNumber should contain * @return An initialized OFNumber */ -- (instancetype)initWithUnsignedInt: (unsigned int)uInt; +- (instancetype)initWithUnsignedInt: (unsigned int)value; /*! * @brief Initializes an already allocated OFNumber with the specified * `unsigned long`. * - * @param uLong An `unsigned long` which the OFNumber should contain + * @param value The `unsigned long` value which the OFNumber should contain * @return An initialized OFNumber */ -- (instancetype)initWithUnsignedLong: (unsigned long)uLong; +- (instancetype)initWithUnsignedLong: (unsigned long)value; /*! * @brief Initializes an already allocated OFNumber with the specified * `unsigned long long`. * - * @param uLongLong An `unsigned long long` which the OFNumber should contain + * @param value The `unsigned long long` value which the OFNumber should contain * @return An initialized OFNumber */ -- (instancetype)initWithUnsignedLongLong: (unsigned long long)uLongLong; +- (instancetype)initWithUnsignedLongLong: (unsigned long long)value; /*! * @brief Initializes an already allocated OFNumber with the specified `int8_t`. * - * @param int8 An `int8_t` which the OFNumber should contain + * @param value The `int8_t` value which the OFNumber should contain * @return An initialized OFNumber */ -- (instancetype)initWithInt8: (int8_t)int8; +- (instancetype)initWithInt8: (int8_t)value; /*! * @brief Initializes an already allocated OFNumber with the specified * `int16_t`. * - * @param int16 An `int16_t` which the OFNumber should contain + * @param value The `int16_t` value which the OFNumber should contain * @return An initialized OFNumber */ -- (instancetype)initWithInt16: (int16_t)int16; +- (instancetype)initWithInt16: (int16_t)value; /*! * @brief Initializes an already allocated OFNumber with the specified * `int32_t`. * - * @param int32 An `int32_t` which the OFNumber should contain + * @param value The `int32_t` value which the OFNumber should contain * @return An initialized OFNumber */ -- (instancetype)initWithInt32: (int32_t)int32; +- (instancetype)initWithInt32: (int32_t)value; /*! * @brief Initializes an already allocated OFNumber with the specified * `int64_t`. * - * @param int64 An `int64_t` which the OFNumber should contain + * @param value The `int64_t` value which the OFNumber should contain * @return An initialized OFNumber */ -- (instancetype)initWithInt64: (int64_t)int64; +- (instancetype)initWithInt64: (int64_t)value; /*! * @brief Initializes an already allocated OFNumber with the specified * `uint8_t`. * - * @param uInt8 A `uint8_t` which the OFNumber should contain + * @param value The `uint8_t` value which the OFNumber should contain * @return An initialized OFNumber */ -- (instancetype)initWithUInt8: (uint8_t)uInt8; +- (instancetype)initWithUInt8: (uint8_t)value; /*! * @brief Initializes an already allocated OFNumber with the specified * `uint16_t`. * - * @param uInt16 A `uint16_t` which the OFNumber should contain + * @param value The `uint16_t` value which the OFNumber should contain * @return An initialized OFNumber */ -- (instancetype)initWithUInt16: (uint16_t)uInt16; +- (instancetype)initWithUInt16: (uint16_t)value; /*! * @brief Initializes an already allocated OFNumber with the specified * `uint32_t`. * - * @param uInt32 A `uint32_t` which the OFNumber should contain + * @param value The `uint32_t` value which the OFNumber should contain * @return An initialized OFNumber */ -- (instancetype)initWithUInt32: (uint32_t)uInt32; +- (instancetype)initWithUInt32: (uint32_t)value; /*! * @brief Initializes an already allocated OFNumber with the specified * `uint64_t`. * - * @param uInt64 A `uint64_t` which the OFNumber should contain + * @param value The `uint64_t` value which the OFNumber should contain * @return An initialized OFNumber */ -- (instancetype)initWithUInt64: (uint64_t)uInt64; +- (instancetype)initWithUInt64: (uint64_t)value; /*! * @brief Initializes an already allocated OFNumber with the specified `size_t`. * - * @param size A `size_t` which the OFNumber should contain + * @param value The `size_t` value which the OFNumber should contain * @return An initialized OFNumber */ -- (instancetype)initWithSize: (size_t)size; +- (instancetype)initWithSize: (size_t)value; /*! * @brief Initializes an already allocated OFNumber with the specified * `ssize_t`. * - * @param sSize An `ssize_t` which the OFNumber should contain - * @return An initialized OFNumber - */ -- (instancetype)initWithSSize: (ssize_t)sSize; - -/*! - * @brief Initializes an already allocated OFNumber with the specified - * `intmax_t`. - * - * @param intMax An `intmax_t` which the OFNumber should contain - * @return An initialized OFNumber - */ -- (instancetype)initWithIntMax: (intmax_t)intMax; - -/*! - * @brief Initializes an already allocated OFNumber with the specified - * `uintmax_t`. - * - * @param uIntMax A `uintmax_t` which the OFNumber should contain - * @return An initialized OFNumber - */ -- (instancetype)initWithUIntMax: (uintmax_t)uIntMax; + * @param value The `ssize_t` value which the OFNumber should contain + * @return An initialized OFNumber + */ +- (instancetype)initWithSSize: (ssize_t)value; /*! * @brief Initializes an already allocated OFNumber with the specified * `ptrdiff_t`. * - * @param ptrDiff A `ptrdiff_t` which the OFNumber should contain + * @param value The `ptrdiff_t` value which the OFNumber should contain * @return An initialized OFNumber */ -- (instancetype)initWithPtrDiff: (ptrdiff_t)ptrDiff; +- (instancetype)initWithPtrDiff: (ptrdiff_t)value; /*! * @brief Initializes an already allocated OFNumber with the specified * `intptr_t`. * - * @param intPtr An `intptr_t` which the OFNumber should contain + * @param value The `intptr_t` value which the OFNumber should contain * @return An initialized OFNumber */ -- (instancetype)initWithIntPtr: (intptr_t)intPtr; +- (instancetype)initWithIntPtr: (intptr_t)value; /*! * @brief Initializes an already allocated OFNumber with the specified * `uintptr_t`. * - * @param uIntPtr A `uintptr_t` which the OFNumber should contain + * @param value The `uintptr_t` value which the OFNumber should contain * @return An initialized OFNumber */ -- (instancetype)initWithUIntPtr: (uintptr_t)uIntPtr; +- (instancetype)initWithUIntPtr: (uintptr_t)value; /*! * @brief Initializes an already allocated OFNumber with the specified `float`. * - * @param float_ A `float` which the OFNumber should contain + * @param value The `float` value which the OFNumber should contain * @return An initialized OFNumber */ -- (instancetype)initWithFloat: (float)float_; +- (instancetype)initWithFloat: (float)value; /*! * @brief Initializes an already allocated OFNumber with the specified `double`. * - * @param double_ A `double` which the OFNumber should contain + * @param value The `double` value which the OFNumber should contain * @return An initialized OFNumber */ -- (instancetype)initWithDouble: (double)double_; +- (instancetype)initWithDouble: (double)value; @end OF_ASSUME_NONNULL_END #if !defined(NSINTEGER_DEFINED) && !__has_feature(modules) /* Required for number literals to work */ @compatibility_alias NSNumber OFNumber; #endif Index: src/OFNumber.m ================================================================== --- src/OFNumber.m +++ src/OFNumber.m @@ -79,13 +79,13 @@ { falseNumber = [[OFNumberSingleton alloc] initWithBool: false]; } @implementation OFNumberPlaceholder -- (instancetype)initWithBool: (bool)bool_ +- (instancetype)initWithBool: (bool)value { - if (bool_) { + if (value) { static of_once_t once; of_once(&once, initTrueNumber); return (id)trueNumber; } else { static of_once_t once; @@ -92,61 +92,61 @@ of_once(&once, initFalseNumber); return (id)falseNumber; } } -- (instancetype)initWithChar: (signed char)sChar -{ - if (sChar >= 0) - return [self initWithUnsignedChar: sChar]; - - return (id)[[OFNumber of_alloc] initWithChar: sChar]; -} - -- (instancetype)initWithShort: (short)sShort -{ - if (sShort >= 0) - return [self initWithUnsignedShort: sShort]; - if (sShort >= SCHAR_MIN) - return [self initWithChar: (signed char)sShort]; - - return (id)[[OFNumber of_alloc] initWithShort: sShort]; -} - -- (instancetype)initWithInt: (int)sInt -{ - if (sInt >= 0) - return [self initWithUnsignedInt: sInt]; - if (sInt >= SHRT_MIN) - return [self initWithShort: (short)sInt]; - - return (id)[[OFNumber of_alloc] initWithInt: sInt]; -} - -- (instancetype)initWithLong: (long)sLong -{ - if (sLong >= 0) - return [self initWithUnsignedLong: sLong]; - if (sLong >= INT_MIN) - return [self initWithShort: (int)sLong]; - - return (id)[[OFNumber of_alloc] initWithLong: sLong]; -} - -- (instancetype)initWithLongLong: (long long)sLongLong -{ - if (sLongLong >= 0) - return [self initWithUnsignedLongLong: sLongLong]; - if (sLongLong >= LONG_MIN) - return [self initWithLong: (long)sLongLong]; - - return (id)[[OFNumber of_alloc] initWithLongLong: sLongLong]; -} - -- (instancetype)initWithUnsignedChar: (unsigned char)uChar -{ - switch (uChar) { +- (instancetype)initWithChar: (signed char)value +{ + if (value >= 0) + return [self initWithUnsignedChar: value]; + + return (id)[[OFNumber of_alloc] initWithChar: value]; +} + +- (instancetype)initWithShort: (short)value +{ + if (value >= 0) + return [self initWithUnsignedShort: value]; + if (value >= SCHAR_MIN) + return [self initWithChar: (signed char)value]; + + return (id)[[OFNumber of_alloc] initWithShort: value]; +} + +- (instancetype)initWithInt: (int)value +{ + if (value >= 0) + return [self initWithUnsignedInt: value]; + if (value >= SHRT_MIN) + return [self initWithShort: (short)value]; + + return (id)[[OFNumber of_alloc] initWithInt: value]; +} + +- (instancetype)initWithLong: (long)value +{ + if (value >= 0) + return [self initWithUnsignedLong: value]; + if (value >= INT_MIN) + return [self initWithShort: (int)value]; + + return (id)[[OFNumber of_alloc] initWithLong: value]; +} + +- (instancetype)initWithLongLong: (long long)value +{ + if (value >= 0) + return [self initWithUnsignedLongLong: value]; + if (value >= LONG_MIN) + return [self initWithLong: (long)value]; + + return (id)[[OFNumber of_alloc] initWithLongLong: value]; +} + +- (instancetype)initWithUnsignedChar: (unsigned char)value +{ + switch (value) { case 0: { static of_once_t once = OF_ONCE_INIT; of_once(&once, initZeroNumber); return (id)zeroNumber; } @@ -160,147 +160,128 @@ of_once(&once, initTwoNumber); return (id)twoNumber; } } - return (id)[[OFNumber of_alloc] initWithUnsignedChar: uChar]; -} - -- (instancetype)initWithUnsignedShort: (unsigned short)uShort -{ - if (uShort <= UCHAR_MAX) - return [self initWithUnsignedChar: (unsigned char)uShort]; - - return (id)[[OFNumber of_alloc] initWithUnsignedShort: uShort]; -} - -- (instancetype)initWithUnsignedInt: (unsigned int)uInt -{ - if (uInt <= USHRT_MAX) - return [self initWithUnsignedShort: (unsigned short)uInt]; - - return (id)[[OFNumber of_alloc] initWithUnsignedInt: uInt]; -} - -- (instancetype)initWithUnsignedLong: (unsigned long)uLong -{ - if (uLong <= UINT_MAX) - return [self initWithUnsignedInt: (unsigned int)uLong]; - - return (id)[[OFNumber of_alloc] initWithUnsignedLong: uLong]; -} - -- (instancetype)initWithUnsignedLongLong: (unsigned long long)uLongLong -{ - if (uLongLong <= ULONG_MAX) - return [self initWithUnsignedLong: (unsigned long)uLongLong]; - - return (id)[[OFNumber of_alloc] initWithUnsignedLongLong: uLongLong]; -} - -- (instancetype)initWithInt8: (int8_t)int8 -{ - if (int8 >= 0) - return [self initWithUInt8: int8]; - - return (id)[[OFNumber of_alloc] initWithInt8: int8]; -} - -- (instancetype)initWithInt16: (int16_t)int16 -{ - if (int16 >= 0) - return [self initWithUInt16: int16]; - if (int16 >= INT8_MIN) - return [self initWithInt8: (int8_t)int16]; - - return (id)[[OFNumber of_alloc] initWithInt16: int16]; -} - -- (instancetype)initWithInt32: (int32_t)int32 -{ - if (int32 >= 0) - return [self initWithUInt32: int32]; - if (int32 >= INT16_MIN) - return [self initWithInt16: (int16_t)int32]; - - return (id)[[OFNumber of_alloc] initWithInt32: int32]; -} - -- (instancetype)initWithInt64: (int64_t)int64 -{ - if (int64 >= 0) - return [self initWithUInt64: int64]; - if (int64 >= INT32_MIN) - return [self initWithInt32: (int32_t)int64]; - - return (id)[[OFNumber of_alloc] initWithInt64: int64]; -} - -- (instancetype)initWithUInt8: (uint8_t)uInt8 -{ - return (id)[[OFNumber of_alloc] initWithUInt8: uInt8]; -} - -- (instancetype)initWithUInt16: (uint16_t)uInt16 -{ - if (uInt16 <= UINT8_MAX) - return [self initWithUInt8: (uint8_t)uInt16]; - - return (id)[[OFNumber of_alloc] initWithUInt16: uInt16]; -} - -- (instancetype)initWithUInt32: (uint32_t)uInt32 -{ - if (uInt32 <= UINT16_MAX) - return [self initWithUInt16: (uint16_t)uInt32]; - - return (id)[[OFNumber of_alloc] initWithUInt32: uInt32]; -} - -- (instancetype)initWithUInt64: (uint64_t)uInt64 -{ - if (uInt64 <= UINT32_MAX) - return [self initWithUInt32: (uint32_t)uInt64]; - - return (id)[[OFNumber of_alloc] initWithUInt64: uInt64]; -} - -- (instancetype)initWithSize: (size_t)size -{ - if (size <= ULONG_MAX) - return [self initWithUnsignedLong: (unsigned long)size]; - - return (id)[[OFNumber of_alloc] initWithSize: size]; -} - -- (instancetype)initWithSSize: (ssize_t)sSize -{ - if (sSize >= 0) - return [self initWithSize: sSize]; - if (sSize <= LONG_MIN) - return [self initWithLong: (long)sSize]; - - return (id)[[OFNumber of_alloc] initWithSSize: sSize]; -} - -- (instancetype)initWithIntMax: (intmax_t)intMax -{ - if (intMax >= 0) - return [self initWithUIntMax: intMax]; - if (intMax <= LLONG_MIN) - return [self initWithLongLong: (long long)intMax]; - - return (id)[[OFNumber of_alloc] initWithIntMax: intMax]; -} - -- (instancetype)initWithUIntMax: (uintmax_t)uIntMax -{ - if (uIntMax <= ULLONG_MAX) - return [self initWithUnsignedLongLong: - (unsigned long long)uIntMax]; - - return (id)[[OFNumber of_alloc] initWithUIntMax: uIntMax]; + return (id)[[OFNumber of_alloc] initWithUnsignedChar: value]; +} + +- (instancetype)initWithUnsignedShort: (unsigned short)value +{ + if (value <= UCHAR_MAX) + return [self initWithUnsignedChar: (unsigned char)value]; + + return (id)[[OFNumber of_alloc] initWithUnsignedShort: value]; +} + +- (instancetype)initWithUnsignedInt: (unsigned int)value +{ + if (value <= USHRT_MAX) + return [self initWithUnsignedShort: (unsigned short)value]; + + return (id)[[OFNumber of_alloc] initWithUnsignedInt: value]; +} + +- (instancetype)initWithUnsignedLong: (unsigned long)value +{ + if (value <= UINT_MAX) + return [self initWithUnsignedInt: (unsigned int)value]; + + return (id)[[OFNumber of_alloc] initWithUnsignedLong: value]; +} + +- (instancetype)initWithUnsignedLongLong: (unsigned long long)value +{ + if (value <= ULONG_MAX) + return [self initWithUnsignedLong: (unsigned long)value]; + + return (id)[[OFNumber of_alloc] initWithUnsignedLongLong: value]; +} + +- (instancetype)initWithInt8: (int8_t)value +{ + if (value >= 0) + return [self initWithUInt8: value]; + + return (id)[[OFNumber of_alloc] initWithInt8: value]; +} + +- (instancetype)initWithInt16: (int16_t)value +{ + if (value >= 0) + return [self initWithUInt16: value]; + if (value >= INT8_MIN) + return [self initWithInt8: (int8_t)value]; + + return (id)[[OFNumber of_alloc] initWithInt16: value]; +} + +- (instancetype)initWithInt32: (int32_t)value +{ + if (value >= 0) + return [self initWithUInt32: value]; + if (value >= INT16_MIN) + return [self initWithInt16: (int16_t)value]; + + return (id)[[OFNumber of_alloc] initWithInt32: value]; +} + +- (instancetype)initWithInt64: (int64_t)value +{ + if (value >= 0) + return [self initWithUInt64: value]; + if (value >= INT32_MIN) + return [self initWithInt32: (int32_t)value]; + + return (id)[[OFNumber of_alloc] initWithInt64: value]; +} + +- (instancetype)initWithUInt8: (uint8_t)value +{ + return (id)[[OFNumber of_alloc] initWithUInt8: value]; +} + +- (instancetype)initWithUInt16: (uint16_t)value +{ + if (value <= UINT8_MAX) + return [self initWithUInt8: (uint8_t)value]; + + return (id)[[OFNumber of_alloc] initWithUInt16: value]; +} + +- (instancetype)initWithUInt32: (uint32_t)value +{ + if (value <= UINT16_MAX) + return [self initWithUInt16: (uint16_t)value]; + + return (id)[[OFNumber of_alloc] initWithUInt32: value]; +} + +- (instancetype)initWithUInt64: (uint64_t)value +{ + if (value <= UINT32_MAX) + return [self initWithUInt32: (uint32_t)value]; + + return (id)[[OFNumber of_alloc] initWithUInt64: value]; +} + +- (instancetype)initWithSize: (size_t)value +{ + if (value <= ULONG_MAX) + return [self initWithUnsignedLong: (unsigned long)value]; + + return (id)[[OFNumber of_alloc] initWithSize: value]; +} + +- (instancetype)initWithSSize: (ssize_t)value +{ + if (value >= 0) + return [self initWithSize: value]; + if (value <= LONG_MIN) + return [self initWithLong: (long)value]; + + return (id)[[OFNumber of_alloc] initWithSSize: value]; } #ifdef __clang__ /* * This warning should probably not exist at all, as it prevents checking @@ -308,61 +289,63 @@ */ # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wtautological-constant-out-of-range-compare" #endif -- (instancetype)initWithPtrDiff: (ptrdiff_t)ptrDiff -{ - if (ptrDiff >= LLONG_MIN && ptrDiff <= LLONG_MAX) - return [self initWithLongLong: (long long)ptrDiff]; - - return (id)[[OFNumber of_alloc] initWithPtrDiff: ptrDiff]; -} - -- (instancetype)initWithIntPtr: (intptr_t)intPtr -{ - if (intPtr >= 0) - return [self initWithUIntPtr: intPtr]; - if (intPtr >= LLONG_MIN) - return [self initWithLongLong: (long long)intPtr]; - - return (id)[[OFNumber of_alloc] initWithIntPtr: intPtr]; -} - -- (instancetype)initWithUIntPtr: (uintptr_t)uIntPtr -{ - if (uIntPtr <= ULLONG_MAX) +- (instancetype)initWithPtrDiff: (ptrdiff_t)value +{ + if (value >= LLONG_MIN && value <= LLONG_MAX) + return [self initWithLongLong: (long long)value]; + + return (id)[[OFNumber of_alloc] initWithPtrDiff: value]; +} + +- (instancetype)initWithIntPtr: (intptr_t)value +{ + if (value >= 0) + return [self initWithUIntPtr: value]; + if (value >= LLONG_MIN) + return [self initWithLongLong: (long long)value]; + + return (id)[[OFNumber of_alloc] initWithIntPtr: value]; +} + +- (instancetype)initWithUIntPtr: (uintptr_t)value +{ + if (value <= ULLONG_MAX) return [self initWithUnsignedLongLong: - (unsigned long long)uIntPtr]; + (unsigned long long)value]; - return (id)[[OFNumber of_alloc] initWithUIntPtr: uIntPtr]; + return (id)[[OFNumber of_alloc] initWithUIntPtr: value]; } #ifdef __clang__ # pragma clang diagnostic pop #endif -- (instancetype)initWithFloat: (float)float_ -{ - if (float_ == (uintmax_t)float_) - return [self initWithUIntMax: (uintmax_t)float_]; - if (float_ == (intmax_t)float_) - return [self initWithIntMax: (intmax_t)float_]; - - return (id)[[OFNumber of_alloc] initWithFloat: float_]; -} - -- (instancetype)initWithDouble: (double)double_ -{ - if (double_ == (uintmax_t)double_) - return [self initWithUIntMax: (uintmax_t)double_]; - if (double_ == (intmax_t)double_) - return [self initWithIntMax: (intmax_t)double_]; - if (double_ == (float)double_) - return [self initWithFloat: (float)double_]; - - return (id)[[OFNumber of_alloc] initWithDouble: double_]; +- (instancetype)initWithFloat: (float)value +{ + if (value == (unsigned long long)value) + return [self initWithUnsignedLongLong: + (unsigned long long)value]; + if (value == (long long)value) + return [self initWithLongLong: (long long)value]; + + return (id)[[OFNumber of_alloc] initWithFloat: value]; +} + +- (instancetype)initWithDouble: (double)value +{ + if (value == (unsigned long long)value) + return [self initWithUnsignedLongLong: + (unsigned long long)value]; + if (value == (long long)value) + return [self initWithLongLong: (long long)value]; + if (value == (float)value) + return [self initWithFloat: (float)value]; + + return (id)[[OFNumber of_alloc] initWithDouble: value]; } - (instancetype)initWithSerialization: (OFXMLElement *)element { return (id)[[OFNumber of_alloc] initWithSerialization: element]; @@ -408,457 +391,425 @@ return (id)&placeholder; return [super alloc]; } -+ (instancetype)numberWithBool: (bool)bool_ -{ - return [[[self alloc] initWithBool: bool_] autorelease]; -} - -+ (instancetype)numberWithChar: (signed char)sChar -{ - return [[[self alloc] initWithChar: sChar] autorelease]; -} - -+ (instancetype)numberWithShort: (short)sShort -{ - return [[[self alloc] initWithShort: sShort] autorelease]; -} - -+ (instancetype)numberWithInt: (int)sInt -{ - return [[[self alloc] initWithInt: sInt] autorelease]; -} - -+ (instancetype)numberWithLong: (long)sLong -{ - return [[[self alloc] initWithLong: sLong] autorelease]; -} - -+ (instancetype)numberWithLongLong: (long long)sLongLong -{ - return [[[self alloc] initWithLongLong: sLongLong] autorelease]; -} - -+ (instancetype)numberWithUnsignedChar: (unsigned char)uChar -{ - return [[[self alloc] initWithUnsignedChar: uChar] autorelease]; -} - -+ (instancetype)numberWithUnsignedShort: (unsigned short)uShort -{ - return [[[self alloc] initWithUnsignedShort: uShort] autorelease]; -} - -+ (instancetype)numberWithUnsignedInt: (unsigned int)uInt -{ - return [[[self alloc] initWithUnsignedInt: uInt] autorelease]; -} - -+ (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]; -} - -+ (instancetype)numberWithInt16: (int16_t)int16 -{ - return [[[self alloc] initWithInt16: int16] autorelease]; -} - -+ (instancetype)numberWithInt32: (int32_t)int32 -{ - return [[[self alloc] initWithInt32: int32] autorelease]; -} - -+ (instancetype)numberWithInt64: (int64_t)int64 -{ - return [[[self alloc] initWithInt64: int64] autorelease]; -} - -+ (instancetype)numberWithUInt8: (uint8_t)uInt8 -{ - return [[[self alloc] initWithUInt8: uInt8] autorelease]; -} - -+ (instancetype)numberWithUInt16: (uint16_t)uInt16 -{ - return [[[self alloc] initWithUInt16: uInt16] autorelease]; -} - -+ (instancetype)numberWithUInt32: (uint32_t)uInt32 -{ - return [[[self alloc] initWithUInt32: uInt32] autorelease]; -} - -+ (instancetype)numberWithUInt64: (uint64_t)uInt64 -{ - return [[[self alloc] initWithUInt64: uInt64] autorelease]; -} - -+ (instancetype)numberWithSize: (size_t)size -{ - return [[[self alloc] initWithSize: size] autorelease]; -} - -+ (instancetype)numberWithSSize: (ssize_t)sSize -{ - return [[[self alloc] initWithSSize: sSize] autorelease]; -} - -+ (instancetype)numberWithIntMax: (intmax_t)intMax -{ - return [[[self alloc] initWithIntMax: intMax] autorelease]; -} - -+ (instancetype)numberWithUIntMax: (uintmax_t)uIntMax -{ - return [[[self alloc] initWithUIntMax: uIntMax] autorelease]; -} - -+ (instancetype)numberWithPtrDiff: (ptrdiff_t)ptrDiff -{ - return [[[self alloc] initWithPtrDiff: ptrDiff] autorelease]; -} - -+ (instancetype)numberWithIntPtr: (intptr_t)intPtr -{ - return [[[self alloc] initWithIntPtr: intPtr] autorelease]; -} - -+ (instancetype)numberWithUIntPtr: (uintptr_t)uIntPtr -{ - return [[[self alloc] initWithUIntPtr: uIntPtr] autorelease]; -} - -+ (instancetype)numberWithFloat: (float)float_ -{ - return [[[self alloc] initWithFloat: float_] autorelease]; -} - -+ (instancetype)numberWithDouble: (double)double_ -{ - return [[[self alloc] initWithDouble: double_] autorelease]; ++ (instancetype)numberWithBool: (bool)value +{ + return [[[self alloc] initWithBool: value] autorelease]; +} + ++ (instancetype)numberWithChar: (signed char)value +{ + return [[[self alloc] initWithChar: value] autorelease]; +} + ++ (instancetype)numberWithShort: (short)value +{ + return [[[self alloc] initWithShort: value] autorelease]; +} + ++ (instancetype)numberWithInt: (int)value +{ + return [[[self alloc] initWithInt: value] autorelease]; +} + ++ (instancetype)numberWithLong: (long)value +{ + return [[[self alloc] initWithLong: value] autorelease]; +} + ++ (instancetype)numberWithLongLong: (long long)value +{ + return [[[self alloc] initWithLongLong: value] autorelease]; +} + ++ (instancetype)numberWithUnsignedChar: (unsigned char)value +{ + return [[[self alloc] initWithUnsignedChar: value] autorelease]; +} + ++ (instancetype)numberWithUnsignedShort: (unsigned short)value +{ + return [[[self alloc] initWithUnsignedShort: value] autorelease]; +} + ++ (instancetype)numberWithUnsignedInt: (unsigned int)value +{ + return [[[self alloc] initWithUnsignedInt: value] autorelease]; +} + ++ (instancetype)numberWithUnsignedLong: (unsigned long)value +{ + return [[[self alloc] initWithUnsignedLong: value] autorelease]; +} + ++ (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)numberWithSSize: (ssize_t)value +{ + return [[[self alloc] initWithSSize: 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]; +} + ++ (instancetype)numberWithDouble: (double)value +{ + return [[[self alloc] initWithDouble: value] autorelease]; } - (instancetype)init { OF_INVALID_INIT_METHOD } -- (instancetype)initWithBool: (bool)bool_ +- (instancetype)initWithBool: (bool)value { self = [super init]; - _value.unsigned_ = bool_; + _value.unsigned_ = value; _type = OF_NUMBER_TYPE_UNSIGNED; _typeEncoding = @encode(bool); return self; } -- (instancetype)initWithChar: (signed char)sChar +- (instancetype)initWithChar: (signed char)value { self = [super init]; - _value.signed_ = sChar; + _value.signed_ = value; _type = OF_NUMBER_TYPE_SIGNED; _typeEncoding = @encode(signed char); return self; } -- (instancetype)initWithShort: (short)sShort +- (instancetype)initWithShort: (short)value { self = [super init]; - _value.signed_ = sShort; + _value.signed_ = value; _type = OF_NUMBER_TYPE_SIGNED; _typeEncoding = @encode(short); return self; } -- (instancetype)initWithInt: (int)sInt +- (instancetype)initWithInt: (int)value { self = [super init]; - _value.signed_ = sInt; + _value.signed_ = value; _type = OF_NUMBER_TYPE_SIGNED; _typeEncoding = @encode(int); return self; } -- (instancetype)initWithLong: (long)sLong +- (instancetype)initWithLong: (long)value { self = [super init]; - _value.signed_ = sLong; + _value.signed_ = value; _type = OF_NUMBER_TYPE_SIGNED; _typeEncoding = @encode(long); return self; } -- (instancetype)initWithLongLong: (long long)sLongLong +- (instancetype)initWithLongLong: (long long)value { self = [super init]; - _value.signed_ = sLongLong; + _value.signed_ = value; _type = OF_NUMBER_TYPE_SIGNED; _typeEncoding = @encode(long long); return self; } -- (instancetype)initWithUnsignedChar: (unsigned char)uChar +- (instancetype)initWithUnsignedChar: (unsigned char)value { self = [super init]; - _value.unsigned_ = uChar; + _value.unsigned_ = value; _type = OF_NUMBER_TYPE_UNSIGNED; _typeEncoding = @encode(unsigned long); return self; } -- (instancetype)initWithUnsignedShort: (unsigned short)uShort +- (instancetype)initWithUnsignedShort: (unsigned short)value { self = [super init]; - _value.unsigned_ = uShort; + _value.unsigned_ = value; _type = OF_NUMBER_TYPE_UNSIGNED; _typeEncoding = @encode(unsigned short); return self; } -- (instancetype)initWithUnsignedInt: (unsigned int)uInt +- (instancetype)initWithUnsignedInt: (unsigned int)value { self = [super init]; - _value.unsigned_ = uInt; + _value.unsigned_ = value; _type = OF_NUMBER_TYPE_UNSIGNED; _typeEncoding = @encode(unsigned int); return self; } -- (instancetype)initWithUnsignedLong: (unsigned long)uLong +- (instancetype)initWithUnsignedLong: (unsigned long)value { self = [super init]; - _value.unsigned_ = uLong; + _value.unsigned_ = value; _type = OF_NUMBER_TYPE_UNSIGNED; _typeEncoding = @encode(unsigned long); return self; } -- (instancetype)initWithUnsignedLongLong: (unsigned long long)uLongLong +- (instancetype)initWithUnsignedLongLong: (unsigned long long)value { self = [super init]; - _value.unsigned_ = uLongLong; + _value.unsigned_ = value; _type = OF_NUMBER_TYPE_UNSIGNED; _typeEncoding = @encode(unsigned long long); return self; } -- (instancetype)initWithInt8: (int8_t)int8 +- (instancetype)initWithInt8: (int8_t)value { self = [super init]; - _value.signed_ = int8; + _value.signed_ = value; _type = OF_NUMBER_TYPE_SIGNED; _typeEncoding = @encode(int8_t); return self; } -- (instancetype)initWithInt16: (int16_t)int16 +- (instancetype)initWithInt16: (int16_t)value { self = [super init]; - _value.signed_ = int16; + _value.signed_ = value; _type = OF_NUMBER_TYPE_SIGNED; _typeEncoding = @encode(int16_t); return self; } -- (instancetype)initWithInt32: (int32_t)int32 +- (instancetype)initWithInt32: (int32_t)value { self = [super init]; - _value.signed_ = int32; + _value.signed_ = value; _type = OF_NUMBER_TYPE_SIGNED; _typeEncoding = @encode(int32_t); return self; } -- (instancetype)initWithInt64: (int64_t)int64 +- (instancetype)initWithInt64: (int64_t)value { self = [super init]; - _value.signed_ = int64; + _value.signed_ = value; _type = OF_NUMBER_TYPE_SIGNED; _typeEncoding = @encode(int64_t); return self; } -- (instancetype)initWithUInt8: (uint8_t)uInt8 +- (instancetype)initWithUInt8: (uint8_t)value { self = [super init]; - _value.unsigned_ = uInt8; + _value.unsigned_ = value; _type = OF_NUMBER_TYPE_UNSIGNED; _typeEncoding = @encode(uint8_t); return self; } -- (instancetype)initWithUInt16: (uint16_t)uInt16 +- (instancetype)initWithUInt16: (uint16_t)value { self = [super init]; - _value.unsigned_ = uInt16; + _value.unsigned_ = value; _type = OF_NUMBER_TYPE_UNSIGNED; _typeEncoding = @encode(uint16_t); return self; } -- (instancetype)initWithUInt32: (uint32_t)uInt32 +- (instancetype)initWithUInt32: (uint32_t)value { self = [super init]; - _value.unsigned_ = uInt32; + _value.unsigned_ = value; _type = OF_NUMBER_TYPE_UNSIGNED; _typeEncoding = @encode(uint32_t); return self; } -- (instancetype)initWithUInt64: (uint64_t)uInt64 +- (instancetype)initWithUInt64: (uint64_t)value { self = [super init]; - _value.unsigned_ = uInt64; + _value.unsigned_ = value; _type = OF_NUMBER_TYPE_UNSIGNED; _typeEncoding = @encode(uint64_t); return self; } -- (instancetype)initWithSize: (size_t)size +- (instancetype)initWithSize: (size_t)value { self = [super init]; - _value.unsigned_ = size; + _value.unsigned_ = value; _type = OF_NUMBER_TYPE_UNSIGNED; _typeEncoding = @encode(size_t); return self; } -- (instancetype)initWithSSize: (ssize_t)sSize +- (instancetype)initWithSSize: (ssize_t)value { self = [super init]; - _value.signed_ = sSize; + _value.signed_ = value; _type = OF_NUMBER_TYPE_SIGNED; _typeEncoding = @encode(ssize_t); return self; } -- (instancetype)initWithIntMax: (intmax_t)intMax -{ - self = [super init]; - - _value.signed_ = intMax; - _type = OF_NUMBER_TYPE_SIGNED; - _typeEncoding = @encode(intmax_t); - - return self; -} - -- (instancetype)initWithUIntMax: (uintmax_t)uIntMax -{ - self = [super init]; - - _value.unsigned_ = uIntMax; - _type = OF_NUMBER_TYPE_UNSIGNED; - _typeEncoding = @encode(uintmax_t); - - return self; -} - -- (instancetype)initWithPtrDiff: (ptrdiff_t)ptrDiff -{ - self = [super init]; - - _value.signed_ = ptrDiff; +- (instancetype)initWithPtrDiff: (ptrdiff_t)value +{ + self = [super init]; + + _value.signed_ = value; _type = OF_NUMBER_TYPE_SIGNED; _typeEncoding = @encode(ptrdiff_t); return self; } -- (instancetype)initWithIntPtr: (intptr_t)intPtr +- (instancetype)initWithIntPtr: (intptr_t)value { self = [super init]; - _value.signed_ = intPtr; + _value.signed_ = value; _type = OF_NUMBER_TYPE_SIGNED; _typeEncoding = @encode(intptr_t); return self; } -- (instancetype)initWithUIntPtr: (uintptr_t)uIntPtr +- (instancetype)initWithUIntPtr: (uintptr_t)value { self = [super init]; - _value.unsigned_ = uIntPtr; + _value.unsigned_ = value; _type = OF_NUMBER_TYPE_UNSIGNED; _typeEncoding = @encode(uintptr_t); return self; } -- (instancetype)initWithFloat: (float)float_ +- (instancetype)initWithFloat: (float)value { self = [super init]; - _value.float_ = float_; + _value.float_ = value; _type = OF_NUMBER_TYPE_FLOAT; _typeEncoding = @encode(float); return self; } -- (instancetype)initWithDouble: (double)double_ +- (instancetype)initWithDouble: (double)value { self = [super init]; - _value.float_ = double_; + _value.float_ = value; _type = OF_NUMBER_TYPE_FLOAT; _typeEncoding = @encode(double); return self; } @@ -1063,20 +1014,10 @@ - (ssize_t)sSizeValue { RETURN_AS(ssize_t) } -- (intmax_t)intMaxValue -{ - RETURN_AS(intmax_t) -} - -- (uintmax_t)uIntMaxValue -{ - RETURN_AS(uintmax_t) -} - - (ptrdiff_t)ptrDiffValue { RETURN_AS(ptrdiff_t) } @@ -1126,13 +1067,13 @@ return (value1 == value2); } if (_type == OF_NUMBER_TYPE_SIGNED || number->_type == OF_NUMBER_TYPE_SIGNED) - return (number.intMaxValue == self.intMaxValue); + return (number.longLongValue == self.longLongValue); - return (number.uIntMaxValue == self.uIntMaxValue); + return (number.unsignedLongLongValue == self.unsignedLongLongValue); } - (of_comparison_result_t)compare: (id )object { OFNumber *number; @@ -1153,22 +1094,22 @@ return OF_ORDERED_ASCENDING; return OF_ORDERED_SAME; } else if (_type == OF_NUMBER_TYPE_SIGNED || number->_type == OF_NUMBER_TYPE_SIGNED) { - intmax_t int1 = self.intMaxValue; - intmax_t int2 = number.intMaxValue; + long long int1 = self.longLongValue; + long long int2 = number.longLongValue; if (int1 > int2) return OF_ORDERED_DESCENDING; if (int1 < int2) return OF_ORDERED_ASCENDING; return OF_ORDERED_SAME; } else { - uintmax_t uint1 = self.uIntMaxValue; - uintmax_t uint2 = number.uIntMaxValue; + unsigned long long uint1 = self.unsignedLongLongValue; + unsigned long long uint2 = number.unsignedLongLongValue; if (uint1 > uint2) return OF_ORDERED_DESCENDING; if (uint1 < uint2) return OF_ORDERED_ASCENDING; @@ -1193,24 +1134,24 @@ d = OF_BSWAP_DOUBLE_IF_BE(self.doubleValue); for (uint_fast8_t i = 0; i < sizeof(double); i++) OF_HASH_ADD(hash, ((char *)&d)[i]); } else if (type == OF_NUMBER_TYPE_SIGNED) { - intmax_t v = self.intMaxValue * -1; + long long value = self.longLongValue * -1; - while (v != 0) { - OF_HASH_ADD(hash, v & 0xFF); - v >>= 8; + while (value != 0) { + OF_HASH_ADD(hash, value & 0xFF); + value >>= 8; } OF_HASH_ADD(hash, 1); } else if (type == OF_NUMBER_TYPE_UNSIGNED) { - uintmax_t v = self.uIntMaxValue; + unsigned long long value = self.unsignedLongLongValue; - while (v != 0) { - OF_HASH_ADD(hash, v & 0xFF); - v >>= 8; + while (value != 0) { + OF_HASH_ADD(hash, value & 0xFF); + value >>= 8; } } else @throw [OFInvalidFormatException exception]; OF_HASH_FINALIZE(hash); @@ -1233,13 +1174,13 @@ if (*_typeEncoding == 'B') return (_value.unsigned_ ? @"true" : @"false"); if (_type == OF_NUMBER_TYPE_FLOAT) return [OFString stringWithFormat: @"%g", _value.float_]; if (_type == OF_NUMBER_TYPE_SIGNED) - return [OFString stringWithFormat: @"%jd", _value.signed_]; + return [OFString stringWithFormat: @"%lld", _value.signed_]; if (_type == OF_NUMBER_TYPE_UNSIGNED) - return [OFString stringWithFormat: @"%ju", _value.unsigned_]; + return [OFString stringWithFormat: @"%llu", _value.unsigned_]; @throw [OFInvalidFormatException exception]; } - (OFXMLElement *)XMLElementBySerializing @@ -1339,11 +1280,11 @@ [data addItem: &type]; [data addItems: &tmp count: sizeof(tmp)]; } else if (_type == OF_NUMBER_TYPE_SIGNED) { - intmax_t value = self.intMaxValue; + long long value = self.longLongValue; if (value >= -32 && value < 0) { uint8_t tmp = 0xE0 | ((uint8_t)(value - 32) & 0x1F); data = [OFMutableData dataWithItems: &tmp @@ -1388,11 +1329,11 @@ [data addItems: &tmp count: sizeof(tmp)]; } else @throw [OFOutOfRangeException exception]; } else if (_type == OF_NUMBER_TYPE_UNSIGNED) { - uintmax_t value = self.uIntMaxValue; + unsigned long long value = self.unsignedLongLongValue; if (value <= 127) { uint8_t tmp = ((uint8_t)value & 0x7F); data = [OFMutableData dataWithItems: &tmp Index: src/OFString.h ================================================================== --- src/OFString.h +++ src/OFString.h @@ -176,11 +176,11 @@ * Leading and trailing whitespaces are ignored. * * If the string contains any non-number characters, an * @ref OFInvalidFormatException is thrown. * - * If the number is too big to fit into an `long long`, an + * If the number is too big to fit into a `long long`, an * @ref OFOutOfRangeException is thrown. */ @property (readonly, nonatomic) long long longLongValue; /*! @@ -1018,11 +1018,11 @@ * Leading and trailing whitespaces are ignored. * * If the string contains any non-number characters, an * @ref OFInvalidFormatException is thrown. * - * If the number is too big to fit into an `long long`, an + * If the number is too big to fit into a `long long`, an * @ref OFOutOfRangeException is thrown. * * @param base The base to use. If the base is 0, base 16 is assumed if the * string starts with 0x (after stripping white spaces). If the * string starts with 0, base 8 is assumed. Otherwise, base 10 is Index: src/OFString.m ================================================================== --- src/OFString.m +++ src/OFString.m @@ -989,11 +989,11 @@ - (instancetype)initWithContentsOfFile: (OFString *)path encoding: (of_string_encoding_t)encoding { char *tmp; - uintmax_t fileSize; + unsigned long long fileSize; @try { void *pool = objc_autoreleasePoolPush(); OFFile *file = nil; @@ -1007,11 +1007,11 @@ errNo: e.errNo]; } objc_autoreleasePoolPop(pool); -# if UINTMAX_MAX > SIZE_MAX +# if ULLONG_MAX > SIZE_MAX if (fileSize > SIZE_MAX) @throw [OFOutOfRangeException exception]; #endif /* Index: src/OFTarArchiveEntry.m ================================================================== --- src/OFTarArchiveEntry.m +++ src/OFTarArchiveEntry.m @@ -105,11 +105,11 @@ _size = (uint64_t)octalValueFromBuffer( header + 124, 12, UINT64_MAX); _modificationDate = [[OFDate alloc] initWithTimeIntervalSince1970: (of_time_interval_t)octalValueFromBuffer( - header + 136, 12, UINTMAX_MAX)]; + header + 136, 12, ULLONG_MAX)]; _type = header[156]; targetFileName = stringFromBuffer(header + 157, 100, encoding); if (targetFileName.length > 0) _targetFileName = [targetFileName copy]; Index: tests/OFASN1DERValueTests.m ================================================================== --- tests/OFASN1DERValueTests.m +++ tests/OFASN1DERValueTests.m @@ -54,23 +54,25 @@ count: 2] ASN1DERValue]) /* Integer */ TEST(@"Parsing of integer", [[[OFData dataWithItems: "\x02\x00" - count: 2] ASN1DERValue] integerValue] == 0 && + count: 2] ASN1DERValue] longLongValue] == 0 && [[[OFData dataWithItems: "\x02\x01\x01" - count: 3] ASN1DERValue] integerValue] == 1 && + count: 3] ASN1DERValue] longLongValue] == 1 && [[[OFData dataWithItems: "\x02\x02\x01\x04" - count: 4] ASN1DERValue] integerValue] == 260 && + count: 4] ASN1DERValue] longLongValue] == 260 && [[[OFData dataWithItems: "\x02\x01\xFF" - count: 3] ASN1DERValue] integerValue] == -1 && + count: 3] ASN1DERValue] longLongValue] == -1 && [[[OFData dataWithItems: "\x02\x03\xFF\x00\x00" - count: 5] ASN1DERValue] integerValue] == -65536 && - (uintmax_t)[[[OFData dataWithItems: "\x02\x09\x00\xFF\xFF\xFF\xFF" - "\xFF\xFF\xFF\xFF" - count: 11] ASN1DERValue] - integerValue] == UINTMAX_MAX) + count: 5] ASN1DERValue] longLongValue] == + -65536 && + (unsigned long long)[[[OFData dataWithItems: "\x02\x09\x00\xFF\xFF" + "\xFF\xFF\xFF\xFF\xFF" + "\xFF" + count: 11] ASN1DERValue] + longLongValue] == ULLONG_MAX) EXPECT_EXCEPTION(@"Detection of invalid integer #1", OFInvalidFormatException, [[OFData dataWithItems: "\x02\x02\x00\x00" count: 4] ASN1DERValue]) @@ -176,33 +178,33 @@ /* Object Identifier */ TEST(@"Parsing of Object Identifier", (array = [[[OFData dataWithItems: "\x06\x01\x27" count: 3] ASN1DERValue] subidentifiers]) && array.count == 2 && - [[array objectAtIndex: 0] uIntMaxValue] == 0 && - [[array objectAtIndex: 1] uIntMaxValue] == 39 && + [[array objectAtIndex: 0] unsignedLongLongValue] == 0 && + [[array objectAtIndex: 1] unsignedLongLongValue] == 39 && (array = [[[OFData dataWithItems: "\x06\x01\x4F" count: 3] ASN1DERValue] subidentifiers]) && array.count == 2 && - [[array objectAtIndex: 0] uIntMaxValue] == 1 && - [[array objectAtIndex: 1] uIntMaxValue] == 39 && + [[array objectAtIndex: 0] unsignedLongLongValue] == 1 && + [[array objectAtIndex: 1] unsignedLongLongValue] == 39 && (array = [[[OFData dataWithItems: "\x06\x02\x88\x37" count: 4] ASN1DERValue] subidentifiers]) && array.count == 2 && - [[array objectAtIndex: 0] uIntMaxValue] == 2 && - [[array objectAtIndex: 1] uIntMaxValue] == 999 && + [[array objectAtIndex: 0] unsignedLongLongValue] == 2 && + [[array objectAtIndex: 1] unsignedLongLongValue] == 999 && (array = [[[OFData dataWithItems: "\x06\x09\x2A\x86\x48\x86\xF7\x0D" "\x01\x01\x0B" count: 11] ASN1DERValue] subidentifiers]) && array.count == 7 && - [[array objectAtIndex: 0] uIntMaxValue] == 1 && - [[array objectAtIndex: 1] uIntMaxValue] == 2 && - [[array objectAtIndex: 2] uIntMaxValue] == 840 && - [[array objectAtIndex: 3] uIntMaxValue] == 113549 && - [[array objectAtIndex: 4] uIntMaxValue] == 1 && - [[array objectAtIndex: 5] uIntMaxValue] == 1 && - [[array objectAtIndex: 6] uIntMaxValue] == 11) + [[array objectAtIndex: 0] unsignedLongLongValue] == 1 && + [[array objectAtIndex: 1] unsignedLongLongValue] == 2 && + [[array objectAtIndex: 2] unsignedLongLongValue] == 840 && + [[array objectAtIndex: 3] unsignedLongLongValue] == 113549 && + [[array objectAtIndex: 4] unsignedLongLongValue] == 1 && + [[array objectAtIndex: 5] unsignedLongLongValue] == 1 && + [[array objectAtIndex: 6] unsignedLongLongValue] == 11) EXPECT_EXCEPTION(@"Detection of invalid Object Identifier #1", OFInvalidFormatException, [[OFData dataWithItems: "\x06\x01\x81" count: 3] ASN1DERValue]) @@ -221,23 +223,25 @@ count: 3] ASN1DERValue]) /* Enumerated */ TEST(@"Parsing of enumerated", [[[OFData dataWithItems: "\x0A\x00" - count: 2] ASN1DERValue] integerValue] == 0 && + count: 2] ASN1DERValue] longLongValue] == 0 && [[[OFData dataWithItems: "\x0A\x01\x01" - count: 3] ASN1DERValue] integerValue] == 1 && + count: 3] ASN1DERValue] longLongValue] == 1 && [[[OFData dataWithItems: "\x0A\x02\x01\x04" - count: 4] ASN1DERValue] integerValue] == 260 && + count: 4] ASN1DERValue] longLongValue] == 260 && [[[OFData dataWithItems: "\x0A\x01\xFF" - count: 3] ASN1DERValue] integerValue] == -1 && + count: 3] ASN1DERValue] longLongValue] == -1 && [[[OFData dataWithItems: "\x0A\x03\xFF\x00\x00" - count: 5] ASN1DERValue] integerValue] == -65536 && - (uintmax_t)[[[OFData dataWithItems: "\x0A\x09\x00\xFF\xFF\xFF\xFF" - "\xFF\xFF\xFF\xFF" - count: 11] ASN1DERValue] - integerValue] == UINTMAX_MAX) + count: 5] ASN1DERValue] longLongValue] == + -65536 && + (unsigned long long)[[[OFData dataWithItems: "\x0A\x09\x00\xFF\xFF" + "\xFF\xFF\xFF\xFF\xFF" + "\xFF" + count: 11] ASN1DERValue] + longLongValue] == ULLONG_MAX) EXPECT_EXCEPTION(@"Detection of invalid enumerated #1", OFInvalidFormatException, [[OFData dataWithItems: "\x0A\x02\x00\x00" count: 4] ASN1DERValue]) @@ -305,11 +309,11 @@ count: 2] ASN1DERValue]) && [array isKindOfClass: [OFArray class]] && array.count == 0 && (array = [[OFData dataWithItems: "\x30\x09\x02\x01\x7B\x0C\x04Test" count: 11] ASN1DERValue]) && [array isKindOfClass: [OFArray class]] && array.count == 2 && - [[array objectAtIndex: 0] integerValue] == 123 && + [[array objectAtIndex: 0] longLongValue] == 123 && [[[array objectAtIndex: 1] stringValue] isEqual: @"Test"]) EXPECT_EXCEPTION(@"Detection of truncated sequence #1", OFTruncatedDataException, [[OFData dataWithItems: "\x30\x01" count: 2] ASN1DERValue]) @@ -326,11 +330,11 @@ [set isKindOfClass: [OFSet class]] && set.count == 0 && (set = [[OFData dataWithItems: "\x31\x09\x02\x01\x7B\x0C\x04Test" count: 11] ASN1DERValue]) && [set isKindOfClass: [OFSet class]] && set.count == 2 && (enumerator = [set objectEnumerator]) && - [[enumerator nextObject] integerValue] == 123 && + [[enumerator nextObject] longLongValue] == 123 && [[[enumerator nextObject] stringValue] isEqual: @"Test"]) EXPECT_EXCEPTION(@"Detection of invalid set", OFInvalidFormatException, [[OFData dataWithItems: "\x31\x06\x02\x01\x02\x02\x01\x01" Index: tests/OFNumberTests.m ================================================================== --- tests/OFNumberTests.m +++ tests/OFNumberTests.m @@ -25,12 +25,12 @@ - (void)numberTests { void *pool = objc_autoreleasePoolPush(); OFNumber *num; - TEST(@"+[numberWithIntMax:]", - (num = [OFNumber numberWithIntMax: 123456789])) + TEST(@"+[numberWithLongLong:]", + (num = [OFNumber numberWithLongLong: 123456789])) TEST(@"-[isEqual:]", [num isEqual: [OFNumber numberWithUInt32: 123456789]]) TEST(@"-[hash]", num.hash == 0x82D8BC42) Index: utils/ofarc/LHAArchive.m ================================================================== --- utils/ofarc/LHAArchive.m +++ utils/ofarc/LHAArchive.m @@ -487,11 +487,12 @@ entry.compressionMethod = @"-lhd-"; output = [_archive streamForWritingEntry: entry]; if ([type isEqual: of_file_type_regular]) { - uintmax_t written = 0, size = attributes.fileSize; + unsigned long long written = 0; + unsigned long long size = attributes.fileSize; int8_t percent = -1, newPercent; OFFile *input = [OFFile fileWithPath: fileName mode: @"r"]; Index: utils/ofarc/ZIPArchive.m ================================================================== --- utils/ofarc/ZIPArchive.m +++ utils/ofarc/ZIPArchive.m @@ -419,11 +419,11 @@ OFArray OF_GENERIC (OFString *) *components; OFString *fileName; of_file_attributes_t attributes; bool isDirectory = false; OFMutableZIPArchiveEntry *entry; - uintmax_t size; + unsigned long long size; OFStream *output; components = localFileName.pathComponents; fileName = [components componentsJoinedByString: @"/"]; @@ -456,11 +456,11 @@ [entry makeImmutable]; output = [_archive streamForWritingEntry: entry]; if (!isDirectory) { - uintmax_t written = 0; + unsigned long long written = 0; int8_t percent = -1, newPercent; OFFile *input = [OFFile fileWithPath: fileName mode: @"r"]; Index: utils/ofhttp/OFHTTP.m ================================================================== --- utils/ofhttp/OFHTTP.m +++ utils/ofhttp/OFHTTP.m @@ -332,11 +332,12 @@ else { _body = [[OFFile alloc] initWithPath: path mode: @"r"]; @try { - uintmax_t fileSize = [[OFFileManager defaultManager] + unsigned long long fileSize = + [[OFFileManager defaultManager] attributesOfItemAtPath: path].fileSize; contentLength = [OFString stringWithFormat: @"%ju", fileSize]; [_clientHeaders setObject: contentLength @@ -1008,11 +1009,12 @@ if (_currentFileName == nil) _currentFileName = [URL.path.lastPathComponent copy]; if (_continue) { @try { - uintmax_t size = [[OFFileManager defaultManager] + unsigned long long size = + [[OFFileManager defaultManager] attributesOfItemAtPath: _currentFileName].fileSize; OFString *range; if (size > ULLONG_MAX) @throw [OFOutOfRangeException exception]; Index: utils/ofhttp/ProgressBar.h ================================================================== --- utils/ofhttp/ProgressBar.h +++ utils/ofhttp/ProgressBar.h @@ -22,22 +22,22 @@ #define BPS_WINDOW_SIZE 10 @interface ProgressBar: OFObject { - intmax_t _received, _lastReceived, _length, _resumedFrom; + unsigned long long _received, _lastReceived, _length, _resumedFrom; OFDate *_startDate, *_lastReceivedDate; OFTimer *_drawTimer, *_BPSTimer; bool _stopped; float _BPS; double _ETA; float _BPSWindow[BPS_WINDOW_SIZE]; size_t _BPSWindowIndex, _BPSWindowLength; } -- (instancetype)initWithLength: (intmax_t)length - resumedFrom: (intmax_t)resumedFrom; -- (void)setReceived: (intmax_t)received; +- (instancetype)initWithLength: (unsigned long long)length + resumedFrom: (unsigned long long)resumedFrom; +- (void)setReceived: (unsigned long long)received; - (void)draw; - (void)calculateBPSAndETA; - (void)stop; @end Index: utils/ofhttp/ProgressBar.m ================================================================== --- utils/ofhttp/ProgressBar.m +++ utils/ofhttp/ProgressBar.m @@ -31,12 +31,12 @@ #define KIBIBYTE (1024) #define UPDATE_INTERVAL 0.1 @implementation ProgressBar -- (instancetype)initWithLength: (intmax_t)length - resumedFrom: (intmax_t)resumedFrom +- (instancetype)initWithLength: (unsigned long long)length + resumedFrom: (unsigned long long)resumedFrom { self = [super init]; @try { void *pool = objc_autoreleasePoolPush(); @@ -76,11 +76,11 @@ [_BPSTimer release]; [super dealloc]; } -- (void)setReceived: (intmax_t)received +- (void)setReceived: (unsigned long long)received { _received = received; } - (void)_drawProgress