Index: src/OFArray.m ================================================================== --- src/OFArray.m +++ src/OFArray.m @@ -181,13 +181,12 @@ } - initWithObject: (id)object { if (object == nil) { - Class c = [self class]; [self release]; - @throw [OFInvalidArgumentException exceptionWithClass: c]; + @throw [OFInvalidArgumentException exception]; } return [self initWithObjects: object, nil]; } @@ -372,11 +371,11 @@ OFArray *ret; id *buffer; if (range.length > SIZE_MAX - range.location || range.location + range.length < [self count]) - @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; if (![self isKindOfClass: [OFMutableArray class]]) return [OFArray_subarray arrayWithArray: self range: range]; @@ -410,12 +409,11 @@ id *objects; size_t i, count; IMP append; if (separator == nil) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class]]; + @throw [OFInvalidArgumentException exception]; count = [self count]; if (count == 0) return @""; @@ -590,11 +588,11 @@ [data addItem: &type]; [data addItems: &tmp count: sizeof(tmp)]; } else - @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; pool = objc_autoreleasePoolPush(); i = 0; enumerator = [self objectEnumerator]; @@ -677,11 +675,11 @@ count: (int)count { of_range_t range = of_range(state->state, count); if (range.length > SIZE_MAX - range.location) - @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; if (range.location + range.length > [self count]) range.length = [self count] - range.location; [self getObjects: objects @@ -718,12 +716,11 @@ - (OFArray*)arrayByAddingObject: (id)object { OFMutableArray *ret; if (object == nil) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class]]; + @throw [OFInvalidArgumentException exception]; ret = [[self mutableCopy] autorelease]; [ret addObject: object]; [ret makeImmutable]; @@ -854,12 +851,11 @@ - (id)nextObject { if (mutationsPtr != NULL && *mutationsPtr != mutations) @throw [OFEnumerationMutationException - exceptionWithClass: [self class] - object: array]; + exceptionWithObject: array]; if (position < count) return [array objectAtIndex: position++]; return nil; @@ -867,11 +863,10 @@ - (void)reset { if (mutationsPtr != NULL && *mutationsPtr != mutations) @throw [OFEnumerationMutationException - exceptionWithClass: [self class] - object: array]; + exceptionWithObject: array]; position = 0; } @end Index: src/OFArray_adjacent.m ================================================================== --- src/OFArray_adjacent.m +++ src/OFArray_adjacent.m @@ -51,12 +51,11 @@ { self = [self init]; @try { if (object == nil) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class]]; + @throw [OFInvalidArgumentException exception]; [_array addItem: &object]; [object retain]; } @catch (id e) { [self release]; @@ -146,12 +145,11 @@ [objects[i] retain]; } if (!ok) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class]]; + @throw [OFInvalidArgumentException exception]; [_array addItems: objects count: count]; } @catch (id e) { size_t i; @@ -176,13 +174,11 @@ OFXMLElement *child; if ((![[element name] isEqual: @"OFArray"] && ![[element name] isEqual: @"OFMutableArray"]) || ![[element namespace] isEqual: OF_SERIALIZATION_NS]) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; enumerator = [[element elementsForNamespace: OF_SERIALIZATION_NS] objectEnumerator]; while ((child = [enumerator nextObject]) != nil) { @@ -220,11 +216,11 @@ id ret; @try { ret = *((id*)[_array itemAtIndex: index]); } @catch (OFOutOfRangeException *e) { - @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; } return ret; } @@ -233,11 +229,11 @@ id ret; @try { ret = *((id*)[_array itemAtIndex: index]); } @catch (OFOutOfRangeException *e) { - @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; } return ret; } @@ -247,11 +243,11 @@ id *objects = [_array items]; size_t i, count = [_array count]; if (range.length > SIZE_MAX - range.location || range.location + range.length > count) - @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; for (i = 0; i < range.length; i++) buffer[i] = objects[range.location + i]; } @@ -294,12 +290,11 @@ - (OFArray*)objectsInRange: (of_range_t)range { if (range.length > SIZE_MAX - range.location || range.location + range.length > [_array count]) - @throw [OFOutOfRangeException - exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; if ([self isKindOfClass: [OFMutableArray class]]) return [OFArray arrayWithObjects: (id*)[_array items] + range.location count: range.length]; Index: src/OFArray_subarray.m ================================================================== --- src/OFArray_subarray.m +++ src/OFArray_subarray.m @@ -58,21 +58,21 @@ } - (id)objectAtIndex: (size_t)index { if (index >= _range.length) - @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; return [_array objectAtIndex: index + _range.location]; } - (void)getObjects: (id*)buffer inRange: (of_range_t)range { if (range.length > SIZE_MAX - range.location || range.location + range.length > _range.length) - @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; range.location += _range.location; return [_array getObjects: buffer inRange: range]; @@ -110,12 +110,12 @@ - (OFArray*)objectsInRange: (of_range_t)range { if (range.length > SIZE_MAX - range.location || range.location + range.length > _range.length) - @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; range.location += _range.location; return [_array objectsInRange: range]; } @end Index: src/OFCondition.m ================================================================== --- src/OFCondition.m +++ src/OFCondition.m @@ -49,22 +49,20 @@ - (void)dealloc { if (_conditionInitialized) if (!of_condition_free(&_condition)) @throw [OFConditionStillWaitingException - exceptionWithClass: [self class] - condition: self]; + exceptionWithCondition: self]; [super dealloc]; } - (void)wait { if (!of_condition_wait(&_condition, &_mutex)) @throw [OFConditionWaitFailedException - exceptionWithClass: [self class] - condition: self]; + exceptionWithCondition: self]; } - (bool)waitForTimeInterval: (double)timeInterval { return of_condition_timed_wait(&_condition, &_mutex, timeInterval); @@ -78,17 +76,15 @@ - (void)signal { if (!of_condition_signal(&_condition)) @throw [OFConditionSignalFailedException - exceptionWithClass: [self class] - condition: self]; + exceptionWithCondition: self]; } - (void)broadcast { if (!of_condition_broadcast(&_condition)) @throw [OFConditionBroadcastFailedException - exceptionWithClass: [self class] - condition: self]; + exceptionWithCondition: self]; } @end Index: src/OFConstantString.m ================================================================== --- src/OFConstantString.m +++ src/OFConstantString.m @@ -152,12 +152,11 @@ if (object_getClass(self) == [OFString_const class]) return; if ((ivars = calloc(1, sizeof(*ivars))) == NULL) @throw [OFOutOfMemoryException - exceptionWithClass: [self class] - requestedSize: sizeof(*ivars)]; + exceptionWithRequestedSize: sizeof(*ivars)]; ivars->cString = _cString; ivars->cStringLength = _cStringLength; switch (of_string_utf8_check(ivars->cString, @@ -166,12 +165,11 @@ case 1: ivars->isUTF8 = true; break; case -1: free(ivars); - @throw [OFInvalidEncodingException - exceptionWithClass: [self class]]; + @throw [OFInvalidEncodingException exception]; } _cString = (char*)ivars; object_setClass(self, [OFString_const class]); } Index: src/OFCountedSet_hashtable.m ================================================================== --- src/OFCountedSet_hashtable.m +++ src/OFCountedSet_hashtable.m @@ -142,13 +142,11 @@ OFEnumerator *enumerator; OFXMLElement *objectElement; if (![[element name] isEqual: @"OFCountedSet"] || ![[element namespace] isEqual: OF_SERIALIZATION_NS]) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; objects = [element elementsForName: @"object" namespace: OF_SERIALIZATION_NS]; enumerator = [objects objectEnumerator]; @@ -161,12 +159,11 @@ object = [[objectElement elementsForNamespace: OF_SERIALIZATION_NS] firstObject]; count_ = [objectElement attributeForName: @"count"]; if (object == nil || count_ == nil) - @throw [OFInvalidFormatException - exceptionWithClass: [self class]]; + @throw [OFInvalidFormatException exception]; count = (size_t)[[count_ stringValue] decimalValue]; [_mapTable setValue: (void*)(uintptr_t)count forKey: [object objectByDeserializing]]; @@ -197,22 +194,21 @@ ^ (void *key, void *value, bool *stop) { block(key, (size_t)(uintptr_t)value, stop); }]; } @catch (OFEnumerationMutationException *e) { @throw [OFEnumerationMutationException - exceptionWithClass: [self class] - object: self]; + exceptionWithObject: self]; } } #endif - (void)addObject: (id)object { size_t count = (size_t)(uintptr_t)[_mapTable valueForKey: object]; if (SIZE_MAX - count < 1 || UINTPTR_MAX - count < 1) - @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; [_mapTable setValue: (void*)(uintptr_t)(count + 1) forKey: object]; } Index: src/OFDataArray+MessagePackValue.m ================================================================== --- src/OFDataArray+MessagePackValue.m +++ src/OFDataArray+MessagePackValue.m @@ -566,11 +566,10 @@ size_t count = [self count]; id object; if (parse_object([self items], count, &object) != count || object == nil) - @throw [OFInvalidFormatException - exceptionWithClass: [self class]]; + @throw [OFInvalidFormatException exception]; return object; } @end Index: src/OFDataArray.m ================================================================== --- src/OFDataArray.m +++ src/OFDataArray.m @@ -120,14 +120,12 @@ capacity: (size_t)capacity { self = [super init]; if (itemSize == 0) { - Class c = [self class]; [self release]; - @throw [OFInvalidArgumentException exceptionWithClass: c - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; } _items = [self allocMemoryWithSize: itemSize count: capacity]; @@ -143,12 +141,11 @@ OFFile *file = [[OFFile alloc] initWithPath: path mode: @"rb"]; off_t size = [OFFile sizeOfFileAtPath: path]; if (size > SIZE_MAX) - @throw [OFOutOfRangeException - exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; self = [self initWithItemSize: 1 capacity: (size_t)size]; @try { @@ -204,13 +201,12 @@ request = [OFHTTPRequest requestWithURL: URL]; reply = [client performRequest: request]; if ([reply statusCode] != 200) @throw [OFHTTPRequestFailedException - exceptionWithClass: [request class] - request: request - reply: reply]; + exceptionWithRequest: request + reply: reply]; /* * TODO: This can be optimized by allocating a data array with the * capacity from the Content-Length header. */ @@ -217,14 +213,13 @@ self = [[reply readDataArrayTillEndOfStream] retain]; headers = [reply headers]; if ((contentLength = [headers objectForKey: @"Content-Length"]) != nil) if ([self count] != (size_t)[contentLength decimalValue]) - @throw [OFTruncatedDataException - exceptionWithClass: [self class]]; + @throw [OFTruncatedDataException exception]; #else - @throw [OFUnsupportedProtocolException exceptionWithClass: c]; + @throw [OFUnsupportedProtocolException exceptionWithURL: URL]; #endif objc_autoreleasePoolPop(pool); return self; @@ -241,12 +236,11 @@ _itemSize = 1; _count = [string cStringLengthWithEncoding: OF_STRING_ENCODING_ASCII]; if (_count % 2 != 0) - @throw [OFInvalidFormatException - exceptionWithClass: [self class]]; + @throw [OFInvalidFormatException exception]; _count /= 2; cString = [string cStringWithEncoding: OF_STRING_ENCODING_ASCII]; _items = [self allocMemoryWithSize: _count]; @@ -261,22 +255,20 @@ else if (c1 >= 'a' && c1 <= 'f') byte = (c1 - 'a' + 10) << 4; else if (c1 >= 'A' && c1 <= 'F') byte = (c1 - 'A' + 10) << 4; else - @throw [OFInvalidFormatException - exceptionWithClass: [self class]]; + @throw [OFInvalidFormatException exception]; if (c2 >= '0' && c2 <= '9') byte |= c2 - '0'; else if (c2 >= 'a' && c2 <= 'f') byte |= c2 - 'a' + 10; else if (c2 >= 'A' && c2 <= 'F') byte |= c2 - 'A' + 10; else - @throw [OFInvalidFormatException - exceptionWithClass: [self class]]; + @throw [OFInvalidFormatException exception]; _items[i] = byte; } } @catch (id e) { [self release]; @@ -292,15 +284,12 @@ capacity: [string length] / 3]; @try { if (!of_base64_decode(self, [string cStringWithEncoding: OF_STRING_ENCODING_ASCII], [string - cStringLengthWithEncoding: OF_STRING_ENCODING_ASCII])) { - Class c = [self class]; - [self release]; - @throw [OFInvalidFormatException exceptionWithClass: c]; - } + cStringLengthWithEncoding: OF_STRING_ENCODING_ASCII])) + @throw [OFInvalidFormatException exception]; } @catch (id e) { [self release]; @throw e; } @@ -313,13 +302,11 @@ void *pool = objc_autoreleasePoolPush(); OFString *stringValue; if (![[element name] isEqual: [self className]] || ![[element namespace] isEqual: OF_SERIALIZATION_NS]) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; stringValue = [element stringValue]; self = [self initWithBase64EncodedString: stringValue]; @@ -348,11 +335,11 @@ } - (void*)itemAtIndex: (size_t)index { if (index >= _count) - @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; return _items + index * _itemSize; } - (void*)firstItem @@ -372,11 +359,11 @@ } - (void)addItem: (const void*)item { if (SIZE_MAX - _count < 1) - @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; if (_count + 1 > _capacity) { _items = [self resizeMemory: _items size: _itemSize count: _count + 1]; @@ -398,11 +385,11 @@ - (void)addItems: (const void*)items count: (size_t)count { if (count > SIZE_MAX - count) - @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; if (_count + count > _capacity) { _items = [self resizeMemory: _items size: _itemSize count: _count + count]; @@ -416,11 +403,11 @@ - (void)insertItems: (const void*)items atIndex: (size_t)index count: (size_t)count { if (count > SIZE_MAX - _count || index > _count) - @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; if (_count + count > _capacity) { _items = [self resizeMemory: _items size: _itemSize count: _count + count]; @@ -441,11 +428,11 @@ - (void)removeItemsInRange: (of_range_t)range { if (range.length > SIZE_MAX - range.location || range.location + range.length > _count) - @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; memmove(_items + range.location * _itemSize, _items + (range.location + range.length) * _itemSize, (_count - range.location - range.length) * _itemSize); @@ -519,19 +506,16 @@ OFDataArray *dataArray; int comparison; size_t count, minCount; if (![object isKindOfClass: [OFDataArray class]]) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; + dataArray = (OFDataArray*)object; if ([dataArray itemSize] != _itemSize) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; count = [dataArray count]; minCount = (_count > count ? count : _count); if ((comparison = memcmp(_items, [dataArray items], @@ -621,12 +605,11 @@ { void *pool; OFXMLElement *element; if (_itemSize != 1) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class]]; + @throw [OFInvalidArgumentException exception]; pool = objc_autoreleasePoolPush(); element = [OFXMLElement elementWithName: [self className] namespace: OF_SERIALIZATION_NS @@ -642,13 +625,11 @@ - (OFDataArray*)messagePackRepresentation { OFDataArray *data; if (_itemSize != 1) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; if (_count <= UINT8_MAX) { uint8_t type = 0xC4; uint8_t tmp = (uint8_t)_count; @@ -676,11 +657,11 @@ [data addItem: &type]; [data addItems: &tmp count: sizeof(tmp)]; } else - @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; [data addItems: _items count: _count]; return data; @@ -702,11 +683,11 @@ - (void)addItem: (const void*)item { size_t size, lastPageByte; if (SIZE_MAX - _count < 1 || _count + 1 > SIZE_MAX / _itemSize) - @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; lastPageByte = [OFSystemInfo pageSize] - 1; size = ((_count + 1) * _itemSize + lastPageByte) & ~lastPageByte; if (size > _capacity) { @@ -725,11 +706,11 @@ count: (size_t)count { size_t size, lastPageByte; if (count > SIZE_MAX - _count || _count + count > SIZE_MAX / _itemSize) - @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; lastPageByte = [OFSystemInfo pageSize] - 1; size = ((_count + count) * _itemSize + lastPageByte) & ~lastPageByte; if (size > _capacity) { @@ -750,11 +731,11 @@ { size_t size, lastPageByte; if (count > SIZE_MAX - _count || index > _count || _count + count > SIZE_MAX / _itemSize) - @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; lastPageByte = [OFSystemInfo pageSize] - 1; size = ((_count + count) * _itemSize + lastPageByte) & ~lastPageByte; if (size > _capacity) { @@ -775,11 +756,11 @@ { size_t pageSize, size; if (range.length > SIZE_MAX - range.location || range.location + range.length > _count) - @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; memmove(_items + range.location * _itemSize, _items + (range.location + range.length) * _itemSize, (_count - range.location - range.length) * _itemSize); Index: src/OFDate.m ================================================================== --- src/OFDate.m +++ src/OFDate.m @@ -52,47 +52,41 @@ # define GMTIME_RET(field) \ time_t seconds = (time_t)_seconds; \ struct tm tm; \ \ if (seconds != floor(_seconds)) \ - @throw [OFOutOfRangeException \ - exceptionWithClass: [self class]]; \ + @throw [OFOutOfRangeException exception]; \ \ if (gmtime_r(&seconds, &tm) == NULL) \ - @throw [OFOutOfRangeException \ - exceptionWithClass: [self class]]; \ + @throw [OFOutOfRangeException exception]; \ \ return tm.field; # define LOCALTIME_RET(field) \ time_t seconds = (time_t)_seconds; \ struct tm tm; \ \ if (seconds != floor(_seconds)) \ - @throw [OFOutOfRangeException \ - exceptionWithClass: [self class]]; \ + @throw [OFOutOfRangeException exception]; \ \ if (localtime_r(&seconds, &tm) == NULL) \ - @throw [OFOutOfRangeException \ - exceptionWithClass: [self class]]; \ + @throw [OFOutOfRangeException exception]; \ \ return tm.field; #else # ifdef OF_HAVE_THREADS # define GMTIME_RET(field) \ time_t seconds = (time_t)_seconds; \ struct tm *tm; \ \ if (seconds != floor(_seconds)) \ - @throw [OFOutOfRangeException \ - exceptionWithClass: [self class]]; \ + @throw [OFOutOfRangeException exception]; \ \ [mutex lock]; \ \ @try { \ if ((tm = gmtime(&seconds)) == NULL) \ - @throw [OFOutOfRangeException \ - exceptionWithClass: [self class]]; \ + @throw [OFOutOfRangeException exception]; \ \ return tm->field; \ } @finally { \ [mutex unlock]; \ } @@ -99,19 +93,17 @@ # define LOCALTIME_RET(field) \ time_t seconds = (time_t)_seconds; \ struct tm *tm; \ \ if (seconds != floor(_seconds)) \ - @throw [OFOutOfRangeException \ - exceptionWithClass: [self class]]; \ + @throw [OFOutOfRangeException exception]; \ \ [mutex lock]; \ \ @try { \ if ((tm = localtime(&seconds)) == NULL) \ - @throw [OFOutOfRangeException \ - exceptionWithClass: [self class]]; \ + @throw [OFOutOfRangeException exception]; \ \ return tm->field; \ } @finally { \ [mutex unlock]; \ } @@ -119,29 +111,25 @@ # define GMTIME_RET(field) \ time_t seconds = (time_t)_seconds; \ struct tm *tm; \ \ if (seconds != floor(_seconds)) \ - @throw [OFOutOfRangeException \ - exceptionWithClass: [self class]]; \ + @throw [OFOutOfRangeException exception]; \ \ if ((tm = gmtime(&seconds)) == NULL) \ - @throw [OFOutOfRangeException \ - exceptionWithClass: [self class]]; \ + @throw [OFOutOfRangeException exception]; \ \ return tm->field; # define LOCALTIME_RET(field) \ time_t seconds = (time_t)_seconds; \ struct tm *tm; \ \ if (seconds != floor(_seconds)) \ - @throw [OFOutOfRangeException \ - exceptionWithClass: [self class]]; \ + @throw [OFOutOfRangeException exception]; \ \ if ((tm = localtime(&seconds)) == NULL) \ - @throw [OFOutOfRangeException \ - exceptionWithClass: [self class]]; \ + @throw [OFOutOfRangeException exception]; \ \ return tm->field; # endif #endif @@ -255,12 +243,11 @@ tm.tm_isdst = -1; if (of_strptime([string UTF8String], [format UTF8String], &tm) == NULL) - @throw [OFInvalidFormatException - exceptionWithClass: [self class]]; + @throw [OFInvalidFormatException exception]; /* Years */ _seconds = (int64_t)(tm.tm_year - 70) * 31536000; /* Days of leap years, excluding the year to look at */ _seconds += (((tm.tm_year + 1899) / 4) - 492) * 86400; @@ -271,12 +258,11 @@ (tm.tm_year + 1900) % 100 != 0) || (tm.tm_year + 1900) % 400 == 0)) _seconds += 86400; /* Months */ if (tm.tm_mon < 0 || tm.tm_mon > 12) - @throw [OFInvalidFormatException - exceptionWithClass: [self class]]; + @throw [OFInvalidFormatException exception]; _seconds += month_to_day_of_year[tm.tm_mon] * 86400; /* Days */ _seconds += (tm.tm_mday - 1) * 86400; /* Hours */ _seconds += tm.tm_hour * 3600; @@ -302,16 +288,14 @@ tm.tm_isdst = -1; if (of_strptime([string UTF8String], [format UTF8String], &tm) == NULL) - @throw [OFInvalidFormatException - exceptionWithClass: [self class]]; + @throw [OFInvalidFormatException exception]; if ((_seconds = mktime(&tm)) == -1) - @throw [OFInvalidFormatException - exceptionWithClass: [self class]]; + @throw [OFInvalidFormatException exception]; } @catch (id e) { [self release]; @throw e; } @@ -329,13 +313,11 @@ uint64_t u; } d; if (![[element name] isEqual: [self className]] || ![[element namespace] isEqual: OF_SERIALIZATION_NS]) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; d.u = (uint64_t)[element hexadecimalValue]; _seconds = d.d; objc_autoreleasePoolPop(pool); @@ -391,13 +373,11 @@ - (of_comparison_result_t)compare: (id )object { OFDate *otherDate; if (![object isKindOfClass: [OFDate class]]) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; otherDate = (OFDate*)object; if (_seconds < otherDate->_seconds) return OF_ORDERED_ASCENDING; @@ -517,26 +497,25 @@ struct tm tm; size_t pageSize; char *buffer; if (seconds != floor(_seconds)) - @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; #ifdef HAVE_GMTIME_R if (gmtime_r(&seconds, &tm) == NULL) - @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; #else # ifdef OF_HAVE_THREADS [mutex lock]; @try { # endif struct tm *tmp; if ((tmp = gmtime(&seconds)) == NULL) - @throw [OFOutOfRangeException - exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; tm = *tmp; # ifdef OF_HAVE_THREADS } @finally { [mutex unlock]; @@ -547,12 +526,11 @@ pageSize = [OFSystemInfo pageSize]; buffer = [self allocMemoryWithSize: pageSize]; @try { if (!strftime(buffer, pageSize, [format UTF8String], &tm)) - @throw [OFOutOfRangeException - exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; ret = [OFString stringWithUTF8String: buffer]; } @finally { [self freeMemory: buffer]; } @@ -567,26 +545,25 @@ struct tm tm; size_t pageSize; char *buffer; if (seconds != floor(_seconds)) - @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; #ifdef HAVE_LOCALTIME_R if (localtime_r(&seconds, &tm) == NULL) - @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; #else # ifdef OF_HAVE_THREADS [mutex lock]; @try { # endif struct tm *tmp; if ((tmp = localtime(&seconds)) == NULL) - @throw [OFOutOfRangeException - exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; tm = *tmp; # ifdef OF_HAVE_THREADS } @finally { [mutex unlock]; @@ -597,12 +574,11 @@ pageSize = [OFSystemInfo pageSize]; buffer = [self allocMemoryWithSize: pageSize]; @try { if (!strftime(buffer, pageSize, [format UTF8String], &tm)) - @throw [OFOutOfRangeException - exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; ret = [OFString stringWithUTF8String: buffer]; } @finally { [self freeMemory: buffer]; } Index: src/OFDictionary.m ================================================================== --- src/OFDictionary.m +++ src/OFDictionary.m @@ -216,12 +216,11 @@ - initWithObject: (id)object forKey: (id)key { if (key == nil || object == nil) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class]]; + @throw [OFInvalidArgumentException exception]; return [self initWithKeysAndObjects: key, object, nil]; } - initWithObjects: (OFArray*)objects_ @@ -232,12 +231,11 @@ @try { count = [objects_ count]; if (count != [keys_ count]) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class]]; + @throw [OFInvalidArgumentException exception]; objects = [objects_ objects]; keys = [keys_ objects]; } @catch (id e) { [self release]; @@ -673,11 +671,11 @@ [data addItem: &type]; [data addItems: &tmp count: sizeof(tmp)]; } else - @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; pool = objc_autoreleasePoolPush(); i = 0; keyEnumerator = [self keyEnumerator]; Index: src/OFDictionary_hashtable.m ================================================================== --- src/OFDictionary_hashtable.m +++ src/OFDictionary_hashtable.m @@ -198,28 +198,22 @@ size_t i, count; va_copy(argumentsCopy, arguments); if (firstKey == nil) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; key = firstKey; if ((object = va_arg(arguments, id)) == nil) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; count = 1; for (; va_arg(argumentsCopy, id) != nil; count++); if (count % 2 != 0) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; count /= 2; _mapTable = [[OFMapTable alloc] initWithKeyFunctions: keyFunctions @@ -232,13 +226,11 @@ for (i = 1; i < count; i++) { key = va_arg(arguments, id); object = va_arg(arguments, id); if (key == nil || object == nil) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; [_mapTable setValue: object forKey: key]; } } @catch (id e) { @@ -263,12 +255,11 @@ namespace: OF_SERIALIZATION_NS]; objects = [element elementsForName: @"object" namespace: OF_SERIALIZATION_NS]; if ([keys count] != [objects count]) - @throw [OFInvalidFormatException - exceptionWithClass: [self class]]; + @throw [OFInvalidFormatException exception]; _mapTable = [[OFMapTable alloc] initWithKeyFunctions: keyFunctions valueFunctions: valueFunctions capacity: [keys count]]; @@ -284,12 +275,11 @@ OF_SERIALIZATION_NS] firstObject]; object = [[objectElement elementsForNamespace: OF_SERIALIZATION_NS] firstObject]; if (key == nil || object == nil) - @throw [OFInvalidFormatException - exceptionWithClass: [self class]]; + @throw [OFInvalidFormatException exception]; [_mapTable setValue: [object objectByDeserializing] forKey: [key objectByDeserializing]]; objc_autoreleasePoolPop(pool2); @@ -311,21 +301,11 @@ [super dealloc]; } - (id)objectForKey: (id)key { - id ret; - - @try { - ret = [_mapTable valueForKey: key]; - } @catch (OFInvalidArgumentException *e) { - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; - } - - return ret; + return [_mapTable valueForKey: key]; } - (size_t)count { return [_mapTable count]; @@ -456,16 +436,15 @@ ^ (void *key, void *value, bool *stop) { block(key, value, stop); }]; } @catch (OFEnumerationMutationException *e) { @throw [OFEnumerationMutationException - exceptionWithClass: [self class] - object: self]; + exceptionWithObject: self]; } } #endif - (uint32_t)hash { return [_mapTable hash]; } @end Index: src/OFFile.m ================================================================== --- src/OFFile.m +++ src/OFFile.m @@ -158,12 +158,12 @@ } + (instancetype)fileWithPath: (OFString*)path mode: (OFString*)mode { - return [[[self alloc] initWithPath: path - mode: mode] autorelease]; + return [[(OFFile*)[self alloc] initWithPath: path + mode: mode] autorelease]; } + (instancetype)fileWithFileDescriptor: (int)filedescriptor { return [[[self alloc] @@ -242,12 +242,11 @@ DIR_MODE)) #else if (_wmkdir([path UTF16String])) #endif @throw [OFCreateDirectoryFailedException - exceptionWithClass: self - path: path]; + exceptionWithPath: path]; } + (void)createDirectoryAtPath: (OFString*)path createParents: (bool)createParents { @@ -296,13 +295,12 @@ DIR *dir; struct dirent *dirent; if ((dir = opendir([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE])) == NULL) - @throw [OFOpenFileFailedException exceptionWithClass: self - path: path - mode: @"r"]; + @throw [OFOpenFileFailedException exceptionWithPath: path + mode: @"r"]; @try { while ((dirent = readdir(dir)) != NULL) { void *pool = objc_autoreleasePoolPush(); OFString *file; @@ -328,13 +326,12 @@ path = [path stringByAppendingString: @"\\*"]; if ((handle = FindFirstFileW([path UTF16String], &fd)) == INVALID_HANDLE_VALUE) - @throw [OFOpenFileFailedException exceptionWithClass: self - path: path - mode: @"r"]; + @throw [OFOpenFileFailedException exceptionWithPath: path + mode: @"r"]; @try { do { void *pool2 = objc_autoreleasePoolPush(); OFString *file; @@ -366,12 +363,11 @@ if (chdir([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE])) #else if (_wchdir([path UTF16String])) #endif @throw [OFChangeDirectoryFailedException - exceptionWithClass: self - path: path]; + exceptionWithPath: path]; } #ifdef OF_HAVE_CHMOD + (void)changeModeOfFileAtPath: (OFString*)path mode: (mode_t)mode @@ -380,13 +376,12 @@ if (chmod([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE], mode)) # else if (_wchmod([path UTF16String], mode)) # endif @throw [OFChangeFileModeFailedException - exceptionWithClass: self - path: path - mode: mode]; + exceptionWithPath: path + mode: mode]; } #endif + (off_t)sizeOfFileAtPath: (OFString*)path { @@ -399,13 +394,12 @@ struct _stat s; if (_wstat([path UTF16String], &s) == -1) #endif /* FIXME: Maybe use another exception? */ - @throw [OFOpenFileFailedException exceptionWithClass: self - path: path - mode: @"r"]; + @throw [OFOpenFileFailedException exceptionWithPath: path + mode: @"r"]; return s.st_size; } + (OFDate*)modificationDateOfFileAtPath: (OFString*)path @@ -419,13 +413,12 @@ struct _stat s; if (_wstat([path UTF16String], &s) == -1) #endif /* FIXME: Maybe use another exception? */ - @throw [OFOpenFileFailedException exceptionWithClass: self - path: path - mode: @"r"]; + @throw [OFOpenFileFailedException exceptionWithPath: path + mode: @"r"]; /* FIXME: We could be more precise on some OSes */ return [OFDate dateWithTimeIntervalSince1970: s.st_mtime]; } @@ -436,29 +429,27 @@ { uid_t uid = -1; gid_t gid = -1; if (owner == nil && group == nil) - @throw [OFInvalidArgumentException exceptionWithClass: self - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; # ifdef OF_HAVE_THREADS if (!of_mutex_lock(&mutex)) - @throw [OFLockFailedException exceptionWithClass: self]; + @throw [OFLockFailedException exception]; @try { # endif if (owner != nil) { struct passwd *passwd; if ((passwd = getpwnam([owner cStringWithEncoding: OF_STRING_ENCODING_NATIVE])) == NULL) @throw [OFChangeFileOwnerFailedException - exceptionWithClass: self - path: path - owner: owner - group: group]; + exceptionWithPath: path + owner: owner + group: group]; uid = passwd->pw_uid; } if (group != nil) { @@ -465,32 +456,29 @@ struct group *group_; if ((group_ = getgrnam([group cStringWithEncoding: OF_STRING_ENCODING_NATIVE])) == NULL) @throw [OFChangeFileOwnerFailedException - exceptionWithClass: self - path: path - owner: owner - group: group]; + exceptionWithPath: path + owner: owner + group: group]; gid = group_->gr_gid; } # ifdef OF_HAVE_THREADS } @finally { if (!of_mutex_unlock(&mutex)) - @throw [OFUnlockFailedException - exceptionWithClass: self]; + @throw [OFUnlockFailedException exception]; } # endif if (chown([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE], uid, gid)) @throw [OFChangeFileOwnerFailedException - exceptionWithClass: self - path: path - owner: owner - group: group]; + exceptionWithPath: path + owner: owner + group: group]; } #endif + (void)copyFileAtPath: (OFString*)source toPath: (OFString*)destination @@ -510,12 +498,12 @@ override = [self fileExistsAtPath: destination]; pageSize = [OFSystemInfo pageSize]; if ((buffer = malloc(pageSize)) == NULL) - @throw [OFOutOfMemoryException exceptionWithClass: self - requestedSize: pageSize]; + @throw [OFOutOfMemoryException + exceptionWithRequestedSize: pageSize]; @try { sourceFile = [OFFile fileWithPath: source mode: @"rb"]; destinationFile = [OFFile fileWithPath: destination @@ -566,13 +554,12 @@ [destination cStringWithEncoding: OF_STRING_ENCODING_NATIVE])) #else if (_wrename([source UTF16String], [destination UTF16String])) #endif @throw [OFRenameFileFailedException - exceptionWithClass: self - sourcePath: source - destinationPath: destination]; + exceptionWithSourcePath: source + destinationPath: destination]; objc_autoreleasePoolPop(pool); } + (void)deleteFileAtPath: (OFString*)path @@ -580,12 +567,11 @@ #ifndef _WIN32 if (unlink([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE])) #else if (_wunlink([path UTF16String])) #endif - @throw [OFDeleteFileFailedException exceptionWithClass: self - path: path]; + @throw [OFDeleteFileFailedException exceptionWithPath: path]; } + (void)deleteDirectoryAtPath: (OFString*)path { #ifndef _WIN32 @@ -592,12 +578,11 @@ if (rmdir([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE])) #else if (_wrmdir([path UTF16String])) #endif @throw [OFDeleteDirectoryFailedException - exceptionWithClass: self - path: path]; + exceptionWithPath: path]; } #ifdef OF_HAVE_LINK + (void)linkFileAtPath: (OFString*)source toPath: (OFString*)destination @@ -610,13 +595,13 @@ nil]; } if (link([source cStringWithEncoding: OF_STRING_ENCODING_NATIVE], [destination cStringWithEncoding: OF_STRING_ENCODING_NATIVE]) != 0) - @throw [OFLinkFailedException exceptionWithClass: self - sourcePath: source - destinationPath: destination]; + @throw [OFLinkFailedException + exceptionWithSourcePath: source + destinationPath: destination]; objc_autoreleasePoolPop(pool); } #endif @@ -633,13 +618,12 @@ } if (symlink([source cStringWithEncoding: OF_STRING_ENCODING_NATIVE], [destination cStringWithEncoding: OF_STRING_ENCODING_NATIVE]) != 0) @throw [OFSymlinkFailedException - exceptionWithClass: self - sourcePath: source - destinationPath: destination]; + exceptionWithSourcePath: source + destinationPath: destination]; objc_autoreleasePoolPop(pool); } #endif @@ -662,25 +646,22 @@ @try { int flags; if ((flags = parse_mode([mode UTF8String])) == -1) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; #ifndef _WIN32 if ((_fd = open([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE], flags, DEFAULT_MODE)) == -1) #else if ((_fd = _wopen([path UTF16String], flags, DEFAULT_MODE)) == -1) #endif @throw [OFOpenFileFailedException - exceptionWithClass: [self class] - path: path - mode: mode]; + exceptionWithPath: path + mode: mode]; } @catch (id e) { [self release]; @throw e; } @@ -709,13 +690,12 @@ { ssize_t ret; if (_fd == -1 || _atEndOfStream || (ret = read(_fd, buffer, length)) < 0) - @throw [OFReadFailedException exceptionWithClass: [self class] - stream: self - requestedLength: length]; + @throw [OFReadFailedException exceptionWithStream: self + requestedLength: length]; if (ret == 0) _atEndOfStream = true; return ret; @@ -723,23 +703,21 @@ - (void)lowlevelWriteBuffer: (const void*)buffer length: (size_t)length { if (_fd == -1 || _atEndOfStream || write(_fd, buffer, length) < length) - @throw [OFWriteFailedException exceptionWithClass: [self class] - stream: self - requestedLength: length]; + @throw [OFWriteFailedException exceptionWithStream: self + requestedLength: length]; } - (void)lowlevelSeekToOffset: (off_t)offset whence: (int)whence { if (lseek(_fd, offset, whence) == -1) - @throw [OFSeekFailedException exceptionWithClass: [self class] - stream: self - offset: offset - whence: whence]; + @throw [OFSeekFailedException exceptionWithStream: self + offset: offset + whence: whence]; } - (int)fileDescriptorForReading { return _fd; Index: src/OFHTTPClient.m ================================================================== --- src/OFHTTPClient.m +++ src/OFHTTPClient.m @@ -113,12 +113,11 @@ _hasContentLength = true; @try { _toRead = (size_t)[contentLength decimalValue]; } @catch (OFInvalidFormatException *e) { - @throw [OFInvalidServerReplyException - exceptionWithClass: [self class]]; + @throw [OFInvalidServerReplyException exception]; } } } - (size_t)lowlevelReadIntoBuffer: (void*)buffer @@ -125,13 +124,12 @@ length: (size_t)length { if (_atEndOfStream) { OFReadFailedException *e; - e = [OFReadFailedException exceptionWithClass: [self class] - stream: self - requestedLength: length]; + e = [OFReadFailedException exceptionWithStream: self + requestedLength: length]; #ifndef _WIN32 e->_errNo = ENOTCONN; #else e->_errNo = WSAENOTCONN; @@ -180,11 +178,11 @@ _toRead -= length; if (_toRead == 0) if ([[_socket readLine] length] > 0) @throw [OFInvalidServerReplyException - exceptionWithClass: [self class]]; + exception]; return length; } else { void *pool = objc_autoreleasePoolPush(); OFString *line; @@ -191,12 +189,11 @@ of_range_t range; @try { line = [_socket readLine]; } @catch (OFInvalidEncodingException *e) { - @throw [OFInvalidServerReplyException - exceptionWithClass: [self class]]; + @throw [OFInvalidServerReplyException exception]; } range = [line rangeOfString: @";"]; if (range.location != OF_NOT_FOUND) line = [line substringWithRange: @@ -204,12 +201,11 @@ @try { _toRead = (size_t)[line hexadecimalValue]; } @catch (OFInvalidFormatException *e) { - @throw [OFInvalidServerReplyException - exceptionWithClass: [self class]]; + @throw [OFInvalidServerReplyException exception]; } if (_toRead == 0) { _atEndOfStream = true; @@ -216,16 +212,16 @@ if (_keepAlive) { @try { line = [_socket readLine]; } @catch (OFInvalidEncodingException *e) { @throw [OFInvalidServerReplyException - exceptionWithClass: [self class]]; + exception]; } if ([line length] > 0) @throw [OFInvalidServerReplyException - exceptionWithClass: [self class]]; + exception]; } else [_socket close]; } objc_autoreleasePoolPop(pool); @@ -306,12 +302,11 @@ [self close]; if ([[URL scheme] isEqual: @"https"]) { if (of_tls_socket_class == Nil) @throw [OFUnsupportedProtocolException - exceptionWithClass: [self class] - URL: URL]; + exceptionWithURL: URL]; socket = [[[of_tls_socket_class alloc] init] autorelease]; } else socket = [OFTCPSocket socket]; @@ -346,13 +341,11 @@ OFString *key, *object; int status; const char *type = NULL; if (![scheme isEqual: @"http"] && ![scheme isEqual: @"https"]) - @throw [OFUnsupportedProtocolException - exceptionWithClass: [self class] - URL: URL]; + @throw [OFUnsupportedProtocolException exceptionWithURL: URL]; /* Can we reuse the socket? */ if (_socket != nil && [[_lastURL scheme] isEqual: [URL scheme]] && [[_lastURL host] isEqual: [URL host]] && [_lastURL port] == [URL port]) { @@ -458,12 +451,11 @@ length: [POSTData count] * [POSTData itemSize]]; @try { line = [socket readLine]; } @catch (OFInvalidEncodingException *e) { - @throw [OFInvalidServerReplyException - exceptionWithClass: [self class]]; + @throw [OFInvalidServerReplyException exception]; } /* * It's possible that the write succeeds on a connection that is * keep-alive, but the connection has already been closed by the remote @@ -479,24 +471,21 @@ [POSTData itemSize]]; @try { line = [socket readLine]; } @catch (OFInvalidEncodingException *e) { - @throw [OFInvalidServerReplyException - exceptionWithClass: [self class]]; + @throw [OFInvalidServerReplyException exception]; } } if (![line hasPrefix: @"HTTP/"] || [line characterAtIndex: 8] != ' ') - @throw [OFInvalidServerReplyException - exceptionWithClass: [self class]]; + @throw [OFInvalidServerReplyException exception]; version = [line substringWithRange: of_range(5, 3)]; if (![version isEqual: @"1.0"] && ![version isEqual: @"1.1"]) @throw [OFUnsupportedVersionException - exceptionWithClass: [self class] - version: version]; + exceptionWithVersion: version]; status = (int)[[line substringWithRange: of_range(9, 3)] decimalValue]; serverHeaders = [OFMutableDictionary dictionary]; @@ -506,31 +495,27 @@ char *keyC; @try { line = [socket readLine]; } @catch (OFInvalidEncodingException *e) { - @throw [OFInvalidServerReplyException - exceptionWithClass: [self class]]; + @throw [OFInvalidServerReplyException exception]; } if (line == nil) - @throw [OFInvalidServerReplyException - exceptionWithClass: [self class]]; + @throw [OFInvalidServerReplyException exception]; if ([line length] == 0) break; lineC = [line UTF8String]; if ((tmp = strchr(lineC, ':')) == NULL) - @throw [OFInvalidServerReplyException - exceptionWithClass: [self class]]; + @throw [OFInvalidServerReplyException exception]; if ((keyC = malloc(tmp - lineC + 1)) == NULL) @throw [OFOutOfMemoryException - exceptionWithClass: [self class] - requestedSize: tmp - lineC + 1]; + exceptionWithRequestedSize: tmp - lineC + 1]; memcpy(keyC, lineC, tmp - lineC); keyC[tmp - lineC] = '\0'; normalize_key(keyC); @@ -623,13 +608,12 @@ objc_autoreleasePoolPop(pool); [reply autorelease]; if (status / 100 != 2) @throw [OFHTTPRequestFailedException - exceptionWithClass: [self class] - request: request - reply: reply]; + exceptionWithRequest: request + reply: reply]; return reply; } - (void)close Index: src/OFHTTPRequest.m ================================================================== --- src/OFHTTPRequest.m +++ src/OFHTTPRequest.m @@ -99,14 +99,13 @@ - (void)setProtocolVersion: (of_http_request_protocol_version_t)protocolVersion { if (protocolVersion.major != 1 || protocolVersion.minor > 1) @throw [OFUnsupportedVersionException - exceptionWithClass: [self class] - version: [OFString stringWithFormat: @"%u.%u", - protocolVersion.major, - protocolVersion.minor]]; + exceptionWithVersion: [OFString stringWithFormat: @"%u.%u", + protocolVersion.major, + protocolVersion.minor]]; _protocolVersion = protocolVersion; } - (of_http_request_protocol_version_t)protocolVersion @@ -120,18 +119,17 @@ OFArray *components = [string componentsSeparatedByString: @"."]; intmax_t major, minor; of_http_request_protocol_version_t protocolVersion; if ([components count] != 2) - @throw [OFInvalidFormatException - exceptionWithClass: [self class]]; + @throw [OFInvalidFormatException exception]; major = [[components firstObject] decimalValue]; minor = [[components lastObject] decimalValue]; if (major < 0 || major > UINT8_MAX || minor < 0 || minor > UINT8_MAX) - @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; protocolVersion.major = (uint8_t)major; protocolVersion.minor = (uint8_t)minor; [self setProtocolVersion: protocolVersion]; Index: src/OFHTTPRequestReply.m ================================================================== --- src/OFHTTPRequestReply.m +++ src/OFHTTPRequestReply.m @@ -50,14 +50,13 @@ - (void)setProtocolVersion: (of_http_request_protocol_version_t)protocolVersion { if (protocolVersion.major != 1 || protocolVersion.minor > 1) @throw [OFUnsupportedVersionException - exceptionWithClass: [self class] - version: [OFString stringWithFormat: @"%u.%u", - protocolVersion.major, - protocolVersion.minor]]; + exceptionWithVersion: [OFString stringWithFormat: @"%u.%u", + protocolVersion.major, + protocolVersion.minor]]; _protocolVersion = protocolVersion; } - (of_http_request_protocol_version_t)protocolVersion @@ -71,18 +70,17 @@ OFArray *components = [string componentsSeparatedByString: @"."]; intmax_t major, minor; of_http_request_protocol_version_t protocolVersion; if ([components count] != 2) - @throw [OFInvalidFormatException - exceptionWithClass: [self class]]; + @throw [OFInvalidFormatException exception]; major = [[components firstObject] decimalValue]; minor = [[components lastObject] decimalValue]; if (major < 0 || major > UINT8_MAX || minor < 0 || minor > UINT8_MAX) - @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; protocolVersion.major = (uint8_t)major; protocolVersion.minor = (uint8_t)minor; [self setProtocolVersion: protocolVersion]; @@ -146,12 +144,11 @@ data = [self readDataArrayTillEndOfStream]; if ((contentLength = [_headers objectForKey: @"Content-Length"]) != nil) if ([data count] != (size_t)[contentLength decimalValue]) - @throw [OFTruncatedDataException - exceptionWithClass: [self class]]; + @throw [OFTruncatedDataException exception]; ret = [[OFString alloc] initWithCString: (char*)[data items] encoding: encoding length: [data count]]; Index: src/OFHTTPServer.m ================================================================== --- src/OFHTTPServer.m +++ src/OFHTTPServer.m @@ -143,12 +143,11 @@ uint8_t *tmp = (uint8_t*)cString; bool firstLetter = true; if (cString == NULL) @throw [OFOutOfMemoryException - exceptionWithClass: nil - requestedSize: strlen([key UTF8String])]; + exceptionWithRequestedSize: strlen([key UTF8String])]; while (*tmp != '\0') { if (!isalnum(*tmp)) { firstLetter = true; tmp++; @@ -688,18 +687,14 @@ } - (void)start { if (_host == nil || _port == 0) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; if (_listeningSocket != nil) - @throw [OFAlreadyConnectedException - exceptionWithClass: [self class] - socket: _listeningSocket]; + @throw [OFAlreadyConnectedException exception]; _listeningSocket = [[OFTCPSocket alloc] init]; [_listeningSocket bindToHost: _host port: _port]; [_listeningSocket listen]; Index: src/OFList.m ================================================================== --- src/OFList.m +++ src/OFList.m @@ -44,13 +44,11 @@ OFEnumerator *enumerator; OFXMLElement *child; if (![[element name] isEqual: [self className]] || ![[element namespace] isEqual: OF_SERIALIZATION_NS]) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; enumerator = [[element elementsForNamespace: OF_SERIALIZATION_NS] objectEnumerator]; while ((child = [enumerator nextObject]) != nil) { void *pool2 = objc_autoreleasePoolPush(); @@ -442,12 +440,11 @@ { id ret; if (*_mutationsPtr != _mutations) @throw [OFEnumerationMutationException - exceptionWithClass: [self class] - object: _list]; + exceptionWithObject: _list]; if (_current == NULL) return nil; ret = _current->object; @@ -458,11 +455,10 @@ - (void)reset { if (*_mutationsPtr != _mutations) @throw [OFEnumerationMutationException - exceptionWithClass: [self class] - object: _list]; + exceptionWithObject: _list]; _current = [_list firstListObject]; } @end Index: src/OFMD5Hash.m ================================================================== --- src/OFMD5Hash.m +++ src/OFMD5Hash.m @@ -168,12 +168,11 @@ if (length == 0) return; if (_calculated) @throw [OFHashAlreadyCalculatedException - exceptionWithClass: [self class] - hash: self]; + exceptionWithHash: self]; /* Update bitcount */ t = _bits[0]; if ((_bits[0] = t + ((uint32_t)length << 3)) < t) /* Carry from low to high */ Index: src/OFMapTable.m ================================================================== --- src/OFMapTable.m +++ src/OFMapTable.m @@ -135,12 +135,11 @@ #undef SET_DEFAULT if (capacity > UINT32_MAX || capacity > UINT32_MAX / sizeof(*_buckets) || capacity > UINT32_MAX / 8) - @throw [OFOutOfRangeException - exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; for (_capacity = 1; _capacity < capacity; _capacity *= 2); if (capacity * 8 / _capacity >= 6) _capacity *= 2; @@ -255,13 +254,11 @@ - (void*)valueForKey: (void*)key { uint32_t i, hash, last; if (key == NULL) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; hash = OF_ROL(_keyFunctions.hash(key), _rotate); last = _capacity; for (i = hash & (_capacity - 1); i < last && _buckets[i] != NULL; i++) { @@ -294,11 +291,11 @@ uint32_t i, fullness, capacity; struct of_map_table_bucket **buckets; if (count > UINT32_MAX || count > UINT32_MAX / sizeof(*_buckets) || count > UINT32_MAX / 8) - @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; fullness = count * 8 / _capacity; if (fullness >= 6) capacity = _capacity * 2; @@ -353,13 +350,11 @@ { uint32_t i, last; void *old; if (key == NULL || value == NULL) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; hash = OF_ROL(hash, _rotate); last = _capacity; for (i = hash & (_capacity - 1); i < last && _buckets[i] != NULL; i++) { @@ -403,12 +398,11 @@ for (i = 0; i < last && _buckets[i] != NULL && _buckets[i] != &deleted; i++); } if (i >= last) - @throw [OFOutOfRangeException - exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; bucket = [self allocMemoryWithSize: sizeof(*bucket)]; @try { bucket->key = _keyFunctions.retain(key); @@ -449,13 +443,11 @@ - (void)removeValueForKey: (void*)key { uint32_t i, hash, last; if (key == NULL) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; hash = OF_ROL(_keyFunctions.hash(key), _rotate); last = _capacity; for (i = hash & (_capacity - 1); i < last && _buckets[i] != NULL; i++) { @@ -585,12 +577,11 @@ unsigned long mutations = _mutations; for (i = 0; i < _capacity && !stop; i++) { if (_mutations != mutations) @throw [OFEnumerationMutationException - exceptionWithClass: [self class] - object: self]; + exceptionWithObject: self]; if (_buckets[i] != NULL && _buckets[i] != &deleted) block(_buckets[i]->key, _buckets[i]->value, &stop); } } @@ -601,21 +592,18 @@ unsigned long mutations = _mutations; for (i = 0; i < _capacity; i++) { if (_mutations != mutations) @throw [OFEnumerationMutationException - exceptionWithClass: [self class] - object: self]; + exceptionWithObject: self]; if (_buckets[i] != NULL && _buckets[i] != &deleted) { void *new; new = block(_buckets[i]->key, _buckets[i]->value); if (new == NULL) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; if (new != _buckets[i]->value) { _valueFunctions.release(_buckets[i]->value); _buckets[i]->value = _valueFunctions.retain(new); @@ -680,12 +668,11 @@ - (void)reset { if (*_mutationsPtr != _mutations) @throw [OFEnumerationMutationException - exceptionWithClass: [_mapTable class] - object: _mapTable]; + exceptionWithObject: _mapTable]; _position = 0; } @end @@ -692,12 +679,11 @@ @implementation OFMapTableKeyEnumerator - (void*)nextValue { if (*_mutationsPtr != _mutations) @throw [OFEnumerationMutationException - exceptionWithClass: [_mapTable class] - object: _mapTable]; + exceptionWithObject: _mapTable]; for (; _position < _capacity && (_buckets[_position] == NULL || _buckets[_position] == &deleted); _position++); if (_position < _capacity) @@ -710,12 +696,11 @@ @implementation OFMapTableValueEnumerator - (void*)nextValue { if (*_mutationsPtr != _mutations) @throw [OFEnumerationMutationException - exceptionWithClass: [_mapTable class] - object: _mapTable]; + exceptionWithObject: _mapTable]; for (; _position < _capacity && (_buckets[_position] == NULL || _buckets[_position] == &deleted); _position++); if (_position < _capacity) @@ -751,12 +736,11 @@ @try { ret = [_enumerator nextValue]; } @catch (OFEnumerationMutationException *e) { @throw [OFEnumerationMutationException - exceptionWithClass: [_object class] - object: _object]; + exceptionWithObject: _object]; } return ret; } @@ -764,10 +748,9 @@ { @try { [_enumerator reset]; } @catch (OFEnumerationMutationException *e) { @throw [OFEnumerationMutationException - exceptionWithClass: [_object class] - object: _object]; + exceptionWithObject: _object]; } } @end Index: src/OFMessagePackExtension.m ================================================================== --- src/OFMessagePackExtension.m +++ src/OFMessagePackExtension.m @@ -51,13 +51,11 @@ { self = [super init]; @try { if (data == nil || [data itemSize] != 1) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; _type = type; _data = [data retain]; } @catch (id e) { [self release]; Index: src/OFMutableArray.m ================================================================== --- src/OFMutableArray.m +++ src/OFMutableArray.m @@ -267,12 +267,11 @@ withObject: (id)newObject { size_t i, count; if (oldObject == nil || newObject == nil) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class]]; + @throw [OFInvalidArgumentException exception]; count = [self count]; for (i = 0; i < count; i++) { if ([[self objectAtIndex: i] isEqual: oldObject]) { @@ -287,12 +286,11 @@ withObject: (id)newObject { size_t i, count; if (oldObject == nil || newObject == nil) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class]]; + @throw [OFInvalidArgumentException exception]; count = [self count]; for (i = 0; i < count; i++) { if ([self objectAtIndex: i] == oldObject) { @@ -313,12 +311,11 @@ - (void)removeObject: (id)object { size_t i, count; if (object == nil) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class]]; + @throw [OFInvalidArgumentException exception]; count = [self count]; for (i = 0; i < count; i++) { if ([[self objectAtIndex: i] isEqual: object]) { @@ -332,12 +329,11 @@ - (void)removeObjectIdenticalTo: (id)object { size_t i, count; if (object == nil) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class]]; + @throw [OFInvalidArgumentException exception]; count = [self count]; for (i = 0; i < count; i++) { if ([self objectAtIndex: i] == object) { Index: src/OFMutableArray_adjacent.m ================================================================== --- src/OFMutableArray_adjacent.m +++ src/OFMutableArray_adjacent.m @@ -49,12 +49,11 @@ } - (void)addObject: (id)object { if (object == nil) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class]]; + @throw [OFInvalidArgumentException exception]; [_array addItem: &object]; [object retain]; _mutations++; @@ -62,18 +61,17 @@ - (void)insertObject: (id)object atIndex: (size_t)index { if (object == nil) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class]]; + @throw [OFInvalidArgumentException exception]; @try { [_array insertItem: &object atIndex: index]; } @catch (OFOutOfRangeException *e) { - @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; } [object retain]; _mutations++; } @@ -87,11 +85,11 @@ @try { [_array insertItems: objects atIndex: index count: count]; } @catch (OFOutOfRangeException *e) { - @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; } for (i = 0; i < count; i++) [objects[i] retain]; @@ -103,12 +101,11 @@ { id *objects; size_t i, count; if (oldObject == nil || newObject == nil) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class]]; + @throw [OFInvalidArgumentException exception]; objects = [_array items]; count = [_array count]; for (i = 0; i < count; i++) { @@ -127,17 +124,16 @@ { id *objects; id oldObject; if (object == nil) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class]]; + @throw [OFInvalidArgumentException exception]; objects = [_array items]; if (index >= [_array count]) - @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; oldObject = objects[index]; objects[index] = [object retain]; [oldObject release]; } @@ -147,12 +143,11 @@ { id *objects; size_t i, count; if (oldObject == nil || newObject == nil) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class]]; + @throw [OFInvalidArgumentException exception]; objects = [_array items]; count = [_array count]; for (i = 0; i < count; i++) { @@ -170,12 +165,11 @@ { id *objects; size_t i, count; if (object == nil) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class]]; + @throw [OFInvalidArgumentException exception]; objects = [_array items]; count = [_array count]; for (i = 0; i < count; i++) { @@ -196,12 +190,11 @@ { id *objects; size_t i, count; if (object == nil) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class]]; + @throw [OFInvalidArgumentException exception]; objects = [_array items]; count = [_array count]; for (i = 0; i < count; i++) { @@ -241,11 +234,11 @@ id *objects = [_array items], *copy; size_t i, count = [_array count]; if (range.length > SIZE_MAX - range.location || range.length > count - range.location) - @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; copy = [self allocMemoryWithSize: sizeof(*copy) count: range.length]; memcpy(copy, objects + range.location, range.length * sizeof(id)); @@ -281,11 +274,11 @@ id *objects = [_array items]; size_t count = [_array count]; id tmp; if (index1 >= count || index2 >= count) - @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; tmp = objects[index1]; objects[index1] = objects[index2]; objects[index2] = tmp; } @@ -339,12 +332,11 @@ unsigned long mutations = _mutations; for (i = 0; i < count && !stop; i++) { if (_mutations != mutations) @throw [OFEnumerationMutationException - exceptionWithClass: [self class] - object: self]; + exceptionWithObject: self]; block(objects[i], i, &stop); } } @@ -357,19 +349,16 @@ for (i = 0; i < count; i++) { id new; if (_mutations != mutations) @throw [OFEnumerationMutationException - exceptionWithClass: [self class] - object: self]; + exceptionWithObject: self]; new = block(objects[i], i); if (new == nil) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; if (new != objects[i]) { [objects[i] release]; objects[i] = [new retain]; } Index: src/OFMutableDictionary_hashtable.m ================================================================== --- src/OFMutableDictionary_hashtable.m +++ src/OFMutableDictionary_hashtable.m @@ -21,11 +21,10 @@ #import "OFMutableDictionary_hashtable.h" #import "OFDictionary_hashtable.h" #import "OFMapTable.h" #import "OFEnumerationMutationException.h" -#import "OFInvalidArgumentException.h" #import "OFOutOfRangeException.h" #import "macros.h" @implementation OFMutableDictionary_hashtable @@ -36,29 +35,17 @@ } - (void)setObject: (id)object forKey: (id)key { - @try { - [_mapTable setValue: object - forKey: key]; - } @catch (OFInvalidArgumentException *e) { - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; - } + [_mapTable setValue: object + forKey: key]; } - (void)removeObjectForKey: (id)key { - @try { - [_mapTable removeValueForKey: key]; - } @catch (OFInvalidArgumentException *e) { - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; - } + [_mapTable removeValueForKey: key]; } #ifdef OF_HAVE_BLOCKS - (void)replaceObjectsUsingBlock: (of_dictionary_replace_block_t)block { @@ -67,16 +54,15 @@ ^ void* (void *key, void *value) { return block(key, value); }]; } @catch (OFEnumerationMutationException *e) { @throw [OFEnumerationMutationException - exceptionWithClass: [self class] - object: self]; + exceptionWithObject: self]; } } #endif - (void)makeImmutable { object_setClass(self, [OFDictionary_hashtable class]); } @end Index: src/OFMutableString.m ================================================================== --- src/OFMutableString.m +++ src/OFMutableString.m @@ -396,18 +396,15 @@ { char *UTF8String; int UTF8StringLength; if (format == nil) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; if ((UTF8StringLength = of_vasprintf(&UTF8String, [format UTF8String], arguments)) == -1) - @throw [OFInvalidFormatException - exceptionWithClass: [self class]]; + @throw [OFInvalidFormatException exception]; @try { [self appendUTF8String: UTF8String length: UTF8StringLength]; } @finally { @@ -499,11 +496,11 @@ size_t replacementLength = [replacement length]; size_t i; if (range.length > SIZE_MAX - range.location || range.location + range.length > [self length]) - @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; if (searchLength > range.length) { objc_autoreleasePoolPop(pool); return; } Index: src/OFMutableString_UTF8.m ================================================================== --- src/OFMutableString_UTF8.m +++ src/OFMutableString_UTF8.m @@ -125,12 +125,11 @@ cLen = of_string_utf8_decode(_s->cString + i, _s->cStringLength - i, &c); if (cLen == 0 || c > 0x10FFFF) { [self freeMemory: unicodeString]; - @throw [OFInvalidEncodingException - exceptionWithClass: [self class]]; + @throw [OFInvalidEncodingException exception]; } switch (c) { case ' ': case '\t': @@ -159,12 +158,11 @@ newCStringLength += 3; else if (c < 0x110000) newCStringLength += 4; else { [self freeMemory: unicodeString]; - @throw [OFInvalidEncodingException - exceptionWithClass: [self class]]; + @throw [OFInvalidEncodingException exception]; } i += cLen; } @@ -182,12 +180,11 @@ if ((d = of_string_utf8_encode(unicodeString[i], newCString + j)) == 0) { [self freeMemory: unicodeString]; [self freeMemory: newCString]; - @throw [OFInvalidEncodingException - exceptionWithClass: [self class]]; + @throw [OFInvalidEncodingException exception]; } j += d; } assert(j == newCStringLength); @@ -215,27 +212,25 @@ if (_s->isUTF8) index = of_string_utf8_get_position(_s->cString, index, _s->cStringLength); if (index > _s->cStringLength) - @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; /* Shortcut if old and new character both are ASCII */ if (!(character & 0x80) && !(_s->cString[index] & 0x80)) { _s->hashed = false; _s->cString[index] = character; return; } if ((lenNew = of_string_utf8_encode(character, buffer)) == 0) - @throw [OFInvalidEncodingException - exceptionWithClass: [self class]]; + @throw [OFInvalidEncodingException exception]; if ((lenOld = of_string_utf8_decode(_s->cString + index, _s->cStringLength - index, &c)) == 0) - @throw [OFInvalidEncodingException - exceptionWithClass: [self class]]; + @throw [OFInvalidEncodingException exception]; _s->hashed = false; if (lenNew == lenOld) memcpy(_s->cString + index, buffer, lenNew); @@ -289,12 +284,11 @@ switch (of_string_utf8_check(UTF8String, UTF8StringLength, &length)) { case 1: _s->isUTF8 = true; break; case -1: - @throw [OFInvalidEncodingException - exceptionWithClass: [self class]]; + @throw [OFInvalidEncodingException exception]; } _s->hashed = false; _s->cString = [self resizeMemory: _s->cString size: _s->cStringLength + @@ -319,12 +313,11 @@ switch (of_string_utf8_check(UTF8String, UTF8StringLength, &length)) { case 1: _s->isUTF8 = true; break; case -1: - @throw [OFInvalidEncodingException - exceptionWithClass: [self class]]; + @throw [OFInvalidEncodingException exception]; } _s->hashed = false; _s->cString = [self resizeMemory: _s->cString size: _s->cStringLength + @@ -365,13 +358,11 @@ - (void)appendString: (OFString*)string { size_t UTF8StringLength; if (string == nil) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; UTF8StringLength = [string UTF8StringLength]; _s->hashed = false; _s->cString = [self resizeMemory: _s->cString @@ -430,12 +421,11 @@ memcpy(tmp + j, buffer, 4); j += 4; break; default: - @throw [OFInvalidEncodingException - exceptionWithClass: [self class]]; + @throw [OFInvalidEncodingException exception]; } } tmp[j] = '\0'; @@ -459,18 +449,15 @@ { char *UTF8String; int UTF8StringLength; if (format == nil) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; if ((UTF8StringLength = of_vasprintf(&UTF8String, [format UTF8String], arguments)) == -1) - @throw [OFInvalidFormatException - exceptionWithClass: [self class]]; + @throw [OFInvalidFormatException exception]; @try { [self appendUTF8String: UTF8String length: UTF8StringLength]; } @finally { @@ -500,18 +487,16 @@ if OF_LIKELY (!(_s->cString[i] & 0x80)) continue; /* A start byte can't happen first as we reversed everything */ if OF_UNLIKELY (_s->cString[i] & 0x40) - @throw [OFInvalidEncodingException - exceptionWithClass: [self class]]; + @throw [OFInvalidEncodingException exception]; /* Next byte must not be ASCII */ if OF_UNLIKELY (_s->cStringLength < i + 1 || !(_s->cString[i + 1] & 0x80)) - @throw [OFInvalidEncodingException - exceptionWithClass: [self class]]; + @throw [OFInvalidEncodingException exception]; /* Next byte is the start byte */ if OF_LIKELY (_s->cString[i + 1] & 0x40) { _s->cString[i] ^= _s->cString[i + 1]; _s->cString[i + 1] ^= _s->cString[i]; @@ -522,12 +507,11 @@ } /* Second next byte must not be ASCII */ if OF_UNLIKELY (_s->cStringLength < i + 2 || !(_s->cString[i + 2] & 0x80)) - @throw [OFInvalidEncodingException - exceptionWithClass: [self class]]; + @throw [OFInvalidEncodingException exception]; /* Second next byte is the start byte */ if OF_LIKELY (_s->cString[i + 2] & 0x40) { _s->cString[i] ^= _s->cString[i + 2]; _s->cString[i + 2] ^= _s->cString[i]; @@ -538,12 +522,11 @@ } /* Third next byte must not be ASCII */ if OF_UNLIKELY (_s->cStringLength < i + 3 || !(_s->cString[i + 3] & 0x80)) - @throw [OFInvalidEncodingException - exceptionWithClass: [self class]]; + @throw [OFInvalidEncodingException exception]; /* Third next byte is the start byte */ if OF_LIKELY (_s->cString[i + 3] & 0x40) { _s->cString[i] ^= _s->cString[i + 3]; _s->cString[i + 3] ^= _s->cString[i]; @@ -556,23 +539,21 @@ i += 3; continue; } /* UTF-8 does not allow more than 4 bytes per character */ - @throw [OFInvalidEncodingException - exceptionWithClass: [self class]]; + @throw [OFInvalidEncodingException exception]; } } - (void)insertString: (OFString*)string atIndex: (size_t)index { size_t newCStringLength; if (index > _s->length) - @throw [OFOutOfRangeException - exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; if (_s->isUTF8) index = of_string_utf8_get_position(_s->cString, index, _s->cStringLength); @@ -602,11 +583,11 @@ { size_t start = range.location; size_t end = range.location + range.length; if (range.length > SIZE_MAX - range.location || end > _s->length) - @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; if (_s->isUTF8) { start = of_string_utf8_get_position(_s->cString, start, _s->cStringLength); end = of_string_utf8_get_position(_s->cString, end, @@ -634,11 +615,11 @@ size_t start = range.location; size_t end = range.location + range.length; size_t newCStringLength, newLength; if (range.length > SIZE_MAX - range.location || end > _s->length) - @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; newLength = _s->length - range.length + [replacement length]; if (_s->isUTF8) { start = of_string_utf8_get_position(_s->cString, start, @@ -675,11 +656,11 @@ size_t i, last, newCStringLength, newLength; char *newCString; if (range.length > SIZE_MAX - range.location || range.location + range.length > [self length]) - @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; if (_s->isUTF8) { range.location = of_string_utf8_get_position(_s->cString, range.location, _s->cStringLength); range.length = of_string_utf8_get_position( Index: src/OFMutex.m ================================================================== --- src/OFMutex.m +++ src/OFMutex.m @@ -48,12 +48,11 @@ } - (void)lock { if (!of_mutex_lock(&_mutex)) - @throw [OFLockFailedException exceptionWithClass: [self class] - lock: self]; + @throw [OFLockFailedException exceptionWithLock: self]; } - (bool)tryLock { return of_mutex_trylock(&_mutex); @@ -60,12 +59,11 @@ } - (void)unlock { if (!of_mutex_unlock(&_mutex)) - @throw [OFUnlockFailedException exceptionWithClass: [self class] - lock: self]; + @throw [OFUnlockFailedException exceptionWithLock: self]; } - (void)setName: (OFString*)name { OF_SETTER(_name, name, true, 1) @@ -87,14 +85,12 @@ - (void)dealloc { if (_initialized) if (!of_mutex_free(&_mutex)) - @throw [OFStillLockedException - exceptionWithClass: [self class] - lock: self]; + @throw [OFStillLockedException exceptionWithLock: self]; [_name release]; [super dealloc]; } @end Index: src/OFNull.m ================================================================== --- src/OFNull.m +++ src/OFNull.m @@ -48,13 +48,11 @@ pool = objc_autoreleasePoolPush(); if (![[element name] isEqual: [self className]] || ![[element namespace] isEqual: OF_SERIALIZATION_NS]) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; objc_autoreleasePoolPop(pool); return [OFNull null]; } Index: src/OFNumber.m ================================================================== --- src/OFNumber.m +++ src/OFNumber.m @@ -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 Index: src/OFObject.m ================================================================== --- src/OFObject.m +++ src/OFObject.m @@ -127,13 +127,11 @@ #endif static void enumeration_mutation_handler(id object) { - @throw [OFEnumerationMutationException - exceptionWithClass: [object class] - object: object]; + @throw [OFEnumerationMutationException exceptionWithObject: object]; } void of_method_not_found(id obj, SEL sel) { @@ -872,15 +870,15 @@ if OF_UNLIKELY (size == 0) return NULL; if OF_UNLIKELY (size > SIZE_MAX - PRE_IVARS_ALIGN) - @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; if OF_UNLIKELY ((pointer = malloc(PRE_MEM_ALIGN + size)) == NULL) - @throw [OFOutOfMemoryException exceptionWithClass: [self class] - requestedSize: size]; + @throw [OFOutOfMemoryException + exceptionWithRequestedSize: size]; preMem = pointer; preMem->owner = self; preMem->prev = PRE_IVARS->lastMem; preMem->next = NULL; @@ -897,11 +895,11 @@ - (void*)allocMemoryWithSize: (size_t)size count: (size_t)count { if OF_UNLIKELY (count > SIZE_MAX / size) - @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; return [self allocMemoryWithSize: size * count]; } - (void*)resizeMemory: (void*)pointer @@ -918,17 +916,17 @@ return NULL; } if OF_UNLIKELY (PRE_MEM(pointer)->owner != self) @throw [OFMemoryNotPartOfObjectException - exceptionWithClass: [self class] - pointer: pointer]; + exceptionWithPointer: pointer + object: self]; if OF_UNLIKELY ((new = realloc(PRE_MEM(pointer), PRE_MEM_ALIGN + size)) == NULL) - @throw [OFOutOfMemoryException exceptionWithClass: [self class] - requestedSize: size]; + @throw [OFOutOfMemoryException + exceptionWithRequestedSize: size]; preMem = new; if OF_UNLIKELY (preMem != PRE_MEM(pointer)) { if OF_LIKELY (preMem->prev != NULL) preMem->prev->next = preMem; @@ -956,11 +954,11 @@ [self freeMemory: pointer]; return NULL; } if OF_UNLIKELY (count > SIZE_MAX / size) - @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; return [self resizeMemory: pointer size: size * count]; } @@ -969,12 +967,12 @@ if OF_UNLIKELY (pointer == NULL) return; if OF_UNLIKELY (PRE_MEM(pointer)->owner != self) @throw [OFMemoryNotPartOfObjectException - exceptionWithClass: [self class] - pointer: pointer]; + exceptionWithPointer: pointer + object: self]; if OF_LIKELY (PRE_MEM(pointer)->prev != NULL) PRE_MEM(pointer)->prev->next = PRE_MEM(pointer)->next; if OF_LIKELY (PRE_MEM(pointer)->next != NULL) PRE_MEM(pointer)->next->prev = PRE_MEM(pointer)->prev; @@ -995,12 +993,12 @@ return nil; } - (void)doesNotRecognizeSelector: (SEL)selector { - @throw [OFNotImplementedException exceptionWithClass: [self class] - selector: selector]; + @throw [OFNotImplementedException exceptionWithSelector: selector + object: self]; } - retain { #if defined(OF_HAVE_ATOMIC_OPS) Index: src/OFProcess.m ================================================================== --- src/OFProcess.m +++ src/OFProcess.m @@ -390,13 +390,12 @@ _atEndOfStream = true; return 0; } #endif - @throw [OFReadFailedException exceptionWithClass: [self class] - stream: self - requestedLength: length]; + @throw [OFReadFailedException exceptionWithStream: self + requestedLength: length]; } if (ret == 0) _atEndOfStream = true; @@ -414,13 +413,12 @@ if (_writePipe[1] == NULL || _atEndOfStream || !WriteFile(_writePipe[1], buffer, length, &ret, NULL) || ret < length) #endif - @throw [OFWriteFailedException exceptionWithClass: [self class] - stream: self - requestedLength: length]; + @throw [OFWriteFailedException exceptionWithStream: self + requestedLength: length]; } - (int)fileDescriptorForReading { #ifndef _WIN32 Index: src/OFRecursiveMutex.m ================================================================== --- src/OFRecursiveMutex.m +++ src/OFRecursiveMutex.m @@ -48,12 +48,11 @@ } - (void)lock { if (!of_rmutex_lock(&_rmutex)) - @throw [OFLockFailedException exceptionWithClass: [self class] - lock: self]; + @throw [OFLockFailedException exceptionWithLock: self]; } - (bool)tryLock { return of_rmutex_trylock(&_rmutex); @@ -60,12 +59,11 @@ } - (void)unlock { if (!of_rmutex_unlock(&_rmutex)) - @throw [OFUnlockFailedException exceptionWithClass: [self class] - lock: self]; + @throw [OFUnlockFailedException exceptionWithLock: self]; } - (void)setName: (OFString*)name { OF_SETTER(_name, name, true, 1) @@ -87,14 +85,12 @@ - (void)dealloc { if (_initialized) if (!of_rmutex_free(&_rmutex)) - @throw [OFStillLockedException - exceptionWithClass: [self class] - lock: self]; + @throw [OFStillLockedException exceptionWithLock: self]; [_name release]; [super dealloc]; } @end Index: src/OFSHA1Hash.m ================================================================== --- src/OFSHA1Hash.m +++ src/OFSHA1Hash.m @@ -163,12 +163,11 @@ if (length == 0) return; if (_calculated) @throw [OFHashAlreadyCalculatedException - exceptionWithClass: [self class] - hash: self]; + exceptionWithHash: self]; sha1_update(_state, &_count, _buffer, buffer, length); } - (uint8_t*)digest Index: src/OFSet_hashtable.m ================================================================== --- src/OFSet_hashtable.m +++ src/OFSet_hashtable.m @@ -216,13 +216,11 @@ OFXMLElement *child; if ((![[element name] isEqual: @"OFSet"] && ![[element name] isEqual: @"OFMutableSet"]) || ![[element namespace] isEqual: OF_SERIALIZATION_NS]) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; enumerator = [[element elementsForNamespace: OF_SERIALIZATION_NS] objectEnumerator]; while ((child = [enumerator nextObject]) != nil) { void *pool2 = objc_autoreleasePoolPush(); @@ -313,11 +311,10 @@ ^ (void *key, void *value, bool *stop) { block(key, stop); }]; } @catch (OFEnumerationMutationException *e) { @throw [OFEnumerationMutationException - exceptionWithClass: [self class] - object: self]; + exceptionWithObject: self]; } } #endif @end Index: src/OFStdIOStream.m ================================================================== --- src/OFStdIOStream.m +++ src/OFStdIOStream.m @@ -97,13 +97,12 @@ { ssize_t ret; if (_fd == -1 || _atEndOfStream || (ret = read(_fd, buffer, length)) < 0) - @throw [OFReadFailedException exceptionWithClass: [self class] - stream: self - requestedLength: length]; + @throw [OFReadFailedException exceptionWithStream: self + requestedLength: length]; if (ret == 0) _atEndOfStream = true; return ret; @@ -111,13 +110,12 @@ - (void)lowlevelWriteBuffer: (const void*)buffer length: (size_t)length { if (_fd == -1 || _atEndOfStream || write(_fd, buffer, length) < length) - @throw [OFWriteFailedException exceptionWithClass: [self class] - stream: self - requestedLength: length]; + @throw [OFWriteFailedException exceptionWithStream: self + requestedLength: length]; } - (int)fileDescriptorForReading { return _fd; Index: src/OFStream.m ================================================================== --- src/OFStream.m +++ src/OFStream.m @@ -787,13 +787,11 @@ delimiterCString = [delimiter cStringWithEncoding: encoding]; delimiterLength = [delimiter cStringLengthWithEncoding: encoding]; j = 0; if (delimiterLength == 0) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; /* Look if there's something in our buffer */ if (!_waitingForDelimiter && _readBuffer != NULL) { for (i = 0; i < _readBufferLength; i++) { if (_readBuffer[i] != delimiterCString[j++]) @@ -1447,18 +1445,15 @@ { char *UTF8String; int length; if (format == nil) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; if ((length = of_vasprintf(&UTF8String, [format UTF8String], arguments)) == -1) - @throw [OFInvalidFormatException - exceptionWithClass: [self class]]; + @throw [OFInvalidFormatException exception]; @try { [self writeBuffer: UTF8String length: length]; } @finally { @@ -1490,23 +1485,21 @@ readImplemented = true; if (readFlags == -1) @throw [OFSetOptionFailedException - exceptionWithClass: [self class] - stream: self]; + exceptionWithStream: self]; if (enable) readFlags &= ~O_NONBLOCK; else readFlags |= O_NONBLOCK; if (fcntl([self fileDescriptorForReading], F_SETFL, readFlags) == -1) @throw [OFSetOptionFailedException - exceptionWithClass: [self class] - stream: self]; + exceptionWithStream: self]; } @catch (OFNotImplementedException *e) { } @try { int writeFlags; @@ -1515,30 +1508,27 @@ writeImplemented = true; if (writeFlags == -1) @throw [OFSetOptionFailedException - exceptionWithClass: [self class] - stream: self]; + exceptionWithStream: self]; if (enable) writeFlags &= ~O_NONBLOCK; else writeFlags |= O_NONBLOCK; if (fcntl([self fileDescriptorForWriting], F_SETFL, writeFlags) == -1) @throw [OFSetOptionFailedException - exceptionWithClass: [self class] - stream: self]; + exceptionWithStream: self]; } @catch (OFNotImplementedException *e) { } if (!readImplemented && !writeImplemented) - @throw [OFNotImplementedException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFNotImplementedException exceptionWithSelector: _cmd + object: self]; _blocking = enable; #else [self doesNotRecognizeSelector: _cmd]; abort(); Index: src/OFStreamObserver_kqueue.m ================================================================== --- src/OFStreamObserver_kqueue.m +++ src/OFStreamObserver_kqueue.m @@ -71,11 +71,11 @@ - (void)OF_addFileDescriptorForReading: (int)fd { struct kevent event; if ([_changeList count] >= INT_MAX) - @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; EV_SET(&event, fd, EVFILT_READ, EV_ADD, 0, 0, 0); [_changeList addItem: &event]; } @@ -82,11 +82,11 @@ - (void)OF_addFileDescriptorForWriting: (int)fd { struct kevent event; if ([_changeList count] >= INT_MAX) - @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; EV_SET(&event, fd, EVFILT_WRITE, EV_ADD, 0, 0, 0); [_changeList addItem: &event]; } Index: src/OFStreamObserver_poll.m ================================================================== --- src/OFStreamObserver_poll.m +++ src/OFStreamObserver_poll.m @@ -151,11 +151,11 @@ FDs = [_FDs items]; nFDs = [_FDs count]; #ifdef OPEN_MAX if (nFDs > OPEN_MAX) - @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; #endif if (poll(FDs, (nfds_t)nFDs, (int)(timeInterval != -1 ? timeInterval * 1000 : -1)) < 1) return false; Index: src/OFStreamSocket.m ================================================================== --- src/OFStreamSocket.m +++ src/OFStreamSocket.m @@ -88,19 +88,17 @@ length: (size_t)length { ssize_t ret; if (_socket == INVALID_SOCKET) - @throw [OFNotConnectedException exceptionWithClass: [self class] - socket: self]; + @throw [OFNotConnectedException exceptionWithSocket: self]; if (_atEndOfStream) { OFReadFailedException *e; - e = [OFReadFailedException exceptionWithClass: [self class] - stream: self - requestedLength: length]; + e = [OFReadFailedException exceptionWithStream: self + requestedLength: length]; #ifndef _WIN32 e->_errNo = ENOTCONN; #else e->_errNo = WSAENOTCONN; #endif @@ -107,13 +105,12 @@ @throw e; } if ((ret = recv(_socket, buffer, length, 0)) < 0) - @throw [OFReadFailedException exceptionWithClass: [self class] - stream: self - requestedLength: length]; + @throw [OFReadFailedException exceptionWithStream: self + requestedLength: length]; if (ret == 0) _atEndOfStream = true; return ret; @@ -121,19 +118,17 @@ - (void)lowlevelWriteBuffer: (const void*)buffer length: (size_t)length { if (_socket == INVALID_SOCKET) - @throw [OFNotConnectedException exceptionWithClass: [self class] - socket: self]; + @throw [OFNotConnectedException exceptionWithSocket: self]; if (_atEndOfStream) { OFWriteFailedException *e; - e = [OFWriteFailedException exceptionWithClass: [self class] - stream: self - requestedLength: length]; + e = [OFWriteFailedException exceptionWithStream: self + requestedLength: length]; #ifndef _WIN32 e->_errNo = ENOTCONN; #else e->_errNo = WSAENOTCONN; #endif @@ -140,25 +135,22 @@ @throw e; } if (send(_socket, buffer, length, 0) < length) - @throw [OFWriteFailedException exceptionWithClass: [self class] - stream: self - requestedLength: length]; + @throw [OFWriteFailedException exceptionWithStream: self + requestedLength: length]; } #ifdef _WIN32 - (void)setBlocking: (bool)enable { u_long v = enable; _blocking = enable; if (ioctlsocket(_socket, FIONBIO, &v) == SOCKET_ERROR) - @throw [OFSetOptionFailedException - exceptionWithClass: [self class] - stream: self]; + @throw [OFSetOptionFailedException exceptionWithStream: self]; } #endif - (int)fileDescriptorForReading { @@ -171,12 +163,11 @@ } - (void)close { if (_socket == INVALID_SOCKET) - @throw [OFNotConnectedException exceptionWithClass: [self class] - socket: self]; + @throw [OFNotConnectedException exceptionWithSocket: self]; close(_socket); _socket = INVALID_SOCKET; _atEndOfStream = false; Index: src/OFString+JSONValue.m ================================================================== --- src/OFString+JSONValue.m +++ src/OFString+JSONValue.m @@ -663,11 +663,11 @@ object = nextObject(&pointer, stop, &line, 0, depthLimit); skipWhitespacesAndComments(&pointer, stop, &line); if (pointer < stop || object == nil) - @throw [OFInvalidJSONException exceptionWithClass: [self class] - line: line]; + @throw [OFInvalidJSONException exceptionWithString: self + line: line]; return object; } @end Index: src/OFString+Serialization.m ================================================================== --- src/OFString+Serialization.m +++ src/OFString+Serialization.m @@ -42,39 +42,30 @@ id object; @try { root = [OFXMLElement elementWithXMLString: self]; } @catch (OFMalformedXMLException *e) { - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; } @catch (OFUnboundNamespaceException *e) { - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; } version = [[root attributeForName: @"version"] stringValue]; if (version == nil) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; if ([version decimalValue] != 1) @throw [OFUnsupportedVersionException - exceptionWithClass: [self class] - version: version]; + exceptionWithVersion: version]; elements = [root elementsForNamespace: OF_SERIALIZATION_NS]; if ([elements count] != 1) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; object = [[[elements firstObject] objectByDeserializing] retain]; objc_autoreleasePoolPop(pool); return [object autorelease]; } @end Index: src/OFString+URLEncoding.m ================================================================== --- src/OFString+URLEncoding.m +++ src/OFString+URLEncoding.m @@ -20,11 +20,11 @@ #include #include #import "OFString+URLEncoding.h" -#import "OFInvalidEncodingException.h" +#import "OFInvalidFormatException.h" #import "OFOutOfMemoryException.h" /* Reference for static linking */ int _OFString_URLEncoding_reference; @@ -40,13 +40,12 @@ * Worst case: 3 times longer than before. * Oh, and we can't use [self allocWithSize:] here as self might be a * @"" literal. */ if ((retCString = malloc(([self UTF8StringLength] * 3) + 1)) == NULL) - @throw [OFOutOfMemoryException - exceptionWithClass: [self class] - requestedSize: ([self UTF8StringLength] * 3) + 1]; + @throw [OFOutOfMemoryException exceptionWithRequestedSize: + ([self UTF8StringLength] * 3) + 1]; for (i = 0; *string != '\0'; string++) { if (isalnum((int)*string) || *string == '-' || *string == '_' || *string == '.' || *string == '~') retCString[i++] = *string; @@ -83,12 +82,11 @@ int state = 0; size_t i; if ((retCString = malloc([self UTF8StringLength] + 1)) == NULL) @throw [OFOutOfMemoryException - exceptionWithClass: [self class] - requestedSize: [self UTF8StringLength] + 1]; + exceptionWithRequestedSize: [self UTF8StringLength] + 1]; for (i = 0; *string; string++) { switch (state) { case 0: if (*string == '%') @@ -108,12 +106,11 @@ byte += (*string - 'A' + 10) << shift; else if (*string >= 'a' && *string <= 'f') byte += (*string - 'a' + 10) << shift; else { free(retCString); - @throw [OFInvalidEncodingException - exceptionWithClass: [self class]]; + @throw [OFInvalidFormatException exception]; } if (++state == 3) { retCString[i++] = byte; state = 0; @@ -125,12 +122,11 @@ } retCString[i] = '\0'; if (state != 0) { free(retCString); - @throw [OFInvalidEncodingException - exceptionWithClass: [self class]]; + @throw [OFInvalidFormatException exception]; } @try { ret = [OFString stringWithUTF8String: retCString length: i]; Index: src/OFString+XMLEscaping.m ================================================================== --- src/OFString+XMLEscaping.m +++ src/OFString+XMLEscaping.m @@ -43,12 +43,12 @@ /* * We can't use allocMemoryWithSize: here as it might be a @"" literal */ if ((retCString = malloc(retLength)) == NULL) - @throw [OFOutOfMemoryException exceptionWithClass: [self class] - requestedSize: retLength]; + @throw [OFOutOfMemoryException + exceptionWithRequestedSize: retLength]; for (i = 0; i < length; i++) { switch (string[i]) { case '<': append = "<"; @@ -84,12 +84,12 @@ if ((newRetCString = realloc(retCString, retLength + appendLen)) == NULL) { free(retCString); @throw [OFOutOfMemoryException - exceptionWithClass: [self class] - requestedSize: retLength + appendLen]; + exceptionWithRequestedSize: retLength + + appendLen]; } retCString = newRetCString; retLength += appendLen - 1; memcpy(retCString + j, append, appendLen); Index: src/OFString+XMLUnescaping.m ================================================================== --- src/OFString+XMLUnescaping.m +++ src/OFString+XMLUnescaping.m @@ -18,11 +18,11 @@ #include #import "OFString.h" -#import "OFInvalidEncodingException.h" +#import "OFInvalidFormatException.h" #import "autorelease.h" #import "macros.h" int _OFString_XMLUnescaping_reference; @@ -137,12 +137,12 @@ pool = objc_autoreleasePoolPush(); tmp = parse_numeric_entity(entity, entityLength); if (tmp == nil) - @throw [OFInvalidEncodingException - exceptionWithClass: [self class]]; + @throw [OFInvalidFormatException + exception]; [ret appendString: tmp]; objc_autoreleasePoolPop(pool); } else if (delegate != nil) { void *pool; @@ -155,27 +155,25 @@ length: entityLength]; tmp = [delegate string: self containsUnknownEntityNamed: n]; if (tmp == nil) - @throw [OFInvalidEncodingException - exceptionWithClass: [self class]]; + @throw [OFInvalidFormatException + exception]; [ret appendString: tmp]; objc_autoreleasePoolPop(pool); } else - @throw [OFInvalidEncodingException - exceptionWithClass: [self class]]; + @throw [OFInvalidFormatException exception]; last = i + 1; inEntity = false; } } if (inEntity) - @throw [OFInvalidEncodingException - exceptionWithClass: [self class]]; + @throw [OFInvalidFormatException exception]; [ret appendUTF8String: string + last length: i - last]; [ret makeImmutable]; @@ -240,12 +238,12 @@ pool = objc_autoreleasePoolPush(); tmp = parse_numeric_entity(entity, entityLength); if (tmp == nil) - @throw [OFInvalidEncodingException - exceptionWithClass: [self class]]; + @throw [OFInvalidFormatException + exception]; [ret appendString: tmp]; objc_autoreleasePoolPop(pool); } else { void *pool; @@ -257,12 +255,12 @@ stringWithUTF8String: entity length: entityLength]; tmp = block(self, entityString); if (tmp == nil) - @throw [OFInvalidEncodingException - exceptionWithClass: [self class]]; + @throw [OFInvalidFormatException + exception]; [ret appendString: tmp]; objc_autoreleasePoolPop(pool); } @@ -270,12 +268,11 @@ inEntity = false; } } if (inEntity) - @throw [OFInvalidEncodingException - exceptionWithClass: [self class]]; + @throw [OFInvalidFormatException exception]; [ret appendUTF8String: string + last length: i - last]; [ret makeImmutable]; Index: src/OFString.m ================================================================== --- src/OFString.m +++ src/OFString.m @@ -884,17 +884,15 @@ OFFile *file; if (stat([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE], &st) == -1) @throw [OFOpenFileFailedException - exceptionWithClass: [self class] - path: path - mode: @"rb"]; + exceptionWithPath: path + mode: @"rb"]; if (st.st_size > SIZE_MAX) - @throw [OFOutOfRangeException - exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; file = [[OFFile alloc] initWithPath: path mode: @"rb"]; @try { @@ -958,13 +956,12 @@ request = [OFHTTPRequest requestWithURL: URL]; reply = [client performRequest: request]; if ([reply statusCode] != 200) @throw [OFHTTPRequestFailedException - exceptionWithClass: [request class] - request: request - reply: reply]; + exceptionWithRequest: request + reply: reply]; headers = [reply headers]; if (encoding == OF_STRING_ENCODING_AUTODETECT && (contentType = [headers objectForKey: @"Content-Type"]) != nil) { @@ -985,18 +982,17 @@ data = [reply readDataArrayTillEndOfStream]; if ((contentLength = [headers objectForKey: @"Content-Length"]) != nil) if ([data count] != (size_t)[contentLength decimalValue]) - @throw [OFTruncatedDataException - exceptionWithClass: [self class]]; + @throw [OFTruncatedDataException exception]; self = [[c alloc] initWithCString: (char*)[data items] encoding: encoding length: [data count]]; #else - @throw [OFUnsupportedProtocolException exceptionWithClass: c]; + @throw [OFUnsupportedProtocolException exceptionWithURL: URL]; #endif objc_autoreleasePoolPop(pool); return self; @@ -1006,24 +1002,18 @@ { @try { void *pool = objc_autoreleasePoolPush(); if (![[element namespace] isEqual: OF_SERIALIZATION_NS]) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; if ([self isKindOfClass: [OFMutableString class]]) { if (![[element name] isEqual: @"OFMutableString"]) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; } else { if (![[element name] isEqual: @"OFString"]) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; } self = [self initWithString: [element stringValue]]; objc_autoreleasePoolPop(pool); @@ -1054,12 +1044,11 @@ /* * Check for one more than the current index, as we * need one for the terminating zero. */ if (j + len >= maxLength) - @throw [OFOutOfRangeException - exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; switch (len) { case 1: cString[j++] = buffer[0]; @@ -1070,54 +1059,48 @@ memcpy(cString + j, buffer, len); j += len; break; default: - @throw [OFInvalidEncodingException - exceptionWithClass: [self class]]; + @throw [OFInvalidEncodingException exception]; } } cString[j] = '\0'; return j; case OF_STRING_ENCODING_ASCII: if (length + 1 > maxLength) - @throw [OFOutOfRangeException - exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; for (i = 0; i < length; i++) { if OF_UNLIKELY (characters[i] > 0x80) - @throw [OFInvalidEncodingException - exceptionWithClass: [self class]]; + @throw [OFInvalidEncodingException exception]; cString[i] = (char)characters[i]; } cString[i] = '\0'; return length; case OF_STRING_ENCODING_ISO_8859_1: if (length + 1 > maxLength) - @throw [OFOutOfRangeException - exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; for (i = 0; i < length; i++) { if OF_UNLIKELY (characters[i] > 0xFF) - @throw [OFInvalidEncodingException - exceptionWithClass: [self class]]; + @throw [OFInvalidEncodingException exception]; cString[i] = (uint8_t)characters[i]; } cString[i] = '\0'; return length; case OF_STRING_ENCODING_ISO_8859_15: if (length + 1 > maxLength) - @throw [OFOutOfRangeException - exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; for (i = 0; i < length; i++) { of_unichar_t c = characters[i]; switch (c) { @@ -1127,12 +1110,11 @@ case 0xB4: case 0xB8: case 0xBC: case 0xBD: case 0xBE: - @throw [OFInvalidEncodingException - exceptionWithClass: [self class]]; + @throw [OFInvalidEncodingException exception]; } if OF_UNLIKELY (c > 0xFF) { switch (c) { case 0x20AC: @@ -1159,11 +1141,11 @@ case 0x178: cString[i] = 0xBE; break; default: @throw [OFInvalidEncodingException - exceptionWithClass: [self class]]; + exception]; } } else cString[i] = (uint8_t)c; } @@ -1170,19 +1152,17 @@ cString[i] = '\0'; return length; case OF_STRING_ENCODING_WINDOWS_1252: if (length + 1 > maxLength) - @throw [OFOutOfRangeException - exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; for (i = 0; i < length; i++) { of_unichar_t c = characters[i]; if OF_UNLIKELY (c >= 0x80 && c <= 0x9F) - @throw [OFInvalidEncodingException - exceptionWithClass: [self class]]; + @throw [OFInvalidEncodingException exception]; if OF_UNLIKELY (c > 0xFF) { switch (c) { case 0x20AC: cString[i] = 0x80; @@ -1265,23 +1245,22 @@ case 0x178: cString[i] = 0x9F; break; default: @throw [OFInvalidEncodingException - exceptionWithClass: [self class]]; + exception]; } } else cString[i] = (uint8_t)c; } cString[i] = '\0'; return length; default: - @throw [OFNotImplementedException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFNotImplementedException exceptionWithSelector: _cmd + object: self]; } } - (const char*)cStringWithEncoding: (of_string_encoding_t)encoding { @@ -1317,13 +1296,12 @@ maxLength: length + 1 encoding: encoding]; break; default: - @throw [OFNotImplementedException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFNotImplementedException exceptionWithSelector: _cmd + object: self]; } return cString; } @@ -1352,12 +1330,11 @@ char buffer[4]; size_t len = of_string_utf8_encode(characters[i], buffer); if (len == 0) - @throw [OFInvalidEncodingException - exceptionWithClass: [self class]]; + @throw [OFInvalidEncodingException exception]; UTF8StringLength += len; } return UTF8StringLength; @@ -1365,13 +1342,12 @@ case OF_STRING_ENCODING_ISO_8859_1: case OF_STRING_ENCODING_ISO_8859_15: case OF_STRING_ENCODING_WINDOWS_1252: return [self length]; default: - @throw [OFNotImplementedException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFNotImplementedException exceptionWithSelector: _cmd + object: self]; } } - (size_t)UTF8StringLength { @@ -1447,13 +1423,11 @@ if (object == self) return OF_ORDERED_SAME; if (![object isKindOfClass: [OFString class]]) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; otherString = (OFString*)object; minimumLength = ([self length] > [otherString length] ? [otherString length] : [self length]); @@ -1658,11 +1632,11 @@ [data addItem: &type]; [data addItems: &tmp count: sizeof(tmp)]; } else - @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; [data addItems: [self UTF8String] count: length]; return data; @@ -1697,21 +1671,20 @@ if (searchLength > range.length) return of_range(OF_NOT_FOUND, 0); if (range.length > SIZE_MAX / sizeof(of_unichar_t)) - @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; pool = objc_autoreleasePoolPush(); searchCharacters = [string characters]; characters = malloc(range.length * sizeof(of_unichar_t)); if (characters == NULL) - @throw [OFOutOfMemoryException - exceptionWithClass: [self class] - requestedSize: range.length * sizeof(of_unichar_t)]; + @throw [OFOutOfMemoryException exceptionWithRequestedSize: + range.length * sizeof(of_unichar_t)]; @try { [self getCharacters: characters inRange: range]; @@ -1782,12 +1755,11 @@ void *pool; OFString *ret; if (range.length > SIZE_MAX - range.location || range.location + range.length > [self length]) - @throw [OFOutOfRangeException - exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; pool = objc_autoreleasePoolPush(); ret = [[OFString alloc] initWithCharacters: [self characters] + range.location length: range.length]; @@ -2244,29 +2216,26 @@ for (; i < length; i++) { if (expectWhitespace) { if (characters[i] != ' ' && characters[i] != '\t' && characters[i] != '\n' && characters[i] != '\r' && characters[i] != '\f') - @throw [OFInvalidFormatException - exceptionWithClass: [self class]]; + @throw [OFInvalidFormatException exception]; continue; } if (characters[i] >= '0' && characters[i] <= '9') { if (INTMAX_MAX / 10 < value || INTMAX_MAX - value * 10 < characters[i] - '0') - @throw [OFOutOfRangeException - exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; value = (value * 10) + (characters[i] - '0'); } else if (characters[i] == ' ' || characters[i] == '\t' || characters[i] == '\n' || characters[i] == '\r' || characters[i] == '\f') expectWhitespace = true; else - @throw [OFInvalidFormatException - exceptionWithClass: [self class]]; + @throw [OFInvalidFormatException exception]; } if (characters[0] == '-') value *= -1; @@ -2306,12 +2275,11 @@ if (expectWhitespace) { if (characters[i] != ' ' && characters[i] != '\t' && characters[i] != '\n' && characters[i] != '\r' && characters[i] != '\f') - @throw [OFInvalidFormatException - exceptionWithClass: [self class]]; + @throw [OFInvalidFormatException exception]; continue; } if (characters[i] >= '0' && characters[i] <= '9') { newValue = (value << 4) | (characters[i] - '0'); @@ -2326,23 +2294,20 @@ characters[i] == '\t' || characters[i] == '\n' || characters[i] == '\r' || characters[i] == '\f') { expectWhitespace = true; continue; } else - @throw [OFInvalidFormatException - exceptionWithClass: [self class]]; + @throw [OFInvalidFormatException exception]; if (newValue < value) - @throw [OFOutOfRangeException - exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; value = newValue; } if (!foundValue) - @throw [OFInvalidFormatException - exceptionWithClass: [self class]]; + @throw [OFInvalidFormatException exception]; objc_autoreleasePoolPop(pool); return value; } @@ -2364,12 +2329,11 @@ if (endPointer != NULL) for (; *endPointer != '\0'; endPointer++) if (*endPointer != ' ' && *endPointer != '\t' && *endPointer != '\n' && *endPointer != '\r' && *endPointer != '\f') - @throw [OFInvalidFormatException - exceptionWithClass: [self class]]; + @throw [OFInvalidFormatException exception]; objc_autoreleasePoolPop(pool); return value; } @@ -2391,12 +2355,11 @@ if (endPointer != NULL) for (; *endPointer != '\0'; endPointer++) if (*endPointer != ' ' && *endPointer != '\t' && *endPointer != '\n' && *endPointer != '\r' && *endPointer != '\f') - @throw [OFInvalidFormatException - exceptionWithClass: [self class]]; + @throw [OFInvalidFormatException exception]; objc_autoreleasePoolPop(pool); return value; } @@ -2438,12 +2401,11 @@ for (i = 0; i < length; i++) { of_unichar_t c = characters[i]; if (c > 0x10FFFF) - @throw [OFInvalidEncodingException - exceptionWithClass: [self class]]; + @throw [OFInvalidEncodingException exception]; if (swap) { if (c > 0xFFFF) { c -= 0x10000; ret[j++] = OF_BSWAP16(0xD800 | (c >> 10)); Index: src/OFString_UTF8.m ================================================================== --- src/OFString_UTF8.m +++ src/OFString_UTF8.m @@ -189,12 +189,11 @@ &_s->length)) { case 1: _s->isUTF8 = true; break; case -1: - @throw [OFInvalidEncodingException - exceptionWithClass: [self class]]; + @throw [OFInvalidEncodingException exception]; } memcpy(_s->cString, UTF8String, UTF8StringLength); _s->cString[UTF8StringLength] = 0; } @catch (id e) { @@ -231,17 +230,16 @@ switch (of_string_utf8_check(cString, cStringLength, &_s->length)) { case 1: if (encoding == OF_STRING_ENCODING_ASCII) @throw [OFInvalidEncodingException - exceptionWithClass: [self class]]; + exception]; _s->isUTF8 = true; break; case -1: - @throw [OFInvalidEncodingException - exceptionWithClass: [self class]]; + @throw [OFInvalidEncodingException exception]; } memcpy(_s->cString, cString, cStringLength); _s->cString[cStringLength] = 0; @@ -265,11 +263,11 @@ bytes = of_string_utf8_encode( (uint8_t)cString[i], buffer); if (bytes == 0) @throw [OFInvalidEncodingException - exceptionWithClass: [self class]]; + exception]; _s->cStringLength += bytes - 1; _s->cString = [self resizeMemory: _s->cString size: _s->cStringLength + 1]; @@ -289,12 +287,11 @@ break; case OF_STRING_ENCODING_WINDOWS_1252: table = of_windows_1252; break; default: - @throw [OFInvalidEncodingException - exceptionWithClass: [self class]]; + @throw [OFInvalidEncodingException exception]; } for (i = j = 0; i < cStringLength; i++) { char buffer[4]; of_unichar_t character; @@ -306,20 +303,18 @@ } character = table[(uint8_t)cString[i]]; if (character == 0xFFFD) - @throw [OFInvalidEncodingException - exceptionWithClass: [self class]]; + @throw [OFInvalidEncodingException exception]; _s->isUTF8 = true; characterBytes = of_string_utf8_encode(character, buffer); if (characterBytes == 0) - @throw [OFInvalidEncodingException - exceptionWithClass: [self class]]; + @throw [OFInvalidEncodingException exception]; _s->cStringLength += characterBytes - 1; _s->cString = [self resizeMemory: _s->cString size: _s->cStringLength + 1]; @@ -363,12 +358,11 @@ &_s->length)) { case 1: _s->isUTF8 = true; break; case -1: - @throw [OFInvalidEncodingException - exceptionWithClass: [self class]]; + @throw [OFInvalidEncodingException exception]; } } @catch (id e) { [self release]; @throw e; } @@ -433,12 +427,11 @@ memcpy(_s->cString + j, buffer, len); j += len; break; default: - @throw [OFInvalidEncodingException - exceptionWithClass: [self class]]; + @throw [OFInvalidEncodingException exception]; } } _s->cString[j] = '\0'; _s->cStringLength = j; @@ -488,27 +481,26 @@ (swap ? OF_BSWAP16(string[i]) : string[i]); size_t len; /* Missing high surrogate */ if ((character & 0xFC00) == 0xDC00) - @throw [OFInvalidEncodingException - exceptionWithClass: [self class]]; + @throw [OFInvalidEncodingException exception]; if ((character & 0xFC00) == 0xD800) { of_char16_t nextCharacter; if (length <= i + 1) @throw [OFInvalidEncodingException - exceptionWithClass: [self class]]; + exception]; nextCharacter = (swap ? OF_BSWAP16(string[i + 1]) : string[i + 1]); if ((nextCharacter & 0xFC00) != 0xDC00) @throw [OFInvalidEncodingException - exceptionWithClass: [self class]]; + exception]; character = (((character & 0x3FF) << 10) | (nextCharacter & 0x3FF)) + 0x10000; i++; @@ -529,12 +521,11 @@ memcpy(_s->cString + j, buffer, len); j += len; break; default: - @throw [OFInvalidEncodingException - exceptionWithClass: [self class]]; + @throw [OFInvalidEncodingException exception]; } } _s->cString[j] = '\0'; _s->cStringLength = j; @@ -596,12 +587,11 @@ memcpy(_s->cString + j, buffer, len); j += len; break; default: - @throw [OFInvalidEncodingException - exceptionWithClass: [self class]]; + @throw [OFInvalidEncodingException exception]; } } _s->cString[j] = '\0'; _s->cStringLength = j; @@ -628,20 +618,17 @@ @try { char *tmp; int cStringLength; if (format == nil) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; _s = &_storage; if ((cStringLength = of_vasprintf(&tmp, [format UTF8String], arguments)) == -1) - @throw [OFInvalidFormatException - exceptionWithClass: [self class]]; + @throw [OFInvalidFormatException exception]; _s->cStringLength = cStringLength; @try { switch (of_string_utf8_check(tmp, cStringLength, @@ -648,12 +635,11 @@ &_s->length)) { case 1: _s->isUTF8 = true; break; case -1: - @throw [OFInvalidEncodingException - exceptionWithClass: [self class]]; + @throw [OFInvalidEncodingException exception]; } _s->cString = [self allocMemoryWithSize: cStringLength + 1]; memcpy(_s->cString, tmp, cStringLength + 1); @@ -745,17 +731,15 @@ encoding: (of_string_encoding_t)encoding { switch (encoding) { case OF_STRING_ENCODING_ASCII: if (_s->isUTF8) - @throw [OFInvalidEncodingException - exceptionWithClass: [self class]]; + @throw [OFInvalidEncodingException exception]; /* intentional fall-through */ case OF_STRING_ENCODING_UTF_8: if (_s->cStringLength + 1 > maxLength) - @throw [OFOutOfRangeException - exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; memcpy(cString, _s->cString, _s->cStringLength + 1); return _s->cStringLength; default: @@ -768,12 +752,11 @@ - (const char*)cStringWithEncoding: (of_string_encoding_t)encoding { switch (encoding) { case OF_STRING_ENCODING_ASCII: if (_s->isUTF8) - @throw [OFInvalidEncodingException - exceptionWithClass: [self class]]; + @throw [OFInvalidEncodingException exception]; /* intentional fall-through */ case OF_STRING_ENCODING_UTF_8: return _s->cString; default: return [super cStringWithEncoding: encoding]; @@ -842,13 +825,11 @@ if (object == self) return OF_ORDERED_SAME; if (![object isKindOfClass: [OFString class]]) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; otherString = (OFString*)object; otherCStringLength = [otherString UTF8StringLength]; minimumCStringLength = (_s->cStringLength > otherCStringLength ? otherCStringLength : _s->cStringLength); @@ -876,13 +857,11 @@ if (otherString == self) return OF_ORDERED_SAME; if (![otherString isKindOfClass: [OFString class]]) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; otherCString = [otherString UTF8String]; otherCStringLength = [otherString UTF8StringLength]; if (!_s->isUTF8) { @@ -914,12 +893,11 @@ _s->cStringLength - i, &c1); l2 = of_string_utf8_decode(otherCString + j, otherCStringLength - j, &c2); if (l1 == 0 || l2 == 0 || c1 > 0x10FFFF || c2 > 0x10FFFF) - @throw [OFInvalidEncodingException - exceptionWithClass: [self class]]; + @throw [OFInvalidEncodingException exception]; if (c1 >> 8 < OF_UNICODE_CASEFOLDING_TABLE_SIZE) { of_unichar_t tc = of_unicode_casefolding_table[c1 >> 8][c1 & 0xFF]; @@ -966,12 +944,11 @@ of_unichar_t c; size_t length; if ((length = of_string_utf8_decode(_s->cString + i, _s->cStringLength - i, &c)) == 0) - @throw [OFInvalidEncodingException - exceptionWithClass: [self class]]; + @throw [OFInvalidEncodingException exception]; OF_HASH_ADD(hash, (c & 0xFF0000) >> 16); OF_HASH_ADD(hash, (c & 0x00FF00) >> 8); OF_HASH_ADD(hash, c & 0x0000FF); @@ -989,22 +966,21 @@ - (of_unichar_t)characterAtIndex: (size_t)index { of_unichar_t character; if (index >= _s->length) - @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; if (!_s->isUTF8) return _s->cString[index]; index = of_string_utf8_get_position(_s->cString, index, _s->cStringLength); if (!of_string_utf8_decode(_s->cString + index, _s->cStringLength - index, &character)) - @throw [OFInvalidEncodingException - exceptionWithClass: [self class]]; + @throw [OFInvalidEncodingException exception]; return character; } - (void)getCharacters: (of_unichar_t*)buffer @@ -1014,11 +990,11 @@ void *pool = objc_autoreleasePoolPush(); const of_unichar_t *characters = [self characters]; if (range.length > SIZE_MAX - range.location || range.location + range.length > _s->length) - @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; memcpy(buffer, characters + range.location, range.length * sizeof(of_unichar_t)); objc_autoreleasePoolPop(pool); @@ -1032,11 +1008,11 @@ size_t i, cStringLength = [string UTF8StringLength]; size_t rangeLocation, rangeLength; if (range.length > SIZE_MAX - range.location || range.location + range.length > _s->length) - @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; if (_s->isUTF8) { rangeLocation = of_string_utf8_get_position( _s->cString, range.location, _s->cStringLength); rangeLength = of_string_utf8_get_position( @@ -1106,11 +1082,11 @@ { size_t start = range.location; size_t end = range.location + range.length; if (range.length > SIZE_MAX - range.location || end > _s->length) - @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; if (_s->isUTF8) { start = of_string_utf8_get_position(_s->cString, start, _s->cStringLength); end = of_string_utf8_get_position(_s->cString, end, @@ -1324,12 +1300,11 @@ cLen = of_string_utf8_decode(_s->cString + i, _s->cStringLength - i, &c); if (cLen == 0 || c > 0x10FFFF) - @throw [OFInvalidEncodingException - exceptionWithClass: [self class]]; + @throw [OFInvalidEncodingException exception]; ret[j++] = c; i += cLen; } @@ -1353,12 +1328,11 @@ cLen = of_string_utf8_decode(_s->cString + i, _s->cStringLength - i, &c); if (cLen == 0 || c > 0x10FFFF) - @throw [OFInvalidEncodingException - exceptionWithClass: [self class]]; + @throw [OFInvalidEncodingException exception]; if (byteOrder != OF_BYTE_ORDER_NATIVE) ret[j++] = OF_BSWAP32(c); else ret[j++] = c; Index: src/OFTCPSocket+SOCKS5.m ================================================================== --- src/OFTCPSocket+SOCKS5.m +++ src/OFTCPSocket+SOCKS5.m @@ -38,15 +38,13 @@ [self readIntoBuffer: reply exactLength: 2]; if (reply[0] != 5 || reply[1] != 0) { [self close]; - @throw [OFConnectionFailedException - exceptionWithClass: [self class] - socket: self - host: host - port: port]; + @throw [OFConnectionFailedException exceptionWithHost: host + port: port + socket: self]; } wasWriteBufferEnabled = [self isWriteBufferEnabled]; [self setWriteBufferEnabled: true]; @@ -64,15 +62,13 @@ [self readIntoBuffer: reply exactLength: 4]; if (reply[0] != 5 || reply[1] != 0 || reply[2] != 0) { [self close]; - @throw [OFConnectionFailedException - exceptionWithClass: [self class] - socket: self - host: host - port: port]; + @throw [OFConnectionFailedException exceptionWithHost: host + port: port + socket: self]; } /* Skip the rest of the reply */ switch (reply[3]) { case 1: /* IPv4 */ @@ -87,15 +83,13 @@ [self readIntoBuffer: reply exactLength: 16]; break; default: [self close]; - @throw [OFConnectionFailedException - exceptionWithClass: [self class] - socket: self - host: host - port: port]; + @throw [OFConnectionFailedException exceptionWithHost: host + port: port + socket: self]; } [self readBigEndianInt16]; } @end Index: src/OFTCPSocket.m ================================================================== --- src/OFTCPSocket.m +++ src/OFTCPSocket.m @@ -332,13 +332,11 @@ { OFString *destinationHost = host; uint16_t destinationPort = port; if (_socket != INVALID_SOCKET) - @throw [OFAlreadyConnectedException - exceptionWithClass: [self class] - socket: self]; + @throw [OFAlreadyConnectedException exceptionWithSocket: self]; if (_SOCKS5Host != nil) { /* Connect to the SOCKS5 proxy instead */ host = _SOCKS5Host; port = _SOCKS5Port; @@ -355,13 +353,12 @@ snprintf(portCString, 7, "%" PRIu16, port); if (getaddrinfo([host cStringWithEncoding: OF_STRING_ENCODING_NATIVE], portCString, &hints, &res0)) @throw [OFAddressTranslationFailedException - exceptionWithClass: [self class] - socket: self - host: host]; + exceptionWithHost: host + socket: self]; for (res = res0; res != NULL; res = res->ai_next) { if ((_socket = socket(res->ai_family, res->ai_socktype, res->ai_protocol)) == INVALID_SOCKET) continue; @@ -392,25 +389,23 @@ if ((addr.sin_addr.s_addr = inet_addr([host cStringWithEncoding: OF_STRING_ENCODING_NATIVE])) != (in_addr_t)(-1)) { if ((_socket = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) { @throw [OFConnectionFailedException - exceptionWithClass: [self class] - socket: self - host: host - port: port]; + exceptionWithHost: host + port: port + socket: self]; } if (connect(_socket, (struct sockaddr*)&addr, sizeof(addr)) == -1) { close(_socket); _socket = INVALID_SOCKET; @throw [OFConnectionFailedException - exceptionWithClass: [self class] - socket: self - host: host - port: port]; + exceptionWithHost: host + port: port + socket: self]; } if (_SOCKS5Host != nil) [self OF_SOCKS5ConnectToHost: destinationHost port: destinationPort]; @@ -428,26 +423,23 @@ # ifdef OF_HAVE_THREADS [addrlist release]; [mutex unlock]; # endif @throw [OFAddressTranslationFailedException - exceptionWithClass: [self class] - socket: self - host: host]; + exceptionWithHost: host + socket: self]; } if (he->h_addrtype != AF_INET || (_socket = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) { # ifdef OF_HAVE_THREADS [addrlist release]; [mutex unlock]; # endif - @throw [OFConnectionFailedException - exceptionWithClass: [self class] - socket: self - host: host - port: port]; + @throw [OFConnectionFailedException exceptionWithHost: host + port: port + socket: self]; } # ifdef OF_HAVE_THREADS @try { for (ip = he->h_addr_list; *ip != NULL; ip++) @@ -485,15 +477,13 @@ _socket = INVALID_SOCKET; } #endif if (_socket == INVALID_SOCKET) - @throw [OFConnectionFailedException - exceptionWithClass: [self class] - socket: self - host: host - port: port]; + @throw [OFConnectionFailedException exceptionWithHost: host + port: port + socket: self]; if (_SOCKS5Host != nil) [self OF_SOCKS5ConnectToHost: destinationHost port: destinationPort]; } @@ -550,18 +540,15 @@ #ifndef __wii__ socklen_t addrLen; #endif if (_socket != INVALID_SOCKET) - @throw [OFAlreadyConnectedException - exceptionWithClass: [self class] - socket: self]; + @throw [OFAlreadyConnectedException exceptionWithSocket: self]; if (_SOCKS5Host != nil) - @throw [OFNotImplementedException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFNotImplementedException exceptionWithSelector: _cmd + object: self]; #ifdef __wii__ if (port == 0) port = freePort--; #endif @@ -577,35 +564,30 @@ snprintf(portCString, 7, "%" PRIu16, port); if (getaddrinfo([host cStringWithEncoding: OF_STRING_ENCODING_NATIVE], portCString, &hints, &res)) @throw [OFAddressTranslationFailedException - exceptionWithClass: [self class] - socket: self - host: host]; + exceptionWithHost: host + socket: self]; if ((_socket = socket(res->ai_family, SOCK_STREAM, 0)) == INVALID_SOCKET) - @throw [OFBindFailedException exceptionWithClass: [self class] - socket: self - host: host - port: port]; + @throw [OFBindFailedException exceptionWithHost: host + port: port + socket: self]; if (setsockopt(_socket, SOL_SOCKET, SO_REUSEADDR, (const char*)&one, sizeof(one))) - @throw [OFSetOptionFailedException - exceptionWithClass: [self class] - stream: self]; + @throw [OFSetOptionFailedException exceptionWithStream: self]; if (bind(_socket, res->ai_addr, res->ai_addrlen) == -1) { freeaddrinfo(res); close(_socket); _socket = INVALID_SOCKET; - @throw [OFBindFailedException exceptionWithClass: [self class] - socket: self - host: host - port: port]; + @throw [OFBindFailedException exceptionWithHost: host + port: port + socket: self]; } freeaddrinfo(res); #else memset(&addr, 0, sizeof(addr)); @@ -621,20 +603,18 @@ struct hostent *he; if ((he = gethostbyname([host cStringWithEncoding: OF_STRING_ENCODING_NATIVE])) == NULL) @throw [OFAddressTranslationFailedException - exceptionWithClass: [self class] - socket: self - host: host]; + exceptionWithHost: host + socket: self]; if (he->h_addrtype != AF_INET || he->h_addr_list[0] == NULL) { @throw [OFAddressTranslationFailedException - exceptionWithClass: [self class] - socket: self - host: host]; + exceptionWithHost: host + socket: self]; } memcpy(&addr.in.sin_addr.s_addr, he->h_addr_list[0], he->h_length); # ifdef OF_HAVE_THREADS @@ -643,28 +623,24 @@ } # endif } if ((_socket = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) - @throw [OFBindFailedException exceptionWithClass: [self class] - socket: self - host: host - port: port]; + @throw [OFBindFailedException exceptionWithHost: host + port: port + socket: self]; if (setsockopt(_socket, SOL_SOCKET, SO_REUSEADDR, (const char*)&one, sizeof(one))) - @throw [OFSetOptionFailedException - exceptionWithClass: [self class] - stream: self]; + @throw [OFSetOptionFailedException exceptionWithStream: self]; if (bind(_socket, (struct sockaddr*)&addr.in, sizeof(addr.in)) == -1) { close(_socket); _socket = INVALID_SOCKET; - @throw [OFBindFailedException exceptionWithClass: [self class] - socket: self - host: host - port: port]; + @throw [OFBindFailedException exceptionWithHost: host + port: port + socket: self]; } #endif if (port > 0) return port; @@ -672,14 +648,13 @@ #ifndef __wii__ addrLen = sizeof(addr.storage); if (getsockname(_socket, (struct sockaddr*)&addr, &addrLen)) { close(_socket); _socket = INVALID_SOCKET; - @throw [OFBindFailedException exceptionWithClass: [self class] - socket: self - host: host - port: port]; + @throw [OFBindFailedException exceptionWithHost: host + port: port + socket: self]; } if (addr.storage.ss_family == AF_INET) return OF_BSWAP16_IF_LE(addr.in.sin_port); # ifdef AF_INET6 @@ -688,26 +663,23 @@ # endif #endif close(_socket); _socket = INVALID_SOCKET; - @throw [OFBindFailedException exceptionWithClass: [self class] - socket: self - host: host - port: port]; + @throw [OFBindFailedException exceptionWithHost: host + port: port + socket: self]; } - (void)listenWithBackLog: (int)backLog { if (_socket == INVALID_SOCKET) - @throw [OFNotConnectedException exceptionWithClass: [self class] - socket: self]; + @throw [OFNotConnectedException exceptionWithSocket: self]; if (listen(_socket, backLog) == -1) - @throw [OFListenFailedException exceptionWithClass: [self class] - socket: self - backLog: backLog]; + @throw [OFListenFailedException exceptionWithSocket: self + backLog: backLog]; _listening = true; } - (void)listen @@ -726,12 +698,11 @@ addrLen = sizeof(*addr); addr = [client allocMemoryWithSize: addrLen]; if ((socket = accept(_socket, (struct sockaddr*)addr, &addrLen)) == INVALID_SOCKET) - @throw [OFAcceptFailedException exceptionWithClass: [self class] - socket: self]; + @throw [OFAcceptFailedException exceptionWithSocket: self]; client->_socket = socket; client->_sockAddr = addr; client->_sockAddrLen = addrLen; @@ -757,32 +728,28 @@ - (void)setKeepAlivesEnabled: (bool)enable { int v = enable; if (setsockopt(_socket, SOL_SOCKET, SO_KEEPALIVE, (char*)&v, sizeof(v))) - @throw [OFSetOptionFailedException - exceptionWithClass: [self class] - stream: self]; + @throw [OFSetOptionFailedException exceptionWithStream: self]; } - (OFString*)remoteAddress { char *host; if (_sockAddr == NULL || _sockAddrLen == 0) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFNotConnectedException exceptionWithSocket: self]; #ifdef HAVE_THREADSAFE_GETADDRINFO host = [self allocMemoryWithSize: NI_MAXHOST]; @try { if (getnameinfo((struct sockaddr*)_sockAddr, _sockAddrLen, host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST | NI_NUMERICSERV)) @throw [OFAddressTranslationFailedException - exceptionWithClass: [self class]]; + exceptionWithSocket: self]; return [OFString stringWithCString: host encoding: OF_STRING_ENCODING_NATIVE]; } @finally { [self freeMemory: host]; @@ -795,11 +762,11 @@ # endif host = inet_ntoa(((struct sockaddr_in*)_sockAddr)->sin_addr); if (host == NULL) @throw [OFAddressTranslationFailedException - exceptionWithClass: [self class]]; + exceptionWithSocket: self]; return [OFString stringWithCString: host encoding: OF_STRING_ENCODING_NATIVE]; # ifdef OF_HAVE_THREADS } @finally { Index: src/OFThread.m ================================================================== --- src/OFThread.m +++ src/OFThread.m @@ -157,12 +157,12 @@ forTLSKey: (OFTLSKey*)key { id oldObject = of_tlskey_get(key->_key); if (!of_tlskey_set(key->_key, [object retain])) - @throw [OFInvalidArgumentException exceptionWithClass: self - selector: _cmd]; + /* FIXME: Find a better exception */ + @throw [OFInvalidArgumentException exception]; [oldObject release]; } + (id)objectForTLSKey: (OFTLSKey*)key @@ -182,31 +182,31 @@ #endif + (void)sleepForTimeInterval: (double)seconds { if (seconds < 0) - @throw [OFOutOfRangeException exceptionWithClass: self]; + @throw [OFOutOfRangeException exception]; #if defined(HAVE_NANOSLEEP) struct timespec rqtp; rqtp.tv_sec = (time_t)seconds; rqtp.tv_nsec = lrint((seconds - rqtp.tv_sec) * 1000000000); if (rqtp.tv_sec != floor(seconds)) - @throw [OFOutOfRangeException exceptionWithClass: self]; + @throw [OFOutOfRangeException exception]; nanosleep(&rqtp, NULL); #elif !defined(_WIN32) if (seconds > UINT_MAX) - @throw [OFOutOfRangeException exceptionWithClass: self]; + @throw [OFOutOfRangeException exception]; sleep((unsigned int)seconds); usleep((useconds_t)lrint((seconds - floor(seconds)) * 1000000)); #else if (seconds * 1000 > UINT_MAX) - @throw [OFOutOfRangeException exceptionWithClass: self]; + @throw [OFOutOfRangeException exception]; Sleep((unsigned int)(seconds * 1000)); #endif } @@ -299,12 +299,11 @@ - (void)start { if (_running == OF_THREAD_RUNNING) @throw [OFThreadStillRunningException - exceptionWithClass: [self class] - thread: self]; + exceptionWithThread: self]; if (_running == OF_THREAD_WAITING_FOR_JOIN) { of_thread_detach(_thread); [_returnValue release]; } @@ -313,24 +312,20 @@ _running = OF_THREAD_RUNNING; if (!of_thread_new(&_thread, call_main, self)) { [self release]; - @throw [OFThreadStartFailedException - exceptionWithClass: [self class] - thread: self]; + @throw [OFThreadStartFailedException exceptionWithThread: self]; } set_thread_name(self); } - (id)join { if (_running == OF_THREAD_NOT_RUNNING || !of_thread_join(_thread)) - @throw [OFThreadJoinFailedException - exceptionWithClass: [self class] - thread: self]; + @throw [OFThreadJoinFailedException exceptionWithThread: self]; _running = OF_THREAD_NOT_RUNNING; return _returnValue; } @@ -374,12 +369,11 @@ - (void)dealloc { if (_running == OF_THREAD_RUNNING) @throw [OFThreadStillRunningException - exceptionWithClass: [self class] - thread: self]; + exceptionWithThread: self]; /* * We should not be running anymore, but call detach in order to free * the resources. */ Index: src/OFTimer.m ================================================================== --- src/OFTimer.m +++ src/OFTimer.m @@ -351,13 +351,11 @@ - (of_comparison_result_t)compare: (id )object { OFTimer *timer; if (![object isKindOfClass: [OFTimer class]]) - @throw[OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; timer = (OFTimer*)object; return [_fireDate compare: timer->_fireDate]; } Index: src/OFURL.m ================================================================== --- src/OFURL.m +++ src/OFURL.m @@ -59,12 +59,12 @@ @try { char *tmp, *tmp2; if ((UTF8String2 = strdup([string UTF8String])) == NULL) @throw [OFOutOfMemoryException - exceptionWithClass: [self class] - requestedSize: [string UTF8StringLength]]; + exceptionWithRequestedSize: [string + UTF8StringLength]]; UTF8String = UTF8String2; if (!strncmp(UTF8String, "file://", 7)) { _scheme = @"file"; @@ -76,12 +76,11 @@ UTF8String += 7; } else if (!strncmp(UTF8String, "https://", 8)) { _scheme = @"https"; UTF8String += 8; } else - @throw [OFInvalidFormatException - exceptionWithClass: [self class]]; + @throw [OFInvalidFormatException exception]; if ((tmp = strchr(UTF8String, '/')) != NULL) { *tmp = '\0'; tmp++; } @@ -119,12 +118,11 @@ pool = objc_autoreleasePoolPush(); portString = [OFString stringWithUTF8String: tmp2]; if ([portString decimalValue] > 65535) - @throw [OFInvalidFormatException - exceptionWithClass: [self class]]; + @throw [OFInvalidFormatException exception]; _port = [portString decimalValue]; if (_port == 0) _port = 80; @@ -197,12 +195,12 @@ _user = [URL->_user copy]; _password = [URL->_password copy]; if ((UTF8String2 = strdup([string UTF8String])) == NULL) @throw [OFOutOfMemoryException - exceptionWithClass: [self class] - requestedSize: [string UTF8StringLength]]; + exceptionWithRequestedSize: + [string UTF8StringLength]]; UTF8String = UTF8String2; if ((tmp = strchr(UTF8String, '#')) != NULL) { *tmp = '\0'; @@ -258,13 +256,11 @@ @try { void *pool = objc_autoreleasePoolPush(); if (![[element name] isEqual: [self className]] || ![[element namespace] isEqual: OF_SERIALIZATION_NS]) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; self = [self initWithString: [element stringValue]]; objc_autoreleasePoolPop(pool); } @catch (id e) { @@ -374,13 +370,11 @@ } - (void)setScheme: (OFString*)scheme { if (![scheme isEqual: @"http"] && ![scheme isEqual: @"https"]) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; OF_SETTER(_scheme, scheme, true, 1) } - (OFString*)host @@ -430,13 +424,11 @@ - (void)setPath: (OFString*)path { if (([_scheme isEqual: @"http"] || [_scheme isEqual: @"https"]) && ![path hasPrefix: @"/"]) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; OF_SETTER(_path, path, true, 1) } - (OFString*)parameters Index: src/OFXMLAttribute.m ================================================================== --- src/OFXMLAttribute.m +++ src/OFXMLAttribute.m @@ -76,13 +76,11 @@ @try { void *pool = objc_autoreleasePoolPush(); if (![[element name] isEqual: [self className]] || ![[element namespace] isEqual: OF_SERIALIZATION_NS]) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; _name = [[[element attributeForName: @"name"] stringValue] copy]; _namespace = [[[element attributeForName: @"namespace"] stringValue] copy]; Index: src/OFXMLCDATA.m ================================================================== --- src/OFXMLCDATA.m +++ src/OFXMLCDATA.m @@ -51,13 +51,11 @@ @try { void *pool = objc_autoreleasePoolPush(); if (![[element name] isEqual: [self className]] || ![[element namespace] isEqual: OF_SERIALIZATION_NS]) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; _CDATA = [[element stringValue] copy]; objc_autoreleasePoolPop(pool); } @catch (id e) { Index: src/OFXMLCharacters.m ================================================================== --- src/OFXMLCharacters.m +++ src/OFXMLCharacters.m @@ -51,13 +51,11 @@ @try { void *pool = objc_autoreleasePoolPush(); if (![[element name] isEqual: [self className]] || ![[element namespace] isEqual: OF_SERIALIZATION_NS]) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; _characters = [[element stringValue] copy]; objc_autoreleasePoolPop(pool); } @catch (id e) { Index: src/OFXMLComment.m ================================================================== --- src/OFXMLComment.m +++ src/OFXMLComment.m @@ -53,13 +53,11 @@ @try { void *pool = objc_autoreleasePoolPush(); if (![[element name] isEqual: [self className]] || ![[element namespace] isEqual: OF_SERIALIZATION_NS]) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; _comment = [[element stringValue] copy]; objc_autoreleasePoolPop(pool); } @catch (id e) { Index: src/OFXMLElement+Serialization.m ================================================================== --- src/OFXMLElement+Serialization.m +++ src/OFXMLElement+Serialization.m @@ -35,19 +35,17 @@ Class class; id object; if ((class = objc_getClass([_name cStringWithEncoding: OF_STRING_ENCODING_ASCII])) == Nil) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class]]; + @throw [OFInvalidArgumentException exception]; if (![class conformsToProtocol: @protocol(OFSerialization)]) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class]]; + @throw [OFInvalidArgumentException exception]; object = [[class alloc] initWithSerialization: self]; objc_autoreleasePoolPop(pool); return [object autorelease]; } @end Index: src/OFXMLElement.m ================================================================== --- src/OFXMLElement.m +++ src/OFXMLElement.m @@ -165,13 +165,11 @@ { self = [super init]; @try { if (name == nil) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; _name = [name copy]; _namespace = [namespace copy]; _namespaces = [[OFMutableDictionary alloc] @@ -193,13 +191,11 @@ { self = [super init]; @try { if (element == nil) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; _name = [element->_name copy]; _namespace = [element->_namespace copy]; _defaultNamespace = [element->_defaultNamespace copy]; _attributes = [element->_attributes mutableCopy]; @@ -223,12 +219,11 @@ c = [self class]; [self release]; if (string == nil) - @throw [OFInvalidArgumentException exceptionWithClass: c - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; pool = objc_autoreleasePoolPush(); parser = [OFXMLParser parser]; builder = [OFXMLElementBuilder elementBuilder]; @@ -239,12 +234,11 @@ [builder setDelegate: delegate]; [parser parseString: string]; if (![parser finishedParsing]) - @throw [OFMalformedXMLException exceptionWithClass: c - parser: parser]; + @throw [OFMalformedXMLException exceptionWithParser: parser]; self = [delegate->_element retain]; objc_autoreleasePoolPop(pool); @@ -273,12 +267,11 @@ [builder setDelegate: delegate]; [parser parseFile: path]; if (![parser finishedParsing]) - @throw [OFMalformedXMLException exceptionWithClass: c - parser: parser]; + @throw [OFMalformedXMLException exceptionWithParser: parser]; self = [delegate->_element retain]; objc_autoreleasePoolPop(pool); @@ -296,13 +289,11 @@ OFEnumerator *keyEnumerator, *objectEnumerator; id key, object; if (![[element name] isEqual: [self className]] || ![[element namespace] isEqual: OF_SERIALIZATION_NS]) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; _name = [[[element attributeForName: @"name"] stringValue] copy]; _namespace = [[[element attributeForName: @"namespace"] stringValue] copy]; @@ -333,37 +324,29 @@ if ((_attributes != nil && ![_attributes isKindOfClass: [OFMutableArray class]]) || (_namespaces != nil && ![_namespaces isKindOfClass: [OFMutableDictionary class]]) || (_children != nil && ![_children isKindOfClass: [OFMutableArray class]])) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; objectEnumerator = [_attributes objectEnumerator]; while ((object = [objectEnumerator nextObject]) != nil) if (![object isKindOfClass: [OFXMLAttribute class]]) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; keyEnumerator = [_namespaces keyEnumerator]; objectEnumerator = [_namespaces objectEnumerator]; while ((key = [keyEnumerator nextObject]) != nil && (object = [objectEnumerator nextObject]) != nil) if (![key isKindOfClass: [OFString class]] || ![object isKindOfClass: [OFString class]]) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; objectEnumerator = [_children objectEnumerator]; while ((object = [objectEnumerator nextObject]) != nil) if (![object isKindOfClass: [OFXMLNode class]]) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; if (_namespaces == nil) _namespaces = [[OFMutableDictionary alloc] init]; [_namespaces @@ -371,13 +354,11 @@ forKey: @"http://www.w3.org/XML/1998/namespace"]; [_namespaces setObject: @"xmlns" forKey: @"http://www.w3.org/2000/xmlns/"]; if (_name == nil) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; objc_autoreleasePoolPop(pool); } @catch (id e) { [self release]; @throw e; @@ -399,13 +380,11 @@ } - (void)setName: (OFString*)name { if (name == nil) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; OF_SETTER(_name, name, true, 1) } - (OFString*)name @@ -583,14 +562,13 @@ if ([attributesObjects[j] namespace] != nil && (attributePrefix = [allNamespaces objectForKey: [attributesObjects[j] namespace]]) == nil) @throw [OFUnboundNamespaceException - exceptionWithClass: [self class] - namespace: [attributesObjects[j] - namespace] - element: self]; + exceptionWithNamespace: [attributesObjects[j] + namespace] + element: self]; length += [attributeName UTF8StringLength] + (attributePrefix != nil ? [attributePrefix UTF8StringLength] + 1 : 0) + [tmp UTF8StringLength] + 4; @@ -921,13 +899,11 @@ - (void)setPrefix: (OFString*)prefix forNamespace: (OFString*)namespace { if ([prefix length] == 0) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; if (namespace == nil) namespace = @""; [_namespaces setObject: prefix forKey: namespace]; @@ -954,13 +930,11 @@ } - (void)addChild: (OFXMLNode*)child { if ([child isKindOfClass: [OFXMLAttribute class]]) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; if (_children == nil) _children = [[OFMutableArray alloc] init]; [_children addObject: child]; @@ -968,13 +942,11 @@ - (void)insertChild: (OFXMLNode*)child atIndex: (size_t)index { if ([child isKindOfClass: [OFXMLAttribute class]]) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; if (_children == nil) _children = [[OFMutableArray alloc] init]; [_children insertObject: child @@ -988,13 +960,11 @@ OFEnumerator *enumerator = [children objectEnumerator]; OFXMLNode *node; while ((node = [enumerator nextObject]) != nil) if ([node isKindOfClass: [OFXMLAttribute class]]) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; [_children insertObjectsFromArray: children atIndex: index]; objc_autoreleasePoolPop(pool); @@ -1001,13 +971,11 @@ } - (void)removeChild: (OFXMLNode*)child { if ([child isKindOfClass: [OFXMLAttribute class]]) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; [_children removeObject: child]; } - (void)removeChildAtIndex: (size_t)index @@ -1018,25 +986,21 @@ - (void)replaceChild: (OFXMLNode*)child withNode: (OFXMLNode*)node { if ([node isKindOfClass: [OFXMLAttribute class]] || [child isKindOfClass: [OFXMLAttribute class]]) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; [_children replaceObject: child withObject: node]; } - (void)replaceChildAtIndex: (size_t)index withNode: (OFXMLNode*)node { if ([node isKindOfClass: [OFXMLAttribute class]]) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; [_children replaceObjectAtIndex: index withObject: node]; } Index: src/OFXMLElementBuilder.m ================================================================== --- src/OFXMLElementBuilder.m +++ src/OFXMLElementBuilder.m @@ -127,12 +127,11 @@ [_delegate elementBuilder: self didNotExpectCloseTag: name prefix: prefix namespace: namespace]; else - @throw [OFMalformedXMLException - exceptionWithClass: [self class]]; + @throw [OFMalformedXMLException exception]; return; case 1: [_delegate elementBuilder: self didBuildElement: [_stack firstObject]]; Index: src/OFXMLParser.m ================================================================== --- src/OFXMLParser.m +++ src/OFXMLParser.m @@ -125,13 +125,12 @@ attributeNS = namespace_for_prefix(attributePrefix, namespaces); if ((attributePrefix != nil && attributeNS == nil)) @throw [OFUnboundPrefixException - exceptionWithClass: [self class] - prefix: attributePrefix - parser: self]; + exceptionWithPrefix: attributePrefix + parser: self]; [attribute->_namespace release]; attribute->_namespace = [attributeNS retain]; } @@ -322,12 +321,11 @@ _state = OF_XMLPARSER_OUTSIDE_TAG; _i--; return; } - @throw [OFMalformedXMLException exceptionWithClass: [self class] - parser: self]; + @throw [OFMalformedXMLException exceptionWithParser: self]; } if (_level++ == 2) _state = OF_XMLPARSER_OUTSIDE_TAG; @@ -340,12 +338,11 @@ size_t length; if ((_finishedParsing || [_previous count] < 1) && _data[_i] != ' ' && _data[_i] != '\t' && _data[_i] != '\n' && _data[_i] != '\r' && _data[_i] != '<') - @throw [OFMalformedXMLException exceptionWithClass: [self class] - parser: self]; + @throw [OFMalformedXMLException exceptionWithParser: self]; if (_data[_i] != '<') return; if ((length = _i - _last) > 0) @@ -371,12 +368,11 @@ /* Tag was just opened */ - (void)OF_tagOpenedState { if (_finishedParsing && _data[_i] != '!' && _data[_i] != '?') - @throw [OFMalformedXMLException exceptionWithClass: [self class] - parser: self]; + @throw [OFMalformedXMLException exceptionWithParser: self]; switch (_data[_i]) { case '?': _last = _i + 1; _state = OF_XMLPARSER_IN_PROCESSING_INSTRUCTIONS; @@ -393,12 +389,11 @@ _acceptProlog = false; break; default: if (_depthLimit > 0 && [_previous count] >= _depthLimit) @throw [OFMalformedXMLException - exceptionWithClass: [self class] - parser: self]; + exceptionWithParser: self]; _state = OF_XMLPARSER_IN_TAG_NAME; _acceptProlog = false; _i--; break; @@ -522,12 +517,11 @@ if ([PI isEqual: @"xml"] || [PI hasPrefix: @"xml "] || [PI hasPrefix: @"xml\t"] || [PI hasPrefix: @"xml\r"] || [PI hasPrefix: @"xml\n"]) if (![self OF_parseXMLProcessingInstructions: PI]) @throw [OFMalformedXMLException - exceptionWithClass: [self class] - parser: self]; + exceptionWithParser: self]; if ([_delegate respondsToSelector: @selector(parser:foundProcessingInstructions:)]) [_delegate parser: self foundProcessingInstructions: PI]; @@ -582,13 +576,12 @@ namespace = namespace_for_prefix(_prefix, _namespaces); if (_prefix != nil && namespace == nil) @throw [OFUnboundPrefixException - exceptionWithClass: [self class] - prefix: _prefix - parser: self]; + exceptionWithPrefix: _prefix + parser: self]; if ([_delegate respondsToSelector: @selector(parser: didStartElement:prefix:namespace:attributes:)]) [_delegate parser: self didStartElement: _name @@ -662,23 +655,20 @@ _name = [bufferString copy]; _prefix = nil; } if (![[_previous lastObject] isEqual: bufferString]) - @throw [OFMalformedXMLException exceptionWithClass: [self class] - parser: self]; + @throw [OFMalformedXMLException exceptionWithParser: self]; [_previous removeLastObject]; [_buffer removeAllItems]; namespace = namespace_for_prefix(_prefix, _namespaces); if (_prefix != nil && namespace == nil) - @throw [OFUnboundPrefixException - exceptionWithClass: [self class] - prefix: _prefix - parser: self]; + @throw [OFUnboundPrefixException exceptionWithPrefix: _prefix + parser: self]; if ([_delegate respondsToSelector: @selector(parser:didEndElement:prefix:namespace:)]) [_delegate parser: self didEndElement: _name @@ -724,14 +714,12 @@ attributesCount = [_attributes count]; namespace = namespace_for_prefix(_prefix, _namespaces); if (_prefix != nil && namespace == nil) - @throw [OFUnboundPrefixException - exceptionWithClass: [self class] - prefix: _prefix - parser: self]; + @throw [OFUnboundPrefixException exceptionWithPrefix: _prefix + parser: self]; for (j = 0; j < attributesCount; j++) resolve_attribute_namespace(attributesObjects[j], _namespaces, self); @@ -831,12 +819,11 @@ if (_data[_i] == ' ' || _data[_i] == '\t' || _data[_i] == '\n' || _data[_i] == '\r') return; if (_data[_i] != '\'' && _data[_i] != '"') - @throw [OFMalformedXMLException exceptionWithClass: [self class] - parser: self]; + @throw [OFMalformedXMLException exceptionWithParser: self]; _delimiter = _data[_i]; _state = OF_XMLPARSER_IN_ATTR_VALUE; } @@ -884,12 +871,11 @@ { if (_data[_i] == '>') { _last = _i + 1; _state = OF_XMLPARSER_OUTSIDE_TAG; } else - @throw [OFMalformedXMLException exceptionWithClass: [self class] - parser: self]; + @throw [OFMalformedXMLException exceptionWithParser: self]; } /* Expecting closing '>' or space */ - (void)OF_expectSpaceOrCloseState { @@ -896,20 +882,18 @@ if (_data[_i] == '>') { _last = _i + 1; _state = OF_XMLPARSER_OUTSIDE_TAG; } else if (_data[_i] != ' ' && _data[_i] != '\t' && _data[_i] != '\n' && _data[_i] != '\r') - @throw [OFMalformedXMLException exceptionWithClass: [self class] - parser: self]; + @throw [OFMalformedXMLException exceptionWithParser: self]; } /* In ') - @throw [OFMalformedXMLException exceptionWithClass: [self class] - parser: self]; + @throw [OFMalformedXMLException exceptionWithParser: self]; pool = objc_autoreleasePoolPush(); buffer_append(_buffer, _data + _last, _encoding, _i - _last); comment = transform_string(_buffer, 2, false, nil); @@ -1032,12 +1012,11 @@ - (void)OF_inDOCTYPEState { if ((_level < 6 && _data[_i] != "OCTYPE"[_level]) || (_level == 6 && _data[_i] != ' ' && _data[_i] != '\t' && _data[_i] != '\n' && _data[_i] != '\r')) - @throw [OFMalformedXMLException exceptionWithClass: [self class] - parser: self]; + @throw [OFMalformedXMLException exceptionWithParser: self]; _level++; if (_level > 6 && _data[_i] == '>') _state = OF_XMLPARSER_OUTSIDE_TAG; Index: src/OFXMLProcessingInstructions.m ================================================================== --- src/OFXMLProcessingInstructions.m +++ src/OFXMLProcessingInstructions.m @@ -53,13 +53,11 @@ @try { void *pool = objc_autoreleasePoolPush(); if (![[element name] isEqual: [self className]] || ![[element namespace] isEqual: OF_SERIALIZATION_NS]) - @throw [OFInvalidArgumentException - exceptionWithClass: [self class] - selector: _cmd]; + @throw [OFInvalidArgumentException exception]; _processingInstructions = [[element stringValue] copy]; objc_autoreleasePoolPop(pool); } @catch (id e) { Index: src/bridge/NSArray_OFArray.m ================================================================== --- src/bridge/NSArray_OFArray.m +++ src/bridge/NSArray_OFArray.m @@ -47,10 +47,10 @@ - (NSUInteger)count { size_t count = [_array count]; if (count > NSUIntegerMax) - @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; return (NSUInteger)count; } @end Index: src/bridge/NSDictionary_OFDictionary.m ================================================================== --- src/bridge/NSDictionary_OFDictionary.m +++ src/bridge/NSDictionary_OFDictionary.m @@ -54,10 +54,10 @@ - (NSUInteger)count { size_t count = [_dictionary count]; if (count > NSUIntegerMax) - @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; return (NSUInteger)count; } @end Index: src/bridge/OFArray_NSArray.m ================================================================== --- src/bridge/OFArray_NSArray.m +++ src/bridge/OFArray_NSArray.m @@ -44,11 +44,11 @@ - (id)objectAtIndex: (size_t)index { id object; if (index > NSUIntegerMax) - @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + @throw [OFOutOfRangeException exception]; object = [_array objectAtIndex: index]; if ([(NSObject*)object conformsToProtocol: @protocol(NSBridging)]) return [object OFObject]; Index: src/exceptions/OFAcceptFailedException.h ================================================================== --- src/exceptions/OFAcceptFailedException.h +++ src/exceptions/OFAcceptFailedException.h @@ -37,26 +37,22 @@ #endif /*! * @brief Creates a new, autoreleased accept failed exception. * - * @param class_ The class of the object which caused the exception * @param socket The socket which could not accept a connection * @return A new, autoreleased accept failed exception */ -+ (instancetype)exceptionWithClass: (Class)class_ - socket: (OFTCPSocket*)socket; ++ (instancetype)exceptionWithSocket: (OFTCPSocket*)socket; /*! * @brief Initializes an already allocated accept failed exception. * - * @param class_ The class of the object which caused the exception * @param socket The socket which could not accept a connection * @return An initialized accept failed exception */ -- initWithClass: (Class)class_ - socket: (OFTCPSocket*)socket; +- initWithSocket: (OFTCPSocket*)socket; /*! * @brief Returns the socket which could not accept a connection. * * @return The socket which could not accept a connection Index: src/exceptions/OFAcceptFailedException.m ================================================================== --- src/exceptions/OFAcceptFailedException.m +++ src/exceptions/OFAcceptFailedException.m @@ -23,18 +23,16 @@ #import "OFTCPSocket.h" #import "common.h" @implementation OFAcceptFailedException -+ (instancetype)exceptionWithClass: (Class)class - socket: (OFTCPSocket*)socket ++ (instancetype)exceptionWithSocket: (OFTCPSocket*)socket { - return [[[self alloc] initWithClass: class - socket: socket] autorelease]; + return [[[self alloc] initWithSocket: socket] autorelease]; } -- initWithClass: (Class)class +- init { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @@ -42,14 +40,13 @@ } abort(); } -- initWithClass: (Class)class - socket: (OFTCPSocket*)socket +- initWithSocket: (OFTCPSocket*)socket { - self = [super initWithClass: class]; + self = [super init]; _socket = [socket retain]; _errNo = GET_SOCK_ERRNO; return self; @@ -63,12 +60,12 @@ } - (OFString*)description { return [OFString stringWithFormat: - @"Failed to accept connection in socket of type %@! " ERRFMT, - _inClass, ERRPARAM]; + @"Failed to accept connection in socket of class %@! " ERRFMT, + [_socket class], ERRPARAM]; } - (OFTCPSocket*)socket { OF_GETTER(_socket, false) Index: src/exceptions/OFAddressTranslationFailedException.h ================================================================== --- src/exceptions/OFAddressTranslationFailedException.h +++ src/exceptions/OFAddressTranslationFailedException.h @@ -31,55 +31,67 @@ OFString *_host; int _errNo; } #ifdef OF_HAVE_PROPERTIES -@property (readonly, retain, nonatomic) OFTCPSocket *socket; @property (readonly, copy, nonatomic) OFString *host; +@property (readonly, retain, nonatomic) OFTCPSocket *socket; @property (readonly) int errNo; #endif /*! * @brief Creates a new, autoreleased address translation failed exception. * - * @param class_ The class of the object which caused the exception * @param socket The socket which could not translate the address + * @return A new, autoreleased address translation failed exception + */ ++ (instancetype)exceptionWithSocket: (OFTCPSocket*)socket; + +/*! + * @brief Creates a new, autoreleased address translation failed exception. + * * @param host The host for which translation was requested + * @param socket The socket which could not translate the address * @return A new, autoreleased address translation failed exception */ -+ (instancetype)exceptionWithClass: (Class)class_ - socket: (OFTCPSocket*)socket - host: (OFString*)host; ++ (instancetype)exceptionWithHost: (OFString*)host + socket: (OFTCPSocket*)socket; + +/*! + * @brief Initializes an already allocated address translation failed exception. + * + * @param socket The socket which could not translate the address + * @return An initialized address translation failed exception + */ +- initWithSocket: (OFTCPSocket*)socket; /*! * @brief Initializes an already allocated address translation failed exception. * - * @param class_ The class of the object which caused the exception - * @param socket The socket which could not translate the address * @param host The host for which translation was requested + * @param socket The socket which could not translate the address * @return An initialized address translation failed exception */ -- initWithClass: (Class)class_ - socket: (OFTCPSocket*)socket - host: (OFString*)host; - -/*! - * @brief Returns the socket which could not translate the address. - * - * @return The socket which could not translate the address - */ -- (OFTCPSocket*)socket; +- initWithHost: (OFString*)host + socket: (OFTCPSocket*)socket; /*! * @brief Returns the host for which the address translation was requested. * * @return The host for which the address translation was requested */ - (OFString*)host; +/*! + * @brief Returns the socket which could not translate the address. + * + * @return The socket which could not translate the address + */ +- (OFTCPSocket*)socket; + /*! * @brief Returns the errno from when the exception was created. * * @return The errno from when the exception was created */ - (int)errNo; @end Index: src/exceptions/OFAddressTranslationFailedException.m ================================================================== --- src/exceptions/OFAddressTranslationFailedException.m +++ src/exceptions/OFAddressTranslationFailedException.m @@ -21,37 +21,57 @@ #import "OFTCPSocket.h" #import "common.h" @implementation OFAddressTranslationFailedException -+ (instancetype)exceptionWithClass: (Class)class - socket: (OFTCPSocket*)socket - host: (OFString*)host ++ (instancetype)exceptionWithSocket: (OFTCPSocket*)socket +{ + return [[[self alloc] initWithSocket: socket] autorelease]; +} + ++ (instancetype)exceptionWithHost: (OFString*)host + socket: (OFTCPSocket*)socket +{ + return [[[self alloc] initWithHost: host + socket: socket] autorelease]; +} + +- init { - return [[[self alloc] initWithClass: class - socket: socket - host: host] autorelease]; + @try { + [self doesNotRecognizeSelector: _cmd]; + } @catch (id e) { + [self release]; + @throw e; + } + + abort(); } -- initWithClass: (Class)class +- initWithSocket: (OFTCPSocket*)socket { - self = [super initWithClass: class]; + self = [super init]; - _errNo = GET_AT_ERRNO; + @try { + _socket = [socket retain]; + _errNo = GET_AT_ERRNO; + } @catch (id e) { + [self release]; + @throw e; + } return self; } -- initWithClass: (Class)class - socket: (OFTCPSocket*)socket - host: (OFString*)host +- initWithHost: (OFString*)host + socket: (OFTCPSocket*)socket { - self = [super initWithClass: class]; + self = [super init]; @try { - _socket = [socket retain]; _host = [host copy]; + _socket = [socket retain]; _errNo = GET_AT_ERRNO; } @catch (id e) { [self release]; @throw e; } @@ -59,41 +79,43 @@ return self; } - (void)dealloc { - [_socket release]; [_host release]; + [_socket release]; [super dealloc]; } - (OFString*)description { if (_host != nil) return [OFString stringWithFormat: - @"The host %@ could not be translated to an address in " - @"class %@. This means that either the host was not found, " - @"there was a problem with the name server, there was a " - @"problem with your network connection or you specified an " - @"invalid host. " ERRFMT, _host, _inClass, AT_ERRPARAM]; + @"The host %@ could not be translated to an address for a " + @"socket of type %@. This means that either the host was " + @"not found, there was a problem with the name server, " + @"there was a problem with your network connection or you " + @"specified an invalid host. " ERRFMT, _host, + [_socket class], AT_ERRPARAM]; else return [OFString stringWithFormat: - @"An address translation failed in class %@! " ERRFMT, - _inClass, AT_ERRPARAM]; + @"An address could not be translated translation for a " + @"socket of type %@! " ERRFMT, [_socket class], + AT_ERRPARAM]; +} + +- (OFString*)host +{ + OF_GETTER(_host, false) } - (OFTCPSocket*)socket { OF_GETTER(_socket, false) } -- (OFString*)host -{ - OF_GETTER(_host, false) -} - - (int)errNo { return _errNo; } @end Index: src/exceptions/OFAlreadyConnectedException.h ================================================================== --- src/exceptions/OFAlreadyConnectedException.h +++ src/exceptions/OFAlreadyConnectedException.h @@ -36,29 +36,25 @@ #endif /*! * @brief Creates a new, autoreleased already connected exception. * - * @param class_ The class of the object which caused the exception * @param socket The socket which is already connected * @return A new, autoreleased already connected exception */ -+ (instancetype)exceptionWithClass: (Class)class_ - socket: (OFTCPSocket*)socket; ++ (instancetype)exceptionWithSocket: (OFTCPSocket*)socket; /*! * @brief Initializes an already allocated already connected exception. * - * @param class_ The class of the object which caused the exception * @param socket The socket which is already connected * @return An initialized already connected exception */ -- initWithClass: (Class)class_ - socket: (OFTCPSocket*)socket; +- initWithSocket: (OFTCPSocket*)socket; /*! * @brief Returns the socket which is already connected. * * @return The socket which is already connected */ - (OFTCPSocket*)socket; @end Index: src/exceptions/OFAlreadyConnectedException.m ================================================================== --- src/exceptions/OFAlreadyConnectedException.m +++ src/exceptions/OFAlreadyConnectedException.m @@ -23,18 +23,16 @@ #import "OFTCPSocket.h" #import "common.h" @implementation OFAlreadyConnectedException -+ (instancetype)exceptionWithClass: (Class)class - socket: (OFTCPSocket*)socket ++ (instancetype)exceptionWithSocket: (OFTCPSocket*)socket { - return [[[self alloc] initWithClass: class - socket: socket] autorelease]; + return [[[self alloc] initWithSocket: socket] autorelease]; } -- initWithClass: (Class)class +- init { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @@ -42,14 +40,13 @@ } abort(); } -- initWithClass: (Class)class - socket: (OFTCPSocket*)socket +- initWithSocket: (OFTCPSocket*)socket { - self = [super initWithClass: class]; + self = [super init]; _socket = [socket retain]; return self; } @@ -63,13 +60,13 @@ - (OFString*)description { return [OFString stringWithFormat: @"The socket of type %@ is already connected or bound and thus " - @"can't be connected or bound again!", _inClass]; + @"can't be connected or bound again!", [_socket class]]; } - (OFTCPSocket*)socket { OF_GETTER(_socket, false) } @end Index: src/exceptions/OFBindFailedException.h ================================================================== --- src/exceptions/OFBindFailedException.h +++ src/exceptions/OFBindFailedException.h @@ -32,50 +32,39 @@ uint16_t _port; int _errNo; } #ifdef OF_HAVE_PROPERTIES -@property (readonly, retain, nonatomic) OFTCPSocket *socket; @property (readonly, copy, nonatomic) OFString *host; @property (readonly) uint16_t port; +@property (readonly, retain, nonatomic) OFTCPSocket *socket; @property (readonly) int errNo; #endif /*! * @brief Creates a new, autoreleased bind failed exception. * - * @param class_ The class of the object which caused the exception - * @param socket The socket which could not be bound * @param host The host on which binding failed * @param port The port on which binding failed + * @param socket The socket which could not be bound * @return A new, autoreleased bind failed exception */ -+ (instancetype)exceptionWithClass: (Class)class_ - socket: (OFTCPSocket*)socket - host: (OFString*)host - port: (uint16_t)port; ++ (instancetype)exceptionWithHost: (OFString*)host + port: (uint16_t)port + socket: (OFTCPSocket*)socket; /*! * @brief Initializes an already allocated bind failed exception. * - * @param class_ The class of the object which caused the exception - * @param socket The socket which could not be bound * @param host The host on which binding failed * @param port The port on which binding failed + * @param socket The socket which could not be bound * @return An initialized bind failed exception */ -- initWithClass: (Class)class_ - socket: (OFTCPSocket*)socket - host: (OFString*)host - port: (uint16_t)port; - -/*! - * @brief Returns the socket which could not be bound. - * - * @return The socket which could not be bound - */ -- (OFTCPSocket*)socket; +- initWithHost: (OFString*)host + port: (uint16_t)port + socket: (OFTCPSocket*)socket; /*! * @brief Returns the host on which binding failed. * * @return The host on which binding failed @@ -87,12 +76,19 @@ * * @return The port on which binding failed */ - (uint16_t)port; +/*! + * @brief Returns the socket which could not be bound. + * + * @return The socket which could not be bound + */ +- (OFTCPSocket*)socket; + /*! * @brief Returns the errno from when the exception was created. * * @return The errno from when the exception was created */ - (int)errNo; @end Index: src/exceptions/OFBindFailedException.m ================================================================== --- src/exceptions/OFBindFailedException.m +++ src/exceptions/OFBindFailedException.m @@ -23,22 +23,20 @@ #import "OFTCPSocket.h" #import "common.h" @implementation OFBindFailedException -+ (instancetype)exceptionWithClass: (Class)class - socket: (OFTCPSocket*)socket - host: (OFString*)host - port: (uint16_t)port -{ - return [[[self alloc] initWithClass: class - socket: socket - host: host - port: port] autorelease]; ++ (instancetype)exceptionWithHost: (OFString*)host + port: (uint16_t)port + socket: (OFTCPSocket*)socket +{ + return [[[self alloc] initWithHost: host + port: port + socket: socket] autorelease]; } -- initWithClass: (Class)class +- init { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @@ -46,21 +44,20 @@ } abort(); } -- initWithClass: (Class)class - socket: (OFTCPSocket*)socket - host: (OFString*)host - port: (uint16_t)port +- initWithHost: (OFString*)host + port: (uint16_t)port + socket: (OFTCPSocket*)socket { - self = [super initWithClass: class]; + self = [super init]; @try { - _socket = [socket retain]; _host = [host copy]; _port = port; + _socket = [socket retain]; _errNo = GET_SOCK_ERRNO; } @catch (id e) { [self release]; @throw e; } @@ -68,26 +65,21 @@ return self; } - (void)dealloc { - [_socket release]; [_host release]; + [_socket release]; [super dealloc]; } - (OFString*)description { return [OFString stringWithFormat: - @"Binding to port %" @PRIu16 @" on host %@ failed in class %@! " - ERRFMT, _port, _host, _inClass, ERRPARAM]; -} - -- (OFTCPSocket*)socket -{ - OF_GETTER(_socket, false) + @"Binding to port %" @PRIu16 @" on host %@ failed in socket of " + @"type %@! " ERRFMT, _port, _host, [_socket class], ERRPARAM]; } - (OFString*)host { OF_GETTER(_host, false) @@ -95,11 +87,16 @@ - (uint16_t)port { return _port; } + +- (OFTCPSocket*)socket +{ + OF_GETTER(_socket, false) +} - (int)errNo { return _errNo; } @end Index: src/exceptions/OFChangeDirectoryFailedException.h ================================================================== --- src/exceptions/OFChangeDirectoryFailedException.h +++ src/exceptions/OFChangeDirectoryFailedException.h @@ -31,38 +31,34 @@ #endif /*! * @brief Creates a new, autoreleased change directory failed exception. * - * @param class_ The class of the object which caused the exception * @param path A string with the path of the directory to which couldn't be * changed * @return A new, autoreleased change directory failed exception */ -+ (instancetype)exceptionWithClass: (Class)class_ - path: (OFString*)path; ++ (instancetype)exceptionWithPath: (OFString*)path; /*! * @brief Initializes an already allocated change directory failed exception. * - * @param class_ The class of the object which caused the exception * @param path A string with the path of the directory to which couldn't be * changed * @return An initialized change directory failed exception */ -- initWithClass: (Class)class_ - path: (OFString*)path; +- initWithPath: (OFString*)path; + +/*! + * @brief Returns the path to which changing failed. + * + * @return The path to which changing failed + */ +- (OFString*)path; /*! * @brief Returns the errno from when the exception was created. * * @return The errno from when the exception was created */ - (int)errNo; - -/*! - * @brief Returns the path to which changing failed. - * - * @return The path to which changing failed - */ -- (OFString*)path; @end Index: src/exceptions/OFChangeDirectoryFailedException.m ================================================================== --- src/exceptions/OFChangeDirectoryFailedException.m +++ src/exceptions/OFChangeDirectoryFailedException.m @@ -22,18 +22,16 @@ #import "OFString.h" #import "common.h" @implementation OFChangeDirectoryFailedException -+ (instancetype)exceptionWithClass: (Class)class - path: (OFString*)path ++ (instancetype)exceptionWithPath: (OFString*)path { - return [[[self alloc] initWithClass: class - path: path] autorelease]; + return [[[self alloc] initWithPath: path] autorelease]; } -- initWithClass: (Class)class +- init { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @@ -41,14 +39,13 @@ } abort(); } -- initWithClass: (Class)class - path: (OFString*)path +- initWithPath: (OFString*)path { - self = [super initWithClass: class]; + self = [super init]; @try { _path = [path copy]; _errNo = GET_ERRNO; } @catch (id e) { @@ -67,19 +64,18 @@ } - (OFString*)description { return [OFString stringWithFormat: - @"Failed to change to directory %@ in class %@! " ERRFMT, _path, - _inClass, ERRPARAM]; + @"Failed to change to directory %@! " ERRFMT, _path, ERRPARAM]; +} + +- (OFString*)path +{ + OF_GETTER(_path, false) } - (int)errNo { return _errNo; } - -- (OFString*)path -{ - OF_GETTER(_path, false) -} @end Index: src/exceptions/OFChangeFileModeFailedException.h ================================================================== --- src/exceptions/OFChangeFileModeFailedException.h +++ src/exceptions/OFChangeFileModeFailedException.h @@ -35,37 +35,26 @@ #endif /*! * @brief Creates a new, autoreleased change file mode failed exception. * - * @param class_ The class of the object which caused the exception * @param path The path of the file * @param mode The new mode for the file * @return A new, autoreleased change file mode failed exception */ -+ (instancetype)exceptionWithClass: (Class)class_ - path: (OFString*)path - mode: (mode_t)mode; ++ (instancetype)exceptionWithPath: (OFString*)path + mode: (mode_t)mode; /*! * @brief Initializes an already allocated change file mode failed exception. * - * @param class_ The class of the object which caused the exception * @param path The path of the file * @param mode The new mode for the file * @return An initialized change file mode failed exception */ -- initWithClass: (Class)class_ - path: (OFString*)path - mode: (mode_t)mode; - -/*! - * @brief Returns the errno from when the exception was created. - * - * @return The errno from when the exception was created - */ -- (int)errNo; +- initWithPath: (OFString*)path + mode: (mode_t)mode; /*! * @brief Returns the path of the file. * * @return The path of the file @@ -76,6 +65,13 @@ * @brief Returns the new mode for the file. * * @return The new mode for the file */ - (mode_t)mode; + +/*! + * @brief Returns the errno from when the exception was created. + * + * @return The errno from when the exception was created + */ +- (int)errNo; @end Index: src/exceptions/OFChangeFileModeFailedException.m ================================================================== --- src/exceptions/OFChangeFileModeFailedException.m +++ src/exceptions/OFChangeFileModeFailedException.m @@ -22,20 +22,18 @@ #import "OFString.h" #import "common.h" @implementation OFChangeFileModeFailedException -+ (instancetype)exceptionWithClass: (Class)class - path: (OFString*)path - mode: (mode_t)mode -{ - return [[[self alloc] initWithClass: class - path: path - mode: mode] autorelease]; -} - -- initWithClass: (Class)class ++ (instancetype)exceptionWithPath: (OFString*)path + mode: (mode_t)mode +{ + return [[[self alloc] initWithPath: path + mode: mode] autorelease]; +} + +- init { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @@ -43,15 +41,14 @@ } abort(); } -- initWithClass: (Class)class - path: (OFString*)path - mode: (mode_t)mode +- initWithPath: (OFString*)path + mode: (mode_t)mode { - self = [super initWithClass: class]; + self = [super init]; @try { _path = [path copy]; _mode = mode; _errNo = GET_ERRNO; @@ -71,17 +68,12 @@ } - (OFString*)description { return [OFString stringWithFormat: - @"Failed to change mode for file %@ to %d in class %@! " ERRFMT, - _path, _mode, _inClass, ERRPARAM]; -} - -- (int)errNo -{ - return _errNo; + @"Failed to change mode for file %@ to %d! " ERRFMT, _path, _mode, + ERRPARAM]; } - (OFString*)path { OF_GETTER(_path, false) @@ -89,6 +81,11 @@ - (mode_t)mode { return _mode; } + +- (int)errNo +{ + return _errNo; +} @end Index: src/exceptions/OFChangeFileOwnerFailedException.h ================================================================== --- src/exceptions/OFChangeFileOwnerFailedException.h +++ src/exceptions/OFChangeFileOwnerFailedException.h @@ -14,11 +14,11 @@ * file. */ #import "OFException.h" -#ifndef _WIN32 +#ifdef OF_HAVE_CHOWN /*! * @brief An exception indicating that changing the owner of a file failed. */ @interface OFChangeFileOwnerFailedException: OFException { @@ -32,41 +32,30 @@ #endif /*! * @brief Creates a new, autoreleased change file owner failed exception. * - * @param class_ The class of the object which caused the exception * @param path The path of the file * @param owner The new owner for the file * @param group The new group for the file * @return A new, autoreleased change file owner failed exception */ -+ (instancetype)exceptionWithClass: (Class)class_ - path: (OFString*)path - owner: (OFString*)owner - group: (OFString*)group; ++ (instancetype)exceptionWithPath: (OFString*)path + owner: (OFString*)owner + group: (OFString*)group; /*! * @brief Initializes an already allocated change file owner failed exception. * - * @param class_ The class of the object which caused the exception * @param path The path of the file * @param owner The new owner for the file * @param group The new group for the file * @return An initialized change file owner failed exception */ -- initWithClass: (Class)class_ - path: (OFString*)path - owner: (OFString*)owner - group: (OFString*)group; - -/*! - * @brief Returns the errno from when the exception was created. - * - * @return The errno from when the exception was created - */ -- (int)errNo; +- initWithPath: (OFString*)path + owner: (OFString*)owner + group: (OFString*)group; /*! * @brief Returns the path of the file. * * @return The path of the file @@ -84,7 +73,14 @@ * @brief Returns the new group for the file. * * @return The new group for the file */ - (OFString*)group; + +/*! + * @brief Returns the errno from when the exception was created. + * + * @return The errno from when the exception was created + */ +- (int)errNo; @end #endif Index: src/exceptions/OFChangeFileOwnerFailedException.m ================================================================== --- src/exceptions/OFChangeFileOwnerFailedException.m +++ src/exceptions/OFChangeFileOwnerFailedException.m @@ -21,24 +21,22 @@ #import "OFChangeFileOwnerFailedException.h" #import "OFString.h" #import "common.h" -#ifndef _WIN32 +#ifdef OF_HAVE_CHOWN @implementation OFChangeFileOwnerFailedException -+ (instancetype)exceptionWithClass: (Class)class - path: (OFString*)path - owner: (OFString*)owner - group: (OFString*)group -{ - return [[[self alloc] initWithClass: class - path: path - owner: owner - group: group] autorelease]; ++ (instancetype)exceptionWithPath: (OFString*)path + owner: (OFString*)owner + group: (OFString*)group +{ + return [[[self alloc] initWithPath: path + owner: owner + group: group] autorelease]; } -- initWithClass: (Class)class +- init { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @@ -46,16 +44,15 @@ } abort(); } -- initWithClass: (Class)class - path: (OFString*)path - owner: (OFString*)owner - group: (OFString*)group +- initWithPath: (OFString*)path + owner: (OFString*)owner + group: (OFString*)group { - self = [super initWithClass: class]; + self = [super init]; @try { _path = [path copy]; _owner = [owner copy]; _group = [group copy]; @@ -79,25 +76,20 @@ - (OFString*)description { if (_group == nil) return [OFString stringWithFormat: - @"Failed to change owner for file %@ to %@ in class %@! " - ERRFMT, _path, _owner, _inClass, ERRPARAM]; + @"Failed to change owner of file %@ to %@! " + ERRFMT, _path, _owner, ERRPARAM]; else if (_owner == nil) return [OFString stringWithFormat: - @"Failed to change group for file %@ to %@ in class %@! " - ERRFMT, _path, _group, _inClass, ERRPARAM]; + @"Failed to change group of file %@ to %@! " + ERRFMT, _path, _group, ERRPARAM]; else return [OFString stringWithFormat: - @"Failed to change owner for file %@ to %@:%@ in class %@! " - ERRFMT, _path, _owner, _group, _inClass, ERRPARAM]; -} - -- (int)errNo -{ - return _errNo; + @"Failed to change owner of file %@ to %@:%@! " + ERRFMT, _path, _owner, _group, ERRPARAM]; } - (OFString*)path { OF_GETTER(_path, false) @@ -110,7 +102,12 @@ - (OFString*)group { OF_GETTER(_group, false) } + +- (int)errNo +{ + return _errNo; +} @end #endif Index: src/exceptions/OFConditionBroadcastFailedException.h ================================================================== --- src/exceptions/OFConditionBroadcastFailedException.h +++ src/exceptions/OFConditionBroadcastFailedException.h @@ -35,29 +35,25 @@ #endif /*! * @brief Returns a new, autoreleased condition broadcast failed exception. * - * @param class_ The class of the object which caused the exception * @param condition The condition which could not be broadcasted * @return A new, autoreleased condition broadcast failed exception */ -+ (instancetype)exceptionWithClass: (Class)class_ - condition: (OFCondition*)condition; ++ (instancetype)exceptionWithCondition: (OFCondition*)condition; /*! * @brief Initializes an already allocated condition broadcast failed exception. * - * @param class_ The class of the object which caused the exception * @param condition The condition which could not be broadcasted * @return An initialized condition broadcast failed exception */ -- initWithClass: (Class)class_ - condition: (OFCondition*)condition; +- initWithCondition: (OFCondition*)condition; /*! * @brief Returns the condition which could not be broadcasted. * * @return The condition which could not be broadcasted */ - (OFCondition*)condition; @end Index: src/exceptions/OFConditionBroadcastFailedException.m ================================================================== --- src/exceptions/OFConditionBroadcastFailedException.m +++ src/exceptions/OFConditionBroadcastFailedException.m @@ -21,18 +21,16 @@ #import "OFConditionBroadcastFailedException.h" #import "OFString.h" #import "OFCondition.h" @implementation OFConditionBroadcastFailedException -+ (instancetype)exceptionWithClass: (Class)class - condition: (OFCondition*)condition ++ (instancetype)exceptionWithCondition: (OFCondition*)condition { - return [[[self alloc] initWithClass: class - condition: condition] autorelease]; + return [[[self alloc] initWithCondition: condition] autorelease]; } -- initWithClass: (Class)class +- init { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @@ -40,14 +38,13 @@ } abort(); } -- initWithClass: (Class)class - condition: (OFCondition*)condition +- initWithCondition: (OFCondition*)condition { - self = [super initWithClass: class]; + self = [super init]; _condition = [condition retain]; return self; } @@ -60,13 +57,13 @@ } - (OFString*)description { return [OFString stringWithFormat: - @"Broadcasting a condition of type %@ failed!", _inClass]; + @"Broadcasting a condition of type %@ failed!", [_condition class]]; } - (OFCondition*)condition { OF_GETTER(_condition, false) } @end Index: src/exceptions/OFConditionSignalFailedException.h ================================================================== --- src/exceptions/OFConditionSignalFailedException.h +++ src/exceptions/OFConditionSignalFailedException.h @@ -35,29 +35,25 @@ #endif /*! * @brief Creates a new, autoreleased condition signal failed exception. * - * @param class_ The class of the object which caused the exception * @param condition The condition which could not be signaled * @return A new, autoreleased condition signal failed exception */ -+ (instancetype)exceptionWithClass: (Class)class_ - condition: (OFCondition*)condition; ++ (instancetype)exceptionWithCondition: (OFCondition*)condition; /*! * @brief Initializes an already allocated condition signal failed exception. * - * @param class_ The class of the object which caused the exception * @param condition The condition which could not be signaled * @return An initialized condition signal failed exception */ -- initWithClass: (Class)class_ - condition: (OFCondition*)condition; +- initWithCondition: (OFCondition*)condition; /*! * @brief Return the condition which could not be signaled. * * @return The condition which could not be signaled */ - (OFCondition*)condition; @end Index: src/exceptions/OFConditionSignalFailedException.m ================================================================== --- src/exceptions/OFConditionSignalFailedException.m +++ src/exceptions/OFConditionSignalFailedException.m @@ -21,18 +21,16 @@ #import "OFConditionSignalFailedException.h" #import "OFString.h" #import "OFCondition.h" @implementation OFConditionSignalFailedException -+ (instancetype)exceptionWithClass: (Class)class - condition: (OFCondition*)condition ++ (instancetype)exceptionWithCondition: (OFCondition*)condition { - return [[[self alloc] initWithClass: class - condition: condition] autorelease]; + return [[[self alloc] initWithCondition: condition] autorelease]; } -- initWithClass: (Class)class +- init { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @@ -40,14 +38,13 @@ } abort(); } -- initWithClass: (Class)class - condition: (OFCondition*)condition +- initWithCondition: (OFCondition*)condition { - self = [super initWithClass: class]; + self = [super init]; _condition = [condition retain]; return self; } @@ -60,13 +57,13 @@ } - (OFString*)description { return [OFString stringWithFormat: - @"Signaling a condition of type %@ failed!", _inClass]; + @"Signaling a condition of type %@ failed!", [_condition class]]; } - (OFCondition*)condition { OF_GETTER(_condition, false) } @end Index: src/exceptions/OFConditionStillWaitingException.h ================================================================== --- src/exceptions/OFConditionStillWaitingException.h +++ src/exceptions/OFConditionStillWaitingException.h @@ -36,29 +36,25 @@ #endif /*! * @brief Creates a new, autoreleased condition still waiting exception. * - * @param class_ The class of the object which caused the exception * @param condition The condition for which is still being waited * @return A new, autoreleased condition still waiting exception */ -+ (instancetype)exceptionWithClass: (Class)class_ - condition: (OFCondition*)condition; ++ (instancetype)exceptionWithCondition: (OFCondition*)condition; /*! * @brief Initializes an already allocated condition still waiting exception. * - * @param class_ The class of the object which caused the exception * @param condition The condition for which is still being waited * @return An initialized condition still waiting exception */ -- initWithClass: (Class)class_ - condition: (OFCondition*)condition; +- initWithCondition: (OFCondition*)condition; /*! * @brief Return the condition for which is still being waited. * * @return The condition for which is still being waited */ - (OFCondition*)condition; @end Index: src/exceptions/OFConditionStillWaitingException.m ================================================================== --- src/exceptions/OFConditionStillWaitingException.m +++ src/exceptions/OFConditionStillWaitingException.m @@ -21,18 +21,16 @@ #import "OFConditionStillWaitingException.h" #import "OFString.h" #import "OFCondition.h" @implementation OFConditionStillWaitingException -+ (instancetype)exceptionWithClass: (Class)class - condition: (OFCondition*)condition ++ (instancetype)exceptionWithCondition: (OFCondition*)condition { - return [[[self alloc] initWithClass: class - condition: condition] autorelease]; + return [[[self alloc] initWithCondition: condition] autorelease]; } -- initWithClass: (Class)class +- init { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @@ -40,14 +38,13 @@ } abort(); } -- initWithClass: (Class)class - condition: (OFCondition*)condition +- initWithCondition: (OFCondition*)condition { - self = [super initWithClass: class]; + self = [super init]; _condition = [condition retain]; return self; } @@ -61,13 +58,13 @@ - (OFString*)description { return [OFString stringWithFormat: @"Deallocation of a condition of type %@ was tried, even though a " - @"thread was still waiting for it!", _inClass]; + @"thread was still waiting for it!", [_condition class]]; } - (OFCondition*)condition { OF_GETTER(_condition, false) } @end Index: src/exceptions/OFConditionWaitFailedException.h ================================================================== --- src/exceptions/OFConditionWaitFailedException.h +++ src/exceptions/OFConditionWaitFailedException.h @@ -35,29 +35,25 @@ #endif /*! * @brief Creates a new, autoreleased condition wait failed exception. * - * @param class_ The class of the object which caused the exception * @param condition The condition for which could not be waited * @return A new, autoreleased condition wait failed exception */ -+ (instancetype)exceptionWithClass: (Class)class_ - condition: (OFCondition*)condition; ++ (instancetype)exceptionWithCondition: (OFCondition*)condition; /*! * @brief Initializes an already allocated condition wait failed exception. * - * @param class_ The class of the object which caused the exception * @param condition The condition for which could not be waited * @return An initialized condition wait failed exception */ -- initWithClass: (Class)class_ - condition: (OFCondition*)condition; +- initWithCondition: (OFCondition*)condition; /*! * @brief Return the condition for which could not be waited. * * @return The condition for which could not be waited */ - (OFCondition*)condition; @end Index: src/exceptions/OFConditionWaitFailedException.m ================================================================== --- src/exceptions/OFConditionWaitFailedException.m +++ src/exceptions/OFConditionWaitFailedException.m @@ -21,18 +21,16 @@ #import "OFConditionWaitFailedException.h" #import "OFString.h" #import "OFCondition.h" @implementation OFConditionWaitFailedException -+ (instancetype)exceptionWithClass: (Class)class - condition: (OFCondition*)condition ++ (instancetype)exceptionWithCondition: (OFCondition*)condition { - return [[[self alloc] initWithClass: class - condition: condition] autorelease]; + return [[[self alloc] initWithCondition: condition] autorelease]; } -- initWithClass: (Class)class +- init { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @@ -40,14 +38,13 @@ } abort(); } -- initWithClass: (Class)class - condition: (OFCondition*)condition +- initWithCondition: (OFCondition*)condition { - self = [super initWithClass: class]; + self = [super init]; _condition = [condition retain]; return self; } @@ -60,13 +57,13 @@ } - (OFString*)description { return [OFString stringWithFormat: - @"Waiting for a condition of type %@ failed!", _inClass]; + @"Waiting for a condition of type %@ failed!", [_condition class]]; } - (OFCondition*)condition { OF_GETTER(_condition, false) } @end Index: src/exceptions/OFConnectionFailedException.h ================================================================== --- src/exceptions/OFConnectionFailedException.h +++ src/exceptions/OFConnectionFailedException.h @@ -41,34 +41,30 @@ #endif /*! * @brief Creates a new, autoreleased connection failed exception. * - * @param class_ The class of the object which caused the exception - * @param socket The socket which could not connect * @param host The host to which the connection failed * @param port The port on the host to which the connection failed + * @param socket The socket which could not connect * @return A new, autoreleased connection failed exception */ -+ (instancetype)exceptionWithClass: (Class)class_ - socket: (OFTCPSocket*)socket - host: (OFString*)host - port: (uint16_t)port; ++ (instancetype)exceptionWithHost: (OFString*)host + port: (uint16_t)port + socket: (OFTCPSocket*)socket; /*! * @brief Initializes an already allocated connection failed exception. * - * @param class_ The class of the object which caused the exception - * @param socket The socket which could not connect * @param host The host to which the connection failed * @param port The port on the host to which the connection failed + * @param socket The socket which could not connect * @return An initialized connection failed exception */ -- initWithClass: (Class)class_ - socket: (OFTCPSocket*)socket - host: (OFString*)host - port: (uint16_t)port; +- initWithHost: (OFString*)host + port: (uint16_t)port + socket: (OFTCPSocket*)socket; /*! * @brief Returns the socket which could not connect. * * @return The socket which could not connect Index: src/exceptions/OFConnectionFailedException.m ================================================================== --- src/exceptions/OFConnectionFailedException.m +++ src/exceptions/OFConnectionFailedException.m @@ -23,22 +23,20 @@ #import "OFTCPSocket.h" #import "common.h" @implementation OFConnectionFailedException -+ (instancetype)exceptionWithClass: (Class)class - socket: (OFTCPSocket*)socket - host: (OFString*)host - port: (uint16_t)port -{ - return [[[self alloc] initWithClass: class - socket: socket - host: host - port: port] autorelease]; -} - -- initWithClass: (Class)class ++ (instancetype)exceptionWithHost: (OFString*)host + port: (uint16_t)port + socket: (OFTCPSocket*)socket +{ + return [[[self alloc] initWithHost: host + port: port + socket: socket] autorelease]; +} + +- init { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @@ -46,20 +44,19 @@ } abort(); } -- initWithClass: (Class)class - socket: (OFTCPSocket*)socket - host: (OFString*)host - port: (uint16_t)port +- initWithHost: (OFString*)host + port: (uint16_t)port + socket: (OFTCPSocket*)socket { - self = [super initWithClass: class]; + self = [super init]; @try { - _socket = [socket retain]; _host = [host copy]; + _socket = [socket retain]; _port = port; _errNo = GET_SOCK_ERRNO; } @catch (id e) { [self release]; @throw e; @@ -68,27 +65,22 @@ return self; } - (void)dealloc { - [_socket release]; [_host release]; + [_socket release]; [super dealloc]; } - (OFString*)description { return [OFString stringWithFormat: @"A connection to %@ on port %" @PRIu16 @" could not be " - @"established in class %@! " ERRFMT, _host, _port, _inClass, - ERRPARAM]; -} - -- (OFTCPSocket*)socket -{ - OF_GETTER(_socket, false) + @"established in socket of type %@! " ERRFMT, _host, _port, + [_socket class], ERRPARAM]; } - (OFString*)host { OF_GETTER(_host, false) @@ -96,11 +88,16 @@ - (uint16_t)port { return _port; } + +- (OFTCPSocket*)socket +{ + OF_GETTER(_socket, false) +} - (int)errNo { return _errNo; } @end Index: src/exceptions/OFCopyFileFailedException.h ================================================================== --- src/exceptions/OFCopyFileFailedException.h +++ src/exceptions/OFCopyFileFailedException.h @@ -32,37 +32,26 @@ #endif /*! * @brief Creates a new, autoreleased copy file failed exception. * - * @param class_ The class of the object which caused the exception * @param sourcePath The original path * @param destinationPath The new path * @return A new, autoreleased copy file failed exception */ -+ (instancetype)exceptionWithClass: (Class)class_ - sourcePath: (OFString*)sourcePath - destinationPath: (OFString*)destinationPath; ++ (instancetype)exceptionWithSourcePath: (OFString*)sourcePath + destinationPath: (OFString*)destinationPath; /*! * @brief Initializes an already allocated copy file failed exception. * - * @param class_ The class of the object which caused the exception * @param sourcePath The original path * @param destinationPath The new path * @return An initialized copy file failed exception */ -- initWithClass: (Class)class_ - sourcePath: (OFString*)sourcePath - destinationPath: (OFString*)destinationPath; - -/*! - * @brief Returns the errno from when the exception was created. - * - * @return The errno from when the exception was created - */ -- (int)errNo; +- initWithSourcePath: (OFString*)sourcePath + destinationPath: (OFString*)destinationPath; /*! * @brief Returns the path of the source file. * * @return The path of the source file @@ -73,6 +62,13 @@ * @brief Returns the destination path. * * @return The destination path */ - (OFString*)destinationPath; + +/*! + * @brief Returns the errno from when the exception was created. + * + * @return The errno from when the exception was created + */ +- (int)errNo; @end Index: src/exceptions/OFCopyFileFailedException.m ================================================================== --- src/exceptions/OFCopyFileFailedException.m +++ src/exceptions/OFCopyFileFailedException.m @@ -22,20 +22,18 @@ #import "OFString.h" #import "common.h" @implementation OFCopyFileFailedException -+ (instancetype)exceptionWithClass: (Class)class - sourcePath: (OFString*)sourcePath - destinationPath: (OFString*)destinationPath ++ (instancetype)exceptionWithSourcePath: (OFString*)sourcePath + destinationPath: (OFString*)destinationPath { - return [[[self alloc] initWithClass: class - sourcePath: sourcePath - destinationPath: destinationPath] autorelease]; + return [[[self alloc] initWithSourcePath: sourcePath + destinationPath: destinationPath] autorelease]; } -- initWithClass: (Class)class +- init { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @@ -43,15 +41,14 @@ } abort(); } -- initWithClass: (Class)class - sourcePath: (OFString*)sourcePath - destinationPath: (OFString*)destinationPath +- initWithSourcePath: (OFString*)sourcePath + destinationPath: (OFString*)destinationPath { - self = [super initWithClass: class]; + self = [super init]; @try { _sourcePath = [sourcePath copy]; _destinationPath = [destinationPath copy]; _errNo = GET_ERRNO; @@ -72,17 +69,12 @@ } - (OFString*)description { return [OFString stringWithFormat: - @"Failed to copy file %@ to %@ in class %@! " ERRFMT, - _sourcePath, _destinationPath, _inClass, ERRPARAM]; -} - -- (int)errNo -{ - return _errNo; + @"Failed to copy file %@ to %@! " ERRFMT, _sourcePath, + _destinationPath, ERRPARAM]; } - (OFString*)sourcePath { OF_GETTER(_sourcePath, false) @@ -90,6 +82,11 @@ - (OFString*)destinationPath { OF_GETTER(_destinationPath, false) } + +- (int)errNo +{ + return _errNo; +} @end Index: src/exceptions/OFCreateDirectoryFailedException.h ================================================================== --- src/exceptions/OFCreateDirectoryFailedException.h +++ src/exceptions/OFCreateDirectoryFailedException.h @@ -31,37 +31,33 @@ #endif /*! * @brief Creates a new, autoreleased create directory failed exception. * - * @param class_ The class of the object which caused the exception * @param path A string with the path of the directory which couldn't be created * @return A new, autoreleased create directory failed exception */ -+ (instancetype)exceptionWithClass: (Class)class_ - path: (OFString*)path; ++ (instancetype)exceptionWithPath: (OFString*)path; /*! * @brief Initializes an already allocated create directory failed exception. * - * @param class_ The class of the object which caused the exception * @param path A string with the path of the directory which couldn't be created * @return An initialized create directory failed exception */ -- initWithClass: (Class)class_ - path: (OFString*)path; - -/*! - * @brief Returns the errno from when the exception was created. - * - * @return The errno from when the exception was created - */ -- (int)errNo; +- initWithPath: (OFString*)path; /*! * @brief Returns a string with the path of the directory which couldn't be * created. * * @return A string with the path of the directory which couldn't be created */ - (OFString*)path; + +/*! + * @brief Returns the errno from when the exception was created. + * + * @return The errno from when the exception was created + */ +- (int)errNo; @end Index: src/exceptions/OFCreateDirectoryFailedException.m ================================================================== --- src/exceptions/OFCreateDirectoryFailedException.m +++ src/exceptions/OFCreateDirectoryFailedException.m @@ -22,18 +22,16 @@ #import "OFString.h" #import "common.h" @implementation OFCreateDirectoryFailedException -+ (instancetype)exceptionWithClass: (Class)class - path: (OFString*)path ++ (instancetype)exceptionWithPath: (OFString*)path { - return [[[self alloc] initWithClass: class - path: path] autorelease]; + return [[[self alloc] initWithPath: path] autorelease]; } -- initWithClass: (Class)class +- init { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @@ -41,14 +39,13 @@ } abort(); } -- initWithClass: (Class)class - path: (OFString*)path +- initWithPath: (OFString*)path { - self = [super initWithClass: class]; + self = [super init]; @try { _path = [path copy]; _errNo = GET_ERRNO; } @catch (id e) { @@ -67,19 +64,18 @@ } - (OFString*)description { return [OFString stringWithFormat: - @"Failed to create directory %@ in class %@! " ERRFMT, _path, - _inClass, ERRPARAM]; + @"Failed to create directory %@! " ERRFMT, _path, ERRPARAM]; +} + +- (OFString*)path +{ + OF_GETTER(_path, false) } - (int)errNo { return _errNo; } - -- (OFString*)path -{ - OF_GETTER(_path, false) -} @end Index: src/exceptions/OFDeleteDirectoryFailedException.h ================================================================== --- src/exceptions/OFDeleteDirectoryFailedException.h +++ src/exceptions/OFDeleteDirectoryFailedException.h @@ -31,36 +31,32 @@ #endif /*! * @brief Creates a new, autoreleased delete directory failed exception. * - * @param class_ The class of the object which caused the exception * @param path The path of the directory * @return A new, autoreleased delete directory failed exception */ -+ (instancetype)exceptionWithClass: (Class)class_ - path: (OFString*)path; ++ (instancetype)exceptionWithPath: (OFString*)path; /*! * @brief Initializes an already allocated delete directory failed exception. * - * @param class_ The class of the object which caused the exception * @param path The path of the directory * @return An initialized delete directory failed exception */ -- initWithClass: (Class)class_ - path: (OFString*)path; +- initWithPath: (OFString*)path; + +/*! + * @brief Returns the path of the directory. + * + * @return The path of the directory + */ +- (OFString*)path; /*! * @brief Returns the errno from when the exception was created. * * @return The errno from when the exception was created */ - (int)errNo; - -/*! - * @brief Returns the path of the directory. - * - * @return The path of the directory - */ -- (OFString*)path; @end Index: src/exceptions/OFDeleteDirectoryFailedException.m ================================================================== --- src/exceptions/OFDeleteDirectoryFailedException.m +++ src/exceptions/OFDeleteDirectoryFailedException.m @@ -22,18 +22,16 @@ #import "OFString.h" #import "common.h" @implementation OFDeleteDirectoryFailedException -+ (instancetype)exceptionWithClass: (Class)class - path: (OFString*)path_ ++ (instancetype)exceptionWithPath: (OFString*)path_ { - return [[[self alloc] initWithClass: class - path: path_] autorelease]; + return [[[self alloc] initWithPath: path_] autorelease]; } -- initWithClass: (Class)class +- init { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @@ -41,14 +39,13 @@ } abort(); } -- initWithClass: (Class)class - path: (OFString*)path +- initWithPath: (OFString*)path { - self = [super initWithClass: class]; + self = [super init]; @try { _path = [path copy]; _errNo = GET_ERRNO; } @catch (id e) { @@ -67,19 +64,18 @@ } - (OFString*)description { return [OFString stringWithFormat: - @"Failed to delete directory %@ in class %@! " ERRFMT, _path, - _inClass, ERRPARAM]; + @"Failed to delete directory %@! " ERRFMT, _path, ERRPARAM]; +} + +- (OFString*)path +{ + OF_GETTER(_path, false) } - (int)errNo { return _errNo; } - -- (OFString*)path -{ - OF_GETTER(_path, false) -} @end Index: src/exceptions/OFDeleteFileFailedException.h ================================================================== --- src/exceptions/OFDeleteFileFailedException.h +++ src/exceptions/OFDeleteFileFailedException.h @@ -31,36 +31,32 @@ #endif /*! * @brief Creates a new, autoreleased delete file failed exception. * - * @param class_ The class of the object which caused the exception * @param path The path of the file * @return A new, autoreleased delete file failed exception */ -+ (instancetype)exceptionWithClass: (Class)class_ - path: (OFString*)path; ++ (instancetype)exceptionWithPath: (OFString*)path; /*! * @brief Initializes an already allocated delete file failed exception. * - * @param class_ The class of the object which caused the exception * @param path The path of the file * @return An initialized delete file failed exception */ -- initWithClass: (Class)class_ - path: (OFString*)path; +- initWithPath: (OFString*)path; + +/*! + * @brief Returns the path of the file. + * + * @return The path of the file + */ +- (OFString*)path; /*! * @brief Returns the errno from when the exception was created. * * @return The errno from when the exception was created */ - (int)errNo; - -/*! - * @brief Returns the path of the file. - * - * @return The path of the file - */ -- (OFString*)path; @end Index: src/exceptions/OFDeleteFileFailedException.m ================================================================== --- src/exceptions/OFDeleteFileFailedException.m +++ src/exceptions/OFDeleteFileFailedException.m @@ -22,18 +22,16 @@ #import "OFString.h" #import "common.h" @implementation OFDeleteFileFailedException -+ (instancetype)exceptionWithClass: (Class)class - path: (OFString*)path ++ (instancetype)exceptionWithPath: (OFString*)path { - return [[[self alloc] initWithClass: class - path: path] autorelease]; + return [[[self alloc] initWithPath: path] autorelease]; } -- initWithClass: (Class)class +- init { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @@ -41,14 +39,13 @@ } abort(); } -- initWithClass: (Class)class - path: (OFString*)path +- initWithPath: (OFString*)path { - self = [super initWithClass: class]; + self = [super init]; @try { _path = [path copy]; _errNo = GET_ERRNO; } @catch (id e) { @@ -67,19 +64,18 @@ } - (OFString*)description { return [OFString stringWithFormat: - @"Failed to delete file %@ in class %@! " ERRFMT, _path, _inClass, - ERRPARAM]; + @"Failed to delete file %@! " ERRFMT, _path, ERRPARAM]; +} + +- (OFString*)path +{ + OF_GETTER(_path, false) } - (int)errNo { return _errNo; } - -- (OFString*)path -{ - OF_GETTER(_path, false) -} @end Index: src/exceptions/OFEnumerationMutationException.h ================================================================== --- src/exceptions/OFEnumerationMutationException.h +++ src/exceptions/OFEnumerationMutationException.h @@ -30,29 +30,25 @@ #endif /*! * @brief Creates a new, autoreleased enumeration mutation exception. * - * @param class_ The class of the object which caused the exception * @param object The object which was mutated during enumeration * @return A new, autoreleased enumeration mutation exception */ -+ (instancetype)exceptionWithClass: (Class)class_ - object: (id)object; ++ (instancetype)exceptionWithObject: (id)object; /*! * @brief Initializes an already allocated enumeration mutation exception. * - * @param class_ The class of the object which caused the exception * @param object The object which was mutated during enumeration * @return An initialized enumeration mutation exception */ -- initWithClass: (Class)class_ - object: (id)object; +- initWithObject: (id)object; /*! * @brief Returns the object which was mutated during enumeration. * * @return The object which was mutated during enumeration */ - (id)object; @end Index: src/exceptions/OFEnumerationMutationException.m ================================================================== --- src/exceptions/OFEnumerationMutationException.m +++ src/exceptions/OFEnumerationMutationException.m @@ -22,18 +22,16 @@ #import "OFString.h" #import "common.h" @implementation OFEnumerationMutationException -+ (instancetype)exceptionWithClass: (Class)class - object: (id)object ++ (instancetype)exceptionWithObject: (id)object { - return [[[self alloc] initWithClass: class - object: object] autorelease]; + return [[[self alloc] initWithObject: object] autorelease]; } -- initWithClass: (Class)class +- init { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @@ -41,14 +39,13 @@ } abort(); } -- initWithClass: (Class)class - object: (id)object +- initWithObject: (id)object { - self = [super initWithClass: class]; + self = [super init]; _object = [object retain]; return self; } @@ -61,13 +58,14 @@ } - (OFString*)description { return [OFString stringWithFormat: - @"Object of class %@ was mutated during enumeration!", _inClass]; + @"Object of class %@ was mutated during enumeration!", + [_object class]]; } - (id)object { OF_GETTER(_object, false) } @end Index: src/exceptions/OFException.h ================================================================== --- src/exceptions/OFException.h +++ src/exceptions/OFException.h @@ -28,40 +28,19 @@ * The OFException class is the base class for all exceptions in ObjFW, except * the OFAllocFailedException. */ @interface OFException: OFObject { - Class _inClass; void *_backtrace[OF_BACKTRACE_SIZE]; } -#ifdef OF_HAVE_PROPERTIES -@property (readonly) Class inClass; -#endif - /*! * @brief Creates a new, autoreleased exception. * - * @param class_ The class of the object which caused the exception * @return A new, autoreleased exception */ -+ (instancetype)exceptionWithClass: (Class)class_; - -/*! - * @brief Initializes an already allocated OFException. - * - * @param class_ The class of the object which caused the exception - * @return An initialized OFException - */ -- initWithClass: (Class)class_; - -/*! - * @brief Returns the class of the object in which the exception occurred. - * - * @return The class of the object in which the exception occurred - */ -- (Class)inClass; ++ (instancetype)exception; /*! * @brief Returns a description of the exception. * * @return A description of the exception Index: src/exceptions/OFException.m ================================================================== --- src/exceptions/OFException.m +++ src/exceptions/OFException.m @@ -57,52 +57,32 @@ return _URC_END_OF_STACK; } @implementation OFException -+ (instancetype)exceptionWithClass: (Class)class ++ (instancetype)exception { - return [[[self alloc] initWithClass: class] autorelease]; + return [[[self alloc] init] autorelease]; } - init { - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); -} - -- initWithClass: (Class)class -{ struct backtrace_ctx ctx; self = [super init]; - _inClass = class; - ctx.backtrace = _backtrace; ctx.i = 0; _Unwind_Backtrace(backtrace_callback, &ctx); return self; } -- (Class)inClass -{ - return _inClass; -} - - (OFString*)description { return [OFString stringWithFormat: - @"An exception of class %@ occurred in class %@!", - object_getClass(self), _inClass]; + @"An exception of type %@ occurred!", [self class]]; } - (OFArray*)backtrace { OFMutableArray *backtrace = [OFMutableArray array]; Index: src/exceptions/OFHTTPRequestFailedException.h ================================================================== --- src/exceptions/OFHTTPRequestFailedException.h +++ src/exceptions/OFHTTPRequestFailedException.h @@ -38,30 +38,26 @@ #endif /*! * @brief Creates a new, autoreleased HTTP request failed exception. * - * @param class_ The class of the object which caused the exception * @param request The HTTP request which failed * @param reply The reply of the failed HTTP request * @return A new, autoreleased HTTP request failed exception */ -+ (instancetype)exceptionWithClass: (Class)class_ - request: (OFHTTPRequest*)request - reply: (OFHTTPRequestReply*)reply; ++ (instancetype)exceptionWithRequest: (OFHTTPRequest*)request + reply: (OFHTTPRequestReply*)reply; /*! * @brief Initializes an already allocated HTTP request failed exception. * - * @param class_ The class of the object which caused the exception * @param request The HTTP request which failed * @param reply The reply of the failed HTTP request * @return A new HTTP request failed exception */ -- initWithClass: (Class)class_ - request: (OFHTTPRequest*)request - reply: (OFHTTPRequestReply*)reply; +- initWithRequest: (OFHTTPRequest*)request + reply: (OFHTTPRequestReply*)reply; /*! * @brief Returns the HTTP request which failed. * * @return The HTTP request which failed Index: src/exceptions/OFHTTPRequestFailedException.m ================================================================== --- src/exceptions/OFHTTPRequestFailedException.m +++ src/exceptions/OFHTTPRequestFailedException.m @@ -24,20 +24,18 @@ #import "OFHTTPRequestReply.h" #import "common.h" @implementation OFHTTPRequestFailedException -+ (instancetype)exceptionWithClass: (Class)class - request: (OFHTTPRequest*)request - reply: (OFHTTPRequestReply*)reply ++ (instancetype)exceptionWithRequest: (OFHTTPRequest*)request + reply: (OFHTTPRequestReply*)reply { - return [[[self alloc] initWithClass: class - request: request - reply: reply] autorelease]; + return [[[self alloc] initWithRequest: request + reply: reply] autorelease]; } -- initWithClass: (Class)class +- init { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @@ -45,15 +43,14 @@ } abort(); } -- initWithClass: (Class)class - request: (OFHTTPRequest*)request - reply: (OFHTTPRequestReply*)reply +- initWithRequest: (OFHTTPRequest*)request + reply: (OFHTTPRequestReply*)reply { - self = [super initWithClass: class]; + self = [super init]; _request = [request retain]; _reply = [reply retain]; return self; @@ -82,12 +79,12 @@ type = "POST"; break; } return [OFString stringWithFormat: - @"A HTTP %s request in class %@ with URL %@ failed with code %d", - type, _inClass, [_request URL], [_reply statusCode]]; + @"A HTTP %s request with URL %@ failed with code %d!", type, + [_request URL], [_reply statusCode]]; } - (OFHTTPRequest*)request { OF_GETTER(_request, false) Index: src/exceptions/OFHashAlreadyCalculatedException.h ================================================================== --- src/exceptions/OFHashAlreadyCalculatedException.h +++ src/exceptions/OFHashAlreadyCalculatedException.h @@ -30,29 +30,25 @@ #endif /*! * @brief Creates a new, autoreleased hash already calculated exception. * - * @param class_ The class of the object which caused the exception - * @param hashObject The hash which has already been calculated + * @param hash The hash which has already been calculated * @return A new, autoreleased hash already calculated exception */ -+ (instancetype)exceptionWithClass: (Class)class_ - hash: (id )hashObject; ++ (instancetype)exceptionWithHash: (id )hash; /*! * @brief Initializes an already allocated hash already calculated exception. * - * @param class_ The class of the object which caused the exception - * @param hashObject The hash which has already been calculated + * @param hash The hash which has already been calculated * @return An initialized hash already calculated exception */ -- initWithClass: (Class)class_ - hash: (id )hashObject; +- initWithHash: (id )hash; /*! * @brief Returns the hash which has already been calculated. * * @return The hash which has already been calculated */ - (id )hashObject; @end Index: src/exceptions/OFHashAlreadyCalculatedException.m ================================================================== --- src/exceptions/OFHashAlreadyCalculatedException.m +++ src/exceptions/OFHashAlreadyCalculatedException.m @@ -22,18 +22,16 @@ #import "OFString.h" #import "common.h" @implementation OFHashAlreadyCalculatedException -+ (instancetype)exceptionWithClass: (Class)class - hash: (id )hash ++ (instancetype)exceptionWithHash: (id )hash { - return [[[self alloc] initWithClass: class - hash: hash] autorelease]; + return [[[self alloc] initWithHash: hash] autorelease]; } -- initWithClass: (Class)class +- init { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @@ -41,14 +39,13 @@ } abort(); } -- initWithClass: (Class)class - hash: (id )hashObject +- initWithHash: (id )hashObject { - self = [super initWithClass: class]; + self = [super init]; _hashObject = [hashObject retain]; return self; } @@ -61,14 +58,14 @@ } - (OFString*)description { return [OFString stringWithFormat: - @"The hash has already been calculated in class %@ and thus no new " - @"data can be added", _inClass]; + @"The hash of type %@ has already been calculated and thus no new " + @"data can be added!", [_hashObject class]]; } - (id )hashObject { OF_GETTER(_hashObject, false) } @end Index: src/exceptions/OFInitializationFailedException.h ================================================================== --- src/exceptions/OFInitializationFailedException.h +++ src/exceptions/OFInitializationFailedException.h @@ -18,6 +18,36 @@ /*! * @brief An exception indicating that initializing something failed. */ @interface OFInitializationFailedException: OFException +{ + Class _inClass; +} + +#ifdef OF_HAVE_PROPERTIES +@property (readonly) Class inClass; +#endif + +/*! + * @brief Creates a new, autoreleased initialization failed exception. + * + * @param class_ The class for which initialization failed + * @return A new, autoreleased initialization failed exception + */ ++ (instancetype)exceptionWithClass: (Class)class_; + +/*! + * @brief Initializes an already allocated initialization failed exception. + * + * @param class_ The class for which initialization failed + * @return An initialized initialization failed exception + */ +- initWithClass: (Class)class_; + +/*! + * @brief Returns the class for which initialization failed. + * + * @return The class for which initialization failed + */ +- (Class)inClass; @end Index: src/exceptions/OFInitializationFailedException.m ================================================================== --- src/exceptions/OFInitializationFailedException.m +++ src/exceptions/OFInitializationFailedException.m @@ -13,16 +13,51 @@ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" + +#include #import "OFInitializationFailedException.h" #import "OFString.h" + +#import "common.h" @implementation OFInitializationFailedException ++ (instancetype)exceptionWithClass: (Class)class +{ + return [[[self alloc] initWithClass: class] autorelease]; +} + +- init +{ + @try { + [self doesNotRecognizeSelector: _cmd]; + } @catch (id e) { + [self release]; + @throw e; + } + + abort(); +} + +- initWithClass: (Class)class +{ + self = [super init]; + + _inClass = class; + + return self; +} + - (OFString*)description { return [OFString stringWithFormat: @"Initialization failed for or in class %@!", _inClass]; } + +- (Class)inClass +{ + return _inClass; +} @end Index: src/exceptions/OFInvalidArgumentException.h ================================================================== --- src/exceptions/OFInvalidArgumentException.h +++ src/exceptions/OFInvalidArgumentException.h @@ -18,40 +18,6 @@ /*! * @brief An exception indicating that the argument is invalid for this method. */ @interface OFInvalidArgumentException: OFException -{ - SEL _selector; -} - -#ifdef OF_HAVE_PROPERTIES -@property (readonly) SEL selector; -#endif - -/*! - * @brief Creates a new, autoreleased invalid argument exception. - * - * @param class_ The class of the object which caused the exception - * @param selector The selector which doesn't accept the argument - * @return A new, autoreleased invalid argument exception - */ -+ (instancetype)exceptionWithClass: (Class)class_ - selector: (SEL)selector; - -/*! - * @brief Initializes an already allocated invalid argument exception. - * - * @param class_ The class of the object which caused the exception - * @param selector The selector which doesn't accept the argument - * @return An initialized invalid argument exception - */ -- initWithClass: (Class)class_ - selector: (SEL)selector; - -/*! - * @brief Returns the selector to which an invalid argument was passed. - * - * @return The selector to which an invalid argument was passed - */ -- (SEL)selector; @end Index: src/exceptions/OFInvalidArgumentException.m ================================================================== --- src/exceptions/OFInvalidArgumentException.m +++ src/exceptions/OFInvalidArgumentException.m @@ -14,54 +14,14 @@ * file. */ #include "config.h" -#include - #import "OFInvalidArgumentException.h" #import "OFString.h" -#import "common.h" - @implementation OFInvalidArgumentException -+ (instancetype)exceptionWithClass: (Class)class - selector: (SEL)selector -{ - return [[[self alloc] initWithClass: class - selector: selector] autorelease]; -} - -- initWithClass: (Class)class -{ - @try { - [self doesNotRecognizeSelector: _cmd]; - } @catch (id e) { - [self release]; - @throw e; - } - - abort(); -} - -- initWithClass: (Class)class - selector: (SEL)selector -{ - self = [super initWithClass: class]; - - _selector = selector; - - return self; -} - - (OFString*)description { - return [OFString stringWithFormat: - @"The argument or receiver for method %s of class %@ is invalid!", - sel_getName(_selector), _inClass]; -} - -- (SEL)selector -{ - return _selector; + return @"An invalid argument or receiver has been specified!"; } @end Index: src/exceptions/OFInvalidEncodingException.m ================================================================== --- src/exceptions/OFInvalidEncodingException.m +++ src/exceptions/OFInvalidEncodingException.m @@ -20,9 +20,8 @@ #import "OFString.h" @implementation OFInvalidEncodingException - (OFString*)description { - return [OFString stringWithFormat: - @"The encoding is invalid for class %@!", _inClass]; + return @"An encoding is invalid!"; } @end Index: src/exceptions/OFInvalidFormatException.m ================================================================== --- src/exceptions/OFInvalidFormatException.m +++ src/exceptions/OFInvalidFormatException.m @@ -20,9 +20,8 @@ #import "OFString.h" @implementation OFInvalidFormatException - (OFString*)description { - return [OFString stringWithFormat: - @"The format is invalid for class %@!", _inClass]; + return @"A format is invalid!"; } @end Index: src/exceptions/OFInvalidJSONException.h ================================================================== --- src/exceptions/OFInvalidJSONException.h +++ src/exceptions/OFInvalidJSONException.h @@ -19,39 +19,48 @@ /*! * @brief An exception indicating a JSON representation is invalid. */ @interface OFInvalidJSONException: OFException { + OFString *_string; size_t _line; } #ifdef OF_HAVE_PROPERTIES +@property (readonly, copy, nonatomic) OFString *string; @property (readonly) size_t line; #endif /*! * @brief Creates a new, autoreleased invalid JSON exception. * - * @param class_ The class of the object which caused the exception + * @param string The string containing the invalid JSON representation * @param line The line in which the parsing error encountered * @return A new, autoreleased invalid JSON exception */ -+ (instancetype)exceptionWithClass: (Class)class_ - line: (size_t)line; ++ (instancetype)exceptionWithString: (OFString*)string + line: (size_t)line; /*! * @brief Initializes an already allocated invalid JSON exception. * - * @param class_ The class of the object which caused the exception + * @param string The string containing the invalid JSON representation * @param line The line in which the parsing error encountered * @return An initialized invalid JSON exception */ -- initWithClass: (Class)class_ - line: (size_t)line; +- initWithString: (OFString*)string + line: (size_t)line; + +/*! + * @brief Returns the string containing the invalid JSON representation. + * + * @return The string containing the invalid JSON representation + */ +- (OFString*)string; /*! * @brief Returns the line in which parsing the JSON representation failed. * * @return The line in which parsing the JSON representation failed */ - (size_t)line; @end Index: src/exceptions/OFInvalidJSONException.m ================================================================== --- src/exceptions/OFInvalidJSONException.m +++ src/exceptions/OFInvalidJSONException.m @@ -20,15 +20,15 @@ #import "OFInvalidJSONException.h" #import "OFString.h" @implementation OFInvalidJSONException -+ (instancetype)exceptionWithClass: (Class)class - line: (size_t)line ++ (instancetype)exceptionWithString: (OFString*)string + line: (size_t)line { - return [[[self alloc] initWithClass: class - line: line] autorelease]; + return [[[self alloc] initWithString: string + line: line] autorelease]; } - init { @try { @@ -39,27 +39,44 @@ } abort(); } -- initWithClass: (Class)class - line: (size_t)line +- initWithString: (OFString*)string + line: (size_t)line { - self = [super initWithClass: class]; + self = [super init]; - _line = line; + @try { + _string = [string copy]; + _line = line; + } @catch (id e) { + [self release]; + @throw e; + } return self; } + +- (void)dealloc +{ + [_string release]; + + [super dealloc]; +} - (OFString*)description { return [OFString stringWithFormat: - @"The JSON representation class %@ tried to parse is invalid in " - @"line %zd!", _inClass, _line]; + @"The JSON representation is invalid in line %zd!", _line]; +} + +- (OFString*)string +{ + return _string; } - (size_t)line { return _line; } @end Index: src/exceptions/OFInvalidServerReplyException.m ================================================================== --- src/exceptions/OFInvalidServerReplyException.m +++ src/exceptions/OFInvalidServerReplyException.m @@ -20,9 +20,8 @@ #import "OFString.h" @implementation OFInvalidServerReplyException - (OFString*)description { - return [OFString stringWithFormat: - @"Got an invalid reply from the server in class %@!", _inClass]; + return @"Got an invalid reply from the server!"; } @end Index: src/exceptions/OFLinkFailedException.h ================================================================== --- src/exceptions/OFLinkFailedException.h +++ src/exceptions/OFLinkFailedException.h @@ -14,11 +14,11 @@ * file. */ #import "OFException.h" -#ifndef _WIN32 +#ifdef OF_HAVE_LINK /*! * @brief An exception indicating that creating a link failed. */ @interface OFLinkFailedException: OFException { @@ -32,37 +32,26 @@ # endif /*! * @brief Creates a new, autoreleased link failed exception. * - * @param class_ The class of the object which caused the exception * @param sourcePath The source for the link * @param destinationPath The destination for the link * @return A new, autoreleased link failed exception */ -+ (instancetype)exceptionWithClass: (Class)class_ - sourcePath: (OFString*)sourcePath - destinationPath: (OFString*)destinationPath; ++ (instancetype)exceptionWithSourcePath: (OFString*)sourcePath + destinationPath: (OFString*)destinationPath; /*! * @brief Initializes an already allocated link failed exception. * - * @param class_ The class of the object which caused the exception * @param sourcePath The source for the link * @param destinationPath The destination for the link * @return An initialized link failed exception */ -- initWithClass: (Class)class_ - sourcePath: (OFString*)sourcePath - destinationPath: (OFString*)destinationPath; - -/*! - * @brief Returns the errno from when the exception was created. - * - * @return The errno from when the exception was created - */ -- (int)errNo; +- initWithSourcePath: (OFString*)sourcePath + destinationPath: (OFString*)destinationPath; /*! * @brief Returns a string with the source for the link. * * @return A string with the source for the link @@ -73,7 +62,14 @@ * @brief Returns a string with the destination for the link. * * @return A string with the destination for the link */ - (OFString*)destinationPath; + +/*! + * @brief Returns the errno from when the exception was created. + * + * @return The errno from when the exception was created + */ +- (int)errNo; @end #endif Index: src/exceptions/OFLinkFailedException.m ================================================================== --- src/exceptions/OFLinkFailedException.m +++ src/exceptions/OFLinkFailedException.m @@ -21,22 +21,20 @@ #import "OFLinkFailedException.h" #import "OFString.h" #import "common.h" -#ifndef _WIN32 +#ifdef OF_HAVE_LINK @implementation OFLinkFailedException -+ (instancetype)exceptionWithClass: (Class)class - sourcePath: (OFString*)sourcePath - destinationPath: (OFString*)destinationPath ++ (instancetype)exceptionWithSourcePath: (OFString*)sourcePath + destinationPath: (OFString*)destinationPath { - return [[[self alloc] initWithClass: class - sourcePath: sourcePath - destinationPath: destinationPath] autorelease]; + return [[[self alloc] initWithSourcePath: sourcePath + destinationPath: destinationPath] autorelease]; } -- initWithClass: (Class)class +- init { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @@ -44,15 +42,14 @@ } abort(); } -- initWithClass: (Class)class - sourcePath: (OFString*)sourcePath - destinationPath: (OFString*)destinationPath +- initWithSourcePath: (OFString*)sourcePath + destinationPath: (OFString*)destinationPath { - self = [super initWithClass: class]; + self = [super init]; @try { _sourcePath = [sourcePath copy]; _destinationPath = [destinationPath copy]; _errNo = GET_ERRNO; @@ -73,17 +70,12 @@ } - (OFString*)description { return [OFString stringWithFormat: - @"Failed to link file %@ to %@ in class %@! " ERRFMT, _sourcePath, - _destinationPath, _inClass, ERRPARAM]; -} - -- (int)errNo -{ - return _errNo; + @"Failed to link file %@ to %@! " ERRFMT, _sourcePath, + _destinationPath, ERRPARAM]; } - (OFString*)sourcePath { OF_GETTER(_sourcePath, false) @@ -91,7 +83,12 @@ - (OFString*)destinationPath { OF_GETTER(_destinationPath, false) } + +- (int)errNo +{ + return _errNo; +} @end #endif Index: src/exceptions/OFListenFailedException.h ================================================================== --- src/exceptions/OFListenFailedException.h +++ src/exceptions/OFListenFailedException.h @@ -37,30 +37,26 @@ #endif /*! * @brief Creates a new, autoreleased listen failed exception. * - * @param class_ The class of the object which caused the exception * @param socket The socket which failed to listen * @param backLog The requested size of the back log * @return A new, autoreleased listen failed exception */ -+ (instancetype)exceptionWithClass: (Class)class_ - socket: (OFTCPSocket*)socket - backLog: (int)backLog; ++ (instancetype)exceptionWithSocket: (OFTCPSocket*)socket + backLog: (int)backLog; /*! * @brief Initializes an already allocated listen failed exception * - * @param class_ The class of the object which caused the exception * @param socket The socket which failed to listen * @param backLog The requested size of the back log * @return An initialized listen failed exception */ -- initWithClass: (Class)class_ - socket: (OFTCPSocket*)socket - backLog: (int)backLog; +- initWithSocket: (OFTCPSocket*)socket + backLog: (int)backLog; /*! * @brief Returns the socket which failed to listen. * * @return The socket which failed to listen Index: src/exceptions/OFListenFailedException.m ================================================================== --- src/exceptions/OFListenFailedException.m +++ src/exceptions/OFListenFailedException.m @@ -23,20 +23,18 @@ #import "OFTCPSocket.h" #import "common.h" @implementation OFListenFailedException -+ (instancetype)exceptionWithClass: (Class)class - socket: (OFTCPSocket*)socket - backLog: (int)backLog ++ (instancetype)exceptionWithSocket: (OFTCPSocket*)socket + backLog: (int)backLog { - return [[[self alloc] initWithClass: class - socket: socket - backLog: backLog] autorelease]; + return [[[self alloc] initWithSocket: socket + backLog: backLog] autorelease]; } -- initWithClass: (Class)class +- init { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @@ -44,15 +42,14 @@ } abort(); } -- initWithClass: (Class)class - socket: (OFTCPSocket*)socket - backLog: (int)backLog +- initWithSocket: (OFTCPSocket*)socket + backLog: (int)backLog { - self = [super initWithClass: class]; + self = [super init]; _socket = [socket retain]; _backLog = backLog; _errNo = GET_SOCK_ERRNO; @@ -68,11 +65,11 @@ - (OFString*)description { return [OFString stringWithFormat: @"Failed to listen in socket of type %@ with a back log of %d! " - ERRFMT, _inClass, _backLog, ERRPARAM]; + ERRFMT, [_socket class], _backLog, ERRPARAM]; } - (OFTCPSocket*)socket { OF_GETTER(_socket, false) Index: src/exceptions/OFLockFailedException.h ================================================================== --- src/exceptions/OFLockFailedException.h +++ src/exceptions/OFLockFailedException.h @@ -30,29 +30,25 @@ #endif /*! * @brief Creates a new, autoreleased lock failed exception. * - * @param class_ The class of the object which caused the exception * @param lock The lock which could not be locked * @return A new, autoreleased lock failed exception */ -+ (instancetype)exceptionWithClass: (Class)class_ - lock: (id )lock; ++ (instancetype)exceptionWithLock: (id )lock; /*! * @brief Initializes an already allocated lock failed exception. * - * @param class_ The class of the object which caused the exception * @param lock The lock which could not be locked * @return An initialized lock failed exception */ -- initWithClass: (Class)class_ - lock: (id )lock; +- initWithLock: (id )lock; /*! * @brief Returns the lock which could not be locked. * * @return The lock which could not be locked */ - (id )lock; @end Index: src/exceptions/OFLockFailedException.m ================================================================== --- src/exceptions/OFLockFailedException.m +++ src/exceptions/OFLockFailedException.m @@ -17,24 +17,21 @@ #include "config.h" #import "OFLockFailedException.h" #import "OFString.h" -#import "macros.h" +#import "common.h" @implementation OFLockFailedException -+ (instancetype)exceptionWithClass: (Class)class - lock: (id )lock ++ (instancetype)exceptionWithLock: (id )lock { - return [[[self alloc] initWithClass: class - lock: lock] autorelease]; + return [[[self alloc] initWithLock: lock] autorelease]; } -- initWithClass: (Class)class - lock: (id )lock +- initWithLock: (id )lock { - self = [super initWithClass: class]; + self = [super init]; _lock = [lock retain]; return self; } @@ -46,15 +43,17 @@ [super dealloc]; } - (OFString*)description { - return [OFString stringWithFormat: - @"A lock of type %@ could not be locked in class %@!", - [_lock class], _inClass]; + if (_lock != nil) + return [OFString stringWithFormat: + @"A lock of type %@ could not be locked!", [_lock class]]; + else + return @"A lock could not be locked!"; } - (id )lock { OF_GETTER(_lock, false) } @end Index: src/exceptions/OFMalformedXMLException.h ================================================================== --- src/exceptions/OFMalformedXMLException.h +++ src/exceptions/OFMalformedXMLException.h @@ -31,29 +31,25 @@ #endif /*! * @brief Creates a new, autoreleased malformed XML exception. * - * @param class_ The class of the object which caused the exception * @param parser The parser which encountered malformed XML * @return A new, autoreleased malformed XML exception */ -+ (instancetype)exceptionWithClass: (Class)class_ - parser: (OFXMLParser*)parser; ++ (instancetype)exceptionWithParser: (OFXMLParser*)parser; /*! * @brief Initializes an already allocated malformed XML exception. * - * @param class_ The class of the object which caused the exception * @param parser The parser which encountered malformed XML * @return An initialized malformed XML exception */ -- initWithClass: (Class)class_ - parser: (OFXMLParser*)parser; +- initWithParser: (OFXMLParser*)parser; /*! * @brief Returns the parser which encountered malformed XML. * * @return The parser which encountered malformed XML */ - (OFXMLParser*)parser; @end Index: src/exceptions/OFMalformedXMLException.m ================================================================== --- src/exceptions/OFMalformedXMLException.m +++ src/exceptions/OFMalformedXMLException.m @@ -21,21 +21,18 @@ #import "OFXMLParser.h" #import "common.h" @implementation OFMalformedXMLException -+ (instancetype)exceptionWithClass: (Class)class - parser: (OFXMLParser*)parser ++ (instancetype)exceptionWithParser: (OFXMLParser*)parser { - return [[[self alloc] initWithClass: class - parser: parser] autorelease]; + return [[[self alloc] initWithParser: parser] autorelease]; } -- initWithClass: (Class)class - parser: (OFXMLParser*)parser +- initWithParser: (OFXMLParser*)parser { - self = [super initWithClass: class]; + self = [super init]; _parser = [parser retain]; return self; } @@ -49,16 +46,16 @@ - (OFString*)description { if (_parser != nil) return [OFString stringWithFormat: - @"The XML parser in class %@ encountered malformed XML in " - @"line %zd!", _inClass, [_parser lineNumber]]; + @"An XML parser of type %@ encountered malformed XML in " + @"line %zd!", [_parser class], [_parser lineNumber]]; else return @"An XML parser encountered malformed XML!"; } - (OFXMLParser*)parser { OF_GETTER(_parser, false) } @end Index: src/exceptions/OFMemoryNotPartOfObjectException.h ================================================================== --- src/exceptions/OFMemoryNotPartOfObjectException.h +++ src/exceptions/OFMemoryNotPartOfObjectException.h @@ -20,38 +20,47 @@ * @brief An exception indicating the given memory is not part of the object. */ @interface OFMemoryNotPartOfObjectException: OFException { void *_pointer; + id _object; } #ifdef OF_HAVE_PROPERTIES @property (readonly) void *pointer; +@property (readonly, retain, nonatomic) id object; #endif /*! * @brief Creates a new, autoreleased memory not part of object exception. * - * @param class_ The class of the object which caused the exception * @param pointer A pointer to the memory that is not part of the object + * @param object The object which the memory is not part of * @return A new, autoreleased memory not part of object exception */ -+ (instancetype)exceptionWithClass: (Class)class_ - pointer: (void*)pointer; ++ (instancetype)exceptionWithPointer: (void*)pointer + object: (id)object; /*! * @brief Initializes an already allocated memory not part of object exception. * - * @param class_ The class of the object which caused the exception * @param pointer A pointer to the memory that is not part of the object + * @param object The object which the memory is not part of * @return An initialized memory not part of object exception */ -- initWithClass: (Class)class_ - pointer: (void*)pointer; +- initWithPointer: (void*)pointer + object: (id)object; /*! * @brief Returns a pointer to the memory which is not part of the object. * * @return A pointer to the memory which is not part of the object */ - (void*)pointer; + +/*! + * @brief Returns the object which the memory is not part of. + * + * @return The object which the memory is not part of + */ +- (id)object; @end Index: src/exceptions/OFMemoryNotPartOfObjectException.m ================================================================== --- src/exceptions/OFMemoryNotPartOfObjectException.m +++ src/exceptions/OFMemoryNotPartOfObjectException.m @@ -20,18 +20,18 @@ #import "OFMemoryNotPartOfObjectException.h" #import "OFString.h" @implementation OFMemoryNotPartOfObjectException -+ (instancetype)exceptionWithClass: (Class)class - pointer: (void*)pointer ++ (instancetype)exceptionWithPointer: (void*)pointer + object: (id)object { - return [[[self alloc] initWithClass: class - pointer: pointer] autorelease]; + return [[[self alloc] initWithPointer: pointer + object: object] autorelease]; } -- initWithClass: (Class)class +- init { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @@ -39,29 +39,42 @@ } abort(); } -- initWithClass: (Class)class - pointer: (void*)pointer +- initWithPointer: (void*)pointer + object: (id)object { - self = [super initWithClass: class]; + self = [super init]; _pointer = pointer; + _object = [object retain]; return self; } + +- (void)dealloc +{ + [_object release]; + + [super dealloc]; +} - (OFString*)description { return [OFString stringWithFormat: - @"Memory at %p was not allocated as part of object of class %@, " + @"Memory at %p was not allocated as part of object of type %@, " @"thus the memory allocation was not changed! It is also possible " @"that there was an attempt to free the same memory twice.", - _pointer, _inClass]; + _pointer, [_object class]]; } - (void*)pointer { return _pointer; } + +- (id)object +{ + return _object; +} @end Index: src/exceptions/OFNotConnectedException.h ================================================================== --- src/exceptions/OFNotConnectedException.h +++ src/exceptions/OFNotConnectedException.h @@ -35,29 +35,25 @@ #endif /*! * @brief Creates a new, autoreleased not connected exception. * - * @param class_ The class of the object which caused the exception * @param socket The socket which is not connected * @return A new, autoreleased not connected exception */ -+ (instancetype)exceptionWithClass: (Class)class_ - socket: (OFStreamSocket*)socket; ++ (instancetype)exceptionWithSocket: (OFStreamSocket*)socket; /*! * @brief Initializes an already allocated not connected exception. * - * @param class_ The class of the object which caused the exception * @param socket The socket which is not connected * @return An initialized not connected exception */ -- initWithClass: (Class)class_ - socket: (OFStreamSocket*)socket; +- initWithSocket: (OFStreamSocket*)socket; /*! * @brief Returns the socket which is not connected. * * @return The socket which is not connected */ - (OFStreamSocket*)socket; @end Index: src/exceptions/OFNotConnectedException.m ================================================================== --- src/exceptions/OFNotConnectedException.m +++ src/exceptions/OFNotConnectedException.m @@ -23,18 +23,16 @@ #import "OFTCPSocket.h" #import "common.h" @implementation OFNotConnectedException -+ (instancetype)exceptionWithClass: (Class)class - socket: (OFStreamSocket*)socket ++ (instancetype)exceptionWithSocket: (OFStreamSocket*)socket { - return [[[self alloc] initWithClass: class - socket: socket] autorelease]; + return [[[self alloc] initWithSocket: socket] autorelease]; } -- initWithClass: (Class)class +- init { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @@ -42,14 +40,13 @@ } abort(); } -- initWithClass: (Class)class - socket: (OFStreamSocket*)socket +- initWithSocket: (OFStreamSocket*)socket { - self = [super initWithClass: class]; + self = [super init]; _socket = [socket retain]; return self; } @@ -62,13 +59,14 @@ } - (OFString*)description { return [OFString stringWithFormat: - @"The socket of type %@ is not connected or bound!", _inClass]; + @"The socket of type %@ is not connected or bound!", + [_socket class]]; } - (OFStreamSocket*)socket { OF_GETTER(_socket, false) } @end Index: src/exceptions/OFNotImplementedException.h ================================================================== --- src/exceptions/OFNotImplementedException.h +++ src/exceptions/OFNotImplementedException.h @@ -21,38 +21,47 @@ * implemented. */ @interface OFNotImplementedException: OFException { SEL _selector; + id _object; } #ifdef OF_HAVE_PROPERTIES @property (readonly) SEL selector; +@property (readonly, retain, nonatomic) id object; #endif /*! * @brief Creates a new, autoreleased not implemented exception. * - * @param class_ The class of the object which caused the exception * @param selector The selector which is not or not fully implemented + * @param object The object which does not (fully) implement the selector * @return A new, autoreleased not implemented exception */ -+ (instancetype)exceptionWithClass: (Class)class_ - selector: (SEL)selector; ++ (instancetype)exceptionWithSelector: (SEL)selector + object: (id)object; /*! * @brief Initializes an already allocated not implemented exception. * - * @param class_ The class of the object which caused the exception * @param selector The selector which is not or not fully implemented + * @param object The object which does not (fully) implement the selector * @return An initialized not implemented exception */ -- initWithClass: (Class)class_ - selector: (SEL)selector; +- initWithSelector: (SEL)selector + object: (id)object; /*! * @brief Returns the selector which is not or not fully implemented. * * @return The selector which is not or not fully implemented */ - (SEL)selector; + +/*! + * @brief Returns the object which does not (fully) implement the selector. + * + * @return The object which does not (fully) implement the selector + */ +- (id)object; @end Index: src/exceptions/OFNotImplementedException.m ================================================================== --- src/exceptions/OFNotImplementedException.m +++ src/exceptions/OFNotImplementedException.m @@ -22,18 +22,18 @@ #import "OFString.h" #import "common.h" @implementation OFNotImplementedException -+ (instancetype)exceptionWithClass: (Class)class - selector: (SEL)selector ++ (instancetype)exceptionWithSelector: (SEL)selector + object: (id)object { - return [[[self alloc] initWithClass: class - selector: selector] autorelease]; + return [[[self alloc] initWithSelector: selector + object: object] autorelease]; } -- initWithClass: (Class)class +- init { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @@ -41,27 +41,40 @@ } abort(); } -- initWithClass: (Class)class - selector: (SEL)selector +- initWithSelector: (SEL)selector + object: (id)object { - self = [super initWithClass: class]; + self = [super init]; _selector = selector; + _object = [object retain]; return self; } + +- (void)dealloc +{ + [_object release]; + + [super dealloc]; +} - (OFString*)description { return [OFString stringWithFormat: - @"The selector %s is not understood by class %@ or not (fully) " - @"implemented!", sel_getName(_selector), _inClass]; + @"The selector %s is not understood by an object of type %@ or not " + @"(fully) implemented!", sel_getName(_selector), [_object class]]; } - (SEL)selector { return _selector; } + +- (id)object +{ + return _object; +} @end Index: src/exceptions/OFOpenFileFailedException.h ================================================================== --- src/exceptions/OFOpenFileFailedException.h +++ src/exceptions/OFOpenFileFailedException.h @@ -31,37 +31,26 @@ #endif /*! * @brief Creates a new, autoreleased open file failed exception. * - * @param class_ The class of the object which caused the exception * @param path A string with the path of the file tried to open * @param mode A string with the mode in which the file should have been opened * @return A new, autoreleased open file failed exception */ -+ (instancetype)exceptionWithClass: (Class)class_ - path: (OFString*)path - mode: (OFString*)mode; ++ (instancetype)exceptionWithPath: (OFString*)path + mode: (OFString*)mode; /*! * @brief Initializes an already allocated open file failed exception. * - * @param class_ The class of the object which caused the exception * @param path A string with the path of the file which couldn't be opened * @param mode A string with the mode in which the file should have been opened * @return An initialized open file failed exception */ -- initWithClass: (Class)class_ - path: (OFString*)path - mode: (OFString*)mode; - -/*! - * @brief Returns the errno from when the exception was created. - * - * @return The errno from when the exception was created - */ -- (int)errNo; +- initWithPath: (OFString*)path + mode: (OFString*)mode; /*! * @brief Returns a string with the path of the file which couldn't be opened. * * @return A string with the path of the file which couldn't be opened @@ -73,6 +62,13 @@ * opened. * * @return A string with the mode in which the file should have been opened */ - (OFString*)mode; + +/*! + * @brief Returns the errno from when the exception was created. + * + * @return The errno from when the exception was created + */ +- (int)errNo; @end Index: src/exceptions/OFOpenFileFailedException.m ================================================================== --- src/exceptions/OFOpenFileFailedException.m +++ src/exceptions/OFOpenFileFailedException.m @@ -22,20 +22,18 @@ #import "OFString.h" #import "common.h" @implementation OFOpenFileFailedException -+ (instancetype)exceptionWithClass: (Class)class - path: (OFString*)path - mode: (OFString*)mode ++ (instancetype)exceptionWithPath: (OFString*)path + mode: (OFString*)mode { - return [[[self alloc] initWithClass: class - path: path - mode: mode] autorelease]; + return [[[self alloc] initWithPath: path + mode: mode] autorelease]; } -- initWithClass: (Class)class +- init { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @@ -43,15 +41,14 @@ } abort(); } -- initWithClass: (Class)class - path: (OFString*)path - mode: (OFString*)mode +- initWithPath: (OFString*)path + mode: (OFString*)mode { - self = [super initWithClass: class]; + self = [super init]; @try { _path = [path copy]; _mode = [mode copy]; _errNo = GET_ERRNO; @@ -72,17 +69,12 @@ } - (OFString*)description { return [OFString stringWithFormat: - @"Failed to open file %@ with mode %@ in class %@! " ERRFMT, _path, - _mode, _inClass, ERRPARAM]; -} - -- (int)errNo -{ - return _errNo; + @"Failed to open file %@ with mode %@! " ERRFMT, _path, _mode, + ERRPARAM]; } - (OFString*)path { OF_GETTER(_path, false) @@ -90,6 +82,11 @@ - (OFString*)mode { OF_GETTER(_mode, false) } + +- (int)errNo +{ + return _errNo; +} @end Index: src/exceptions/OFOutOfMemoryException.h ================================================================== --- src/exceptions/OFOutOfMemoryException.h +++ src/exceptions/OFOutOfMemoryException.h @@ -29,29 +29,25 @@ #endif /*! * @brief Creates a new, autoreleased no memory exception. * - * @param class_ The class of the object which caused the exception * @param requestedSize The size of the memory that couldn't be allocated * @return A new, autoreleased no memory exception */ -+ (instancetype)exceptionWithClass: (Class)class_ - requestedSize: (size_t)requestedSize; ++ (instancetype)exceptionWithRequestedSize: (size_t)requestedSize; /*! * @brief Initializes an already allocated no memory exception. * - * @param class_ The class of the object which caused the exception * @param requestedSize The size of the memory that couldn't be allocated * @return An initialized no memory exception */ -- initWithClass: (Class)class_ - requestedSize: (size_t)requestedSize; +- initWithRequestedSize: (size_t)requestedSize; /*! * @brief Returns the size of the memoory that couldn't be allocated. * * @return The size of the memoory that couldn't be allocated */ - (size_t)requestedSize; @end Index: src/exceptions/OFOutOfMemoryException.m ================================================================== --- src/exceptions/OFOutOfMemoryException.m +++ src/exceptions/OFOutOfMemoryException.m @@ -18,21 +18,19 @@ #import "OFOutOfMemoryException.h" #import "OFString.h" @implementation OFOutOfMemoryException -+ (instancetype)exceptionWithClass: (Class)class - requestedSize: (size_t)requestedSize ++ (instancetype)exceptionWithRequestedSize: (size_t)requestedSize { - return [[[self alloc] initWithClass: class - requestedSize: requestedSize] autorelease]; + return [[[self alloc] + initWithRequestedSize: requestedSize] autorelease]; } -- initWithClass: (Class)class - requestedSize: (size_t)requestedSize +- initWithRequestedSize: (size_t)requestedSize { - self = [super initWithClass: class]; + self = [super init]; _requestedSize = requestedSize; return self; } @@ -39,17 +37,15 @@ - (OFString*)description { if (_requestedSize != 0) return [OFString stringWithFormat: - @"Could not allocate %zu bytes in class %@!", - _requestedSize, _inClass]; + @"Could not allocate %zu bytes!", _requestedSize]; else - return [OFString stringWithFormat: - @"Could not allocate enough memory in class %@!", _inClass]; + return @"Could not allocate enough memory!"; } - (size_t)requestedSize { return _requestedSize; } @end Index: src/exceptions/OFOutOfRangeException.m ================================================================== --- src/exceptions/OFOutOfRangeException.m +++ src/exceptions/OFOutOfRangeException.m @@ -20,9 +20,8 @@ #import "OFString.h" @implementation OFOutOfRangeException - (OFString*)description { - return [OFString stringWithFormat: - @"Value out of range in class %@!", _inClass]; + return @"Value out of range!"; } @end Index: src/exceptions/OFReadFailedException.m ================================================================== --- src/exceptions/OFReadFailedException.m +++ src/exceptions/OFReadFailedException.m @@ -23,9 +23,9 @@ @implementation OFReadFailedException - (OFString*)description { return [OFString stringWithFormat: - @"Failed to read %zu bytes in class %@! " ERRFMT, _requestedLength, - _inClass, ERRPARAM]; + @"Failed to read %zu bytes in a stream of type %@! " ERRFMT, + _requestedLength, [_stream class], ERRPARAM]; } @end Index: src/exceptions/OFReadOrWriteFailedException.h ================================================================== --- src/exceptions/OFReadOrWriteFailedException.h +++ src/exceptions/OFReadOrWriteFailedException.h @@ -36,31 +36,27 @@ #endif /*! * @brief Creates a new, autoreleased read or write failed exception. * - * @param class_ The class of the object which caused the exception * @param stream The stream which caused the read or write failed exception * @param requestedLength The requested length of the data that couldn't be * read / written * @return A new, autoreleased read or write failed exception */ -+ (instancetype)exceptionWithClass: (Class)class_ - stream: (OFStream*)stream - requestedLength: (size_t)requestedLength; ++ (instancetype)exceptionWithStream: (OFStream*)stream + requestedLength: (size_t)requestedLength; /*! * @brief Initializes an already allocated read or write failed exception. * - * @param class_ The class of the object which caused the exception * @param stream The stream which caused the read or write failed exception * @param requestedLength The requested length of the data that couldn't be * read / written * @return A new open file failed exception */ -- initWithClass: (Class)class_ - stream: (OFStream*)stream +- initWithStream: (OFStream*)stream requestedLength: (size_t)requestedLength; /*! * @brief Returns the stream which caused the read or write failed exception. * Index: src/exceptions/OFReadOrWriteFailedException.m ================================================================== --- src/exceptions/OFReadOrWriteFailedException.m +++ src/exceptions/OFReadOrWriteFailedException.m @@ -25,20 +25,18 @@ #endif #import "common.h" @implementation OFReadOrWriteFailedException -+ (instancetype)exceptionWithClass: (Class)class - stream: (OFStream*)stream - requestedLength: (size_t)requestedLength ++ (instancetype)exceptionWithStream: (OFStream*)stream + requestedLength: (size_t)requestedLength { - return [[[self alloc] initWithClass: class - stream: stream - requestedLength: requestedLength] autorelease]; + return [[[self alloc] initWithStream: stream + requestedLength: requestedLength] autorelease]; } -- initWithClass: (Class)class +- init { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @@ -46,21 +44,20 @@ } abort(); } -- initWithClass: (Class)class - stream: (OFStream*)stream +- initWithStream: (OFStream*)stream requestedLength: (size_t)requestedLength { - self = [super initWithClass: class]; + self = [super init]; _stream = [stream retain]; _requestedLength = requestedLength; #ifdef OF_HAVE_SOCKETS - if ([class isSubclassOfClass: [OFStreamSocket class]]) + if ([stream isKindOfClass: [OFStreamSocket class]]) _errNo = GET_SOCK_ERRNO; else #endif _errNo = GET_ERRNO; @@ -71,10 +68,17 @@ { [_stream release]; [super dealloc]; } + +- (OFString*)description +{ + return [OFString stringWithFormat: + @"Failed to read or write %zu bytes in a stream of type " + @"%@! " ERRFMT, _requestedLength, [_stream class], ERRPARAM]; +} - (OFStream*)stream { OF_GETTER(_stream, false) } Index: src/exceptions/OFRenameFileFailedException.h ================================================================== --- src/exceptions/OFRenameFileFailedException.h +++ src/exceptions/OFRenameFileFailedException.h @@ -31,37 +31,26 @@ #endif /*! * @brief Creates a new, autoreleased rename file failed exception. * - * @param class_ The class of the object which caused the exception * @param sourcePath The original path * @param destinationPath The new path * @return A new, autoreleased rename file failed exception */ -+ (instancetype)exceptionWithClass: (Class)class_ - sourcePath: (OFString*)sourcePath - destinationPath: (OFString*)destinationPath; ++ (instancetype)exceptionWithSourcePath: (OFString*)sourcePath + destinationPath: (OFString*)destinationPath; /*! * @brief Initializes an already allocated rename failed exception. * - * @param class_ The class of the object which caused the exception * @param sourcePath The original path * @param destinationPath The new path * @return An initialized rename file failed exception */ -- initWithClass: (Class)class_ - sourcePath: (OFString*)sourcePath - destinationPath: (OFString*)destinationPath; - -/*! - * @brief Returns the errno from when the exception was created. - * - * @return The errno from when the exception was created - */ -- (int)errNo; +- initWithSourcePath: (OFString*)sourcePath + destinationPath: (OFString*)destinationPath; /*! * @brief Returns the original path. * * @return The original path @@ -72,6 +61,13 @@ * @brief Returns the new path. * * @return The new path */ - (OFString*)destinationPath; + +/*! + * @brief Returns the errno from when the exception was created. + * + * @return The errno from when the exception was created + */ +- (int)errNo; @end Index: src/exceptions/OFRenameFileFailedException.m ================================================================== --- src/exceptions/OFRenameFileFailedException.m +++ src/exceptions/OFRenameFileFailedException.m @@ -22,20 +22,18 @@ #import "OFString.h" #import "common.h" @implementation OFRenameFileFailedException -+ (instancetype)exceptionWithClass: (Class)class - sourcePath: (OFString*)sourcePath - destinationPath: (OFString*)destinationPath ++ (instancetype)exceptionWithSourcePath: (OFString*)sourcePath + destinationPath: (OFString*)destinationPath { - return [[[self alloc] initWithClass: class - sourcePath: sourcePath - destinationPath: destinationPath] autorelease]; + return [[[self alloc] initWithSourcePath: sourcePath + destinationPath: destinationPath] autorelease]; } -- initWithClass: (Class)class +- init { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @@ -43,15 +41,14 @@ } abort(); } -- initWithClass: (Class)class - sourcePath: (OFString*)sourcePath - destinationPath: (OFString*)destinationPath +- initWithSourcePath: (OFString*)sourcePath + destinationPath: (OFString*)destinationPath { - self = [super initWithClass: class]; + self = [super init]; @try { _sourcePath = [sourcePath copy]; _destinationPath = [destinationPath copy]; _errNo = GET_ERRNO; @@ -72,17 +69,12 @@ } - (OFString*)description { return [OFString stringWithFormat: - @"Failed to rename file %@ to %@ in class %@! " ERRFMT, - _sourcePath, _destinationPath, _inClass, ERRPARAM]; -} - -- (int)errNo -{ - return _errNo; + @"Failed to rename file %@ to %@! " ERRFMT, _sourcePath, + _destinationPath, ERRPARAM]; } - (OFString*)sourcePath { OF_GETTER(_sourcePath, false) @@ -90,6 +82,11 @@ - (OFString*)destinationPath { OF_GETTER(_destinationPath, false) } + +- (int)errNo +{ + return _errNo; +} @end Index: src/exceptions/OFSeekFailedException.h ================================================================== --- src/exceptions/OFSeekFailedException.h +++ src/exceptions/OFSeekFailedException.h @@ -37,34 +37,30 @@ #endif /*! * @brief Creates a new, autoreleased seek failed exception. * - * @param class_ The class of the object which caused the exception * @param stream The stream for which seeking failed * @param offset The offset to which seeking failed * @param whence To what the offset is relative * @return A new, autoreleased seek failed exception */ -+ (instancetype)exceptionWithClass: (Class)class_ - stream: (OFSeekableStream*)stream - offset: (off_t)offset - whence: (int)whence; ++ (instancetype)exceptionWithStream: (OFSeekableStream*)stream + offset: (off_t)offset + whence: (int)whence; /*! * @brief Initializes an already allocated seek failed exception. * - * @param class_ The class of the object which caused the exception * @param stream The stream for which seeking failed * @param offset The offset to which seeking failed * @param whence To what the offset is relative * @return An initialized seek failed exception */ -- initWithClass: (Class)class_ - stream: (OFSeekableStream*)stream - offset: (off_t)offset - whence: (int)whence; +- initWithStream: (OFSeekableStream*)stream + offset: (off_t)offset + whence: (int)whence; /*! * @brief Returns the stream for which seeking failed. * * @return The stream for which seeking failed Index: src/exceptions/OFSeekFailedException.m ================================================================== --- src/exceptions/OFSeekFailedException.m +++ src/exceptions/OFSeekFailedException.m @@ -23,22 +23,20 @@ #import "OFSeekableStream.h" #import "common.h" @implementation OFSeekFailedException -+ (instancetype)exceptionWithClass: (Class)class - stream: (OFSeekableStream*)stream - offset: (off_t)offset - whence: (int)whence -{ - return [[[self alloc] initWithClass: class - stream: stream - offset: offset - whence: whence] autorelease]; ++ (instancetype)exceptionWithStream: (OFSeekableStream*)stream + offset: (off_t)offset + whence: (int)whence +{ + return [[[self alloc] initWithStream: stream + offset: offset + whence: whence] autorelease]; } -- initWithClass: (Class)class +- init { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @@ -46,16 +44,15 @@ } abort(); } -- initWithClass: (Class)class - stream: (OFSeekableStream*)stream - offset: (off_t)offset - whence: (int)whence +- initWithStream: (OFSeekableStream*)stream + offset: (off_t)offset + whence: (int)whence { - self = [super initWithClass: class]; + self = [super init]; _stream = [stream retain]; _offset = offset; _whence = whence; _errNo = GET_ERRNO; @@ -71,11 +68,12 @@ } - (OFString*)description { return [OFString stringWithFormat: - @"Seeking failed in class %@! " ERRFMT, _inClass, ERRPARAM]; + @"Seeking failed in stream of type %@! " ERRFMT, [_stream class], + ERRPARAM]; } - (OFSeekableStream*)stream { OF_GETTER(_stream, false) Index: src/exceptions/OFSetOptionFailedException.h ================================================================== --- src/exceptions/OFSetOptionFailedException.h +++ src/exceptions/OFSetOptionFailedException.h @@ -31,29 +31,25 @@ #endif /*! * @brief Creates a new, autoreleased set option failed exception. * - * @param class_ The class of the object which caused the exception * @param stream The stream for which the option could not be set * @return A new, autoreleased set option failed exception */ -+ (instancetype)exceptionWithClass: (Class)class_ - stream: (OFStream*)stream; ++ (instancetype)exceptionWithStream: (OFStream*)stream; /*! * @brief Initializes an already allocated set option failed exception. * - * @param class_ The class of the object which caused the exception * @param stream The stream for which the option could not be set * @return An initialized set option failed exception */ -- initWithClass: (Class)class_ - stream: (OFStream*)stream; +- initWithStream: (OFStream*)stream; /*! * @brief Returns the stream for which the option could not be set. * * @return The stream for which the option could not be set */ - (OFStream*)stream; @end Index: src/exceptions/OFSetOptionFailedException.m ================================================================== --- src/exceptions/OFSetOptionFailedException.m +++ src/exceptions/OFSetOptionFailedException.m @@ -23,18 +23,16 @@ #import "OFStream.h" #import "common.h" @implementation OFSetOptionFailedException -+ (instancetype)exceptionWithClass: (Class)class - stream: (OFStream*)stream ++ (instancetype)exceptionWithStream: (OFStream*)stream { - return [[[self alloc] initWithClass: class - stream: stream] autorelease]; + return [[[self alloc] initWithStream: stream] autorelease]; } -- initWithClass: (Class)class +- init { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @@ -42,14 +40,13 @@ } abort(); } -- initWithClass: (Class)class - stream: (OFStream*)stream +- initWithStream: (OFStream*)stream { - self = [super initWithClass: class]; + self = [super init]; _stream = [stream retain]; return self; } @@ -62,13 +59,14 @@ } - (OFString*)description { return [OFString stringWithFormat: - @"Setting an option in class %@ failed!", _inClass]; + @"Setting an option in a stream of type %@ failed!", + [_stream class]]; } - (OFStream*)stream { OF_GETTER(_stream, false) } @end Index: src/exceptions/OFStillLockedException.h ================================================================== --- src/exceptions/OFStillLockedException.h +++ src/exceptions/OFStillLockedException.h @@ -30,29 +30,25 @@ #endif /*! * @brief Creates a new, autoreleased still locked exception. * - * @param class_ The class of the object which caused the exception * @param lock The lock which is still locked * @return A new, autoreleased still locked exception */ -+ (instancetype)exceptionWithClass: (Class)class_ - lock: (id )lock; ++ (instancetype)exceptionWithLock: (id )lock; /*! * @brief Initializes an already allocated still locked exception. * - * @param class_ The class of the object which caused the exception * @param lock The lock which is still locked * @return An initialized still locked exception */ -- initWithClass: (Class)class_ - lock: (id )lock; +- initWithLock: (id )lock; /*! * @brief Returns the lock which is still locked. * * @return The lock which is still locked */ - (id )lock; @end Index: src/exceptions/OFStillLockedException.m ================================================================== --- src/exceptions/OFStillLockedException.m +++ src/exceptions/OFStillLockedException.m @@ -17,24 +17,21 @@ #include "config.h" #import "OFStillLockedException.h" #import "OFString.h" -#import "macros.h" +#import "common.h" @implementation OFStillLockedException -+ (instancetype)exceptionWithClass: (Class)class - lock: (id )lock ++ (instancetype)exceptionWithLock: (id )lock { - return [[[self alloc] initWithClass: class - lock: lock] autorelease]; + return [[[self alloc] initWithLock: lock] autorelease]; } -- initWithClass: (Class)class - lock: (id )lock +- initWithLock: (id )lock { - self = [super initWithClass: class]; + self = [super init]; _lock = [lock retain]; return self; } @@ -46,15 +43,19 @@ [super dealloc]; } - (OFString*)description { - return [OFString stringWithFormat: - @"Deallocation of a lock of type %@ was tried in class %@, even " - @"though it was still locked!", [_lock class], _inClass]; + if (_lock != nil) + return [OFString stringWithFormat: + @"Deallocation of a lock of type %@ even though it was " + @"still locked!", [_lock class]]; + else + return @"Deallocation of a lock even though it was still " + @"locked!"; } - (id )lock { OF_GETTER(_lock, false) } @end Index: src/exceptions/OFSymlinkFailedException.h ================================================================== --- src/exceptions/OFSymlinkFailedException.h +++ src/exceptions/OFSymlinkFailedException.h @@ -14,11 +14,11 @@ * file. */ #import "OFException.h" -#ifndef _WIN32 +#ifdef OF_HAVE_SYMLINK /*! * @brief An exception indicating that creating a symlink failed. */ @interface OFSymlinkFailedException: OFException { @@ -32,37 +32,26 @@ #endif /*! * @brief Creates a new, autoreleased symlink failed exception. * - * @param class_ The class of the object which caused the exception * @param sourcePath The source for the symlink * @param destinationPath The destination for the symlink * @return A new, autoreleased symlink failed exception */ -+ (instancetype)exceptionWithClass: (Class)class_ - sourcePath: (OFString*)sourcePath - destinationPath: (OFString*)destinationPath; ++ (instancetype)exceptionWithSourcePath: (OFString*)sourcePath + destinationPath: (OFString*)destinationPath; /*! * @brief Initializes an already allocated symlink failed exception. * - * @param class_ The class of the object which caused the exception * @param sourcePath The source for the symlink * @param destinationPath The destination for the symlink * @return An initialized symlink failed exception */ -- initWithClass: (Class)class_ - sourcePath: (OFString*)sourcePath - destinationPath: (OFString*)destinationPath; - -/*! - * @brief Returns the errno from when the exception was created. - * - * @return The errno from when the exception was created - */ -- (int)errNo; +- initWithSourcePath: (OFString*)sourcePath + destinationPath: (OFString*)destinationPath; /*! * @brief Returns a string with the source for the symlink. * * @return A string with the source for the symlink @@ -73,7 +62,14 @@ * @brief Returns a string with the destination for the symlink. * * @return A string with the destination for the symlink */ - (OFString*)destinationPath; + +/*! + * @brief Returns the errno from when the exception was created. + * + * @return The errno from when the exception was created + */ +- (int)errNo; @end #endif Index: src/exceptions/OFSymlinkFailedException.m ================================================================== --- src/exceptions/OFSymlinkFailedException.m +++ src/exceptions/OFSymlinkFailedException.m @@ -21,22 +21,20 @@ #import "OFSymlinkFailedException.h" #import "OFString.h" #import "common.h" -#ifndef _WIN32 +#ifdef OF_HAVE_SYMLINK @implementation OFSymlinkFailedException -+ (instancetype)exceptionWithClass: (Class)class - sourcePath: (OFString*)sourcePath - destinationPath: (OFString*)destinationPath ++ (instancetype)exceptionWithSourcePath: (OFString*)sourcePath + destinationPath: (OFString*)destinationPath { - return [[[self alloc] initWithClass: class - sourcePath: sourcePath - destinationPath: destinationPath] autorelease]; + return [[[self alloc] initWithSourcePath: sourcePath + destinationPath: destinationPath] autorelease]; } -- initWithClass: (Class)class +- init { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @@ -44,15 +42,14 @@ } abort(); } -- initWithClass: (Class)class - sourcePath: (OFString*)sourcePath - destinationPath: (OFString*)destinationPath +- initWithSourcePath: (OFString*)sourcePath + destinationPath: (OFString*)destinationPath { - self = [super initWithClass: class]; + self = [super init]; @try { _sourcePath = [sourcePath copy]; _destinationPath = [destinationPath copy]; _errNo = GET_ERRNO; @@ -73,17 +70,12 @@ } - (OFString*)description { return [OFString stringWithFormat: - @"Failed to symlink file %@ to %@ in class %@! " ERRFMT, - _sourcePath, _destinationPath, _inClass, ERRPARAM]; -} - -- (int)errNo -{ - return _errNo; + @"Failed to symlink file %@ to %@! " ERRFMT, _sourcePath, + _destinationPath, ERRPARAM]; } - (OFString*)sourcePath { OF_GETTER(_sourcePath, false) @@ -91,7 +83,12 @@ - (OFString*)destinationPath { OF_GETTER(_destinationPath, false) } + +- (int)errNo +{ + return _errNo; +} @end #endif Index: src/exceptions/OFThreadJoinFailedException.h ================================================================== --- src/exceptions/OFThreadJoinFailedException.h +++ src/exceptions/OFThreadJoinFailedException.h @@ -35,29 +35,25 @@ #endif /*! * @brief Creates a new, autoreleased thread join failed exception. * - * @param class_ The class of the object which caused the exception * @param thread The thread which could not be joined * @return A new, autoreleased thread join failed exception */ -+ (instancetype)exceptionWithClass: (Class)class_ - thread: (OFThread*)thread; ++ (instancetype)exceptionWithThread: (OFThread*)thread; /*! * @brief Initializes an already allocated thread join failed exception. * - * @param class_ The class of the object which caused the exception * @param thread The thread which could not be joined * @return An initialized thread join failed exception */ -- initWithClass: (Class)class_ - thread: (OFThread*)thread; +- initWithThread: (OFThread*)thread; /*! * @brief Returns the thread which could not be joined. * * @return The thread which could not be joined */ - (OFThread*)thread; @end Index: src/exceptions/OFThreadJoinFailedException.m ================================================================== --- src/exceptions/OFThreadJoinFailedException.m +++ src/exceptions/OFThreadJoinFailedException.m @@ -21,18 +21,16 @@ #import "OFThreadJoinFailedException.h" #import "OFString.h" #import "OFThread.h" @implementation OFThreadJoinFailedException -+ (instancetype)exceptionWithClass: (Class)class - thread: (OFThread*)thread ++ (instancetype)exceptionWithThread: (OFThread*)thread { - return [[[self alloc] initWithClass: class - thread: thread] autorelease]; + return [[[self alloc] initWithThread: thread] autorelease]; } -- initWithClass: (Class)class +- init { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @@ -40,14 +38,13 @@ } abort(); } -- initWithClass: (Class)class - thread: (OFThread*)thread +- initWithThread: (OFThread*)thread { - self = [super initWithClass: class]; + self = [super init]; _thread = [thread retain]; return self; } @@ -60,14 +57,14 @@ } - (OFString*)description { return [OFString stringWithFormat: - @"Joining a thread of class %@ failed! Most likely, another thread " - @"already waits for the thread to join.", _inClass]; + @"Joining a thread of type %@ failed! Most likely, another thread " + @"already waits for the thread to join.", [_thread class]]; } - (OFThread*)thread { OF_GETTER(_thread, false) } @end Index: src/exceptions/OFThreadStartFailedException.h ================================================================== --- src/exceptions/OFThreadStartFailedException.h +++ src/exceptions/OFThreadStartFailedException.h @@ -35,29 +35,25 @@ #endif /*! * @brief Creates a new, autoreleased thread start failed exception. * - * @param class_ The class of the object which caused the exception * @param thread The thread which could not be started * @return A new, autoreleased thread start failed exception */ -+ (instancetype)exceptionWithClass: (Class)class_ - thread: (OFThread*)thread; ++ (instancetype)exceptionWithThread: (OFThread*)thread; /*! * @brief Initializes an already allocated thread start failed exception. * - * @param class_ The class of the object which caused the exception * @param thread The thread which could not be started * @return An initialized thread start failed exception */ -- initWithClass: (Class)class_ - thread: (OFThread*)thread; +- initWithThread: (OFThread*)thread; /*! * @brief Returns the thread which could not be started. * * @return The thread which could not be started */ - (OFThread*)thread; @end Index: src/exceptions/OFThreadStartFailedException.m ================================================================== --- src/exceptions/OFThreadStartFailedException.m +++ src/exceptions/OFThreadStartFailedException.m @@ -21,18 +21,16 @@ #import "OFThreadStartFailedException.h" #import "OFString.h" #import "OFThread.h" @implementation OFThreadStartFailedException -+ (instancetype)exceptionWithClass: (Class)class - thread: (OFThread*)thread ++ (instancetype)exceptionWithThread: (OFThread*)thread { - return [[[self alloc] initWithClass: class - thread: thread] autorelease]; + return [[[self alloc] initWithThread: thread] autorelease]; } -- initWithClass: (Class)class +- init { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @@ -40,14 +38,13 @@ } abort(); } -- initWithClass: (Class)class - thread: (OFThread*)thread +- initWithThread: (OFThread*)thread { - self = [super initWithClass: class]; + self = [super init]; _thread = [thread retain]; return self; } @@ -60,13 +57,13 @@ } - (OFString*)description { return [OFString stringWithFormat: - @"Starting a thread of class %@ failed!", _inClass]; + @"Starting a thread of type %@ failed!", [_thread class]]; } - (OFThread*)thread { OF_GETTER(_thread, false) } @end Index: src/exceptions/OFThreadStillRunningException.h ================================================================== --- src/exceptions/OFThreadStillRunningException.h +++ src/exceptions/OFThreadStillRunningException.h @@ -35,29 +35,25 @@ #endif /*! * @brief Creates a new, autoreleased thread still running exception. * - * @param class_ The class of the object which caused the exception * @param thread The thread which is still running * @return A new, autoreleased thread still running exception */ -+ (instancetype)exceptionWithClass: (Class)class_ - thread: (OFThread*)thread; ++ (instancetype)exceptionWithThread: (OFThread*)thread; /*! * @brief Initializes an already allocated thread still running exception. * - * @param class_ The class of the object which caused the exception * @param thread The thread which is still running * @return An initialized thread still running exception */ -- initWithClass: (Class)class_ - thread: (OFThread*)thread; +- initWithThread: (OFThread*)thread; /*! * @brief Returns the thread which is still running. * * @return The thread which is still running */ - (OFThread*)thread; @end Index: src/exceptions/OFThreadStillRunningException.m ================================================================== --- src/exceptions/OFThreadStillRunningException.m +++ src/exceptions/OFThreadStillRunningException.m @@ -21,18 +21,16 @@ #import "OFThreadStillRunningException.h" #import "OFString.h" #import "OFThread.h" @implementation OFThreadStillRunningException -+ (instancetype)exceptionWithClass: (Class)class - thread: (OFThread*)thread ++ (instancetype)exceptionWithThread: (OFThread*)thread { - return [[[self alloc] initWithClass: class - thread: thread] autorelease]; + return [[[self alloc] initWithThread: thread] autorelease]; } -- initWithClass: (Class)class +- init { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @@ -40,14 +38,13 @@ } abort(); } -- initWithClass: (Class)class - thread: (OFThread*)thread +- initWithThread: (OFThread*)thread { - self = [super initWithClass: class]; + self = [super init]; _thread = [thread retain]; return self; } @@ -61,13 +58,13 @@ - (OFString*)description { return [OFString stringWithFormat: @"Deallocation of a thread of type %@ was tried, even though it " - @"was still running!", _inClass]; + @"was still running!", [_thread class]]; } - (OFThread*)thread { OF_GETTER(_thread, false) } @end Index: src/exceptions/OFTruncatedDataException.m ================================================================== --- src/exceptions/OFTruncatedDataException.m +++ src/exceptions/OFTruncatedDataException.m @@ -20,10 +20,9 @@ #import "OFString.h" @implementation OFTruncatedDataException - (OFString*)description { - return [OFString stringWithFormat: - @"Truncated data was received or produced in class %@ while it " - @"should not have been truncated!", _inClass]; + return @"Truncated data was received or produced when it should not " + @"have been truncated!"; } @end Index: src/exceptions/OFUnboundNamespaceException.h ================================================================== --- src/exceptions/OFUnboundNamespaceException.h +++ src/exceptions/OFUnboundNamespaceException.h @@ -37,30 +37,26 @@ #endif /*! * @brief Creates a new, autoreleased unbound namespace exception. * - * @param class_ The class of the object which caused the exception * @param namespace_ The namespace which is unbound * @param element The element in which the namespace was not bound * @return A new, autoreleased unbound namespace exception */ -+ (instancetype)exceptionWithClass: (Class)class_ - namespace: (OFString*)namespace_ - element: (OFXMLElement*)element; ++ (instancetype)exceptionWithNamespace: (OFString*)namespace_ + element: (OFXMLElement*)element; /*! * @brief Initializes an already allocated unbound namespace exception. * - * @param class_ The class of the object which caused the exception * @param namespace_ The namespace which is unbound * @param element The element in which the namespace was not bound * @return An initialized unbound namespace exception */ -- initWithClass: (Class)class_ - namespace: (OFString*)namespace_ - element: (OFXMLElement*)element; +- initWithNamespace: (OFString*)namespace_ + element: (OFXMLElement*)element; /*! * @brief Returns the unbound namespace. * * @return The unbound namespace Index: src/exceptions/OFUnboundNamespaceException.m ================================================================== --- src/exceptions/OFUnboundNamespaceException.m +++ src/exceptions/OFUnboundNamespaceException.m @@ -23,20 +23,18 @@ #import "OFXMLElement.h" #import "common.h" @implementation OFUnboundNamespaceException -+ (instancetype)exceptionWithClass: (Class)class - namespace: (OFString*)namespace - element: (OFXMLElement*)element ++ (instancetype)exceptionWithNamespace: (OFString*)namespace + element: (OFXMLElement*)element { - return [[[self alloc] initWithClass: class - namespace: namespace - element: element] autorelease]; + return [[[self alloc] initWithNamespace: namespace + element: element] autorelease]; } -- initWithClass: (Class)class +- init { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @@ -44,15 +42,14 @@ } abort(); } -- initWithClass: (Class)class - namespace: (OFString*)namespace - element: (OFXMLElement*)element +- initWithNamespace: (OFString*)namespace + element: (OFXMLElement*)element { - self = [super initWithClass: class]; + self = [super init]; @try { _namespace = [namespace copy]; _element = [element retain]; } @catch (id e) { @@ -72,11 +69,12 @@ } - (OFString*)description { return [OFString stringWithFormat: - @"The namespace %@ is not bound in class %@", _namespace, _inClass]; + @"The namespace %@ is not bound in an element of type %@!", + _namespace, [_element class]]; } - (OFString*)namespace { OF_GETTER(_namespace, false) Index: src/exceptions/OFUnboundPrefixException.h ================================================================== --- src/exceptions/OFUnboundPrefixException.h +++ src/exceptions/OFUnboundPrefixException.h @@ -33,30 +33,26 @@ #endif /*! * @brief Creates a new, autoreleased unbound prefix exception. * - * @param class_ The class of the object which caused the exception * @param prefix The prefix which is unbound * @param parser The parser which encountered the unbound prefix * @return A new, autoreleased unbound prefix exception */ -+ (instancetype)exceptionWithClass: (Class)class_ - prefix: (OFString*)prefix - parser: (OFXMLParser*)parser; ++ (instancetype)exceptionWithPrefix: (OFString*)prefix + parser: (OFXMLParser*)parser; /*! * @brief Initializes an already allocated unbound prefix exception. * - * @param class_ The class of the object which caused the exception * @param prefix The prefix which is unbound * @param parser The parser which encountered the unbound prefix * @return An initialized unbound prefix exception */ -- initWithClass: (Class)class_ - prefix: (OFString*)prefix - parser: (OFXMLParser*)parser; +- initWithPrefix: (OFString*)prefix + parser: (OFXMLParser*)parser; /*! * @brief Returns the unbound prefix. * * @return The unbound prefix Index: src/exceptions/OFUnboundPrefixException.m ================================================================== --- src/exceptions/OFUnboundPrefixException.m +++ src/exceptions/OFUnboundPrefixException.m @@ -23,20 +23,18 @@ #import "OFXMLParser.h" #import "common.h" @implementation OFUnboundPrefixException -+ (instancetype)exceptionWithClass: (Class)class - prefix: (OFString*)prefix - parser: (OFXMLParser*)parser ++ (instancetype)exceptionWithPrefix: (OFString*)prefix + parser: (OFXMLParser*)parser { - return [[[self alloc] initWithClass: class - prefix: prefix - parser: parser] autorelease]; + return [[[self alloc] initWithPrefix: prefix + parser: parser] autorelease]; } -- initWithClass: (Class)class +- init { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @@ -44,15 +42,14 @@ } abort(); } -- initWithClass: (Class)class - prefix: (OFString*)prefix - parser: (OFXMLParser*)parser +- initWithPrefix: (OFString*)prefix + parser: (OFXMLParser*)parser { - self = [super initWithClass: class]; + self = [super init]; @try { _prefix = [prefix copy]; _parser = [parser retain]; } @catch (id e) { @@ -72,12 +69,12 @@ } - (OFString*)description { return [OFString stringWithFormat: - @"The XML parser in class %@ encountered the unbound prefix %@ in " - @"line %zd!", _inClass, _prefix, [_parser lineNumber]]; + @"An XML parser of type %@ encountered the unbound prefix %@ in " + @"line %zd!", [_parser class], _prefix, [_parser lineNumber]]; } - (OFString*)prefix { OF_GETTER(_prefix, false) Index: src/exceptions/OFUnlockFailedException.h ================================================================== --- src/exceptions/OFUnlockFailedException.h +++ src/exceptions/OFUnlockFailedException.h @@ -30,29 +30,25 @@ #endif /*! * @brief Creates a new, autoreleased unlock failed exception. * - * @param class_ The class of the object which caused the exception * @param lock The lock which could not be unlocked * @return A new, autoreleased unlock failed exception */ -+ (instancetype)exceptionWithClass: (Class)class_ - lock: (id )lock; ++ (instancetype)exceptionWithLock: (id )lock; /*! * @brief Initializes an already allocated unlock failed exception. * - * @param class_ The class of the object which caused the exception * @param lock The lock which could not be unlocked * @return An initialized unlock failed exception */ -- initWithClass: (Class)class_ - lock: (id )lock; +- initWithLock: (id )lock; /*! * @brief Returns the lock which could not be unlocked. * * @return The lock which could not be unlocked */ - (id )lock; @end Index: src/exceptions/OFUnlockFailedException.m ================================================================== --- src/exceptions/OFUnlockFailedException.m +++ src/exceptions/OFUnlockFailedException.m @@ -17,24 +17,21 @@ #include "config.h" #import "OFUnlockFailedException.h" #import "OFString.h" -#import "macros.h" +#import "common.h" @implementation OFUnlockFailedException -+ (instancetype)exceptionWithClass: (Class)class - lock: (id )lock ++ (instancetype)exceptionWithLock: (id )lock { - return [[[self alloc] initWithClass: class - lock: lock] autorelease]; + return [[[self alloc] initWithLock: lock] autorelease]; } -- initWithClass: (Class)class - lock: (id )lock +- initWithLock: (id )lock { - self = [super initWithClass: class]; + self = [super init]; _lock = [lock retain]; return self; } @@ -46,15 +43,17 @@ [super dealloc]; } - (OFString*)description { - return [OFString stringWithFormat: - @"A lock of class %@ could not be unlocked in class %@!", - [_lock class], _inClass]; + if (_lock != nil) + return [OFString stringWithFormat: + @"A lock of type %@ could not be unlocked!", [_lock class]]; + else + return @"A lock could not be unlocked!"; } - (id )lock { OF_GETTER(_lock, false) } @end Index: src/exceptions/OFUnsupportedProtocolException.h ================================================================== --- src/exceptions/OFUnsupportedProtocolException.h +++ src/exceptions/OFUnsupportedProtocolException.h @@ -32,29 +32,25 @@ #endif /*! * @brief Creates a new, autoreleased unsupported protocol exception. * - * @param class_ The class of the object which caused the exception * @param URL The URL whose protocol is unsupported * @return A new, autoreleased unsupported protocol exception */ -+ (instancetype)exceptionWithClass: (Class)class_ - URL: (OFURL*)URL; ++ (instancetype)exceptionWithURL: (OFURL*)URL; /*! * @brief Initializes an already allocated unsupported protocol exception * - * @param class_ The class of the object which caused the exception * @param URL The URL whose protocol is unsupported * @return An initialized unsupported protocol exception */ -- initWithClass: (Class)class_ - URL: (OFURL*)URL; +- initWithURL: (OFURL*)URL; /*! * @brief Returns the URL whose protocol is unsupported. * * @return The URL whose protocol is unsupported */ - (OFURL*)URL; @end Index: src/exceptions/OFUnsupportedProtocolException.m ================================================================== --- src/exceptions/OFUnsupportedProtocolException.m +++ src/exceptions/OFUnsupportedProtocolException.m @@ -23,18 +23,16 @@ #import "OFURL.h" #import "common.h" @implementation OFUnsupportedProtocolException -+ (instancetype)exceptionWithClass: (Class)class - URL: (OFURL*)url ++ (instancetype)exceptionWithURL: (OFURL*)url { - return [[[self alloc] initWithClass: class - URL: url] autorelease]; + return [[[self alloc] initWithURL: url] autorelease]; } -- initWithClass: (Class)class +- init { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @@ -42,14 +40,13 @@ } abort(); } -- initWithClass: (Class)class - URL: (OFURL*)URL +- initWithURL: (OFURL*)URL { - self = [super initWithClass: class]; + self = [super init]; @try { _URL = [URL copy]; } @catch (id e) { [self release]; @@ -67,14 +64,13 @@ } - (OFString*)description { return [OFString stringWithFormat: - @"The protocol of URL %@ is not supported by class %@", _URL, - _inClass]; + @"The protocol of URL %@ is not supported!", _URL]; } - (OFURL*)URL { OF_GETTER(_URL, false) } @end Index: src/exceptions/OFUnsupportedVersionException.h ================================================================== --- src/exceptions/OFUnsupportedVersionException.h +++ src/exceptions/OFUnsupportedVersionException.h @@ -30,29 +30,25 @@ #endif /*! * @brief Creates a new, autoreleased unsupported version exception. * - * @param class_ The class of the object which caused the exception * @param version The version which is unsupported * @return A new, autoreleased unsupported version exception */ -+ (instancetype)exceptionWithClass: (Class)class_ - version: (OFString*)version; ++ (instancetype)exceptionWithVersion: (OFString*)version; /*! * @brief Initializes an already allocated unsupported protocol exception. * - * @param class_ The class of the object which caused the exception * @param version The version which is unsupported * @return An initialized unsupported version exception */ -- initWithClass: (Class)class_ - version: (OFString*)version; +- initWithVersion: (OFString*)version; /*! * @brief Returns the version which is unsupported. * * @return The version which is unsupported */ - (OFString*)version; @end Index: src/exceptions/OFUnsupportedVersionException.m ================================================================== --- src/exceptions/OFUnsupportedVersionException.m +++ src/exceptions/OFUnsupportedVersionException.m @@ -22,18 +22,16 @@ #import "OFString.h" #import "common.h" @implementation OFUnsupportedVersionException -+ (instancetype)exceptionWithClass: (Class)class - version: (OFString*)version ++ (instancetype)exceptionWithVersion: (OFString*)version { - return [[[self alloc] initWithClass: class - version: version] autorelease]; + return [[[self alloc] initWithVersion: version] autorelease]; } -- initWithClass: (Class)class +- init { @try { [self doesNotRecognizeSelector: _cmd]; } @catch (id e) { [self release]; @@ -41,14 +39,13 @@ } abort(); } -- initWithClass: (Class)class - version: (OFString*)version +- initWithVersion: (OFString*)version { - self = [super initWithClass: class]; + self = [super init]; @try { _version = [version copy]; } @catch (id e) { [self release]; @@ -66,14 +63,14 @@ } - (OFString*)description { return [OFString stringWithFormat: - @"Version %@ of the format or protocol is not supported by class " - @"%@", _version, _inClass]; + @"Version %@ of the format or protocol is not supported!", + _version]; } - (OFString*)version { OF_GETTER(_version, false) } @end Index: src/exceptions/OFWriteFailedException.m ================================================================== --- src/exceptions/OFWriteFailedException.m +++ src/exceptions/OFWriteFailedException.m @@ -23,9 +23,9 @@ @implementation OFWriteFailedException - (OFString*)description { return [OFString stringWithFormat: - @"Failed to write %zu bytes in class %@! " ERRFMT, _requestedLength, - _inClass, ERRPARAM]; + @"Failed to write %zu bytes in a stream of type %@! " ERRFMT, + _requestedLength, [_stream class], ERRPARAM]; } @end Index: src/exceptions/common.h ================================================================== --- src/exceptions/common.h +++ src/exceptions/common.h @@ -31,11 +31,11 @@ # else # define GET_AT_ERRNO errno # endif # define GET_SOCK_ERRNO errno # endif -# define ERRFMT "Error string was: %s" +# define ERRFMT @"Error string was: %s" # define ERRPARAM strerror(_errNo) # ifdef OF_HAVE_SOCKETS # if !defined(HAVE_THREADSAFE_GETADDRINFO) && defined(HAVE_HSTRERROR) # define AT_ERRPARAM hstrerror(_errNo) # else @@ -47,11 +47,11 @@ # define GET_ERRNO GetLastError() # ifdef OF_HAVE_SOCKETS # define GET_AT_ERRNO WSAGetLastError() # define GET_SOCK_ERRNO WSAGetLastError() # endif -# define ERRFMT "Error code was: %d" +# define ERRFMT @"Error code was: %d" # define ERRPARAM _errNo # ifdef OF_HAVE_SOCKETS # define AT_ERRPARAM _errNo # endif #endif Index: tests/OFStringTests.m ================================================================== --- tests/OFStringTests.m +++ tests/OFStringTests.m @@ -448,12 +448,12 @@ (s[0] = [OFMutableString stringWithString: @"π„žΓΆΓΆΓΆbÀ€"]) && R([s[0] insertString: @"Àâü" atIndex: 3]) && [s[0] isEqual: @"π„žΓΆΓΆΓ€ΓΆΓΌΓΆbÀ€"]) - EXPECT_EXCEPTION(@"Detect invalid encoding in -[stringByURLDecoding] " - @"#1", OFInvalidEncodingException, [@"foo%bar" stringByURLDecoding]) + EXPECT_EXCEPTION(@"Detect invalid format in -[stringByURLDecoding] " + @"#1", OFInvalidFormatException, [@"foo%xbar" stringByURLDecoding]) EXPECT_EXCEPTION(@"Detect invalid encoding in -[stringByURLDecoding] " @"#2", OFInvalidEncodingException, [@"foo%FFbar" stringByURLDecoding]) TEST(@"-[setCharacter:atIndex:]", @@ -560,21 +560,21 @@ [[@"ä" stringByXMLUnescaping] isEqual: @"Γ€"] && [[@"€" stringByXMLUnescaping] isEqual: @"€"] && [[@"𝄞" stringByXMLUnescaping] isEqual: @"π„ž"]) EXPECT_EXCEPTION(@"Detect invalid entities in -[stringByXMLUnescaping] " - @"#1", OFInvalidEncodingException, [@"&foo;" stringByXMLUnescaping]) - EXPECT_EXCEPTION(@"Detect invalid entities in -[stringByXMLUnescaping] " - @"#2", OFInvalidEncodingException, [@"x&" stringByXMLUnescaping]) - EXPECT_EXCEPTION(@"Detect invalid entities in -[stringByXMLUnescaping] " - @"#3", OFInvalidEncodingException, [@"&#;" stringByXMLUnescaping]) - EXPECT_EXCEPTION(@"Detect invalid entities in -[stringByXMLUnescaping] " - @"#4", OFInvalidEncodingException, [@"&#x;" stringByXMLUnescaping]) - EXPECT_EXCEPTION(@"Detect invalid entities in -[stringByXMLUnescaping] " - @"#5", OFInvalidEncodingException, [@"&#g;" stringByXMLUnescaping]) - EXPECT_EXCEPTION(@"Detect invalid entities in -[stringByXMLUnescaping] " - @"#6", OFInvalidEncodingException, [@"&#xg;" stringByXMLUnescaping]) + @"#1", OFInvalidFormatException, [@"&foo;" stringByXMLUnescaping]) + EXPECT_EXCEPTION(@"Detect invalid entities in -[stringByXMLUnescaping] " + @"#2", OFInvalidFormatException, [@"x&" stringByXMLUnescaping]) + EXPECT_EXCEPTION(@"Detect invalid entities in -[stringByXMLUnescaping] " + @"#3", OFInvalidFormatException, [@"&#;" stringByXMLUnescaping]) + EXPECT_EXCEPTION(@"Detect invalid entities in -[stringByXMLUnescaping] " + @"#4", OFInvalidFormatException, [@"&#x;" stringByXMLUnescaping]) + EXPECT_EXCEPTION(@"Detect invalid entities in -[stringByXMLUnescaping] " + @"#5", OFInvalidFormatException, [@"&#g;" stringByXMLUnescaping]) + EXPECT_EXCEPTION(@"Detect invalid entities in -[stringByXMLUnescaping] " + @"#6", OFInvalidFormatException, [@"&#xg;" stringByXMLUnescaping]) TEST(@"-[stringByXMLUnescapingWithDelegate:]", (h = [[[EntityHandler alloc] init] autorelease]) && [[@"x&foo;y" stringByXMLUnescapingWithDelegate: h] isEqual: @"xbary"])