Index: src/OFApplication.h ================================================================== --- src/OFApplication.h +++ src/OFApplication.h @@ -81,12 +81,12 @@ * You should not call this directly! Use of_application_main instead! * * \param argc The number of arguments * \param argv The argument values */ -- setArgumentCount: (int)argc - andArgumentValues: (char**)argv; +- (void)setArgumentCount: (int)argc + andArgumentValues: (char**)argv; /** * \return The name of the program (argv[0]) */ - (OFString*)programName; @@ -104,16 +104,16 @@ /** * Sets the delegate of the application. * * \param delegate The delegate for the application */ -- setDelegate: (id)delegate; +- (void)setDelegate: (id)delegate; /** * Starts the application after everything has been initialized. */ -- run; +- (void)run; /** * Terminates the application. */ - (void)terminate; Index: src/OFApplication.m ================================================================== --- src/OFApplication.m +++ src/OFApplication.m @@ -86,12 +86,12 @@ atexit(atexit_handler); return self; } -- setArgumentCount: (int)argc - andArgumentValues: (char**)argv +- (void)setArgumentCount: (int)argc + andArgumentValues: (char**)argv { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; int i; [progname release]; @@ -102,12 +102,10 @@ for (i = 1; i < argc; i++) [arguments addObject: [OFString stringWithCString: argv[i]]]; [pool release]; - - return self; } - (OFString*)programName { return [[progname retain] autorelease]; @@ -121,24 +119,20 @@ - (id)delegate { return [[delegate retain] autorelease]; } -- setDelegate: (id)delegate_ +- (void)setDelegate: (id)delegate_ { id old = delegate; delegate = [delegate_ retain]; [old release]; - - return self; } -- run +- (void)run { [delegate applicationDidFinishLaunching]; - - return self; } - (void)terminate { exit(0); Index: src/OFArray.m ================================================================== --- src/OFArray.m +++ src/OFArray.m @@ -389,16 +389,14 @@ return *(OFObject**)[array itemAtIndex: pos++]; return nil; } -- reset +- (void)reset { if (mutations_ptr != NULL && *mutations_ptr != mutations) @throw [OFEnumerationMutationException newWithClass: isa]; pos = 0; - - return self; } @end /// \endcond Index: src/OFAutoreleasePool.h ================================================================== --- src/OFAutoreleasePool.h +++ src/OFAutoreleasePool.h @@ -40,21 +40,21 @@ /** * Adds an object to the specific autorelease pool. * * \param obj The object to add to the autorelease pool */ -- addObject: (OFObject*)obj; +- (void)addObject: (OFObject*)obj; /** * Releases all objects in the autorelease pool. * * If a garbage collector is added in the future, it will tell the GC that now * is a good time to clean up, as this is often used after a lot of objects * have been added to the pool that should be released before the next iteration * of a loop, which adds objects again. Thus, it is usually a clean up call. */ -- releaseObjects; +- (void)releaseObjects; /** * Releases all objects in the autorelease pool and deallocates the pool. */ - (void)release; Index: src/OFAutoreleasePool.m ================================================================== --- src/OFAutoreleasePool.m +++ src/OFAutoreleasePool.m @@ -16,11 +16,11 @@ #import "OFAutoreleasePool.h" #import "OFArray.h" #import "OFExceptions.h" #ifdef OF_THREADS -#import "threading.h" +# import "threading.h" static of_tlskey_t first_key, last_key; #else static OFAutoreleasePool *first = nil, *last = nil; #endif @@ -119,10 +119,36 @@ if (prev != nil) prev->next = self; return self; } + +- (void)addObject: (OFObject*)obj +{ + if (objects == nil) + objects = [[OFMutableArray alloc] init]; + + [objects addObject: obj]; + [obj release]; +} + +- (void)releaseObjects +{ + [next releaseObjects]; + [objects release]; + objects = nil; +} + +- (void)release +{ + [self dealloc]; +} + +- (void)drain +{ + [self dealloc]; +} - (void)dealloc { [next dealloc]; [objects release]; @@ -159,44 +185,10 @@ #endif [super dealloc]; } -- addObject: (OFObject*)obj -{ - if (objects == nil) - objects = [[OFMutableArray alloc] init]; - - [objects addObject: obj]; - [obj release]; - - return self; -} - -- releaseObjects -{ - [next releaseObjects]; - - if (objects == nil) - return self; - - [objects release]; - objects = nil; - - return self; -} - -- (void)release -{ - [self dealloc]; -} - -- (void)drain -{ - [self dealloc]; -} - - retain { @throw [OFNotImplementedException newWithClass: isa selector: _cmd]; } Index: src/OFConstString.m ================================================================== --- src/OFConstString.m +++ src/OFConstString.m @@ -86,11 +86,11 @@ { @throw [OFNotImplementedException newWithClass: isa selector: _cmd]; } -- addMemoryToPool: (void*)ptr +- (void)addMemoryToPool: (void*)ptr { @throw [OFNotImplementedException newWithClass: isa selector: _cmd]; } @@ -120,11 +120,11 @@ { @throw [OFNotImplementedException newWithClass: isa selector: _cmd]; } -- freeMemory: (void*)ptr +- (void)freeMemory: (void*)ptr { @throw [OFNotImplementedException newWithClass: isa selector: _cmd]; } Index: src/OFDataArray.h ================================================================== --- src/OFDataArray.h +++ src/OFDataArray.h @@ -85,63 +85,63 @@ /** * Adds an item to the OFDataArray. * * \param item A pointer to an arbitrary item */ -- addItem: (void*)item; +- (void)addItem: (void*)item; /** * Adds an item to the OFDataArray at the specified index. * * \param item A pointer to an arbitrary item * \param index The index where the item should be added */ -- addItem: (void*)item - atIndex: (size_t)index; +- (void)addItem: (void*)item + atIndex: (size_t)index; /** * Adds items from a C array to the OFDataArray. * * \param nitems The number of items to add * \param carray A C array containing the items to add */ -- addNItems: (size_t)nitems - fromCArray: (void*)carray; +- (void)addNItems: (size_t)nitems + fromCArray: (void*)carray; /** * Adds items from a C array to the OFDataArray at the specified index. * * \param nitems The number of items to add * \param carray A C array containing the items to add * \param index The index where the items should be added */ -- addNItems: (size_t)nitems - fromCArray: (void*)carray - atIndex: (size_t)index; +- (void)addNItems: (size_t)nitems + fromCArray: (void*)carray + atIndex: (size_t)index; /** * Removes the item at the specified index. * * \param index The index of the item to remove */ -- removeItemAtIndex: (size_t)index; +- (void)removeItemAtIndex: (size_t)index; /** * Removes the specified amount of items from the end of the OFDataArray. * * \param nitems The number of items to remove */ -- removeNItems: (size_t)nitems; +- (void)removeNItems: (size_t)nitems; /** * Removes the specified amount of items at the specified index. * * \param nitems The number of items to remove * \param index The index at which the items are removed */ -- removeNItems: (size_t)nitems - atIndex: (size_t)index; +- (void)removeNItems: (size_t)nitems + atIndex: (size_t)index; @end /** * \brief A class for storing arbitrary big data in an array. * Index: src/OFDataArray.m ================================================================== --- src/OFDataArray.m +++ src/OFDataArray.m @@ -87,11 +87,11 @@ return NULL; return data + (count - 1) * itemsize; } -- addItem: (void*)item +- (void)addItem: (void*)item { if (SIZE_MAX - count < 1) @throw [OFOutOfRangeException newWithClass: isa]; data = [self resizeMemory: data @@ -99,24 +99,22 @@ withSize: itemsize]; memcpy(data + count * itemsize, item, itemsize); count++; - - return self; } -- addItem: (void*)item - atIndex: (size_t)index +- (void)addItem: (void*)item + atIndex: (size_t)index { - return [self addNItems: 1 - fromCArray: item - atIndex: index]; + [self addNItems: 1 + fromCArray: item + atIndex: index]; } -- addNItems: (size_t)nitems - fromCArray: (void*)carray +- (void)addNItems: (size_t)nitems + fromCArray: (void*)carray { if (nitems > SIZE_MAX - count) @throw [OFOutOfRangeException newWithClass: isa]; data = [self resizeMemory: data @@ -123,17 +121,15 @@ toNItems: count + nitems withSize: itemsize]; memcpy(data + count * itemsize, carray, nitems * itemsize); count += nitems; - - return self; } -- addNItems: (size_t)nitems - fromCArray: (void*)carray - atIndex: (size_t)index +- (void)addNItems: (size_t)nitems + fromCArray: (void*)carray + atIndex: (size_t)index { if (nitems > SIZE_MAX - count) @throw [OFOutOfRangeException newWithClass: isa]; data = [self resizeMemory: data @@ -143,21 +139,19 @@ memmove(data + (index + nitems) * itemsize, data + index * itemsize, (count - index) * itemsize); memcpy(data + index * itemsize, carray, nitems * itemsize); count += nitems; +} - return self; +- (void)removeItemAtIndex: (size_t)index +{ + [self removeNItems: 1 + atIndex: index]; } -- removeItemAtIndex: (size_t)index -{ - return [self removeNItems: 1 - atIndex: index]; -} - -- removeNItems: (size_t)nitems +- (void)removeNItems: (size_t)nitems { if (nitems > count) @throw [OFOutOfRangeException newWithClass: isa]; @@ -168,16 +162,14 @@ withSize: itemsize]; } @catch (OFOutOfMemoryException *e) { /* We don't really care, as we only made it smaller */ [e dealloc]; } - - return self; } -- removeNItems: (size_t)nitems - atIndex: (size_t)index +- (void)removeNItems: (size_t)nitems + atIndex: (size_t)index { if (nitems > count) @throw [OFOutOfRangeException newWithClass: isa]; memmove(data + index * itemsize, data + (index + nitems) * itemsize, @@ -190,12 +182,10 @@ withSize: itemsize]; } @catch (OFOutOfMemoryException *e) { /* We don't really care, as we only made it smaller */ [e dealloc]; } - - return self; } - (id)copy { OFDataArray *new = [[OFDataArray alloc] initWithItemSize: itemsize]; @@ -260,11 +250,11 @@ return hash; } @end @implementation OFBigDataArray -- addItem: (void*)item +- (void)addItem: (void*)item { size_t nsize, lastpagebyte; if (SIZE_MAX - count < 1 || count + 1 > SIZE_MAX / itemsize) @throw [OFOutOfRangeException newWithClass: isa]; @@ -278,16 +268,14 @@ memcpy(data + count * itemsize, item, itemsize); count++; size = nsize; - - return self; } -- addNItems: (size_t)nitems - fromCArray: (void*)carray +- (void)addNItems: (size_t)nitems + fromCArray: (void*)carray { size_t nsize, lastpagebyte; if (nitems > SIZE_MAX - count || count + nitems > SIZE_MAX / itemsize) @throw [OFOutOfRangeException newWithClass: isa]; @@ -301,17 +289,15 @@ memcpy(data + count * itemsize, carray, nitems * itemsize); count += nitems; size = nsize; - - return self; } -- addNItems: (size_t)nitems - fromCArray: (void*)carray - atIndex: (size_t)index +- (void)addNItems: (size_t)nitems + fromCArray: (void*)carray + atIndex: (size_t)index { size_t nsize, lastpagebyte; if (nitems > SIZE_MAX - count || count + nitems > SIZE_MAX / itemsize) @throw [OFOutOfRangeException newWithClass: isa]; @@ -328,15 +314,13 @@ (count - index) * itemsize); memcpy(data + index * itemsize, carray, nitems * itemsize); count += nitems; size = nsize; - - return self; } -- removeNItems: (size_t)nitems +- (void)removeNItems: (size_t)nitems { size_t nsize, lastpagebyte; if (nitems > count) @throw [OFOutOfRangeException newWithClass: isa]; @@ -347,16 +331,14 @@ if (size != nsize) data = [self resizeMemory: data toSize: nsize]; size = nsize; - - return self; } -- removeNItems: (size_t)nitems - atIndex: (size_t)index +- (void)removeNItems: (size_t)nitems + atIndex: (size_t)index { size_t nsize, lastpagebyte; if (nitems > count) @throw [OFOutOfRangeException newWithClass: isa]; @@ -370,12 +352,10 @@ if (size != nsize) data = [self resizeMemory: data toSize: nsize]; size = nsize; - - return self; } - (id)copy { OFDataArray *new = [[OFBigDataArray alloc] initWithItemSize: itemsize]; Index: src/OFDictionary.m ================================================================== --- src/OFDictionary.m +++ src/OFDictionary.m @@ -694,18 +694,16 @@ mutations_ptr = mutations_ptr_; return self; } -- reset +- (void)reset { if (mutations_ptr != NULL && *mutations_ptr != mutations) @throw [OFEnumerationMutationException newWithClass: isa]; pos = 0; - - return self; } @end @implementation OFDictionaryObjectEnumerator - (id)nextObject Index: src/OFEnumerator.h ================================================================== --- src/OFEnumerator.h +++ src/OFEnumerator.h @@ -22,11 +22,11 @@ /** * Resets the enumerator, so the next call to nextObject returns the first * object again. */ -- reset; +- (void)reset; @end /* * This needs to be exactly like this because it's hardcoded in the compiler. * Index: src/OFEnumerator.m ================================================================== --- src/OFEnumerator.m +++ src/OFEnumerator.m @@ -28,11 +28,11 @@ { @throw [OFNotImplementedException newWithClass: isa selector: _cmd]; } -- reset +- (void)reset { @throw [OFNotImplementedException newWithClass: isa selector: _cmd]; } @end Index: src/OFFile.m ================================================================== --- src/OFFile.m +++ src/OFFile.m @@ -374,16 +374,14 @@ size: size]; return ret; } -- _seekToOffset: (off_t)offset +- (void)_seekToOffset: (off_t)offset { if (lseek(fd, offset, SEEK_SET) == -1) @throw [OFSeekFailedException newWithClass: isa]; - - return self; } - (size_t)_seekForwardWithOffset: (off_t)offset { off_t ret; @@ -402,17 +400,15 @@ @throw [OFSeekFailedException newWithClass: isa]; return ret; } -- close +- (void)close { if (fd != -1) close(fd); fd = -1; - - return self; } - (void)dealloc { if (closable && fd != -1) Index: src/OFHashes.h ================================================================== --- src/OFHashes.h +++ src/OFHashes.h @@ -38,12 +38,12 @@ * Adds a buffer to the hash to be calculated. * * \param buf The buffer which should be included into calculation. * \param size The size of the buffer */ -- updateWithBuffer: (const char*)buf - ofSize: (size_t)size; +- (void)updateWithBuffer: (const char*)buf + ofSize: (size_t)size; /** * \return A buffer containing the hash (OF_MD5_DIGEST_SIZE = 16 bytes). * The buffer is part of object's memory pool. */ @@ -72,12 +72,12 @@ * Adds a buffer to the hash to be calculated. * * \param buf The buffer which should be included into calculation. * \param size The size of the buffer */ -- updateWithBuffer: (const char*)buf - ofSize: (size_t)size; +- (void)updateWithBuffer: (const char*)buf + ofSize: (size_t)size; /** * \return A buffer containing the hash (OF_SHA1_DIGEST_SIZE = 20 bytes). * The buffer is part of object's memory pool. */ Index: src/OFHashes.m ================================================================== --- src/OFHashes.m +++ src/OFHashes.m @@ -134,17 +134,17 @@ buf[3] = 0x10325476; return self; } -- updateWithBuffer: (const char*)buffer - ofSize: (size_t)size +- (void)updateWithBuffer: (const char*)buffer + ofSize: (size_t)size { uint32_t t; if (size == 0) - return self; + return; if (calculated) @throw [OFHashAlreadyCalculatedException newWithClass: isa]; /* Update bitcount */ @@ -163,11 +163,11 @@ t = 64 - t; if (size < t) { memcpy(p, buffer, size); - return self; + return; } memcpy(p, buffer, t); OF_BSWAP32_V_IF_BE((uint32_t*)in, 16); md5_transform(buf, (uint32_t*)in); @@ -186,12 +186,10 @@ size -= 64; } /* Handle any remaining bytes of data. */ memcpy(in, buffer, size); - - return self; } - (uint8_t*)digest { uint8_t *p; @@ -376,22 +374,20 @@ state[4] = 0xC3D2E1F0; return self; } -- updateWithBuffer: (const char*)buf - ofSize: (size_t)size +- (void)updateWithBuffer: (const char*)buf + ofSize: (size_t)size { if (size == 0) - return self; + return; if (calculated) @throw [OFHashAlreadyCalculatedException newWithClass: isa]; sha1_update(state, &count, buffer, buf, size); - - return self; } - (uint8_t*)digest { size_t i; Index: src/OFList.h ================================================================== --- src/OFList.h +++ src/OFList.h @@ -98,12 +98,12 @@ /** * Removes the object with the specified list object from the list. * * \param listobj The list object returned by append / prepend */ -- remove: (of_list_object_t*)listobj; +- (void)remove: (of_list_object_t*)listobj; /** * \return The number of items in the list. */ - (size_t)count; @end Index: src/OFList.m ================================================================== --- src/OFList.m +++ src/OFList.m @@ -147,11 +147,11 @@ [obj retain]; return o; } -- remove: (of_list_object_t*)listobj +- (void)remove: (of_list_object_t*)listobj { if (listobj->prev != NULL) listobj->prev->next = listobj->next; if (listobj->next != NULL) listobj->next->prev = listobj->prev; @@ -164,12 +164,10 @@ count--; [listobj->object release]; [self freeMemory: listobj]; - - return self; } - (size_t)count { return count; Index: src/OFMutableArray.h ================================================================== --- src/OFMutableArray.h +++ src/OFMutableArray.h @@ -22,82 +22,84 @@ /** * Adds an object to the OFArray. * * \param obj An object to add */ -- addObject: (OFObject*)obj; +- (void)addObject: (OFObject*)obj; /** * Adds an object to the OFArray at the specified index. * * \param obj An object to add * \param index The index where the object should be added */ -- addObject: (OFObject*)obj - atIndex: (size_t)index; +- (void)addObject: (OFObject*)obj + atIndex: (size_t)index; /** * Replaces all objects equivalent to the first specified object with the * second specified object. * * \param old The object to replace * \param new The replacement object */ -- replaceObject: (OFObject*)old - withObject: (OFObject*)new; +- (void)replaceObject: (OFObject*)old + withObject: (OFObject*)new; /** * Replaces the object at the specified index with the specified object. * * \param index The index of the object to replace * \param obj The replacement object + * \return The old object, autoreleased */ -- replaceObjectAtIndex: (size_t)index - withObject: (OFObject*)obj; +- (id)replaceObjectAtIndex: (size_t)index + withObject: (OFObject*)obj; /** * Replaces all objects that have the same address as the first specified object * with the second specified object. * * \param old The object to replace * \param new The replacement object */ -- replaceObjectIdenticalTo: (OFObject*)old - withObject: (OFObject*)new; +- (void)replaceObjectIdenticalTo: (OFObject*)old + withObject: (OFObject*)new; /** * Removes all objects equivalent to the specified object. * * \param obj The object to remove */ -- removeObject: (OFObject*)obj; +- (void)removeObject: (OFObject*)obj; /** * Removes all objects that have the same address as the specified object. * * \param obj The object to remove */ -- removeObjectIdenticalTo: (OFObject*)obj; +- (void)removeObjectIdenticalTo: (OFObject*)obj; /** * Removes the object at the specified index. * * \param index The index of the object to remove + * \return The object that was at the index, autoreleased */ -- removeObjectAtIndex: (size_t)index; +- (id)removeObjectAtIndex: (size_t)index; /** * Removes the specified amount of objects from the end of the OFArray. * * \param nobjects The number of objects to remove */ -- removeNObjects: (size_t)nobjects; +- (void)removeNObjects: (size_t)nobjects; /** * Removes the specified amount of objects at the specified index. * * \param nobjects The number of objects to remove * \param index The index at which the objects are removed */ -- removeNObjects: (size_t)nobjects - atIndex: (size_t)index; +- (void)removeNObjects: (size_t)nobjects + atIndex: (size_t)index; @end Index: src/OFMutableArray.m ================================================================== --- src/OFMutableArray.m +++ src/OFMutableArray.m @@ -34,34 +34,30 @@ [objs[i] retain]; return new; } -- addObject: (OFObject*)obj +- (void)addObject: (OFObject*)obj { [array addItem: &obj]; [obj retain]; mutations++; - - return self; } -- addObject: (OFObject*)obj - atIndex: (size_t)index +- (void)addObject: (OFObject*)obj + atIndex: (size_t)index { [array addItem: &obj atIndex: index]; [obj retain]; mutations++; - - return self; } -- replaceObject: (OFObject*)old - withObject: (OFObject*)new +- (void)replaceObject: (OFObject*)old + withObject: (OFObject*)new { OFObject **objs = [array cArray]; size_t i, count = [array count]; for (i = 0; i < count; i++) { @@ -69,31 +65,29 @@ [new retain]; [objs[i] release]; objs[i] = new; } } - - return self; } -- replaceObjectAtIndex: (size_t)index - withObject: (OFObject*)obj +- (id)replaceObjectAtIndex: (size_t)index + withObject: (OFObject*)obj { OFObject **objs = [array cArray]; + id old; if (index >= [array count]) @throw [OFOutOfRangeException newWithClass: isa]; - [obj retain]; - [objs[index] release]; - objs[index] = obj; + old = objs[index]; + objs[index] = [obj retain]; - return self; + return [old autorelease]; } -- replaceObjectIdenticalTo: (OFObject*)old - withObject: (OFObject*)new +- (void)replaceObjectIdenticalTo: (OFObject*)old + withObject: (OFObject*)new { OFObject **objs = [array cArray]; size_t i, count = [array count]; for (i = 0; i < count; i++) { @@ -101,15 +95,13 @@ [new retain]; [objs[i] release]; objs[i] = new; } } - - return self; } -- removeObject: (OFObject*)obj +- (void)removeObject: (OFObject*)obj { OFObject **objs = [array cArray]; size_t i, count = [array count]; for (i = 0; i < count; i++) { @@ -132,15 +124,13 @@ objs = [array cArray]; count--; i--; } } - - return self; } -- removeObjectIdenticalTo: (OFObject*)obj +- (void)removeObjectIdenticalTo: (OFObject*)obj { OFObject **objs = [array cArray]; size_t i, count = [array count]; for (i = 0; i < count; i++) { @@ -161,21 +151,23 @@ objs = [array cArray]; count--; i--; } } - - return self; } -- removeObjectAtIndex: (size_t)index +- (id)removeObjectAtIndex: (size_t)index { - return [self removeNObjects: 1 - atIndex: index]; + id old = [self objectAtIndex: index]; + + [self removeNObjects: 1 + atIndex: index]; + + return old; } -- removeNObjects: (size_t)nobjects +- (void)removeNObjects: (size_t)nobjects { OFObject **objs = [array cArray], **copy; size_t i, count = [array count]; if (nobjects > count) @@ -192,16 +184,14 @@ for (i = 0; i < nobjects; i++) [copy[i] release]; } @finally { [self freeMemory: copy]; } - - return self; } -- removeNObjects: (size_t)nobjects - atIndex: (size_t)index +- (void)removeNObjects: (size_t)nobjects + atIndex: (size_t)index { OFObject **objs = [array cArray], **copy; size_t i, count = [array count]; if (nobjects > count - index) @@ -219,12 +209,10 @@ for (i = 0; i < nobjects; i++) [copy[i] release]; } @finally { [self freeMemory: copy]; } - - return self; } - (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state objects: (id*)objects count: (int)count_ Index: src/OFMutableDictionary.h ================================================================== --- src/OFMutableDictionary.h +++ src/OFMutableDictionary.h @@ -22,16 +22,18 @@ /** * Sets a key to an object. A key can be any object. * * \param key The key to set * \param obj The object to set the key to + * \return The old object, autoreleased */ -- setObject: (OFObject*)obj - forKey: (OFObject *)key; +- (id)setObject: (OFObject*)obj + forKey: (OFObject *)key; /** * Remove the object with the given key from the dictionary. * * \param key The key whose object should be removed + * \return The object that was stored for the key, autoreleased */ -- removeObjectForKey: (OFObject*)key; +- (id)removeObjectForKey: (OFObject*)key; @end Index: src/OFMutableDictionary.m ================================================================== --- src/OFMutableDictionary.m +++ src/OFMutableDictionary.m @@ -77,14 +77,15 @@ [self freeMemory: data]; data = newdata; size = newsize; } -- setObject: (OFObject*)obj - forKey: (OFObject *)key +- (id)setObject: (OFObject*)obj + forKey: (OFObject *)key { uint32_t i, hash, last; + id old; if (key == nil || obj == nil) @throw [OFInvalidArgumentException newWithClass: isa selector: _cmd]; @@ -156,23 +157,23 @@ b->object = obj; b->hash = hash; data[i] = b; count++; - return self; + return nil; } - [obj retain]; - [data[i]->object release]; - data[i]->object = obj; + old = data[i]->object; + data[i]->object = [obj retain]; - return self; + return [old autorelease]; } -- removeObjectForKey: (OFObject*)key +- (id)removeObjectForKey: (OFObject*)key { uint32_t i, hash, last; + id old; if (key == nil) @throw [OFInvalidArgumentException newWithClass: isa selector: _cmd]; @@ -182,48 +183,50 @@ for (i = hash & (size - 1); i < last && data[i] != NULL; i++) { if (data[i] == DELETED) continue; if ([data[i]->key isEqual: key]) { + old = data[i]->object; + [data[i]->key release]; - [data[i]->object release]; [self freeMemory: data[i]]; data[i] = DELETED; count--; mutations++; [self _resizeForCount: count]; - return self; + return [old autorelease]; } } if (i < last) - return self; + return nil; /* In case the last bucket is already used */ last = hash & (size - 1); for (i = 0; i < last && data[i] != NULL; i++) { if (data[i] == DELETED) continue; if ([data[i]->key isEqual: key]) { + old = data[i]->object; + [data[i]->key release]; - [data[i]->object release]; [self freeMemory: data[i]]; data[i] = DELETED; count--; mutations++; [self _resizeForCount: count]; - return self; + return [old autorelease]; } } - return self; + return nil; } - (id)copy { return [[OFDictionary alloc] initWithDictionary: self]; Index: src/OFMutableString.h ================================================================== --- src/OFMutableString.h +++ src/OFMutableString.h @@ -21,27 +21,27 @@ /** * Sets the OFString to the specified UTF-8 encoded C string. * * \param str A UTF-8 encoded C string to set the OFString to. */ -- setToCString: (const char*)str; +- (void)setToCString: (const char*)str; /** * Appends a UTF-8 encoded C string to the OFString. * * \param str A UTF-8 encoded C string to append */ -- appendCString: (const char*)str; +- (void)appendCString: (const char*)str; /** * Appends a UTF-8 encoded C string with the specified length to the OFString. * * \param str A UTF-8 encoded C string to append * \param len The length of the UTF-8 encoded C string */ -- appendCString: (const char*)str - withLength: (size_t)len; +- (void)appendCString: (const char*)str + withLength: (size_t)len; /** * Appends a UTF-8 encoded C string to the OFString without checking whether it * is valid UTF-8. * @@ -48,11 +48,11 @@ * Only use this if you are 100% sure the string you append is either ASCII or * UTF-8! * * \param str A UTF-8 encoded C string to append */ -- appendCStringWithoutUTF8Checking: (const char*)str; +- (void)appendCStringWithoutUTF8Checking: (const char*)str; /** * Appends a UTF-8 encoded C string with the specified length to the OFString * without checking whether it is valid UTF-8. * @@ -60,89 +60,89 @@ * UTF-8! * * \param str A UTF-8 encoded C string to append * \param len The length of the UTF-8 encoded C string */ -- appendCStringWithoutUTF8Checking: (const char*)str - length: (size_t)len; +- (void)appendCStringWithoutUTF8Checking: (const char*)str + length: (size_t)len; /** * Appends another OFString to the OFString. * * \param str An OFString to append */ -- appendString: (OFString*)str; +- (void)appendString: (OFString*)str; /** * Appends a formatted UTF-8 encoded C string to the OFString. * See printf for the format syntax. * * \param fmt A format string which generates the string to append */ -- appendFormat: (OFString*)fmt, ...; +- (void)appendFormat: (OFString*)fmt, ...; /** * Appends a formatted UTF-8 encoded C string to the OFString. * See printf for the format syntax. * * \param fmt A format string which generates the string to append * \param args The arguments used in the format string */ -- appendFormat: (OFString*)fmt - withArguments: (va_list)args; +- (void)appendFormat: (OFString*)fmt + withArguments: (va_list)args; /** * Reverse the OFString. */ -- reverse; +- (void)reverse; /** * Upper the OFString. */ -- upper; +- (void)upper; /** * Lower the OFString. */ -- lower; +- (void)lower; /** * Removes the characters at the specified range. * * \param start The index where the deletion should be started * \param end The index until which the characters should be deleted. * This points BEHIND the last character! */ -- removeCharactersFromIndex: (size_t)start - toIndex: (size_t)end; +- (void)removeCharactersFromIndex: (size_t)start + toIndex: (size_t)end; /** * Removes the characters at the specified range. * * \param range The range of the characters which should be removed */ -- removeCharactersInRange: (of_range_t)range; +- (void)removeCharactersInRange: (of_range_t)range; /** * Replaces all occurrences of a string with another string. * * \param str The string to replace * \param repl The string with which it should be replaced */ -- replaceOccurrencesOfString: (OFString*)str - withString: (OFString*)repl; +- (void)replaceOccurrencesOfString: (OFString*)str + withString: (OFString*)repl; /** * Removes all whitespaces at the beginning of a string. */ -- removeLeadingWhitespaces; +- (void)removeLeadingWhitespaces; /** * Removes all whitespaces at the end of a string. */ -- removeTrailingWhitespaces; +- (void)removeTrailingWhitespaces; /** * Removes all whitespaces at the beginning and the end of a string. */ -- removeLeadingAndTrailingWhitespaces; +- (void)removeLeadingAndTrailingWhitespaces; @end Index: src/OFMutableString.m ================================================================== --- src/OFMutableString.m +++ src/OFMutableString.m @@ -120,11 +120,11 @@ *string = nstr; *length = nlen; } @implementation OFMutableString -- setToCString: (const char*)str +- (void)setToCString: (const char*)str { size_t len; [self freeMemory: string]; @@ -146,15 +146,13 @@ } length = len; string = [self allocMemoryWithSize: length + 1]; memcpy(string, str, length + 1); - - return self; } -- appendCString: (const char*)str +- (void)appendCString: (const char*)str { size_t strlength; strlength = strlen(str); @@ -168,16 +166,14 @@ string = [self resizeMemory: string toSize: length + strlength + 1]; memcpy(string + length, str, strlength + 1); length += strlength; - - return self; } -- appendCString: (const char*)str - withLength: (size_t)len +- (void)appendCString: (const char*)str + withLength: (size_t)len { if (len > strlen(str)) @throw [OFOutOfRangeException newWithClass: isa]; switch (of_string_check_utf8(str, len)) { @@ -191,64 +187,53 @@ string = [self resizeMemory: string toSize: length + len + 1]; memcpy(string + length, str, len); length += len; string[length] = 0; - - return self; } -- appendCStringWithoutUTF8Checking: (const char*)str +- (void)appendCStringWithoutUTF8Checking: (const char*)str { size_t strlength; strlength = strlen(str); string = [self resizeMemory: string toSize: length + strlength + 1]; memcpy(string + length, str, strlength + 1); length += strlength; - - return self; } -- appendCStringWithoutUTF8Checking: (const char*)str - length: (size_t)len +- (void)appendCStringWithoutUTF8Checking: (const char*)str + length: (size_t)len { if (len > strlen(str)) @throw [OFOutOfRangeException newWithClass: isa]; string = [self resizeMemory: string toSize: length + len + 1]; memcpy(string + length, str, len); length += len; string[length] = 0; - - return self; } -- appendString: (OFString*)str +- (void)appendString: (OFString*)str { [self appendCString: [str cString]]; - - return self; } -- appendFormat: (OFString*)fmt, ... +- (void)appendFormat: (OFString*)fmt, ... { - id ret; va_list args; va_start(args, fmt); - ret = [self appendFormat: fmt - withArguments: args]; + [self appendFormat: fmt + withArguments: args]; va_end(args); - - return ret; } -- appendFormat: (OFString*)fmt - withArguments: (va_list)args +- (void)appendFormat: (OFString*)fmt + withArguments: (va_list)args { char *t; if (fmt == nil) @throw [OFInvalidArgumentException newWithClass: isa @@ -265,15 +250,13 @@ @try { [self appendCString: t]; } @finally { free(t); } - - return self; } -- reverse +- (void)reverse { size_t i, j, len = length / 2; madvise(string, len, MADV_SEQUENTIAL); @@ -284,11 +267,11 @@ string[i] ^= string[j]; } if (!is_utf8) { madvise(string, len, MADV_NORMAL); - return self; + return; } for (i = 0; i < length; i++) { /* ASCII */ if (OF_LIKELY(!(string[i] & 0x80))) @@ -356,32 +339,26 @@ madvise(string, len, MADV_NORMAL); @throw [OFInvalidEncodingException newWithClass: isa]; } madvise(string, len, MADV_NORMAL); - - return self; } -- upper +- (void)upper { apply_table(self, isa, &string, &length, is_utf8, of_unicode_upper_table, OF_UNICODE_UPPER_TABLE_SIZE); - - return self; } -- lower +- (void)lower { apply_table(self, isa, &string, &length, is_utf8, of_unicode_lower_table, OF_UNICODE_LOWER_TABLE_SIZE); - - return self; } -- removeCharactersFromIndex: (size_t)start - toIndex: (size_t)end +- (void)removeCharactersFromIndex: (size_t)start + toIndex: (size_t)end { if (is_utf8) { start = of_string_index_to_position(string, start, length); end = of_string_index_to_position(string, end, length); } @@ -402,32 +379,30 @@ toSize: length + 1]; } @catch (OFOutOfMemoryException *e) { /* We don't really care, as we only made it smaller */ [e dealloc]; } - - return self; -} - -- removeCharactersInRange: (of_range_t)range -{ - return [self removeCharactersFromIndex: range.start - toIndex: range.start + range.length]; +} + +- (void)removeCharactersInRange: (of_range_t)range +{ + [self removeCharactersFromIndex: range.start + toIndex: range.start + range.length]; } -- replaceOccurrencesOfString: (OFString*)str - withString: (OFString*)repl +- (void)replaceOccurrencesOfString: (OFString*)str + withString: (OFString*)repl { const char *str_c = [str cString]; const char *repl_c = [repl cString]; size_t str_len = [str cStringLength]; size_t repl_len = [repl cStringLength]; size_t i, last, tmp_len; char *tmp; if (str_len > length) - return self; + return; tmp = NULL; tmp_len = 0; for (i = 0, last = 0; i <= length - str_len; i++) { @@ -461,15 +436,13 @@ tmp[tmp_len] = 0; [self freeMemory: string]; string = tmp; length = tmp_len; - - return self; } -- removeLeadingWhitespaces +- (void)removeLeadingWhitespaces { size_t i; for (i = 0; i < length; i++) if (string[i] != ' ' && string[i] != '\t' && @@ -485,15 +458,13 @@ toSize: length + 1]; } @catch (OFOutOfMemoryException *e) { /* We don't really care, as we only made it smaller */ [e dealloc]; } - - return self; } -- removeTrailingWhitespaces +- (void)removeTrailingWhitespaces { size_t d; char *p; d = 0; @@ -512,15 +483,13 @@ toSize: length + 1]; } @catch (OFOutOfMemoryException *e) { /* We don't really care, as we only made it smaller */ [e dealloc]; } - - return self; } -- removeLeadingAndTrailingWhitespaces +- (void)removeLeadingAndTrailingWhitespaces { size_t d, i; char *p; d = 0; @@ -548,14 +517,12 @@ toSize: length + 1]; } @catch (OFOutOfMemoryException *e) { /* We don't really care, as we only made it smaller */ [e dealloc]; } - - return self; } - (id)copy { return [[OFString alloc] initWithString: self]; } @end Index: src/OFNumber.h ================================================================== --- src/OFNumber.h +++ src/OFNumber.h @@ -557,89 +557,91 @@ */ - (double)asDouble; /** * \param num The OFNumber to add - * \return The OFNumber added with the specified OFNumber + * \return A new autoreleased OFNumber added with the specified OFNumber */ -- add: (OFNumber*)num; +- (OFNumber*)add: (OFNumber*)num; /** * \param num The OFNumber to substract - * \return The OFNumber subtracted by the specified OFNumber + * \return A new autoreleased OFNumber subtracted by the specified OFNumber */ -- subtract: (OFNumber*)num; +- (OFNumber*)subtract: (OFNumber*)num; /** * \param num The OFNumber to multiply with - * \return The OFNumber multiplied with the specified OFNumber + * \return A new autoreleased OFNumber multiplied with the specified OFNumber */ -- multiplyWith: (OFNumber*)num; +- (OFNumber*)multiplyWith: (OFNumber*)num; /** * \param num The OFNumber to divide by - * \return The OFNumber devided by the specified OFNumber + * \return A new autoreleased OFNumber devided by the specified OFNumber */ -- divideBy: (OFNumber*)num; +- (OFNumber*)divideBy: (OFNumber*)num; /** * ANDs two OFNumbers, returning a new one. * * Does not work with floating point types! * * \param num The number to AND with. - * \return The OFNumber ANDed with the specified OFNumber + * \return A new autoreleased OFNumber ANDed with the specified OFNumber */ -- and: (OFNumber*)num; +- (OFNumber*)and: (OFNumber*)num; /** * ORs two OFNumbers, returning a new one. * * Does not work with floating point types! * * \param num The number to OR with. - * \return The OFNumber ORed with the specified OFNumber + * \return A new autoreleased OFNumber ORed with the specified OFNumber */ -- or: (OFNumber*)num; +- (OFNumber*)or: (OFNumber*)num; /** * XORs two OFNumbers, returning a new one. * * Does not work with floating point types! * * \param num The number to XOR with. - * \return The OFNumber XORed with the specified OFNumber + * \return A new autoreleased OFNumber XORed with the specified OFNumber */ -- xor: (OFNumber*)num; +- (OFNumber*)xor: (OFNumber*)num; /** * Bitshifts the OFNumber to the left by the specified OFNumber, returning a new * one. * * Does not work with floating point types! * * \param num The number of bits to shift to the left - * \return The OFNumber bitshifted to the left with the specified OFNumber + * \return A new autoreleased OFNumber bitshifted to the left with the + * specified OFNumber */ -- shiftLeft: (OFNumber*)num; +- (OFNumber*)shiftLeft: (OFNumber*)num; /** * Bitshifts the OFNumber to the right by the specified OFNumber, returning a * new one. * * Does not work with floating point types! * * \param num The number of bits to shift to the right - * \return The OFNumber bitshifted to the right with the specified OFNumber + * \return A new autoreleased OFNumber bitshifted to the right with the + * specified OFNumber */ -- shiftRight: (OFNumber*)num; +- (OFNumber*)shiftRight: (OFNumber*)num; /** - * \return The OFNumber increased by one. + * \return A new autoreleased OFNumber with the value increased by one. */ -- increase; +- (OFNumber*)increase; /** - * \return The OFNumber decreased by one. + * \return A new autoreleased OFNumber with the value decreased by one. */ -- decrease; +- (OFNumber*)decrease; @end Index: src/OFNumber.m ================================================================== --- src/OFNumber.m +++ src/OFNumber.m @@ -862,60 +862,60 @@ default: return [self asUInt32]; } } -- add: (OFNumber*)num +- (OFNumber*)add: (OFNumber*)num { CALCULATE(+, num) } -- subtract: (OFNumber*)num +- (OFNumber*)subtract: (OFNumber*)num { CALCULATE(-, num) } -- multiplyWith: (OFNumber*)num +- (OFNumber*)multiplyWith: (OFNumber*)num { CALCULATE(*, num) } -- divideBy: (OFNumber*)num +- (OFNumber*)divideBy: (OFNumber*)num { CALCULATE(/, num) } -- and: (OFNumber*)num +- (OFNumber*)and: (OFNumber*)num { CALCULATE2(&, num) } -- or: (OFNumber*)num +- (OFNumber*)or: (OFNumber*)num { CALCULATE2(|, num) } -- xor: (OFNumber*)num +- (OFNumber*)xor: (OFNumber*)num { CALCULATE2(^, num) } -- shiftLeft: (OFNumber*)num +- (OFNumber*)shiftLeft: (OFNumber*)num { CALCULATE2(<<, num) } -- shiftRight: (OFNumber*)num +- (OFNumber*)shiftRight: (OFNumber*)num { CALCULATE2(>>, num) } -- increase +- (OFNumber*)increase { CALCULATE3(+ 1) } -- decrease +- (OFNumber*)decrease { CALCULATE3(- 1) } @end Index: src/OFObject.h ================================================================== --- src/OFObject.h +++ src/OFObject.h @@ -236,11 +236,11 @@ * This is useful to add memory allocated by functions such as asprintf to the * pool so it gets free'd automatically when the object is deallocated. * * \param ptr A pointer to add to the memory pool */ -- addMemoryToPool: (void*)ptr; +- (void)addMemoryToPool: (void*)ptr; /** * Allocates memory and stores it in the object's memory pool so it can be * free'd automatically when the object is deallocated. * @@ -288,11 +288,11 @@ * Frees allocated memory and removes it from the object's memory pool. * Does nothing if ptr is NULL. * * \param ptr A pointer to the allocated memory */ -- freeMemory: (void*)ptr; +- (void)freeMemory: (void*)ptr; /** * Increases the retain count. * * Each time an object is released, the retain count gets decreased and the Index: src/OFObject.m ================================================================== --- src/OFObject.m +++ src/OFObject.m @@ -397,11 +397,11 @@ { /* Classes containing data should reimplement this! */ return (uint32_t)(uintptr_t)self; } -- addMemoryToPool: (void*)ptr +- (void)addMemoryToPool: (void*)ptr { void **memchunks; size_t memchunks_size; memchunks_size = PRE_IVAR->memchunks_size + 1; @@ -416,12 +416,10 @@ size: memchunks_size]; PRE_IVAR->memchunks = memchunks; PRE_IVAR->memchunks[PRE_IVAR->memchunks_size] = ptr; PRE_IVAR->memchunks_size = memchunks_size; - - return self; } - (void*)allocMemoryWithSize: (size_t)size { void *ptr, **memchunks; @@ -515,17 +513,17 @@ return [self resizeMemory: ptr toSize: nitems * size]; } -- freeMemory: (void*)ptr; +- (void)freeMemory: (void*)ptr; { void **iter, *last, **memchunks; size_t i, memchunks_size; if (ptr == NULL) - return self; + return; iter = PRE_IVAR->memchunks + PRE_IVAR->memchunks_size; i = PRE_IVAR->memchunks_size; while (iter-- > PRE_IVAR->memchunks) { @@ -543,25 +541,25 @@ free(PRE_IVAR->memchunks); PRE_IVAR->memchunks = NULL; PRE_IVAR->memchunks_size = 0; - return self; + return; } free(ptr); PRE_IVAR->memchunks[i] = last; PRE_IVAR->memchunks_size = memchunks_size; if (OF_UNLIKELY((memchunks = realloc( PRE_IVAR->memchunks, memchunks_size * sizeof(void*))) == NULL)) - return self; + return; PRE_IVAR->memchunks = memchunks; - return self; + return; } } @throw [OFMemoryNotPartOfObjectException newWithClass: isa pointer: ptr]; @@ -644,11 +642,11 @@ /* * Those are needed as the root class is the superclass of the root class's * metaclass and thus instance methods can be sent to class objects as well. */ -+ addMemoryToPool: (void*)ptr ++ (void)addMemoryToPool: (void*)ptr { @throw [OFNotImplementedException newWithClass: self selector: _cmd]; } @@ -678,11 +676,11 @@ { @throw [OFNotImplementedException newWithClass: self selector: _cmd]; } -+ freeMemory: (void*)ptr ++ (void)freeMemory: (void*)ptr { @throw [OFNotImplementedException newWithClass: self selector: _cmd]; } Index: src/OFSeekableStream.h ================================================================== --- src/OFSeekableStream.h +++ src/OFSeekableStream.h @@ -27,11 +27,11 @@ /** * Seeks to the specified absolute offset. * * \param offset The offset in bytes */ -- seekToOffset: (off_t)offset; +- (void)seekToOffset: (off_t)offset; /** * Seeks to the specified offset, relative to the current location. * * \param offset The offset relative to the current location Index: src/OFSeekableStream.m ================================================================== --- src/OFSeekableStream.m +++ src/OFSeekableStream.m @@ -11,11 +11,11 @@ #import "OFSeekableStream.h" #import "OFExceptions.h" @implementation OFSeekableStream -- _seekToOffset: (off_t)offset +- (void)_seekToOffset: (off_t)offset { @throw [OFNotImplementedException newWithClass: isa selector: _cmd]; } @@ -29,20 +29,18 @@ { @throw [OFNotImplementedException newWithClass: isa selector: _cmd]; } -- seekToOffset: (off_t)offset +- (void)seekToOffset: (off_t)offset { [self flushWriteBuffer]; [self _seekToOffset: offset]; [self freeMemory: cache]; cache = NULL; cache_len = 0; - - return self; } - (off_t)seekForwardWithOffset: (off_t)offset { off_t ret; Index: src/OFSocket.h ================================================================== --- src/OFSocket.h +++ src/OFSocket.h @@ -35,7 +35,7 @@ + socket; /** * Enables/disables non-blocking I/O. */ -- setBlocking: (BOOL)enable; +- (void)setBlocking: (BOOL)enable; @end Index: src/OFSocket.m ================================================================== --- src/OFSocket.m +++ src/OFSocket.m @@ -95,11 +95,11 @@ /* This is safe, as we already checked for -1 */ return ret; } -- setBlocking: (BOOL)enable +- (void)setBlocking: (BOOL)enable { #ifndef _WIN32 int flags; if ((flags = fcntl(sock, F_GETFL)) == -1) @@ -116,9 +116,7 @@ u_long v = enable; if (ioctlsocket(sock, FIONBIO, &v) == SOCKET_ERROR) @throw [OFSetOptionFailedException newWithClass: isa]; #endif - - return self; } @end Index: src/OFStream.h ================================================================== --- src/OFStream.h +++ src/OFStream.h @@ -168,16 +168,16 @@ withEncoding: (enum of_string_encoding)encoding; /** * Buffer all writes until flushWriteBuffer is called. */ -- bufferWrites; +- (void)bufferWrites; /** * Writes everything in the write cache to the stream. */ -- flushWriteBuffer; +- (void)flushWriteBuffer; /** * Writes from a buffer into the stream. * * \param buf The buffer from which the data is written to the stream @@ -279,7 +279,7 @@ withArguments: (va_list)args; /** * Closes the stream. */ -- close; +- (void)close; @end Index: src/OFStream.m ================================================================== --- src/OFStream.m +++ src/OFStream.m @@ -495,31 +495,27 @@ /* Get rid of a warning, never reached anyway */ assert(0); } -- bufferWrites +- (void)bufferWrites { use_wbuffer = YES; - - return self; } -- flushWriteBuffer +- (void)flushWriteBuffer { if (wbuffer == NULL) - return self; + return; [self _writeNBytes: wbuffer_len fromBuffer: wbuffer]; [self freeMemory: wbuffer]; wbuffer = NULL; wbuffer_len = 0; use_wbuffer = NO; - - return self; } - (size_t)writeNBytes: (size_t)size fromBuffer: (const char*)buf { @@ -650,11 +646,11 @@ /* Get rid of a warning, never reached anyway */ assert(0); } -- close +- (void)close { @throw [OFNotImplementedException newWithClass: isa selector: _cmd]; } @end Index: src/OFString.m ================================================================== --- src/OFString.m +++ src/OFString.m @@ -904,11 +904,16 @@ toIndex: range.start + range.length]; } - (OFString*)stringByAppendingString: (OFString*)str { - return [[OFMutableString stringWithString: self] appendString: str]; + OFMutableString *new; + + new = [OFMutableString stringWithString: self]; + [new appendString: str]; + + return new; } - (BOOL)hasPrefix: (OFString*)prefix { size_t len = [prefix cStringLength]; Index: src/OFTCPSocket.h ================================================================== --- src/OFTCPSocket.h +++ src/OFTCPSocket.h @@ -36,35 +36,35 @@ * Connect the OFTCPSocket to the specified destination. * * \param service The service on the node to connect to * \param node The node to connect to */ -- connectToService: (OFString*)service - onNode: (OFString*)node; +- (void)connectToService: (OFString*)service + onNode: (OFString*)node; /** * Bind socket on the specified node and service. * * \param service The service to bind * \param node The node to bind to * \param family The family to use (AF_INET for IPv4 or AF_INET6 for IPv6) */ -- bindService: (OFString*)service - onNode: (OFString*)node - withFamily: (int)family; +- (void)bindService: (OFString*)service + onNode: (OFString*)node + withFamily: (int)family; /** * Listen on the socket. * * \param backlog Maximum length for the queue of pending connections. */ -- listenWithBackLog: (int)backlog; +- (void)listenWithBackLog: (int)backlog; /** * Listen on the socket. */ -- listen; +- (void)listen; /** * Accept an incoming connection. * \return An autoreleased OFTCPSocket for the accepted connection. */ @@ -71,14 +71,14 @@ - (OFTCPSocket*)accept; /** * Enable or disable keep alives for the connection. */ -- enableKeepAlives: (BOOL)enable; +- (void)setKeepAlivesEnabled: (BOOL)enable; /** * Returns the remote address of the socket. Only works with accepted sockets! * * \return The remote address as a string. */ - (OFString*)remoteAddress; @end Index: src/OFTCPSocket.m ================================================================== --- src/OFTCPSocket.m +++ src/OFTCPSocket.m @@ -56,12 +56,12 @@ saddr = NULL; return self; } -- connectToService: (OFString*)service - onNode: (OFString*)node +- (void)connectToService: (OFString*)service + onNode: (OFString*)node { if (sock != INVALID_SOCKET) @throw [OFAlreadyConnectedException newWithClass: isa]; #ifdef HAVE_THREADSAFE_GETADDRINFO @@ -186,17 +186,15 @@ if (sock == INVALID_SOCKET) @throw [OFConnectionFailedException newWithClass: isa node: node service: service]; - - return self; } -- bindService: (OFString*)service - onNode: (OFString*)node - withFamily: (int)family +- (void)bindService: (OFString*)service + onNode: (OFString*)node + withFamily: (int)family { if (sock != INVALID_SOCKET) @throw [OFAlreadyConnectedException newWithClass: isa]; #ifndef HAVE_THREADSAFE_GETADDRINFO @@ -304,36 +302,30 @@ node: node service: service family: family]; } #endif - - return self; } -- listenWithBackLog: (int)backlog +- (void)listenWithBackLog: (int)backlog { if (sock == INVALID_SOCKET) @throw [OFNotConnectedException newWithClass: isa]; if (listen(sock, backlog) == -1) @throw [OFListenFailedException newWithClass: isa backLog: backlog]; - - return self; } -- listen +- (void)listen { if (sock == INVALID_SOCKET) @throw [OFNotConnectedException newWithClass: isa]; if (listen(sock, 5) == -1) @throw [OFListenFailedException newWithClass: isa backLog: 5]; - - return self; } - (OFTCPSocket*)accept { OFTCPSocket *newsock; @@ -361,18 +353,16 @@ newsock->saddr_len = addrlen; return newsock; } -- enableKeepAlives: (BOOL)enable +- (void)setKeepAlivesEnabled: (BOOL)enable { int v = enable; if (setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, (char*)&v, sizeof(v))) @throw [OFSetOptionFailedException newWithClass: isa]; - - return self; } - (OFString*)remoteAddress { if (saddr == NULL || saddr_len == 0) @@ -390,13 +380,10 @@ return [OFString stringWithCString: node]; } @finally { [self freeMemory: node]; } - - /* Get rid of a warning, never reached anyway */ - assert(0); #else char *node; # ifdef OF_THREADS [mutex lock]; @@ -412,18 +399,18 @@ return [OFString stringWithCString: node]; # ifdef OF_THREADS } @finally { [mutex unlock]; } +# endif +#endif /* Get rid of a warning, never reached anyway */ assert(0); -# endif -#endif } -- close +- (void)close { if (sock == INVALID_SOCKET) @throw [OFNotConnectedException newWithClass: isa]; close(sock); @@ -430,12 +417,10 @@ sock = INVALID_SOCKET; [self freeMemory: saddr]; saddr = NULL; saddr_len = 0; - - return self; } - (void)dealloc { if (sock != INVALID_SOCKET) Index: src/OFThread.h ================================================================== --- src/OFThread.h +++ src/OFThread.h @@ -83,13 +83,14 @@ * released. You can specify nil as object if you want the old object to be * released and don't want any new object for the TLS key. * * \param key The Thread Local Storage key * \param obj The object the Thread Local Storage key will be set to + * \return The old object, autoreleased */ -+ setObject: (OFObject*)obj - forTLSKey: (OFTLSKey*)key; ++ (id)setObject: (OFObject*)obj + forTLSKey: (OFTLSKey*)key; /** * Returns the object for the specified Thread Local Storage key. * * \param key The Thread Local Storage key @@ -147,11 +148,11 @@ - (void)handleTermination; /** * Starts the thread. */ -- start; +- (void)start; /** * Joins a thread. * * \return The object returned by the main method of the thread. @@ -173,11 +174,11 @@ + mutex; /** * Locks the mutex. */ -- lock; +- (void)lock; /** * Tries to lock the mutex and returns a boolean whether the mutex could be * acquired. * @@ -186,7 +187,7 @@ - (BOOL)tryLock; /** * Unlocks the mutex. */ -- unlock; +- (void)unlock; @end Index: src/OFThread.m ================================================================== --- src/OFThread.m +++ src/OFThread.m @@ -66,22 +66,20 @@ + threadWithObject: (id)obj { return [[[self alloc] initWithObject: obj] autorelease]; } -+ setObject: (OFObject*)obj - forTLSKey: (OFTLSKey*)key ++ (id)setObject: (OFObject*)obj + forTLSKey: (OFTLSKey*)key { id old = of_tlskey_get(key->key); if (!of_tlskey_set(key->key, [obj retain])) @throw [OFInvalidArgumentException newWithClass: self selector: _cmd]; - [old release]; - - return self; + return [old autorelease]; } + (id)objectForTLSKey: (OFTLSKey*)key { return [[of_tlskey_get(key->key) retain] autorelease]; @@ -160,11 +158,11 @@ - (void)handleTermination { } -- start +- (void)start { if (running == OF_THREAD_RUNNING) @throw [OFThreadStillRunningException newWithClass: isa]; [self retain]; @@ -173,12 +171,10 @@ [self release]; @throw [OFThreadStartFailedException newWithClass: isa]; } running = OF_THREAD_RUNNING; - - return self; } - (id)join { if (running == OF_THREAD_NOT_RUNNING || !of_thread_join(thread)) @@ -301,33 +297,29 @@ } return self; } -- lock +- (void)lock { if (!of_mutex_lock(&mutex)) @throw [OFMutexLockFailedException newWithClass: isa]; - - return self; } - (BOOL)tryLock { return of_mutex_trylock(&mutex); } -- unlock +- (void)unlock { if (!of_mutex_unlock(&mutex)) @throw [OFMutexUnlockFailedException newWithClass: isa]; - - return self; } - (void)dealloc { of_mutex_free(&mutex); [super dealloc]; } @end Index: src/OFXMLElement.h ================================================================== --- src/OFXMLElement.h +++ src/OFXMLElement.h @@ -133,27 +133,27 @@ /** * Adds the specified attribute. * * \param attr The attribute to add */ -- addAttribute: (OFXMLAttribute*)attr; +- (void)addAttribute: (OFXMLAttribute*)attr; /** * Adds the specified attribute with the specified value. * * \param name The name of the attribute * \param value The value of the attribute */ -- addAttributeWithName: (OFString*)name - stringValue: (OFString*)value; +- (void)addAttributeWithName: (OFString*)name + stringValue: (OFString*)value; /** * Adds a child to the OFXMLElement. * * \param child Another OFXMLElement which is added as a child */ -- addChild: (OFXMLElement*)child; +- (void)addChild: (OFXMLElement*)child; @end /** * \brief A category to escape strings for use in an XML document. */ @@ -161,7 +161,7 @@ /** * Escapes a string for use in an XML document. * * \return A new autoreleased string */ -- stringByXMLEscaping; +- (OFString*)stringByXMLEscaping; @end Index: src/OFXMLElement.m ================================================================== --- src/OFXMLElement.m +++ src/OFXMLElement.m @@ -217,50 +217,44 @@ [self freeMemory: str_c]; } return ret; } -- addAttribute: (OFXMLAttribute*)attr +- (void)addAttribute: (OFXMLAttribute*)attr { if (attrs == nil) attrs = [[OFMutableArray alloc] init]; /* FIXME: Prevent having it twice! */ [attrs addObject: attr]; - - return self; } -- addAttributeWithName: (OFString*)name_ - stringValue: (OFString*)value +- (void)addAttributeWithName: (OFString*)name_ + stringValue: (OFString*)value { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; [self addAttribute: [OFXMLAttribute attributeWithName: name_ prefix: nil namespace: nil stringValue: value]]; [pool release]; - - return self; } /* TODO: Replace attribute */ /* TODO: Remove attribute */ -- addChild: (OFXMLElement*)child +- (void)addChild: (OFXMLElement*)child { if (stringval != nil) @throw [OFInvalidArgumentException newWithClass: isa selector: _cmd]; if (children == nil) children = [[OFMutableArray alloc] init]; [children addObject: child]; - - return self; } - (void)dealloc { [name release]; @@ -271,11 +265,11 @@ [super dealloc]; } @end @implementation OFString (OFXMLEscaping) -- stringByXMLEscaping +- (OFString*)stringByXMLEscaping { char *str_c, *append, *tmp; size_t len, append_len; size_t i, j; OFString *ret; Index: src/OFXMLParser.h ================================================================== --- src/OFXMLParser.h +++ src/OFXMLParser.h @@ -148,37 +148,38 @@ /** * Sets the delegate the OFXMLParser should use. * * \param delegate The delegate to use */ -- setDelegate: (OFObject *)delegate; +- (void)setDelegate: (OFObject *)delegate; /** * Parses a buffer with the specified size. * * \param buf The buffer to parse * \param size The size of the buffer */ -- parseBuffer: (const char*)buf - withSize: (size_t)size; +- (void)parseBuffer: (const char*)buf + withSize: (size_t)size; @end /** * \brief A category for unescaping XML in strings. */ @interface OFString (OFXMLUnescaping) /** * Unescapes XML in the string. */ -- stringByXMLUnescaping; +- (OFString*)stringByXMLUnescaping; /** * Unescapes XML in the string and uses the specified handler for unknown * entities. * * \param h An OFXMLUnescapingDelegate as a handler for unknown entities */ -- stringByXMLUnescapingWithHandler: (OFObject *)h; +- (OFString*)stringByXMLUnescapingWithHandler: + (OFObject *)h; @end @interface OFObject (OFXMLParserDelegate) @end Index: src/OFXMLParser.m ================================================================== --- src/OFXMLParser.m +++ src/OFXMLParser.m @@ -121,21 +121,19 @@ - (id)delegate { return [[delegate retain] autorelease]; } -- setDelegate: (OFObject *)delegate_ +- (void)setDelegate: (OFObject *)delegate_ { [delegate_ retain]; [delegate release]; delegate = delegate_; - - return self; } -- parseBuffer: (const char*)buf - withSize: (size_t)size +- (void)parseBuffer: (const char*)buf + withSize: (size_t)size { OFAutoreleasePool *pool; size_t i, last, len; last = 0; @@ -487,12 +485,10 @@ len = size - last; /* In OF_XMLPARSER_IN_TAG, there can be only spaces */ if (len > 0 && state != OF_XMLPARSER_IN_TAG) [cache appendCString: buf + last withLength: len]; - - return self; } - (OFString*)foundUnknownEntityNamed: (OFString*)entity { return [delegate xmlParser: self @@ -499,16 +495,17 @@ foundUnknownEntityNamed: entity]; } @end @implementation OFString (OFXMLUnescaping) -- stringByXMLUnescaping +- (OFString*)stringByXMLUnescaping { return [self stringByXMLUnescapingWithHandler: nil]; } -- stringByXMLUnescapingWithHandler: (OFObject *)h +- (OFString*)stringByXMLUnescapingWithHandler: + (OFObject *)h { size_t i, last; BOOL in_entity; OFMutableString *ret; Index: tests/OFArrayTests.m ================================================================== --- tests/OFArrayTests.m +++ tests/OFArrayTests.m @@ -47,15 +47,15 @@ TEST(@"+[arrayWithCArray:length:]", (a[2] = [OFArray arrayWithCArray: c_ary length: 3]) && [a[2] isEqual: a[1]]) - TEST(@"-[addObject:]", [m[0] addObject: c_ary[0]] && - [m[0] addObject: c_ary[2]]) + TEST(@"-[addObject:]", R([m[0] addObject: c_ary[0]]) && + R([m[0] addObject: c_ary[2]])) - TEST(@"-[addObject:atIndex:]", [m[0] addObject: c_ary[1] - atIndex: 1]) + TEST(@"-[addObject:atIndex:]", R([m[0] addObject: c_ary[1] + atIndex: 1])) TEST(@"-[count]", [m[0] count] == 3 && [a[0] count] == 3 && [a[1] count] == 3) TEST(@"-[isEqual:]", [m[0] isEqual: a[0]] && [a[0] isEqual: a[1]]) @@ -75,19 +75,19 @@ TEST(@"-[indexOfObjectIdenticalTo:]", [a[1] indexOfObjectIdenticalTo: c_ary[1]] == 1) TEST(@"-[replaceObject:withObject:]", - [m[0] replaceObject: c_ary[1] - withObject: c_ary[0]] && + R([m[0] replaceObject: c_ary[1] + withObject: c_ary[0]]) && [[m[0] objectAtIndex: 0] isEqual: c_ary[0]] && [[m[0] objectAtIndex: 1] isEqual: c_ary[0]] && [[m[0] objectAtIndex: 2] isEqual: c_ary[2]]) TEST(@"-[replaceObject:identicalTo:]", - [m[0] replaceObjectIdenticalTo: c_ary[0] - withObject: c_ary[1]] && + R([m[0] replaceObjectIdenticalTo: c_ary[0] + withObject: c_ary[1]]) && [[m[0] objectAtIndex: 0] isEqual: c_ary[1]] && [[m[0] objectAtIndex: 1] isEqual: c_ary[1]] && [[m[0] objectAtIndex: 2] isEqual: c_ary[2]]) TEST(@"-[replaceObjectAtIndex:withObject:]", @@ -96,27 +96,27 @@ [[m[0] objectAtIndex: 0] isEqual: c_ary[0]] && [[m[0] objectAtIndex: 1] isEqual: c_ary[1]] && [[m[0] objectAtIndex: 2] isEqual: c_ary[2]]) TEST(@"-[removeObject:]", - [m[0] removeObject: c_ary[1]] && [m[0] count] == 2) + R([m[0] removeObject: c_ary[1]]) && [m[0] count] == 2) TEST(@"-[removeObjectIdenticalTo:]", - [m[0] removeObjectIdenticalTo: c_ary[2]] && [m[0] count] == 1) + R([m[0] removeObjectIdenticalTo: c_ary[2]]) && [m[0] count] == 1) [m[0] addObject: c_ary[0]]; [m[0] addObject: c_ary[1]]; - TEST(@"-[removeNObjects:]", [m[0] removeNObjects: 2] && + TEST(@"-[removeNObjects:]", R([m[0] removeNObjects: 2]) && [m[0] count] == 1 && [[m[0] objectAtIndex: 0] isEqual: c_ary[0]]) m[1] = [[a[0] mutableCopy] autorelease]; TEST(@"-[removeObjectAtIndex:]", [m[1] removeObjectAtIndex: 1] && [m[1] count] == 2 && [[m[1] objectAtIndex: 1] isEqual: c_ary[2]]) m[1] = [[a[0] mutableCopy] autorelease]; - TEST(@"-[removeNObjects:atIndex:]", [m[1] removeNObjects: 2 - atIndex: 0] && + TEST(@"-[removeNObjects:atIndex:]", R([m[1] removeNObjects: 2 + atIndex: 0]) && [m[1] count] == 1 && [[m[1] objectAtIndex: 0] isEqual: c_ary[2]]) EXPECT_EXCEPTION(@"Detect out of range in -[objectAtIndex:]", OFOutOfRangeException, [a[0] objectAtIndex: [a[0] count]]) Index: tests/OFDataArrayTests.m ================================================================== --- tests/OFDataArrayTests.m +++ tests/OFDataArrayTests.m @@ -36,12 +36,12 @@ data[0] = [array[0] allocMemoryWithSize: 4096]; data[1] = [array[0] allocMemoryWithSize: 4096]; memset(data[0], 0xFF, 4096); memset(data[1], 0x42, 4096); - TEST(@"-[addItem:]", [array[0] addItem: data[0]] && - [array[0] addItem: data[1]]) + TEST(@"-[addItem:]", R([array[0] addItem: data[0]]) && + R([array[0] addItem: data[1]])) TEST(@"-[itemAtIndex:]", !memcmp([array[0] itemAtIndex: 0], data[0], 4096) && !memcmp([array[0] itemAtIndex: 1], data[1], 4096)) @@ -51,14 +51,14 @@ other = (class == [OFDataArray class] ? [OFBigDataArray class] : [OFDataArray class]); TEST(@"-[isEqual:]", (array[1] = [other dataArrayWithItemSize: 4096]) && - [array[1] addNItems: [array[0] count] - fromCArray: [array[0] cArray]] && + R([array[1] addNItems: [array[0] count] + fromCArray: [array[0] cArray]]) && [array[1] isEqual: array[0]] && - [array[1] removeNItems: 1] && ![array[0] isEqual: array[1]]) + R([array[1] removeNItems: 1]) && ![array[0] isEqual: array[1]]) TEST(@"-[copy]", (array[1] = [[array[0] copy] autorelease]) && [array[0] isEqual: array[1]]) array[2] = [OFDataArray dataArrayWithItemSize: 1]; @@ -65,11 +65,11 @@ array[3] = [OFDataArray dataArrayWithItemSize: 1]; [array[2] addItem: "a"]; [array[2] addItem: "a"]; [array[3] addItem: "z"]; TEST(@"-[compare]", [array[0] compare: array[1]] == 0 && - [array[1] removeNItems: 1] && + R([array[1] removeNItems: 1]) && [array[0] compare: array[1]] == OF_ORDERED_DESCENDING && [array[1] compare: array[0]] == OF_ORDERED_ASCENDING && [array[2] compare: array[3]] == OF_ORDERED_ASCENDING) TEST(@"-[hash]", [array[0] hash] == 0xC54621B6) @@ -76,29 +76,29 @@ array[0] = [class dataArrayWithItemSize: 1]; [array[0] addNItems: 6 fromCArray: "abcdef"]; - TEST(@"-[removeNItems:]", [array[0] removeNItems: 1] && + TEST(@"-[removeNItems:]", R([array[0] removeNItems: 1]) && [array[0] count] == 5 && !memcmp([array[0] cArray], "abcde", 5)) TEST(@"-[removeNItems:atIndex:]", - [array[0] removeNItems: 2 - atIndex: 1] && [array[0] count] == 3 && + R([array[0] removeNItems: 2 + atIndex: 1]) && [array[0] count] == 3 && !memcmp([array[0] cArray], "ade", 3)) TEST(@"-[addNItems:atIndex:]", - [array[0] addNItems: 2 - fromCArray: "bc" - atIndex: 1] && [array[0] count] == 5 && + R([array[0] addNItems: 2 + fromCArray: "bc" + atIndex: 1]) && [array[0] count] == 5 && !memcmp([array[0] cArray], "abcde", 5)) TEST(@"Building strings", (array[0] = [class dataArrayWithItemSize: 1]) && - [array[0] addNItems: 6 - fromCArray: (void*)str] && [array[0] addItem: ""] && + R([array[0] addNItems: 6 + fromCArray: (void*)str]) && R([array[0] addItem: ""]) && !strcmp([array[0] cArray], str)) EXPECT_EXCEPTION(@"Detect out of range in -[itemAtIndex:]", OFOutOfRangeException, [array[0] itemAtIndex: [array[0] count]]) Index: tests/OFDictionaryTests.m ================================================================== --- tests/OFDictionaryTests.m +++ tests/OFDictionaryTests.m @@ -126,15 +126,15 @@ TEST(@"-[mutableCopy]", (dict = [[dict mutableCopy] autorelease]) && [dict count] == [dict2 count] && [[dict objectForKey: keys[0]] isEqual: values[0]] && [[dict objectForKey: keys[1]] isEqual: values[1]] && - [dict setObject: @"value3" - forKey: @"key3"] && + R([dict setObject: @"value3" + forKey: @"key3"]) && [[dict objectForKey: @"key3"] isEqual: @"value3"] && - [dict setObject: @"foo" - forKey: keys[0]] && + [[dict setObject: @"foo" + forKey: keys[0]] isEqual: values[0]] && [[dict objectForKey: keys[0]] isEqual: @"foo"]) TEST(@"-[removeObjectForKey:]", [dict removeObjectForKey: keys[0]] && [dict objectForKey: keys[0]] == nil) Index: tests/OFListTests.m ================================================================== --- tests/OFListTests.m +++ tests/OFListTests.m @@ -43,13 +43,13 @@ TEST(@"-[last]", [[list last]->object isEqual: strings[2]]) TEST(@"-[last]->prev", [[list last]->prev->object isEqual: strings[1]]) - TEST(@"-[remove:]", [list remove: [list last]] && + TEST(@"-[remove:]", R([list remove: [list last]]) && [[list last]->object isEqual: strings[1]] && - [list remove: [list first]] && + R([list remove: [list first]]) && [[list first]->object isEqual: [list last]->object]) TEST(@"-[insert:before:]", [list insert: strings[0] before: [list last]] && [[list last]->prev->object isEqual: strings[0]]) Index: tests/OFObjectTests.m ================================================================== --- tests/OFObjectTests.m +++ tests/OFObjectTests.m @@ -30,20 +30,21 @@ OFMemoryNotPartOfObjectException, [obj freeMemory: (void*)1]) TEST(@"Allocating 4096 bytes", (p = [obj allocMemoryWithSize: 4096]) != NULL) - TEST(@"Freeing memory", [obj freeMemory: p]) + TEST(@"Freeing memory", R([obj freeMemory: p])) EXPECT_EXCEPTION(@"Detect freeing of memory twice", OFMemoryNotPartOfObjectException, [obj freeMemory: p]) TEST(@"Allocating and freeing 4096 bytes 3 times", (p = [obj allocMemoryWithSize: 4096]) != NULL && (q = [obj allocMemoryWithSize: 4096]) != NULL && (r = [obj allocMemoryWithSize: 4096]) != NULL && - [obj freeMemory: p] && [obj freeMemory: q] && [obj freeMemory: r]) + R([obj freeMemory: p]) && R([obj freeMemory: q]) && + R([obj freeMemory: r])) EXPECT_EXCEPTION(@"Detect out of memory on alloc", OFOutOfMemoryException, [obj allocMemoryWithSize: SIZE_MAX]) EXPECT_EXCEPTION(@"Detect out of memory on resize", Index: tests/OFStringTests.m ================================================================== --- tests/OFStringTests.m +++ tests/OFStringTests.m @@ -72,12 +72,12 @@ TEST(@"-[hash] is the same if -[isEqual:] is YES", [s[0] hash] == [s[2] hash]) TEST(@"-[appendString:] and -[appendCString:]", - [s[1] appendCString: "1𝄞"] && [s[1] appendString: @"3"] && - [[s[0] appendString: s[1]] isEqual: @"täs€1𝄞3"]) + R([s[1] appendCString: "1𝄞"]) && R([s[1] appendString: @"3"]) && + R([s[0] appendString: s[1]]) && [s[0] isEqual: @"täs€1𝄞3"]) TEST(@"-[length]", [s[0] length] == 7) TEST(@"-[cStringLength]", [s[0] cStringLength] == 13) TEST(@"-[hash]", [s[0] hash] == 0x8AC1EEF6) @@ -87,19 +87,19 @@ [s[0] characterAtIndex: 5] == 0x1D11E) EXPECT_EXCEPTION(@"Detect out of range in -[characterAtIndex:]", OFOutOfRangeException, [s[0] characterAtIndex: 7]) - TEST(@"-[reverse]", [[s[0] reverse] isEqual: @"3𝄞1€sät"]) + TEST(@"-[reverse]", R([s[0] reverse]) && [s[0] isEqual: @"3𝄞1€sät"]) s[1] = [OFMutableString stringWithString: @"abc"]; - TEST(@"-[upper]", [[s[0] upper] isEqual: @"3𝄞1€SÄT"] && - [[s[1] upper] isEqual: @"ABC"]) + TEST(@"-[upper]", R([s[0] upper]) && [s[0] isEqual: @"3𝄞1€SÄT"] && + R([s[1] upper]) && [s[1] isEqual: @"ABC"]) - TEST(@"-[lower]", [[s[0] lower] isEqual: @"3𝄞1€sät"] && - [[s[1] lower] isEqual: @"abc"]) + TEST(@"-[lower]", R([s[0] lower]) && [s[0] isEqual: @"3𝄞1€sät"] && + R([s[1] lower]) && [s[1] isEqual: @"abc"]) TEST(@"+[stringWithCString:length:]", (s[0] = [OFMutableString stringWithCString: "foobar" length: 3]) && [s[0] isEqual: @"foo"]) @@ -108,23 +108,23 @@ stringWithContentsOfFile: @"testfile.txt" encoding: OF_STRING_ENCODING_ISO_8859_1]) && [s[1] isEqual: @"testäöü"]) TEST(@"-[appendCStringWithLength:]", - [[s[0] appendCString: "foobarqux" + 3 - withLength: 3] isEqual: @"foobar"]) + R([s[0] appendCString: "foobarqux" + 3 + withLength: 3]) && [s[0] isEqual: @"foobar"]) EXPECT_EXCEPTION(@"Detection of invalid UTF-8 encoding #1", OFInvalidEncodingException, [OFString stringWithCString: "\xE0\x80"]) EXPECT_EXCEPTION(@"Detection of invalid UTF-8 encoding #2", OFInvalidEncodingException, [OFString stringWithCString: "\xF0\x80\x80\xC0"]) TEST(@"-[reverse] on UTF-8 strings", - (s[0] = [[OFMutableString stringWithCString: "äöü€𝄞"] reverse]) && - [s[0] isEqual: @"𝄞€üöä"]) + (s[0] = [OFMutableString stringWithCString: "äöü€𝄞"]) && + R([s[0] reverse]) && [s[0] isEqual: @"𝄞€üöä"]) TEST(@"Conversion of ISO 8859-1 to UTF-8", [[OFString stringWithCString: "\xE4\xF6\xFC" encoding: OF_STRING_ENCODING_ISO_8859_1] isEqual: @"äöü"]) @@ -144,22 +144,23 @@ TEST(@"+[stringWithFormat:]", [(s[0] = [OFMutableString stringWithFormat: @"%s: %d", "test", 123]) isEqual: @"test: 123"]) + TEST(@"-[appendFormat:]", + R(([s[0] appendFormat: @"%02X", 15])) && + [s[0] isEqual: @"test: 1230F"]) + TEST(@"+[stringWithPath:]", - (s[1] = [OFString stringWithPath: @"foo", @"bar", @"baz", nil]) && + (s[0] = [OFString stringWithPath: @"foo", @"bar", @"baz", nil]) && #ifndef _WIN32 - [s[1] isEqual: @"foo/bar/baz"] && + [s[0] isEqual: @"foo/bar/baz"] && #else - [s[1] isEqual: @"foo\\bar\\baz"] && + [s[0] isEqual: @"foo\\bar\\baz"] && #endif - (s[1] = [OFString stringWithPath: @"foo", nil]) && - [s[1] isEqual: @"foo"]) - - TEST(@"-[appendFormat:]", - [([s[0] appendFormat: @"%02X", 15]) isEqual: @"test: 1230F"]) + (s[0] = [OFString stringWithPath: @"foo", nil]) && + [s[0] isEqual: @"foo"]) TEST(@"-[indexOfFirstOccurrenceOfString:]", [@"𝄞öö" indexOfFirstOccurrenceOfString: @"öö"] == 1 && [@"𝄞öö" indexOfFirstOccurrenceOfString: @"ö"] == 1 && [@"𝄞öö" indexOfFirstOccurrenceOfString: @"𝄞"] == 0 && @@ -269,15 +270,15 @@ @"#2", OFInvalidEncodingException, [@"foo%FFbar" stringByURLDecoding]) TEST(@"-[removeCharactersFromIndex:toIndex:]", (s[0] = [OFMutableString stringWithString: @"𝄞öööbä€"]) && - [s[0] removeCharactersFromIndex: 1 - toIndex: 4] && + R([s[0] removeCharactersFromIndex: 1 + toIndex: 4]) && [s[0] isEqual: @"𝄞bä€"] && - [s[0] removeCharactersFromIndex: 0 - toIndex: 4] && + R([s[0] removeCharactersFromIndex: 0 + toIndex: 4]) && [s[0] isEqual: @""]) EXPECT_EXCEPTION(@"Detect OoR in " @"-[removeCharactersFromIndex:toIndex:] #1", OFOutOfRangeException, { @@ -296,39 +297,44 @@ OFInvalidArgumentException, [s[0] substringFromIndex: 2 toIndex: 0]) TEST(@"-[replaceOccurrencesOfString:withString:]", - [[[OFMutableString stringWithString: @"asd fo asd fofo asd"] - replaceOccurrencesOfString: @"fo" - withString: @"foo"] - isEqual: @"asd foo asd foofoo asd"] && - [[[OFMutableString stringWithString: @"XX"] - replaceOccurrencesOfString: @"X" - withString: @"XX"] - isEqual: @"XXXX"]) + (s[0] = [OFMutableString stringWithString: + @"asd fo asd fofo asd"]) && + R([s[0] replaceOccurrencesOfString: @"fo" + withString: @"foo"]) && + [s[0] isEqual: @"asd foo asd foofoo asd"] && + (s[0] = [OFMutableString stringWithString: @"XX"]) && + R([s[0] replaceOccurrencesOfString: @"X" + withString: @"XX"]) && + [s[0] isEqual: @"XXXX"]) TEST(@"-[removeLeadingWhitespaces]", (s[0] = [OFMutableString stringWithString: whitespace[0]]) && - [[s[0] removeLeadingWhitespaces] isEqual: @"asd \t \t\t\r\n"] && + R([s[0] removeLeadingWhitespaces]) && + [s[0] isEqual: @"asd \t \t\t\r\n"] && (s[0] = [OFMutableString stringWithString: whitespace[1]]) && - [[s[0] removeLeadingWhitespaces] isEqual: @""]) + R([s[0] removeLeadingWhitespaces]) && [s[0] isEqual: @""]) TEST(@"-[removeTrailingWhitespaces]", (s[0] = [OFMutableString stringWithString: whitespace[0]]) && - [[s[0] removeTrailingWhitespaces] isEqual: @" \r \t\n\t \tasd"] && + R([s[0] removeTrailingWhitespaces]) && + [s[0] isEqual: @" \r \t\n\t \tasd"] && (s[0] = [OFMutableString stringWithString: whitespace[1]]) && - [[s[0] removeTrailingWhitespaces] isEqual: @""]) + R([s[0] removeTrailingWhitespaces]) && [s[0] isEqual: @""]) TEST(@"-[removeLeadingAndTrailingWhitespaces]", (s[0] = [OFMutableString stringWithString: whitespace[0]]) && - [[s[0] removeLeadingAndTrailingWhitespaces] isEqual: @"asd"] && + R([s[0] removeLeadingAndTrailingWhitespaces]) && + [s[0] isEqual: @"asd"] && (s[0] = [OFMutableString stringWithString: whitespace[1]]) && - [[s[0] removeLeadingAndTrailingWhitespaces] isEqual: @""]) + R([s[0] removeLeadingAndTrailingWhitespaces]) && + [s[0] isEqual: @""]) TEST(@"-[stringByXMLEscaping]", - (s[0] = [@" &world'\"!&" stringByXMLEscaping]) && + (s[0] = (id)[@" &world'\"!&" stringByXMLEscaping]) && [s[0] isEqual: @"<hello> &world'"!&"]) TEST(@"-[stringByXMLUnescaping]", [[s[0] stringByXMLUnescaping] isEqual: @" &world'\"!&"] && [[@"y" stringByXMLUnescaping] isEqual: @"y"] && @@ -349,11 +355,11 @@ EXPECT_EXCEPTION(@"Detect invalid entities in -[stringByXMLUnescaping] " @"#6", OFInvalidEncodingException, [@"&#xg;" stringByXMLUnescaping]) TEST(@"-[stringByXMLUnescapingWithHandler:]", (h = [[[EntityHandler alloc] init] autorelease]) && - (s[0] = [@"x&foo;y" stringByXMLUnescapingWithHandler: h]) && - [s[0] isEqual: @"xbary"]) + [[@"x&foo;y" stringByXMLUnescapingWithHandler: h] + isEqual: @"xbary"]) [pool drain]; } @end Index: tests/OFTCPSocketTests.m ================================================================== --- tests/OFTCPSocketTests.m +++ tests/OFTCPSocketTests.m @@ -43,19 +43,19 @@ TEST(@"+[socket]", (server = [OFTCPSocket socket]) && (client = [OFTCPSocket socket])) msg = [OFString stringWithFormat: @"-[bindService:onNode:withFamily:] (port %d)", port]; - TEST(msg, [server bindService: service - onNode: @"localhost" - withFamily: AF_INET]) + TEST(msg, R([server bindService: service + onNode: @"localhost" + withFamily: AF_INET])) - TEST(@"-[listen]", [server listen]) + TEST(@"-[listen]", R([server listen])) TEST(@"-[connectToService:onNode:]", - [client connectToService: service - onNode: @"localhost"]) + R([client connectToService: service + onNode: @"localhost"])) TEST(@"-[accept]", (accepted = [server accept])) TEST(@"-[remoteAddress]", [[accepted remoteAddress] isEqual: @"127.0.0.1"]) Index: tests/OFThreadTests.m ================================================================== --- tests/OFThreadTests.m +++ tests/OFThreadTests.m @@ -41,20 +41,23 @@ OFTLSKey *key; TEST(@"+[threadWithObject:]", (t = [TestThread threadWithObject: @"foo"])) - TEST(@"-[start]", [t start]) + TEST(@"-[start]", R([t start])) TEST(@"-[join]", [[t join] isEqual: @"success"]) TEST(@"OFTLSKey's +[tlsKey]", (key = [OFTLSKey tlsKey])) - TEST(@"+[setObject:forTLSKey:]", [OFThread setObject: @"foo" - forTLSKey: key]) + TEST(@"+[setObject:forTLSKey:]", + R([OFThread setObject: @"setme" + forTLSKey: key]) && + [[OFThread setObject: @"foo" + forTLSKey: key] isEqual: @"setme"]) TEST(@"+[objectForTLSKey:]", [[OFThread objectForTLSKey: key] isEqual: @"foo"]) [pool drain]; } @end Index: tests/OFXMLElementTests.m ================================================================== --- tests/OFXMLElementTests.m +++ tests/OFXMLElementTests.m @@ -36,19 +36,19 @@ (elem[1] = [OFXMLElement elementWithName: @"foo" stringValue: @"b&ar"]) && [[elem[1] string] isEqual: @"b&ar"]) TEST(@"-[addAttributeWithName:stringValue:]", - [elem[0] addAttributeWithName: @"foo" - stringValue: @"b&ar"] && + R([elem[0] addAttributeWithName: @"foo" + stringValue: @"b&ar"]) && [[elem[0] string] isEqual: @""] && - [elem[1] addAttributeWithName: @"foo" - stringValue: @"b&ar"] && + R([elem[1] addAttributeWithName: @"foo" + stringValue: @"b&ar"]) && [[elem[1] string] isEqual: @"b&ar"]) TEST(@"-[addChild:]", - [elem[0] addChild: [OFXMLElement elementWithName: @"bar"]] && + R([elem[0] addChild: [OFXMLElement elementWithName: @"bar"]]) && [[elem[0] string] isEqual: @""]) [pool drain]; } @end Index: tests/OFXMLParserTests.m ================================================================== --- tests/OFXMLParserTests.m +++ tests/OFXMLParserTests.m @@ -192,11 +192,11 @@ ""; size_t j, len; TEST(@"+[xmlParser]", (parser = [OFXMLParser xmlParser])) - TEST(@"-[setDelegate:]", [parser setDelegate: self]) + TEST(@"-[setDelegate:]", R([parser setDelegate: self])) /* Simulate a stream where we only get chunks */ len = strlen(str); for (j = 0; j < len; j+= 2) { Index: tests/TestsAppDelegate.h ================================================================== --- tests/TestsAppDelegate.h +++ tests/TestsAppDelegate.h @@ -46,10 +46,11 @@ [self outputFailure: test \ inModule: module]; \ fails++; \ } \ } +#define R(x) (x, 1) @class OFString; @interface TestsAppDelegate: OFObject {