Index: src/OFNumber.m ================================================================== --- src/OFNumber.m +++ src/OFNumber.m @@ -12,10 +12,11 @@ #include "config.h" #include #import "OFNumber.h" +#import "OFString.h" #import "OFExceptions.h" #import "macros.h" #define RETURN_AS(t) \ switch (type) { \ @@ -400,11 +401,11 @@ return [[[self alloc] initWithIntMax: intmax] autorelease]; } + numberWithUIntMax: (uintmax_t)uintmax { - return [[[self alloc] initWithIntMax: uintmax] autorelease]; + return [[[self alloc] initWithUIntMax: uintmax] autorelease]; } + numberWithPtrDiff: (ptrdiff_t)ptrdiff { return [[[self alloc] initWithPtrDiff: ptrdiff] autorelease]; @@ -955,10 +956,12 @@ } - (OFNumber*)remainderOfDivisionWithNumber: (OFNumber*)num { switch (type) { + case OF_NUMBER_BOOL: + return [OFNumber numberWithBool: value.bool_ % [num boolValue]]; case OF_NUMBER_CHAR: return [OFNumber numberWithChar: value.char_ % [num charValue]]; case OF_NUMBER_SHORT: return [OFNumber numberWithShort: value.short_ % [num shortValue]]; @@ -1037,6 +1040,45 @@ - copy { return [self retain]; } + +- (OFString*)description +{ + switch (type) { + case OF_NUMBER_BOOL: + return (value.bool_ ? @"YES" : @"NO"); + case OF_NUMBER_UCHAR: + case OF_NUMBER_USHORT: + case OF_NUMBER_UINT: + case OF_NUMBER_ULONG: + case OF_NUMBER_UINT8: + case OF_NUMBER_UINT16: + case OF_NUMBER_UINT32: + case OF_NUMBER_UINT64: + case OF_NUMBER_SIZE: + case OF_NUMBER_UINTMAX: + case OF_NUMBER_UINTPTR: + 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_INT8: + case OF_NUMBER_INT16: + case OF_NUMBER_INT32: + case OF_NUMBER_INT64: + case OF_NUMBER_SSIZE: + case OF_NUMBER_INTMAX: + case OF_NUMBER_PTRDIFF: + case OF_NUMBER_INTPTR: + return [OFString stringWithFormat: @"%jd", [self intMaxValue]]; + case OF_NUMBER_FLOAT: + return [OFString stringWithFormat: @"%f", [self floatValue]]; + case OF_NUMBER_DOUBLE: + return [OFString stringWithFormat: @"%lf", [self doubleValue]]; + default: + @throw [OFInvalidFormatException newWithClass: isa]; + } +} @end Index: src/OFString.m ================================================================== --- src/OFString.m +++ src/OFString.m @@ -35,10 +35,19 @@ #import "asprintf.h" #import "unicode.h" extern const uint16_t of_iso_8859_15[256]; extern const uint16_t of_windows_1252[256]; + +/* References for static linking */ +void _references_to_categories_of_OFString() +{ + _OFString_Hashing_reference = 1; + _OFString_URLEncoding_reference = 1; + _OFString_XMLEscaping_reference = 1; + _OFString_XMLUnescaping_reference = 1; +}; static inline int memcasecmp(const char *s1, const char *s2, size_t len) { size_t i; @@ -51,19 +60,10 @@ } return OF_ORDERED_SAME; } -/* References for static linking */ -void _references_to_categories_of_OFString() -{ - _OFString_Hashing_reference = 1; - _OFString_URLEncoding_reference = 1; - _OFString_XMLEscaping_reference = 1; - _OFString_XMLUnescaping_reference = 1; -}; - int of_string_check_utf8(const char *str, size_t len) { size_t i; int utf8 = 0;