Index: src/OFArray.h ================================================================== --- src/OFArray.h +++ src/OFArray.h @@ -22,13 +22,14 @@ @class OFDataArray; @class OFString; #ifdef OF_HAVE_BLOCKS -typedef void (^of_array_enumeration_block_t)(id obj, size_t idx, BOOL *stop); -typedef BOOL (^of_array_filter_block_t)(id odj, size_t idx); -typedef id (^of_array_map_block_t)(id obj, size_t idx); +typedef void (^of_array_enumeration_block_t)(id object, size_t index, + BOOL *stop); +typedef BOOL (^of_array_filter_block_t)(id odject, size_t index); +typedef id (^of_array_map_block_t)(id object, size_t index); #endif /** * \brief A class for storing objects in an array. */ @@ -44,86 +45,86 @@ + array; /** * Creates a new OFArray with the specified object. * - * \param obj An object + * \param object An object * \return A new autoreleased OFArray */ -+ arrayWithObject: (id)obj; ++ arrayWithObject: (id)object; /** * Creates a new OFArray with the specified objects, terminated by nil. * - * \param first The first object in the array + * \param firstObject The first object in the array * \return A new autoreleased OFArray */ -+ arrayWithObjects: (id)first, ...; ++ arrayWithObjects: (id)firstObject, ...; /** * Creates a new OFArray with the objects from the specified C array. * - * \param objs A C array of objects, terminated with nil + * \param objects A C array of objects, terminated with nil * \return A new autoreleased OFArray */ -+ arrayWithCArray: (id*)objs; ++ arrayWithCArray: (id*)objects; /** * Creates a new OFArray with the objects from the specified C array of the * specified length. * - * \param objs A C array of objects - * \param len The length of the C array + * \param objects A C array of objects + * \param length The length of the C array * \return A new autoreleased OFArray */ -+ arrayWithCArray: (id*)objs - length: (size_t)len; ++ arrayWithCArray: (id*)objects + length: (size_t)length; /** * Initializes an OFArray with the specified object. * - * \param obj An object + * \param object An object * \return An initialized OFArray */ -- initWithObject: (id)obj; +- initWithObject: (id)object; /** * Initializes an OFArray with the specified objects. * - * \param first The first object + * \param firstObject The first object * \return An initialized OFArray */ -- initWithObjects: (id)first, ...; +- initWithObjects: (id)firstObject, ...; /** * Initializes an OFArray with the specified object and a va_list. * - * \param first The first object - * \param args A va_list + * \param firstObject The first object + * \param arguments A va_list * \return An initialized OFArray */ -- initWithObject: (id)first - argList: (va_list)args; +- initWithObject: (id)firstObject + argumentList: (va_list)arguments; /** * Initializes an OFArray with the objects from the specified C array. * - * \param objs A C array of objects, terminated with nil + * \param objects A C array of objects, terminated with nil * \return An initialized OFArray */ -- initWithCArray: (id*)objs; +- initWithCArray: (id*)objects; /** * Initializes an OFArray with the objects from the specified C array of the * specified length. * - * \param objs A C array of objects - * \param len The length of the C array + * \param objects A C array of objects + * \param length The length of the C array * \return An initialized OFArray */ -- initWithCArray: (id*)objs - length: (size_t)len; +- initWithCArray: (id*)objects + length: (size_t)length; /** * \return The objects of the array as a C array */ - (id*)cArray; @@ -141,25 +142,25 @@ /** * Returns the index of the first object that is equivalent to the specified * object or OF_INVALID_INDEX if it was not found. * - * \param obj The object whose index is returned + * \param object The object whose index is returned * \return The index of the first object equivalent to the specified object * or OF_INVALID_INDEX if it was not found */ -- (size_t)indexOfObject: (id)obj; +- (size_t)indexOfObject: (id)object; /** * Returns the index of the first object that has the same address as the * specified object or OF_INVALID_INDEX if it was not found. * - * \param obj The object whose index is returned + * \param object The object whose index is returned * \return The index of the first object that has the same aaddress as * the specified object or OF_INVALID_INDEX if it was not found */ -- (size_t)indexOfObjectIdenticalTo: (id)obj; +- (size_t)indexOfObjectIdenticalTo: (id)object; /** * Returns the first object of the array or nil. * * The returned object is not retained and autoreleased for performance @@ -216,15 +217,15 @@ /** * Performs the specified selector on all objects in the array with the * specified object. * * \param selector The selector to perform on all objects in the array - * \param obj The object to perform the selector with on all objects in the + * \param object The object to perform the selector with on all objects in the * array */ - (void)makeObjectsPerformSelector: (SEL)selector - withObject: (id)obj; + withObject: (id)object; #ifdef OF_HAVE_BLOCKS /** * Executes a block for each object. * Index: src/OFArray.m ================================================================== --- src/OFArray.m +++ src/OFArray.m @@ -32,38 +32,38 @@ + array { return [[[self alloc] init] autorelease]; } -+ arrayWithObject: (id)obj ++ arrayWithObject: (id)object { - return [[[self alloc] initWithObject: obj] autorelease]; + return [[[self alloc] initWithObject: object] autorelease]; } -+ arrayWithObjects: (id)first, ... ++ arrayWithObjects: (id)firstObject, ... { id ret; - va_list args; + va_list arguments; - va_start(args, first); - ret = [[[self alloc] initWithObject: first - argList: args] autorelease]; - va_end(args); + va_start(arguments, firstObject); + ret = [[[self alloc] initWithObject: firstObject + argumentList: arguments] autorelease]; + va_end(arguments); return ret; } -+ arrayWithCArray: (id*)objs ++ arrayWithCArray: (id*)objects { - return [[[self alloc] initWithCArray: objs] autorelease]; + return [[[self alloc] initWithCArray: objects] autorelease]; } -+ arrayWithCArray: (id*)objs - length: (size_t)len ++ arrayWithCArray: (id*)objects + length: (size_t)length { - return [[[self alloc] initWithCArray: objs - length: len] autorelease]; + return [[[self alloc] initWithCArray: objects + length: length] autorelease]; } - init { self = [super init]; @@ -76,105 +76,105 @@ } return self; } -- initWithObject: (id)obj +- initWithObject: (id)object { self = [self init]; @try { - [array addItem: &obj]; - [obj retain]; + [array addItem: &object]; + [object retain]; } @catch (id e) { [self release]; @throw e; } return self; } -- initWithObjects: (id)first, ... +- initWithObjects: (id)firstObject, ... { id ret; - va_list args; + va_list arguments; - va_start(args, first); - ret = [self initWithObject: first - argList: args]; - va_end(args); + va_start(arguments, firstObject); + ret = [self initWithObject: firstObject + argumentList: arguments]; + va_end(arguments); return ret; } -- initWithObject: (id)first - argList: (va_list)args +- initWithObject: (id)firstObject + argumentList: (va_list)arguments { self = [self init]; @try { - id obj; + id object; - [array addItem: &first]; - while ((obj = va_arg(args, id)) != nil) { - [array addItem: &obj]; - [obj retain]; + [array addItem: &firstObject]; + while ((object = va_arg(arguments, id)) != nil) { + [array addItem: &object]; + [object retain]; } } @catch (id e) { [self release]; @throw e; } return self; } -- initWithCArray: (id*)objs +- initWithCArray: (id*)objects { self = [self init]; @try { - id *obj; + id *object; size_t count = 0; - for (obj = objs; *obj != nil; obj++) { - [*obj retain]; + for (object = objects; *object != nil; object++) { + [*object retain]; count++; } [array addNItems: count - fromCArray: objs]; + fromCArray: objects]; } @catch (id e) { - id *obj; + id *object; - for (obj = objs; *obj != nil; obj++) - [*obj release]; + for (object = objects; *object != nil; object++) + [*object release]; [self release]; @throw e; } return self; } -- initWithCArray: (id*)objs - length: (size_t)len +- initWithCArray: (id*)objects + length: (size_t)length { self = [self init]; @try { size_t i; - for (i = 0; i < len; i++) - [objs[i] retain]; + for (i = 0; i < length; i++) + [objects[i] retain]; - [array addNItems: len - fromCArray: objs]; + [array addNItems: length + fromCArray: objects]; } @catch (id e) { size_t i; - for (i = 0; i < len; i++) - [objs[i] release]; + for (i = 0; i < length; i++) + [objects[i] release]; [self release]; @throw e; } @@ -196,103 +196,103 @@ return [self retain]; } - mutableCopy { - OFArray *new = [[OFMutableArray alloc] init]; - id *objs; + OFArray *mutableCopy = [[OFMutableArray alloc] init]; + id *cArray; size_t count, i; - objs = [array cArray]; + cArray = [array cArray]; count = [array count]; - [new->array addNItems: count - fromCArray: objs]; + [mutableCopy->array addNItems: count + fromCArray: cArray]; for (i = 0; i < count; i++) - [objs[i] retain]; + [cArray[i] retain]; - return new; + return mutableCopy; } - (id)objectAtIndex: (size_t)index { return *((id*)[array itemAtIndex: index]); } -- (size_t)indexOfObject: (id)obj -{ - id *objs = [array cArray]; - size_t i, count = [array count]; - - if (objs == NULL) - return OF_INVALID_INDEX; - - for (i = 0; i < count; i++) - if ([objs[i] isEqual: obj]) - return i; - - return OF_INVALID_INDEX; -} - -- (size_t)indexOfObjectIdenticalTo: (id)obj -{ - id *objs = [array cArray]; - size_t i, count = [array count]; - - if (objs == NULL) - return OF_INVALID_INDEX; - - for (i = 0; i < count; i++) - if (objs[i] == obj) - return i; - - return OF_INVALID_INDEX; -} - -- (BOOL)containsObject: (id)obj -{ - id *objs = [array cArray]; - size_t i, count = [array count]; - - if (objs == NULL) - return NO; - - for (i = 0; i < count; i++) - if ([objs[i] isEqual: obj]) - return YES; - - return NO; -} - -- (BOOL)containsObjectIdenticalTo: (id)obj -{ - id *objs = [array cArray]; - size_t i, count = [array count]; - - if (objs == NULL) - return NO; - - for (i = 0; i < count; i++) - if (objs[i] == obj) +- (size_t)indexOfObject: (id)object +{ + id *cArray = [array cArray]; + size_t i, count = [array count]; + + if (cArray == NULL) + return OF_INVALID_INDEX; + + for (i = 0; i < count; i++) + if ([cArray[i] isEqual: object]) + return i; + + return OF_INVALID_INDEX; +} + +- (size_t)indexOfObjectIdenticalTo: (id)object +{ + id *cArray = [array cArray]; + size_t i, count = [array count]; + + if (cArray == NULL) + return OF_INVALID_INDEX; + + for (i = 0; i < count; i++) + if (cArray[i] == object) + return i; + + return OF_INVALID_INDEX; +} + +- (BOOL)containsObject: (id)object +{ + id *cArray = [array cArray]; + size_t i, count = [array count]; + + if (cArray == NULL) + return NO; + + for (i = 0; i < count; i++) + if ([cArray[i] isEqual: object]) + return YES; + + return NO; +} + +- (BOOL)containsObjectIdenticalTo: (id)object +{ + id *cArray = [array cArray]; + size_t i, count = [array count]; + + if (cArray == NULL) + return NO; + + for (i = 0; i < count; i++) + if (cArray[i] == object) return YES; return NO; } - (id)firstObject { - id *first = [array firstItem]; + id *firstObject = [array firstItem]; - return (first != NULL ? *first : nil); + return (firstObject != NULL ? *firstObject : nil); } - (id)lastObject { - id *last = [array lastItem]; + id *lastObject = [array lastItem]; - return (last != NULL ? *last : nil); + return (lastObject != NULL ? *lastObject : nil); } - (OFArray*)objectsFromIndex: (size_t)start toIndex: (size_t)end { @@ -312,78 +312,80 @@ } - (OFString*)componentsJoinedByString: (OFString*)separator { OFAutoreleasePool *pool; - OFString *str; - OFObject **objs = [array cArray]; + OFString *ret; + OFObject **cArray = [array cArray]; size_t i, count = [array count]; IMP append; if (count == 0) return @""; if (count == 1) - return [objs[0] description]; + return [cArray[0] description]; - str = [OFMutableString string]; - append = [str methodForSelector: @selector(appendString:)]; + ret = [OFMutableString string]; + append = [ret methodForSelector: @selector(appendString:)]; pool = [[OFAutoreleasePool alloc] init]; for (i = 0; i < count - 1; i++) { - append(str, @selector(appendString:), [objs[i] description]); - append(str, @selector(appendString:), separator); + append(ret, @selector(appendString:), [cArray[i] description]); + append(ret, @selector(appendString:), separator); [pool releaseObjects]; } - append(str, @selector(appendString:), [objs[i] description]); + append(ret, @selector(appendString:), [cArray[i] description]); [pool release]; /* * Class swizzle the string to be immutable. We declared the return type * to be OFString*, so it can't be modified anyway. But not swizzling it * would create a real copy each time -[copy] is called. */ - str->isa = [OFString class]; - return str; + ret->isa = [OFString class]; + return ret; } -- (BOOL)isEqual: (id)obj +- (BOOL)isEqual: (id)object { - id *objs, *objs2; - size_t i, count, count2; + OFArray *otherArray; + id *cArray, *otherCArray; + size_t i, count; - if (![obj isKindOfClass: [OFArray class]]) + if (![object isKindOfClass: [OFArray class]]) return NO; + + otherArray = (OFArray*)object; count = [array count]; - count2 = [(OFArray*)obj count]; - if (count != count2) + if (count != [otherArray count]) return NO; - objs = [array cArray]; - objs2 = [(OFArray*)obj cArray]; + cArray = [array cArray]; + otherCArray = [otherArray cArray]; for (i = 0; i < count; i++) - if (![objs[i] isEqual: objs2[i]]) + if (![cArray[i] isEqual: otherCArray[i]]) return NO; return YES; } - (uint32_t)hash { - id *objs = [array cArray]; + id *cArray = [array cArray]; size_t i, count = [array count]; uint32_t hash; OF_HASH_INIT(hash); for (i = 0; i < count; i++) { - uint32_t h = [objs[i] hash]; + uint32_t h = [cArray[i] hash]; OF_HASH_ADD(hash, h >> 24); OF_HASH_ADD(hash, (h >> 16) & 0xFF); OF_HASH_ADD(hash, (h >> 8) & 0xFF); OF_HASH_ADD(hash, h & 0xFF); @@ -424,27 +426,27 @@ return ret; } - (void)makeObjectsPerformSelector: (SEL)selector { - id *objs = [array cArray]; + id *cArray = [array cArray]; size_t i, count = [array count]; for (i = 0; i < count; i++) - ((void(*)(id, SEL))[objs[i] - methodForSelector: selector])(objs[i], selector); + ((void(*)(id, SEL))[cArray[i] + methodForSelector: selector])(cArray[i], selector); } - (void)makeObjectsPerformSelector: (SEL)selector - withObject: (id)obj + withObject: (id)object { - id *objs = [array cArray]; + id *cArray = [array cArray]; size_t i, count = [array count]; for (i = 0; i < count; i++) - ((void(*)(id, SEL, id))[objs[i] - methodForSelector: selector])(objs[i], selector, obj); + ((void(*)(id, SEL, id))[cArray[i] + methodForSelector: selector])(cArray[i], selector, object); } - (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state objects: (id*)objects count: (int)count_ @@ -473,16 +475,16 @@ #ifdef OF_HAVE_BLOCKS - (void)enumerateObjectsUsingBlock: (of_array_enumeration_block_t)block { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; - id *objs = [array cArray]; + id *cArray = [array cArray]; size_t i, count = [array count]; BOOL stop = NO; for (i = 0; i < count && !stop; i++) { - block(objs[i], i, &stop); + block(cArray[i], i, &stop); [pool releaseObjects]; } [pool release]; } @@ -494,15 +496,15 @@ size_t count = [array count]; id *tmp = [self allocMemoryForNItems: count withSize: sizeof(id)]; @try { - id *objs = [array cArray]; + id *cArray = [array cArray]; size_t i; for (i = 0; i < count; i++) - tmp[i] = block(objs[i], i); + tmp[i] = block(cArray[i], i); ret = [[OFArray alloc] initWithCArray: tmp length: count]; @try { @@ -524,16 +526,16 @@ size_t count = [array count]; id *tmp = [self allocMemoryForNItems: count withSize: sizeof(id)]; @try { - id *objs = [array cArray]; + id *cArray = [array cArray]; size_t i, j = 0; for (i = 0; i < count; i++) { - if (block(objs[i], i)) - tmp[j++] = objs[i]; + if (block(cArray[i], i)) + tmp[j++] = cArray[i]; [pool releaseObjects]; } [pool release]; @@ -548,15 +550,15 @@ } #endif - (void)dealloc { - id *objs = [array cArray]; + id *cArray = [array cArray]; size_t i, count = [array count]; for (i = 0; i < count; i++) - [objs[i] release]; + [cArray[i] release]; [array release]; [super dealloc]; } Index: src/OFDataArray+Hashing.m ================================================================== --- src/OFDataArray+Hashing.m +++ src/OFDataArray+Hashing.m @@ -28,11 +28,11 @@ - (OFString*)MD5Hash { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFMD5Hash *hash = [OFMD5Hash MD5Hash]; uint8_t *digest; - char ret_c[OF_MD5_DIGEST_SIZE * 2]; + char cRet[OF_MD5_DIGEST_SIZE * 2]; size_t i; [hash updateWithBuffer: data ofSize: count * itemSize]; digest = [hash digest]; @@ -41,26 +41,26 @@ uint8_t high, low; high = digest[i] >> 4; low = digest[i] & 0x0F; - ret_c[i * 2] = (high > 9 ? high - 10 + 'a' : high + '0'); - ret_c[i * 2 + 1] = (low > 9 ? low - 10 + 'a' : low + '0'); + cRet[i * 2] = (high > 9 ? high - 10 + 'a' : high + '0'); + cRet[i * 2 + 1] = (low > 9 ? low - 10 + 'a' : low + '0'); } [pool release]; - return [OFString stringWithCString: ret_c + return [OFString stringWithCString: cRet length: 32]; } - (OFString*)SHA1Hash { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFMD5Hash *hash = [OFSHA1Hash SHA1Hash]; uint8_t *digest; - char ret_c[OF_SHA1_DIGEST_SIZE * 2]; + char cRet[OF_SHA1_DIGEST_SIZE * 2]; size_t i; [hash updateWithBuffer: data ofSize: count * itemSize]; digest = [hash digest]; @@ -69,15 +69,15 @@ uint8_t high, low; high = digest[i] >> 4; low = digest[i] & 0x0F; - ret_c[i * 2] = (high > 9 ? high - 10 + 'a' : high + '0'); - ret_c[i * 2 + 1] = (low > 9 ? low - 10 + 'a' : low + '0'); + cRet[i * 2] = (high > 9 ? high - 10 + 'a' : high + '0'); + cRet[i * 2 + 1] = (low > 9 ? low - 10 + 'a' : low + '0'); } [pool release]; - return [OFString stringWithCString: ret_c + return [OFString stringWithCString: cRet length: 40]; } @end Index: src/OFDataArray.h ================================================================== --- src/OFDataArray.h +++ src/OFDataArray.h @@ -37,14 +37,14 @@ #endif /** * Creates a new OFDataArray whose items all have the same size. * - * \param is The size of each element in the OFDataArray + * \param itemSize The size of each element in the OFDataArray * \return A new autoreleased OFDataArray */ -+ dataArrayWithItemSize: (size_t)is; ++ dataArrayWithItemSize: (size_t)itemSize; /** * Creates a new OFDataArary with an item size of 1, containing the data of the * specified file. * @@ -55,23 +55,23 @@ /** * Creates a new OFDataArray with an item size of 1, containing the data of the * Base64-encoded string. * - * \param str The string with the Base64-encoded data + * \param string The string with the Base64-encoded data * \return A new autoreleased OFDataArray */ -+ dataArrayWithBase64EncodedString: (OFString*)str; ++ dataArrayWithBase64EncodedString: (OFString*)string; /** * Initializes an already allocated OFDataArray whose items all have the same * size. * - * \param is The size of each element in the OFDataArray + * \param itemSize The size of each element in the OFDataArray * \return An initialized OFDataArray */ -- initWithItemSize: (size_t)is; +- initWithItemSize: (size_t)itemSize; /** * Initializes an already allocated OFDataArray with an item size of 1, * containing the data of the specified file. * @@ -82,14 +82,14 @@ /** * Initializes an already allocated OFDataArray with an item size of 1, * containing the data of the Base64-encoded string. * - * \param str The string with the Base64-encoded data + * \param string The string with the Base64-encoded data * \return A initialized OFDataArray */ -- initWithBase64EncodedString: (OFString*)str; +- initWithBase64EncodedString: (OFString*)string; /** * \return The number of items in the OFDataArray */ - (size_t)count; @@ -139,25 +139,25 @@ 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 + * \param nItems The number of items to add + * \param cArray A C array containing the items to add */ -- (void)addNItems: (size_t)nitems - fromCArray: (const void*)carray; +- (void)addNItems: (size_t)nItems + fromCArray: (const 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 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 */ -- (void)addNItems: (size_t)nitems - fromCArray: (const void*)carray +- (void)addNItems: (size_t)nItems + fromCArray: (const void*)cArray atIndex: (size_t)index; /** * Removes the item at the specified index. * @@ -166,21 +166,21 @@ - (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 + * \param nItems The number of items to remove */ -- (void)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 nItems The number of items to remove * \param index The index at which the items are removed */ -- (void)removeNItems: (size_t)nitems +- (void)removeNItems: (size_t)nItems atIndex: (size_t)index; /** * \return A string containing the data in Base64 encoding */ Index: src/OFDataArray.m ================================================================== --- src/OFDataArray.m +++ src/OFDataArray.m @@ -38,23 +38,23 @@ { _OFDataArray_Hashing_reference = 1; }; @implementation OFDataArray -+ dataArrayWithItemSize: (size_t)is ++ dataArrayWithItemSize: (size_t)itemSize { - return [[[self alloc] initWithItemSize: is] autorelease]; + return [[[self alloc] initWithItemSize: itemSize] autorelease]; } + dataArrayWithContentsOfFile: (OFString*)path { return [[[self alloc] initWithContentsOfFile: path] autorelease]; } -+ dataArrayWithBase64EncodedString: (OFString*)str ++ dataArrayWithBase64EncodedString: (OFString*)string { - return [[[self alloc] initWithBase64EncodedString: str] autorelease]; + return [[[self alloc] initWithBase64EncodedString: string] autorelease]; } - init { Class c = isa; @@ -61,20 +61,20 @@ [self release]; @throw [OFNotImplementedException newWithClass: c selector: _cmd]; } -- initWithItemSize: (size_t)is +- initWithItemSize: (size_t)itemSize_ { self = [super init]; @try { - if (is == 0) + if (itemSize_ == 0) @throw [OFInvalidArgumentException newWithClass: isa selector: _cmd]; - itemSize = is; + itemSize = itemSize_; data = NULL; } @catch (id e) { [self release]; @throw e; } @@ -92,22 +92,22 @@ itemSize = 1; data = NULL; @try { - char *buf = [self allocMemoryWithSize: of_pagesize]; + char *buffer = [self allocMemoryWithSize: of_pagesize]; while (![file isAtEndOfStream]) { - size_t size; + size_t length; - size = [file readNBytes: of_pagesize - intoBuffer: buf]; - [self addNItems: size - fromCArray: buf]; + length = [file readNBytes: of_pagesize + intoBuffer: buffer]; + [self addNItems: length + fromCArray: buffer]; } - [self freeMemory: buf]; + [self freeMemory: buffer]; } @finally { [file release]; } } @catch (id e) { [self release]; @@ -115,18 +115,18 @@ } return self; } -- initWithBase64EncodedString: (OFString*)str +- initWithBase64EncodedString: (OFString*)string { self = [super init]; itemSize = 1; data = NULL; - if (!of_base64_decode(self, [str cString], [str cStringLength])) { + if (!of_base64_decode(self, [string cString], [string cStringLength])) { Class c = isa; [self release]; @throw [OFInvalidEncodingException newWithClass: c]; } @@ -192,55 +192,55 @@ [self addNItems: 1 fromCArray: item atIndex: index]; } -- (void)addNItems: (size_t)nitems - fromCArray: (const void*)carray -{ - if (nitems > SIZE_MAX - count) - @throw [OFOutOfRangeException newWithClass: isa]; - - data = [self resizeMemory: data - toNItems: count + nitems - withSize: itemSize]; - - memcpy(data + count * itemSize, carray, nitems * itemSize); - count += nitems; -} - -- (void)addNItems: (size_t)nitems - fromCArray: (const void*)carray - atIndex: (size_t)index -{ - if (nitems > SIZE_MAX - count) - @throw [OFOutOfRangeException newWithClass: isa]; - - data = [self resizeMemory: data - toNItems: count + nitems - withSize: itemSize]; - - memmove(data + (index + nitems) * itemSize, data + index * itemSize, - (count - index) * itemSize); - memcpy(data + index * itemSize, carray, nitems * itemSize); - - count += nitems; +- (void)addNItems: (size_t)nItems + fromCArray: (const void*)cArray +{ + if (nItems > SIZE_MAX - count) + @throw [OFOutOfRangeException newWithClass: isa]; + + data = [self resizeMemory: data + toNItems: count + nItems + withSize: itemSize]; + + memcpy(data + count * itemSize, cArray, nItems * itemSize); + count += nItems; +} + +- (void)addNItems: (size_t)nItems + fromCArray: (const void*)cArray + atIndex: (size_t)index +{ + if (nItems > SIZE_MAX - count) + @throw [OFOutOfRangeException newWithClass: isa]; + + data = [self resizeMemory: data + toNItems: count + nItems + withSize: itemSize]; + + memmove(data + (index + nItems) * itemSize, data + index * itemSize, + (count - index) * itemSize); + memcpy(data + index * itemSize, cArray, nItems * itemSize); + + count += nItems; } - (void)removeItemAtIndex: (size_t)index { [self removeNItems: 1 atIndex: index]; } -- (void)removeNItems: (size_t)nitems +- (void)removeNItems: (size_t)nItems { - if (nitems > count) + if (nItems > count) @throw [OFOutOfRangeException newWithClass: isa]; - count -= nitems; + count -= nItems; @try { data = [self resizeMemory: data toNItems: count withSize: itemSize]; } @catch (OFOutOfMemoryException *e) { @@ -247,20 +247,20 @@ /* We don't really care, as we only made it smaller */ [e release]; } } -- (void)removeNItems: (size_t)nitems +- (void)removeNItems: (size_t)nItems atIndex: (size_t)index { - if (nitems > count) + if (nItems > count) @throw [OFOutOfRangeException newWithClass: isa]; - memmove(data + index * itemSize, data + (index + nitems) * itemSize, - (count - index - nitems) * itemSize); + memmove(data + index * itemSize, data + (index + nItems) * itemSize, + (count - index - nItems) * itemSize); - count -= nitems; + count -= nItems; @try { data = [self resizeMemory: data toNItems: count withSize: itemSize]; } @catch (OFOutOfMemoryException *e) { @@ -269,55 +269,64 @@ } } - copy { - OFDataArray *new = [[OFDataArray alloc] initWithItemSize: itemSize]; - [new addNItems: count - fromCArray: data]; - - return new; -} - -- (BOOL)isEqual: (id)obj -{ - if (![obj isKindOfClass: [OFDataArray class]]) - return NO; - if ([(OFDataArray*)obj count] != count || - [(OFDataArray*)obj itemSize] != itemSize) - return NO; - if (memcmp([(OFDataArray*)obj cArray], data, count * itemSize)) + OFDataArray *copy = [[OFDataArray alloc] initWithItemSize: itemSize]; + + [copy addNItems: count + fromCArray: data]; + + return copy; +} + +- (BOOL)isEqual: (id)object +{ + OFDataArray *otherDataArray; + + if (![object isKindOfClass: [OFDataArray class]]) + return NO; + + otherDataArray = (OFDataArray*)object; + + if ([otherDataArray count] != count || + [otherDataArray itemSize] != itemSize) + return NO; + if (memcmp([otherDataArray cArray], data, count * itemSize)) return NO; return YES; } -- (of_comparison_result_t)compare: (id)obj +- (of_comparison_result_t)compare: (id)object { - int cmp; - size_t ary_count, min_count; + OFDataArray *otherDataArray; + int comparison; + size_t otherCount, minimumCount; - if (![obj isKindOfClass: [OFDataArray class]]) + if (![object isKindOfClass: [OFDataArray class]]) @throw [OFInvalidArgumentException newWithClass: isa selector: _cmd]; - if ([(OFDataArray*)obj itemSize] != itemSize) + otherDataArray = (OFDataArray*)object; + + if ([otherDataArray itemSize] != itemSize) @throw [OFInvalidArgumentException newWithClass: isa selector: _cmd]; - ary_count = [(OFDataArray*)obj count]; - min_count = (count > ary_count ? ary_count : count); + otherCount = [otherDataArray count]; + minimumCount = (count > otherCount ? otherCount : count); - if ((cmp = memcmp(data, [(OFDataArray*)obj cArray], - min_count * itemSize)) == 0) { - if (count > ary_count) + if ((comparison = memcmp(data, [otherDataArray cArray], + minimumCount * itemSize)) == 0) { + if (count > otherCount) return OF_ORDERED_DESCENDING; - if (count < ary_count) + if (count < otherCount) return OF_ORDERED_ASCENDING; return OF_ORDERED_SAME; } - if (cmp > 0) + if (comparison > 0) return OF_ORDERED_DESCENDING; else return OF_ORDERED_ASCENDING; } @@ -341,117 +350,117 @@ @end @implementation OFBigDataArray - (void)addItem: (const void*)item { - size_t nsize, lastpagebyte; + size_t newSize, lastPageByte; if (SIZE_MAX - count < 1 || count + 1 > SIZE_MAX / itemSize) @throw [OFOutOfRangeException newWithClass: isa]; - lastpagebyte = of_pagesize - 1; - nsize = ((count + 1) * itemSize + lastpagebyte) & ~lastpagebyte; + lastPageByte = of_pagesize - 1; + newSize = ((count + 1) * itemSize + lastPageByte) & ~lastPageByte; - if (size != nsize) + if (size != newSize) data = [self resizeMemory: data - toSize: nsize]; + toSize: newSize]; memcpy(data + count * itemSize, item, itemSize); count++; - size = nsize; -} - -- (void)addNItems: (size_t)nitems - fromCArray: (const void*)carray -{ - size_t nsize, lastpagebyte; - - if (nitems > SIZE_MAX - count || count + nitems > SIZE_MAX / itemSize) - @throw [OFOutOfRangeException newWithClass: isa]; - - lastpagebyte = of_pagesize - 1; - nsize = ((count + nitems) * itemSize + lastpagebyte) & ~lastpagebyte; - - if (size != nsize) - data = [self resizeMemory: data - toSize: nsize]; - - memcpy(data + count * itemSize, carray, nitems * itemSize); - - count += nitems; - size = nsize; -} - -- (void)addNItems: (size_t)nitems - fromCArray: (const void*)carray - atIndex: (size_t)index -{ - size_t nsize, lastpagebyte; - - if (nitems > SIZE_MAX - count || count + nitems > SIZE_MAX / itemSize) - @throw [OFOutOfRangeException newWithClass: isa]; - - lastpagebyte = of_pagesize - 1; - nsize = ((count + nitems) * itemSize + lastpagebyte) & ~lastpagebyte; - - if (size != nsize) - data = [self resizeMemory: data - toNItems: nsize + size = newSize; +} + +- (void)addNItems: (size_t)nItems + fromCArray: (const void*)cArray +{ + size_t newSize, lastPageByte; + + if (nItems > SIZE_MAX - count || count + nItems > SIZE_MAX / itemSize) + @throw [OFOutOfRangeException newWithClass: isa]; + + lastPageByte = of_pagesize - 1; + newSize = ((count + nItems) * itemSize + lastPageByte) & ~lastPageByte; + + if (size != newSize) + data = [self resizeMemory: data + toSize: newSize]; + + memcpy(data + count * itemSize, cArray, nItems * itemSize); + + count += nItems; + size = newSize; +} + +- (void)addNItems: (size_t)nItems + fromCArray: (const void*)cArray + atIndex: (size_t)index +{ + size_t newSize, lastPageByte; + + if (nItems > SIZE_MAX - count || count + nItems > SIZE_MAX / itemSize) + @throw [OFOutOfRangeException newWithClass: isa]; + + lastPageByte = of_pagesize - 1; + newSize = ((count + nItems) * itemSize + lastPageByte) & ~lastPageByte; + + if (size != newSize) + data = [self resizeMemory: data + toNItems: newSize withSize: itemSize]; - memmove(data + (index + nitems) * itemSize, data + index * itemSize, - (count - index) * itemSize); - memcpy(data + index * itemSize, carray, nitems * itemSize); - - count += nitems; - size = nsize; -} - -- (void)removeNItems: (size_t)nitems -{ - size_t nsize, lastpagebyte; - - if (nitems > count) - @throw [OFOutOfRangeException newWithClass: isa]; - - count -= nitems; - lastpagebyte = of_pagesize - 1; - nsize = (count * itemSize + lastpagebyte) & ~lastpagebyte; - - if (size != nsize) - data = [self resizeMemory: data - toSize: nsize]; - size = nsize; -} - -- (void)removeNItems: (size_t)nitems - atIndex: (size_t)index -{ - size_t nsize, lastpagebyte; - - if (nitems > count) - @throw [OFOutOfRangeException newWithClass: isa]; - - memmove(data + index * itemSize, data + (index + nitems) * itemSize, - (count - index - nitems) * itemSize); - - count -= nitems; - lastpagebyte = of_pagesize - 1; - nsize = (count * itemSize + lastpagebyte) & ~lastpagebyte; - - if (size != nsize) - data = [self resizeMemory: data - toSize: nsize]; - size = nsize; + memmove(data + (index + nItems) * itemSize, data + index * itemSize, + (count - index) * itemSize); + memcpy(data + index * itemSize, cArray, nItems * itemSize); + + count += nItems; + size = newSize; +} + +- (void)removeNItems: (size_t)nItems +{ + size_t newSize, lastPageByte; + + if (nItems > count) + @throw [OFOutOfRangeException newWithClass: isa]; + + count -= nItems; + lastPageByte = of_pagesize - 1; + newSize = (count * itemSize + lastPageByte) & ~lastPageByte; + + if (size != newSize) + data = [self resizeMemory: data + toSize: newSize]; + size = newSize; +} + +- (void)removeNItems: (size_t)nItems + atIndex: (size_t)index +{ + size_t newSize, lastPageByte; + + if (nItems > count) + @throw [OFOutOfRangeException newWithClass: isa]; + + memmove(data + index * itemSize, data + (index + nItems) * itemSize, + (count - index - nItems) * itemSize); + + count -= nItems; + lastPageByte = of_pagesize - 1; + newSize = (count * itemSize + lastPageByte) & ~lastPageByte; + + if (size != newSize) + data = [self resizeMemory: data + toSize: newSize]; + size = newSize; } - copy { - OFDataArray *new = [[OFBigDataArray alloc] initWithItemSize: itemSize]; + OFDataArray *copy = [[OFBigDataArray alloc] initWithItemSize: itemSize]; - [new addNItems: count - fromCArray: data]; + [copy addNItems: count + fromCArray: data]; - return new; + return copy; } @end Index: src/OFObject.h ================================================================== --- src/OFObject.h +++ src/OFObject.h @@ -91,40 +91,41 @@ /** * Performs the specified selector with the specified object. * * \param selector The selector to perform - * \param obj The object that is passed to the method specified by the selector + * \param object The object that is passed to the method specified by the + * selector * \return The object returned by the method specified by the selector */ - (id)performSelector: (SEL)selector - withObject: (id)obj; + withObject: (id)object; /** * Performs the specified selector with the specified objects. * * \param selector The selector to perform - * \param obj1 The first object that is passed to the method specified by the - * selector - * \param obj2 The second object that is passed to the method specified by the - * selector + * \param object The first object that is passed to the method specified by the + * selector + * \param otherObject The second object that is passed to the method specified + * by the selector * \return The object returned by the method specified by the selector */ - (id)performSelector: (SEL)selector - withObject: (id)obj1 - withObject: (id)obj2; + withObject: (id)object + withObject: (id)otherObject; /** * Checks two objects for equality. * * Classes containing data (like strings, arrays, lists etc.) should reimplement * this! * - * \param obj The object which should be tested for equality + * \param object The object which should be tested for equality * \return A boolean whether the object is equal to the specified object */ -- (BOOL)isEqual: (id)obj; +- (BOOL)isEqual: (id)object; /** * Calculates a hash for the object. * * Classes containing data (like strings, arrays, lists etc.) should reimplement @@ -442,14 +443,14 @@ */ @protocol OFComparing /** * Compares the object with another object. * - * \param obj An object to compare the object to + * \param object An object to compare the object to * \return The result of the comparison */ -- (of_comparison_result_t)compare: (id)obj; +- (of_comparison_result_t)compare: (id)object; @end #ifdef __cplusplus extern "C" { #endif Index: src/OFObject.m ================================================================== --- src/OFObject.m +++ src/OFObject.m @@ -494,26 +494,26 @@ return imp(self, selector); } - (id)performSelector: (SEL)selector - withObject: (id)obj + withObject: (id)object { id (*imp)(id, SEL, id) = (id(*)(id, SEL, id))[self methodForSelector: selector]; - return imp(self, selector, obj); + return imp(self, selector, object); } - (id)performSelector: (SEL)selector - withObject: (id)obj1 - withObject: (id)obj2 + withObject: (id)object + withObject: (id)otherObject { id (*imp)(id, SEL, id, id) = (id(*)(id, SEL, id, id))[self methodForSelector: selector]; - return imp(self, selector, obj1, obj2); + return imp(self, selector, object, otherObject); } - (const char*)typeEncodingForSelector: (SEL)selector { #if defined(OF_OBJFW_RUNTIME) @@ -544,14 +544,14 @@ return ret; #endif } -- (BOOL)isEqual: (id)obj +- (BOOL)isEqual: (id)object { /* Classes containing data should reimplement this! */ - return (self == obj); + return (self == object); } - (uint32_t)hash { /* Classes containing data should reimplement this! */