@@ -90,12 +90,11 @@ case OF_NUMBER_FLOAT: \ return (t)_value.float_; \ case OF_NUMBER_DOUBLE: \ return (t)_value.double_; \ default: \ - @throw [OFInvalidFormatException \ - exceptionWithClass: [self class]]; \ + @throw [OFInvalidFormatException exception]; \ } #define CALCULATE(o, n) \ switch (_type) { \ case OF_NUMBER_BOOL: \ return [OFNumber numberWithBool: \ @@ -180,12 +179,11 @@ _value.float_ o [n floatValue]]; \ case OF_NUMBER_DOUBLE: \ return [OFNumber numberWithDouble: \ _value.double_ o [n doubleValue]]; \ default: \ - @throw [OFInvalidFormatException \ - exceptionWithClass: [self class]]; \ + @throw [OFInvalidFormatException exception]; \ } #define CALCULATE2(o, n) \ switch (_type) { \ case OF_NUMBER_BOOL: \ return [OFNumber numberWithBool: \ @@ -265,16 +263,13 @@ case OF_NUMBER_UINTPTR: \ return [OFNumber numberWithUIntPtr: \ _value.uintptr o [n uIntPtrValue]]; \ case OF_NUMBER_FLOAT: \ case OF_NUMBER_DOUBLE: \ - @throw [OFInvalidArgumentException \ - exceptionWithClass: [self class] \ - selector: _cmd]; \ + @throw [OFInvalidArgumentException exception]; \ default: \ - @throw [OFInvalidFormatException \ - exceptionWithClass: [self class]]; \ + @throw [OFInvalidFormatException exception]; \ } #define CALCULATE3(o) \ switch (_type) { \ case OF_NUMBER_BOOL: \ return [OFNumber numberWithBool: _value.bool_ o]; \ @@ -336,12 +331,11 @@ case OF_NUMBER_FLOAT: \ return [OFNumber numberWithFloat: _value.float_ o]; \ case OF_NUMBER_DOUBLE: \ return [OFNumber numberWithDouble: _value.double_ o]; \ default: \ - @throw [OFInvalidFormatException \ - exceptionWithClass: [self class]]; \ + @throw [OFInvalidFormatException exception]; \ } @implementation OFNumber + (instancetype)numberWithBool: (bool)bool_ { @@ -783,13 +777,11 @@ void *pool = objc_autoreleasePoolPush(); OFString *typeString; if (![[element name] isEqual: [self className]] || ![[element namespace] isEqual: OF_SERIALIZATION_NS]) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; typeString = [[element attributeForName: @"type"] stringValue]; if ([typeString isEqual: @"boolean"]) { _type = OF_NUMBER_BOOL; @@ -797,13 +789,11 @@ if ([[element stringValue] isEqual: @"true"]) _value.bool_ = true; else if ([[element stringValue] isEqual: @"false"]) _value.bool_ = false; else - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; } else if ([typeString isEqual: @"unsigned"]) { /* * FIXME: This will fail if the value is bigger than * INTMAX_MAX! */ @@ -831,13 +821,11 @@ d.u = (uint64_t)[element hexadecimalValue]; _type = OF_NUMBER_DOUBLE; _value.double_ = d.d; } else - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; objc_autoreleasePoolPop(pool); } @catch (id e) { [self release]; @throw e; @@ -1012,13 +1000,11 @@ - (of_comparison_result_t)compare: (id )object { OFNumber *number; if (![object isKindOfClass: [OFNumber class]]) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; number = (OFNumber*)object; if (_type & OF_NUMBER_FLOAT || number->_type & OF_NUMBER_FLOAT) { double double1 = [self doubleValue]; @@ -1255,12 +1241,11 @@ fmodf(_value.float_, [number floatValue])]; case OF_NUMBER_DOUBLE: return [OFNumber numberWithDouble: fmod(_value.double_, [number doubleValue])]; default: - @throw [OFInvalidFormatException - exceptionWithClass: [self class]]; + @throw [OFInvalidFormatException exception]; } } - copy { @@ -1319,12 +1304,11 @@ [ret makeImmutable]; return ret; default: - @throw [OFInvalidFormatException - exceptionWithClass: [self class]]; + @throw [OFInvalidFormatException exception]; } } - (OFXMLElement*)XMLElementBySerializing { @@ -1398,12 +1382,11 @@ [element setStringValue: [OFString stringWithFormat: @"%016" PRIx64, d.u]]; break; default: - @throw [OFInvalidFormatException - exceptionWithClass: [self class]]; + @throw [OFInvalidFormatException exception]; } [element retain]; objc_autoreleasePoolPop(pool); @@ -1513,12 +1496,11 @@ [data addItem: &type]; [data addItems: &tmp count: sizeof(tmp)]; } else - @throw [OFOutOfRangeException - exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; } else { uintmax_t value = [self uIntMaxValue]; if (value <= 127) { uint8_t tmp = ((uint8_t)value & 0x7F); @@ -1565,12 +1547,11 @@ [data addItem: &type]; [data addItems: &tmp count: sizeof(tmp)]; } else - @throw [OFOutOfRangeException - exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; } return data; } @end