@@ -36,12 +36,13 @@ static struct { Class isa; } placeholder; @interface OFArray () -- (OFString *)of_JSONRepresentationWithOptions: (int)options - depth: (size_t)depth; +- (OFString *) + of_JSONRepresentationWithOptions: (OFJSONRepresentationOptions)options + depth: (size_t)depth; @end @interface OFPlaceholderArray: OFArray @end @@ -226,30 +227,30 @@ - (size_t)count { OF_UNRECOGNIZED_SELECTOR } -- (void)getObjects: (id *)buffer inRange: (of_range_t)range +- (void)getObjects: (id *)buffer inRange: (OFRange)range { for (size_t i = 0; i < range.length; i++) buffer[i] = [self objectAtIndex: range.location + i]; } - (id const *)objects { size_t count = self.count; - id *buffer = of_alloc(count, sizeof(id)); + id *buffer = OFAllocMemory(count, sizeof(id)); @try { - [self getObjects: buffer inRange: of_range(0, count)]; + [self getObjects: buffer inRange: OFRangeMake(0, count)]; return [[OFData dataWithItemsNoCopy: buffer count: count itemSize: sizeof(id) freeWhenDone: true] items]; } @catch (id e) { - free(buffer); + OFFreeMemory(buffer); @throw e; } } - (id)copy @@ -304,47 +305,47 @@ - (size_t)indexOfObject: (id)object { size_t i = 0; if (object == nil) - return OF_NOT_FOUND; + return OFNotFound; for (id objectIter in self) { if ([objectIter isEqual: object]) return i; i++; } - return OF_NOT_FOUND; + return OFNotFound; } - (size_t)indexOfObjectIdenticalTo: (id)object { size_t i = 0; if (object == nil) - return OF_NOT_FOUND; + return OFNotFound; for (id objectIter in self) { if (objectIter == object) return i; i++; } - return OF_NOT_FOUND; + return OFNotFound; } - (bool)containsObject: (id)object { - return ([self indexOfObject: object] != OF_NOT_FOUND); + return ([self indexOfObject: object] != OFNotFound); } - (bool)containsObjectIdenticalTo: (id)object { - return ([self indexOfObjectIdenticalTo: object] != OF_NOT_FOUND); + return ([self indexOfObjectIdenticalTo: object] != OFNotFound); } - (id)firstObject { if (self.count > 0) @@ -361,11 +362,11 @@ return [self objectAtIndex: count - 1]; return nil; } -- (OFArray *)objectsInRange: (of_range_t)range +- (OFArray *)objectsInRange: (OFRange)range { OFArray *ret; id *buffer; if (range.length > SIZE_MAX - range.location || @@ -373,17 +374,17 @@ @throw [OFOutOfRangeException exception]; if (![self isKindOfClass: [OFMutableArray class]]) return [OFSubarray arrayWithArray: self range: range]; - buffer = of_alloc(range.length, sizeof(*buffer)); + buffer = OFAllocMemory(range.length, sizeof(*buffer)); @try { [self getObjects: buffer inRange: range]; ret = [OFArray arrayWithObjects: buffer count: range.length]; } @finally { - free(buffer); + OFFreeMemory(buffer); } return ret; } @@ -393,11 +394,11 @@ usingSelector: @selector(description) options: 0]; } - (OFString *)componentsJoinedByString: (OFString *)separator - options: (int)options + options: (OFArrayJoinOptions)options { return [self componentsJoinedByString: separator usingSelector: @selector(description) options: options]; } @@ -410,11 +411,11 @@ options: 0]; } - (OFString *)componentsJoinedByString: (OFString *)separator usingSelector: (SEL)selector - options: (int)options + options: (OFArrayJoinOptions)options { OFMutableString *ret; if (separator == nil) @throw [OFInvalidArgumentException exception]; @@ -432,11 +433,11 @@ return component; } ret = [OFMutableString string]; - if (options & OF_ARRAY_SKIP_EMPTY) { + if (options & OFArraySkipEmptyComponents) { for (id object in self) { void *pool = objc_autoreleasePoolPush(); OFString *component = [object performSelector: selector]; @@ -505,18 +506,18 @@ return true; } - (unsigned long)hash { - uint32_t hash; + unsigned long hash; - OF_HASH_INIT(hash); + OFHashInit(&hash); for (id object in self) - OF_HASH_ADD_HASH(hash, [object hash]); + OFHashAddHash(&hash, [object hash]); - OF_HASH_FINALIZE(hash); + OFHashFinalize(&hash); return hash; } - (OFString *)description @@ -551,14 +552,14 @@ void *pool = objc_autoreleasePoolPush(); OFXMLElement *element; if ([self isKindOfClass: [OFMutableArray class]]) element = [OFXMLElement elementWithName: @"OFMutableArray" - namespace: OF_SERIALIZATION_NS]; + namespace: OFSerializationNS]; else element = [OFXMLElement elementWithName: @"OFArray" - namespace: OF_SERIALIZATION_NS]; + namespace: OFSerializationNS]; for (id object in self) { void *pool2 = objc_autoreleasePoolPush(); [element addChild: object.XMLElementBySerializing]; @@ -576,23 +577,25 @@ - (OFString *)JSONRepresentation { return [self of_JSONRepresentationWithOptions: 0 depth: 0]; } -- (OFString *)JSONRepresentationWithOptions: (int)options +- (OFString *)JSONRepresentationWithOptions: + (OFJSONRepresentationOptions)options { return [self of_JSONRepresentationWithOptions: options depth: 0]; } -- (OFString *)of_JSONRepresentationWithOptions: (int)options - depth: (size_t)depth +- (OFString *) + of_JSONRepresentationWithOptions: (OFJSONRepresentationOptions)options + depth: (size_t)depth { OFMutableString *JSON = [OFMutableString stringWithString: @"["]; void *pool = objc_autoreleasePoolPush(); size_t i, count = self.count; - if (options & OF_JSON_REPRESENTATION_PRETTY) { + if (options & OFJSONRepresentationOptionPretty) { OFMutableString *indentation = [OFMutableString string]; for (i = 0; i < depth; i++) [indentation appendString: @"\t"]; @@ -653,17 +656,17 @@ if (count <= 15) { uint8_t tmp = 0x90 | ((uint8_t)count & 0xF); [data addItem: &tmp]; } else if (count <= UINT16_MAX) { uint8_t type = 0xDC; - uint16_t tmp = OF_BSWAP16_IF_LE((uint16_t)count); + uint16_t tmp = OFToBigEndian16((uint16_t)count); [data addItem: &type]; [data addItems: &tmp count: sizeof(tmp)]; } else if (count <= UINT32_MAX) { uint8_t type = 0xDD; - uint32_t tmp = OF_BSWAP32_IF_LE((uint32_t)count); + uint32_t tmp = OFToBigEndian32((uint32_t)count); [data addItem: &type]; [data addItems: &tmp count: sizeof(tmp)]; } else @throw [OFOutOfRangeException exception]; @@ -712,21 +715,21 @@ [new makeImmutable]; return new; } - (OFArray *)sortedArrayUsingSelector: (SEL)selector - options: (int)options + options: (OFArraySortOptions)options { OFMutableArray *new = [[self mutableCopy] autorelease]; [new sortUsingSelector: selector options: options]; [new makeImmutable]; return new; } #ifdef OF_HAVE_BLOCKS -- (OFArray *)sortedArrayUsingComparator: (of_comparator_t)comparator - options: (int)options +- (OFArray *)sortedArrayUsingComparator: (OFComparator)comparator + options: (OFArraySortOptions)options { OFMutableArray *new = [[self mutableCopy] autorelease]; [new sortUsingComparator: comparator options: options]; [new makeImmutable]; return new; @@ -739,15 +742,15 @@ [new reverse]; [new makeImmutable]; return new; } -- (int)countByEnumeratingWithState: (of_fast_enumeration_state_t *)state +- (int)countByEnumeratingWithState: (OFFastEnumerationState *)state objects: (id *)objects count: (int)count { - of_range_t range = of_range(state->state, count); + OFRange range = OFRangeMake(state->state, count); if (range.length > SIZE_MAX - range.location) @throw [OFOutOfRangeException exception]; if (range.location + range.length > self.count) @@ -770,11 +773,11 @@ return [[[OFArrayEnumerator alloc] initWithArray: self mutationsPtr: NULL] autorelease]; } #ifdef OF_HAVE_BLOCKS -- (void)enumerateObjectsUsingBlock: (of_array_enumeration_block_t)block +- (void)enumerateObjectsUsingBlock: (OFArrayEnumerationBlock)block { size_t i = 0; bool stop = false; for (id object in self) { @@ -816,35 +819,35 @@ [ret makeImmutable]; return ret; } #ifdef OF_HAVE_BLOCKS -- (OFArray *)mappedArrayUsingBlock: (of_array_map_block_t)block +- (OFArray *)mappedArrayUsingBlock: (OFArrayMapBlock)block { OFArray *ret; size_t count = self.count; - id *tmp = of_alloc(count, sizeof(id)); + id *tmp = OFAllocMemory(count, sizeof(id)); @try { [self enumerateObjectsUsingBlock: ^ (id object, size_t idx, bool *stop) { tmp[idx] = block(object, idx); }]; ret = [OFArray arrayWithObjects: tmp count: count]; } @finally { - free(tmp); + OFFreeMemory(tmp); } return ret; } -- (OFArray *)filteredArrayUsingBlock: (of_array_filter_block_t)block +- (OFArray *)filteredArrayUsingBlock: (OFArrayFilterBlock)block { OFArray *ret; size_t count = self.count; - id *tmp = of_alloc(count, sizeof(id)); + id *tmp = OFAllocMemory(count, sizeof(id)); @try { __block size_t i = 0; [self enumerateObjectsUsingBlock: ^ (id object, size_t idx, @@ -853,17 +856,17 @@ tmp[i++] = object; }]; ret = [OFArray arrayWithObjects: tmp count: i]; } @finally { - free(tmp); + OFFreeMemory(tmp); } return ret; } -- (id)foldUsingBlock: (of_array_fold_block_t)block +- (id)foldUsingBlock: (OFArrayFoldBlock)block { size_t count = self.count; __block id current; if (count == 0)