@@ -261,27 +261,26 @@ - mutableCopy { return [[OFMutableArray alloc] initWithArray: self]; } -- (id)objectAtIndex: (size_t)index +- (id)objectAtIndex: (size_t)idx { OF_UNRECOGNIZED_SELECTOR } -- (id)objectAtIndexedSubscript: (size_t)index +- (id)objectAtIndexedSubscript: (size_t)idx { - return [self objectAtIndex: index]; + return [self objectAtIndex: idx]; } - (id)valueForKey: (OFString *)key { - OFMutableArray *ret; + id ret; if ([key hasPrefix: @"@"]) { void *pool = objc_autoreleasePoolPush(); - id ret; key = [key substringWithRange: of_range(1, [key length] - 1)]; ret = [[super valueForKey: key] retain]; objc_autoreleasePoolPop(pool); @@ -317,13 +316,10 @@ objc_autoreleasePoolPop(pool); return; } - if (value == [OFNull null]) - value = nil; - for (id object in self) [object setValue: value forKey: key]; } @@ -450,21 +446,32 @@ if (separator == nil) @throw [OFInvalidArgumentException exception]; if ([self count] == 0) return @""; - if ([self count] == 1) - return [[self firstObject] performSelector: selector]; + + if ([self count] == 1) { + OFString *component = + [[self firstObject] performSelector: selector]; + + if (component == nil) + @throw [OFInvalidArgumentException exception]; + + return component; + } ret = [OFMutableString string]; if (options & OF_ARRAY_SKIP_EMPTY) { for (id object in self) { void *pool = objc_autoreleasePoolPush(); OFString *component = [object performSelector: selector]; + if (component == nil) + @throw [OFInvalidArgumentException exception]; + if ([component length] > 0) { if ([ret length] > 0) [ret appendString: separator]; [ret appendString: component]; } @@ -474,17 +481,22 @@ } else { bool first = true; for (id object in self) { void *pool = objc_autoreleasePoolPush(); + OFString *component = + [object performSelector: selector]; + + if (component == nil) + @throw [OFInvalidArgumentException exception]; if OF_UNLIKELY (first) first = false; else [ret appendString: separator]; - [ret appendString: [object performSelector: selector]]; + [ret appendString: component]; objc_autoreleasePoolPop(pool); } } @@ -674,11 +686,11 @@ [data addItem: &type]; [data addItems: &tmp count: sizeof(tmp)]; } else if (count <= UINT32_MAX) { - uint8_t type = 0xDC; + uint8_t type = 0xDD; uint32_t tmp = OF_BSWAP32_IF_LE((uint32_t)count); [data addItem: &type]; [data addItems: &tmp count: sizeof(tmp)]; @@ -717,13 +729,13 @@ } - (void)makeObjectsPerformSelector: (SEL)selector withObject: (id)object { - for (id object in self) - [object performSelector: selector - withObject: object]; + for (id objectIter in self) + [objectIter performSelector: selector + withObject: object]; } - (OFArray *)sortedArray { OFMutableArray *new = [[self mutableCopy] autorelease]; @@ -845,13 +857,13 @@ size_t count = [self count]; id *tmp = [self allocMemoryWithSize: sizeof(id) count: count]; @try { - [self enumerateObjectsUsingBlock: ^ (id object, size_t index, + [self enumerateObjectsUsingBlock: ^ (id object, size_t idx, bool *stop) { - tmp[index] = block(object, index); + tmp[idx] = block(object, idx); }]; ret = [OFArray arrayWithObjects: tmp count: count]; } @finally { @@ -869,13 +881,13 @@ count: count]; @try { __block size_t i = 0; - [self enumerateObjectsUsingBlock: ^ (id object, size_t index, + [self enumerateObjectsUsingBlock: ^ (id object, size_t idx, bool *stop) { - if (block(object, index)) + if (block(object, idx)) tmp[i++] = object; }]; ret = [OFArray arrayWithObjects: tmp count: i]; @@ -894,15 +906,15 @@ if (count == 0) return nil; if (count == 1) return [[[self firstObject] retain] autorelease]; - [self enumerateObjectsUsingBlock: ^ (id object, size_t index, + [self enumerateObjectsUsingBlock: ^ (id object, size_t idx, bool *stop) { id new; - if (index == 0) { + if (idx == 0) { current = [object retain]; return; } @try {