@@ -23,16 +23,16 @@ + array { return [[[self alloc] init] autorelease]; } -+ arrayWithObject: (OFObject*)obj ++ arrayWithObject: (id)obj { return [[[self alloc] initWithObject: obj] autorelease]; } -+ arrayWithObjects: (OFObject*)first, ... ++ arrayWithObjects: (id)first, ... { id ret; va_list args; va_start(args, first); @@ -41,16 +41,16 @@ va_end(args); return ret; } -+ arrayWithCArray: (OFObject**)objs ++ arrayWithCArray: (id*)objs { return [[[self alloc] initWithCArray: objs] autorelease]; } -+ arrayWithCArray: (OFObject**)objs ++ arrayWithCArray: (id*)objs length: (size_t)len { return [[[self alloc] initWithCArray: objs length: len] autorelease]; } @@ -58,12 +58,11 @@ - init { self = [super init]; @try { - array = [[OFDataArray alloc] - initWithItemSize: sizeof(OFObject*)]; + array = [[OFDataArray alloc] initWithItemSize: sizeof(id)]; } @catch (OFException *e) { /* * We can't use [super dealloc] on OS X here. Compiler bug? * [self dealloc] will do here as we check for nil in dealloc. */ @@ -72,11 +71,11 @@ } return self; } -- initWithObject: (OFObject*)obj +- initWithObject: (id)obj { self = [self init]; @try { [array addItem: &obj]; @@ -88,11 +87,11 @@ [obj retain]; return self; } -- initWithObjects: (OFObject*)first, ... +- initWithObjects: (id)first, ... { id ret; va_list args; va_start(args, first); @@ -101,11 +100,11 @@ va_end(args); return ret; } -- initWithObject: (OFObject*)first +- initWithObject: (id)first argList: (va_list)args { id obj; self = [self init]; @@ -122,11 +121,11 @@ } return self; } -- initWithCArray: (OFObject**)objs +- initWithCArray: (id*)objs { id *obj; size_t count; self = [self init]; @@ -150,11 +149,11 @@ } return self; } -- initWithCArray: (OFObject**)objs +- initWithCArray: (id*)objs length: (size_t)len { size_t i; self = [self init]; @@ -192,11 +191,11 @@ } - mutableCopy { OFArray *new = [[OFMutableArray alloc] init]; - OFObject **objs; + id *objs; size_t count, i; objs = [array cArray]; count = [array count]; @@ -212,11 +211,11 @@ - (id)objectAtIndex: (size_t)index { return *((id*)[array itemAtIndex: index]); } -- (size_t)indexOfObject: (OFObject*)obj +- (size_t)indexOfObject: (id)obj { id *objs = [array cArray]; size_t i, count = [array count]; if (objs == NULL) @@ -227,11 +226,11 @@ return i; return SIZE_MAX; } -- (size_t)indexOfObjectIdenticalTo: (OFObject*)obj +- (size_t)indexOfObjectIdenticalTo: (id)obj { id *objs = [array cArray]; size_t i, count = [array count]; if (objs == NULL) @@ -261,32 +260,38 @@ - (OFString*)componentsJoinedByString: (OFString*)separator { OFString *str; OFString **objs = [array cArray]; size_t i, count = [array count]; + Class cls; IMP append; if (count == 0) return @""; if (count == 1) return [objs[0] retain]; str = [OFMutableString string]; + cls = [OFString class]; append = [str methodForSelector: @selector(appendString:)]; for (i = 0; i < count - 1; i++) { + if (![objs[i] isKindOfClass: cls]) + @throw [OFInvalidArgumentException newWithClass: isa + selector: _cmd]; + append(str, @selector(appendString:), objs[i]); append(str, @selector(appendString:), separator); } append(str, @selector(appendString:), objs[i]); return str; } -- (BOOL)isEqual: (OFObject*)obj +- (BOOL)isEqual: (id)obj { - OFObject **objs, **objs2; + id *objs, *objs2; size_t i, count, count2; if (![obj isKindOfClass: [OFArray class]]) return NO; @@ -306,11 +311,11 @@ return YES; } - (uint32_t)hash { - OFObject **objs = [array cArray]; + id *objs = [array cArray]; size_t i, count = [array count]; uint32_t hash; OF_HASH_INIT(hash); @@ -352,11 +357,11 @@ } #ifdef OF_HAVE_BLOCKS - (void)enumerateObjectsUsingBlock: (of_array_enumeration_block_t)block { - OFObject **objs = [array cArray]; + id *objs = [array cArray]; size_t i, count = [array count]; BOOL stop = NO; for (i = 0; i < count && !stop; i++) block(objs[i], i, &stop); @@ -363,11 +368,11 @@ } #endif - (void)dealloc { - OFObject **objs = [array cArray]; + id *objs = [array cArray]; size_t i, count = [array count]; for (i = 0; i < count; i++) [objs[i] release]; @@ -396,11 +401,11 @@ { if (mutationsPtr != NULL && *mutationsPtr != mutations) @throw [OFEnumerationMutationException newWithClass: isa]; if (pos < count) - return *(OFObject**)[array itemAtIndex: pos++]; + return *(id*)[array itemAtIndex: pos++]; return nil; } - (void)reset