Index: src/OFList.h ================================================================== --- src/OFList.h +++ src/OFList.h @@ -18,24 +18,24 @@ #import "OFEnumerator.h" #import "OFSerialization.h" OF_ASSUME_NONNULL_BEGIN -typedef struct of_list_object_t of_list_object_t; -/** - * @struct of_list_object_t OFList.h ObjFW/OFList.h - * - * @brief A list object. - * - * A struct that contains a pointer to the next list object, the previous list - * object and the object. - */ -struct of_list_object_t { +typedef struct OFListItem OFListItem; +/** + * @struct OFListItem OFList.h ObjFW/OFList.h + * + * @brief A list item. + * + * A struct that contains a pointer to the next list item, the previous list + * item and the object. + */ +struct OFListItem { /** A pointer to the next list object in the list */ - of_list_object_t *_Nullable next; + OFListItem *_Nullable next; /** A pointer to the previous list object in the list */ - of_list_object_t *_Nullable previous; + OFListItem *_Nullable previous; /** The object for the list object */ id __unsafe_unretained object; }; /** @@ -47,22 +47,21 @@ OFSerialization> #if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN) # define ObjectType id #endif { - of_list_object_t *_Nullable _firstListObject; - of_list_object_t *_Nullable _lastListObject; + OFListItem *_Nullable _firstListItem; + OFListItem *_Nullable _lastListItem; size_t _count; - unsigned long _mutations; + unsigned long _mutations; OF_RESERVE_IVARS(OFList, 4) } /** * @brief The first list object of the list. */ -@property OF_NULLABLE_PROPERTY (readonly, nonatomic) - of_list_object_t *firstListObject; +@property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFListItem *firstListItem; /** * @brief The first object of the list or `nil`. * * @warning The returned object is *not* retained and autoreleased for @@ -71,12 +70,11 @@ @property OF_NULLABLE_PROPERTY (readonly, nonatomic) ObjectType firstObject; /** * @brief The last list object of the list. */ -@property OF_NULLABLE_PROPERTY (readonly, nonatomic) - of_list_object_t *lastListObject; +@property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFListItem *lastListItem; /** * @brief The last object of the list or `nil`. * * @warning The returned object is *not* retained and autoreleased for @@ -93,58 +91,58 @@ /** * @brief Appends an object to the list. * * @param object The object to append - * @return An of_list_object_t, needed to identify the object inside the list. + * @return An OFListItem, needed to identify the object inside the list. * For example, if you want to remove an object from the list, you need - * its of_list_object_t. + * its OFListItem. */ -- (of_list_object_t *)appendObject: (ObjectType)object; +- (OFListItem *)appendObject: (ObjectType)object; /** * @brief Prepends an object to the list. * * @param object The object to prepend - * @return An of_list_object_t, needed to identify the object inside the list. + * @return An OFListItem, needed to identify the object inside the list. * For example, if you want to remove an object from the list, you need - * its of_list_object_t. + * its OFListItem. */ -- (of_list_object_t *)prependObject: (ObjectType)object; +- (OFListItem *)prependObject: (ObjectType)object; /** * @brief Inserts an object before another list object. * * @param object The object to insert - * @param listObject The of_list_object_t of the object before which it should - * be inserted - * @return An of_list_object_t, needed to identify the object inside the list. + * @param listItem The OFListItem of the object before which it should be + * inserted + * @return An OFListItem, needed to identify the object inside the list. * For example, if you want to remove an object from the list, you need - * its of_list_object_t. + * its OFListItem. */ -- (of_list_object_t *)insertObject: (ObjectType)object - beforeListObject: (of_list_object_t *)listObject; +- (OFListItem *)insertObject: (ObjectType)object + beforeListItem: (OFListItem *)listItem; /** * @brief Inserts an object after another list object. * * @param object The object to insert - * @param listObject The of_list_object_t of the object after which it should be + * @param listItem The OFListItem of the object after which it should be * inserted - * @return An of_list_object_t, needed to identify the object inside the list. + * @return An OFListItem, needed to identify the object inside the list. * For example, if you want to remove an object from the list, you need - * its of_list_object_t. + * its OFListItem. */ -- (of_list_object_t *)insertObject: (ObjectType)object - afterListObject: (of_list_object_t *)listObject; +- (OFListItem *)insertObject: (ObjectType)object + afterListItem: (OFListItem *)listItem; /** * @brief Removes the object with the specified list object from the list. * - * @param listObject The list object returned by append / prepend + * @param listItem The list object returned by append / prepend */ -- (void)removeListObject: (of_list_object_t *)listObject; +- (void)removeListItem: (OFListItem *)listItem; /** * @brief Checks whether the list contains an object equal to the specified * object. * Index: src/OFList.m ================================================================== --- src/OFList.m +++ src/OFList.m @@ -28,22 +28,21 @@ OF_DIRECT_MEMBERS @interface OFListEnumerator: OFEnumerator { OFList *_list; - of_list_object_t *_Nullable _current; + OFListItem *_Nullable _current; unsigned long _mutations; unsigned long *_Nullable _mutationsPtr; } - (instancetype)initWithList: (OFList *)list mutationsPointer: (unsigned long *)mutationsPtr; @end @implementation OFList -@synthesize firstListObject = _firstListObject; -@synthesize lastListObject = _lastListObject; +@synthesize firstListItem = _firstListItem, lastListItem = _lastListItem; + (instancetype)list { return [[[self alloc] init] autorelease]; } @@ -77,142 +76,138 @@ return self; } - (void)dealloc { - of_list_object_t *next; + OFListItem *next; - for (of_list_object_t *iter = _firstListObject; - iter != NULL; iter = next) { + for (OFListItem *iter = _firstListItem; iter != NULL; iter = next) { [iter->object release]; next = iter->next; free(iter); } [super dealloc]; } -- (of_list_object_t *)appendObject: (id)object -{ - of_list_object_t *listObject; - - listObject = of_alloc(1, sizeof(of_list_object_t)); - listObject->object = [object retain]; - listObject->next = NULL; - listObject->previous = _lastListObject; - - if (_lastListObject != NULL) - _lastListObject->next = listObject; - - _lastListObject = listObject; - - if (_firstListObject == NULL) - _firstListObject = listObject; - - _count++; - _mutations++; - - return listObject; -} - -- (of_list_object_t *)prependObject: (id)object -{ - of_list_object_t *listObject; - - listObject = of_alloc(1, sizeof(of_list_object_t)); - listObject->object = [object retain]; - listObject->next = _firstListObject; - listObject->previous = NULL; - - if (_firstListObject != NULL) - _firstListObject->previous = listObject; - - _firstListObject = listObject; - if (_lastListObject == NULL) - _lastListObject = listObject; - - _count++; - _mutations++; - - return listObject; -} - -- (of_list_object_t *)insertObject: (id)object - beforeListObject: (of_list_object_t *)listObject -{ - of_list_object_t *newListObject; - - newListObject = of_alloc(1, sizeof(of_list_object_t)); - newListObject->object = [object retain]; - newListObject->next = listObject; - newListObject->previous = listObject->previous; - - if (listObject->previous != NULL) - listObject->previous->next = newListObject; - - listObject->previous = newListObject; - - if (listObject == _firstListObject) - _firstListObject = newListObject; - - _count++; - _mutations++; - - return newListObject; -} - -- (of_list_object_t *)insertObject: (id)object - afterListObject: (of_list_object_t *)listObject -{ - of_list_object_t *newListObject; - - newListObject = of_alloc(1, sizeof(of_list_object_t)); - newListObject->object = [object retain]; - newListObject->next = listObject->next; - newListObject->previous = listObject; - - if (listObject->next != NULL) - listObject->next->previous = newListObject; - - listObject->next = newListObject; - - if (listObject == _lastListObject) - _lastListObject = newListObject; - - _count++; - _mutations++; - - return newListObject; -} - -- (void)removeListObject: (of_list_object_t *)listObject -{ - if (listObject->previous != NULL) - listObject->previous->next = listObject->next; - if (listObject->next != NULL) - listObject->next->previous = listObject->previous; - - if (_firstListObject == listObject) - _firstListObject = listObject->next; - if (_lastListObject == listObject) - _lastListObject = listObject->previous; - - _count--; - _mutations++; - - [listObject->object release]; - free(listObject); -} - -- (id)firstObject -{ - return (_firstListObject != NULL ? _firstListObject->object : nil); -} - -- (id)lastObject -{ - return (_lastListObject != NULL ? _lastListObject->object : nil); +- (OFListItem *)appendObject: (id)object +{ + OFListItem *listItem; + + listItem = of_alloc(1, sizeof(OFListItem)); + listItem->object = [object retain]; + listItem->next = NULL; + listItem->previous = _lastListItem; + + if (_lastListItem != NULL) + _lastListItem->next = listItem; + + _lastListItem = listItem; + + if (_firstListItem == NULL) + _firstListItem = listItem; + + _count++; + _mutations++; + + return listItem; +} + +- (OFListItem *)prependObject: (id)object +{ + OFListItem *listItem = of_alloc(1, sizeof(OFListItem)); + + listItem->object = [object retain]; + listItem->next = _firstListItem; + listItem->previous = NULL; + + if (_firstListItem != NULL) + _firstListItem->previous = listItem; + + _firstListItem = listItem; + if (_lastListItem == NULL) + _lastListItem = listItem; + + _count++; + _mutations++; + + return listItem; +} + +- (OFListItem *)insertObject: (id)object + beforeListItem: (OFListItem *)listItem +{ + OFListItem *newListItem = of_alloc(1, sizeof(OFListItem)); + + newListItem->object = [object retain]; + newListItem->next = listItem; + newListItem->previous = listItem->previous; + + if (listItem->previous != NULL) + listItem->previous->next = newListItem; + + listItem->previous = newListItem; + + if (listItem == _firstListItem) + _firstListItem = newListItem; + + _count++; + _mutations++; + + return newListItem; +} + +- (OFListItem *)insertObject: (id)object + afterListItem: (OFListItem *)listItem +{ + OFListItem *newListItem = of_alloc(1, sizeof(OFListItem)); + + newListItem->object = [object retain]; + newListItem->next = listItem->next; + newListItem->previous = listItem; + + if (listItem->next != NULL) + listItem->next->previous = newListItem; + + listItem->next = newListItem; + + if (listItem == _lastListItem) + _lastListItem = newListItem; + + _count++; + _mutations++; + + return newListItem; +} + +- (void)removeListItem: (OFListItem *)listItem +{ + if (listItem->previous != NULL) + listItem->previous->next = listItem->next; + if (listItem->next != NULL) + listItem->next->previous = listItem->previous; + + if (_firstListItem == listItem) + _firstListItem = listItem->next; + if (_lastListItem == listItem) + _lastListItem = listItem->previous; + + _count--; + _mutations++; + + [listItem->object release]; + free(listItem); +} + +- (id)firstObject +{ + return (_firstListItem != NULL ? _firstListItem->object : nil); +} + +- (id)lastObject +{ + return (_lastListItem != NULL ? _lastListItem->object : nil); } - (size_t)count { return _count; @@ -219,11 +214,11 @@ } - (bool)isEqual: (id)object { OFList *list; - of_list_object_t *iter, *iter2; + OFListItem *iter, *iter2; if (object == self) return true; if (![object isKindOfClass: [OFList class]]) @@ -232,11 +227,11 @@ list = object; if (list.count != _count) return false; - for (iter = _firstListObject, iter2 = list.firstListObject; + for (iter = _firstListItem, iter2 = list.firstListItem; iter != NULL && iter2 != NULL; iter = iter->next, iter2 = iter2->next) if (![iter->object isEqual: iter2->object]) return false; @@ -249,12 +244,11 @@ - (bool)containsObject: (id)object { if (_count == 0) return false; - for (of_list_object_t *iter = _firstListObject; - iter != NULL; iter = iter->next) + for (OFListItem *iter = _firstListItem; iter != NULL; iter = iter->next) if ([iter->object isEqual: object]) return true; return false; } @@ -262,65 +256,63 @@ - (bool)containsObjectIdenticalTo: (id)object { if (_count == 0) return false; - for (of_list_object_t *iter = _firstListObject; - iter != NULL; iter = iter->next) + for (OFListItem *iter = _firstListItem; iter != NULL; iter = iter->next) if (iter->object == object) return true; return false; } - (void)removeAllObjects { - of_list_object_t *next; + OFListItem *next; _mutations++; - for (of_list_object_t *iter = _firstListObject; - iter != NULL; iter = next) { + for (OFListItem *iter = _firstListItem; iter != NULL; iter = next) { [iter->object release]; next = iter->next; free(iter); } - _firstListObject = _lastListObject = NULL; + _firstListItem = _lastListItem = NULL; } - (id)copy { OFList *copy = [[[self class] alloc] init]; - of_list_object_t *listObject, *previous; + OFListItem *listItem, *previous; - listObject = NULL; + listItem = NULL; previous = NULL; @try { - for (of_list_object_t *iter = _firstListObject; + for (OFListItem *iter = _firstListItem; iter != NULL; iter = iter->next) { - listObject = of_alloc(1, sizeof(of_list_object_t)); - listObject->object = [iter->object retain]; - listObject->next = NULL; - listObject->previous = previous; + listItem = of_alloc(1, sizeof(OFListItem)); + listItem->object = [iter->object retain]; + listItem->next = NULL; + listItem->previous = previous; - if (copy->_firstListObject == NULL) - copy->_firstListObject = listObject; + if (copy->_firstListItem == NULL) + copy->_firstListItem = listItem; if (previous != NULL) - previous->next = listObject; + previous->next = listItem; copy->_count++; - previous = listObject; + previous = listItem; } } @catch (id e) { [copy release]; @throw e; } - copy->_lastListObject = listObject; + copy->_lastListItem = listItem; return copy; } - (unsigned long)hash @@ -327,11 +319,11 @@ { uint32_t hash; OF_HASH_INIT(hash); - for (of_list_object_t *iter = _firstListObject; + for (OFListItem *iter = _firstListItem; iter != NULL; iter = iter->next) OF_HASH_ADD_HASH(hash, [iter->object hash]); OF_HASH_FINALIZE(hash); @@ -345,11 +337,11 @@ if (_count == 0) return @"[]"; ret = [OFMutableString stringWithString: @"[\n"]; - for (of_list_object_t *iter = _firstListObject; + for (OFListItem *iter = _firstListItem; iter != NULL; iter = iter->next) { void *pool = objc_autoreleasePoolPush(); [ret appendString: [iter->object description]]; @@ -370,11 +362,11 @@ { OFXMLElement *element = [OFXMLElement elementWithName: self.className namespace: OF_SERIALIZATION_NS]; - for (of_list_object_t *iter = _firstListObject; + for (OFListItem *iter = _firstListItem; iter != NULL; iter = iter->next) { void *pool = objc_autoreleasePoolPush(); [element addChild: [iter->object XMLElementBySerializing]]; @@ -386,31 +378,31 @@ - (int)countByEnumeratingWithState: (OFFastEnumerationState *)state objects: (id *)objects count: (int)count { - of_list_object_t *listObject; + OFListItem *listItem; - memcpy(&listObject, state->extra, sizeof(listObject)); + memcpy(&listItem, state->extra, sizeof(listItem)); state->itemsPtr = objects; state->mutationsPtr = &_mutations; if (state->state == 0) { - listObject = _firstListObject; + listItem = _firstListItem; state->state = 1; } for (int i = 0; i < count; i++) { - if (listObject == NULL) + if (listItem == NULL) return i; - objects[i] = listObject->object; - listObject = listObject->next; + objects[i] = listItem->object; + listItem = listItem->next; } - memcpy(state->extra, &listObject, sizeof(listObject)); + memcpy(state->extra, &listItem, sizeof(listItem)); return count; } - (OFEnumerator *)objectEnumerator @@ -426,11 +418,11 @@ mutationsPointer: (unsigned long *)mutationsPtr { self = [super init]; _list = [list retain]; - _current = _list.firstListObject; + _current = _list.firstListItem; _mutations = *mutationsPtr; _mutationsPtr = mutationsPtr; return self; } Index: src/OFRunLoop.m ================================================================== --- src/OFRunLoop.m +++ src/OFRunLoop.m @@ -274,27 +274,27 @@ assert(queue != nil); @try { if (![queue.firstObject handleObject: object]) { - of_list_object_t *listObject = queue.firstListObject; + OFListItem *listItem = queue.firstListItem; /* * The handler might have called -[cancelAsyncRequests] * so that our queue is now empty, in which case we * should do nothing. */ - if (listObject != NULL) { + if (listItem != NULL) { /* * Make sure we keep the target until after we * are done removing the object. The reason for * this is that the target might call * -[cancelAsyncRequests] in its dealloc. */ - [[listObject->object retain] autorelease]; + [[listItem->object retain] autorelease]; - [queue removeListObject: listObject]; + [queue removeListItem: listItem]; if (queue.count == 0) { [_kernelEventObserver removeObjectForReading: object]; [_readQueues @@ -317,27 +317,27 @@ assert(queue != nil); @try { if (![queue.firstObject handleObject: object]) { - of_list_object_t *listObject = queue.firstListObject; + OFListItem *listItem = queue.firstListItem; /* * The handler might have called -[cancelAsyncRequests] * so that our queue is now empty, in which case we * should do nothing. */ - if (listObject != NULL) { + if (listItem != NULL) { /* * Make sure we keep the target until after we * are done removing the object. The reason for * this is that the target might call * -[cancelAsyncRequests] in its dealloc. */ - [[listObject->object retain] autorelease]; + [[listItem->object retain] autorelease]; - [queue removeListObject: listObject]; + [queue removeListItem: listItem]; if (queue.count == 0) { [_kernelEventObserver removeObjectForWriting: object]; [_writeQueues @@ -1418,16 +1418,14 @@ #ifdef OF_HAVE_THREADS [state->_timersQueueMutex lock]; @try { #endif - of_list_object_t *iter; - - for (iter = state->_timersQueue.firstListObject; iter != NULL; - iter = iter->next) { + for (OFListItem *iter = state->_timersQueue.firstListItem; + iter != NULL; iter = iter->next) { if ([iter->object isEqual: timer]) { - [state->_timersQueue removeListObject: iter]; + [state->_timersQueue removeListItem: iter]; break; } } #ifdef OF_HAVE_THREADS } @finally { @@ -1577,20 +1575,20 @@ #ifdef OF_HAVE_THREADS [state->_timersQueueMutex lock]; @try { #endif - of_list_object_t *listObject = - state->_timersQueue.firstListObject; + OFListItem *listItem = + state->_timersQueue.firstListItem; - if (listObject != NULL && [listObject->object + if (listItem != NULL && [listItem->object fireDate].timeIntervalSinceNow <= 0) { - timer = [[listObject->object + timer = [[listItem->object retain] autorelease]; [state->_timersQueue - removeListObject: listObject]; + removeListItem: listItem]; [timer of_setInRunLoop: nil mode: nil]; } else break; #ifdef OF_HAVE_THREADS Index: src/OFSortedList.h ================================================================== --- src/OFSortedList.h +++ src/OFSortedList.h @@ -31,27 +31,27 @@ #endif { OF_RESERVE_IVARS(OFSortedList, 4) } -- (of_list_object_t *)appendObject: (ObjectType)object OF_UNAVAILABLE; -- (of_list_object_t *)prependObject: (ObjectType)object OF_UNAVAILABLE; -- (of_list_object_t *)insertObject: (ObjectType)object - beforeListObject: (of_list_object_t *)listObject +- (OFListItem *)appendObject: (ObjectType)object OF_UNAVAILABLE; +- (OFListItem *)prependObject: (ObjectType)object OF_UNAVAILABLE; +- (OFListItem *)insertObject: (ObjectType)object + beforeListItem: (OFListItem *)listItem OF_UNAVAILABLE; -- (of_list_object_t *)insertObject: (ObjectType)object - afterListObject: (of_list_object_t *)listObject +- (OFListItem *)insertObject: (ObjectType)object + afterListItem: (OFListItem *)listItem OF_UNAVAILABLE; /** * @brief Inserts the object to the list while keeping the list sorted. * * @param object The object to insert * @return The list object for the object just added */ -- (of_list_object_t *)insertObject: (ObjectType )object; +- (OFListItem *)insertObject: (ObjectType )object; #if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN) # undef ObjectType #endif @end OF_ASSUME_NONNULL_END Index: src/OFSortedList.m ================================================================== --- src/OFSortedList.m +++ src/OFSortedList.m @@ -16,40 +16,39 @@ #include "config.h" #import "OFSortedList.h" @implementation OFSortedList -- (of_list_object_t *)appendObject: (id)object -{ - OF_UNRECOGNIZED_SELECTOR -} - -- (of_list_object_t *)prependObject: (id)object -{ - OF_UNRECOGNIZED_SELECTOR -} - -- (of_list_object_t *)insertObject: (id)object - beforeListObject: (of_list_object_t *)listObject -{ - OF_UNRECOGNIZED_SELECTOR -} - -- (of_list_object_t *)insertObject: (id)object - afterListObject: (of_list_object_t *)listObject -{ - OF_UNRECOGNIZED_SELECTOR -} - -- (of_list_object_t *)insertObject: (id )object -{ - of_list_object_t *iter; - - for (iter = _lastListObject; iter != NULL; iter = iter->previous) { - if ([object compare: iter->object] != OFOrderedAscending) - return [super insertObject: object - afterListObject: iter]; +- (OFListItem *)appendObject: (id)object +{ + OF_UNRECOGNIZED_SELECTOR +} + +- (OFListItem *)prependObject: (id)object +{ + OF_UNRECOGNIZED_SELECTOR +} + +- (OFListItem *)insertObject: (id)object + beforeListItem: (OFListItem *)listItem +{ + OF_UNRECOGNIZED_SELECTOR +} + +- (OFListItem *)insertObject: (id)object + afterListItem: (OFListItem *)listItem +{ + OF_UNRECOGNIZED_SELECTOR +} + +- (OFListItem *)insertObject: (id )object +{ + OFListItem *iter; + + for (iter = _lastListItem; iter != NULL; iter = iter->previous) { + if ([object compare: iter->object] != OFOrderedAscending) + return [super insertObject: object afterListItem: iter]; } return [super prependObject: object]; } @end Index: src/OFThreadPool.m ================================================================== --- src/OFThreadPool.m +++ src/OFThreadPool.m @@ -160,32 +160,32 @@ for (;;) { OFThreadPoolJob *job; [_queueCondition lock]; @try { - of_list_object_t *listObject; + OFListItem *listItem; if (_terminate) { objc_autoreleasePoolPop(pool); return nil; } - listObject = _queue.firstListObject; + listItem = _queue.firstListItem; - while (listObject == NULL) { + while (listItem == NULL) { [_queueCondition wait]; if (_terminate) { objc_autoreleasePoolPop(pool); return nil; } - listObject = _queue.firstListObject; + listItem = _queue.firstListItem; } - job = [[listObject->object retain] autorelease]; - [_queue removeListObject: listObject]; + job = [[listItem->object retain] autorelease]; + [_queue removeListItem: listItem]; } @finally { [_queueCondition unlock]; } if (_terminate) { Index: tests/OFListTests.m ================================================================== --- tests/OFListTests.m +++ tests/OFListTests.m @@ -28,47 +28,46 @@ - (void)listTests { void *pool = objc_autoreleasePoolPush(); OFList *list; OFEnumerator *enumerator; - of_list_object_t *loe; + OFListItem *iter; OFString *obj; size_t i; bool ok; TEST(@"+[list]", (list = [OFList list])) TEST(@"-[appendObject:]", [list appendObject: strings[0]] && [list appendObject: strings[1]] && [list appendObject: strings[2]]) - TEST(@"-[firstListObject]", - [list.firstListObject->object isEqual: strings[0]]) - - TEST(@"-[firstListObject]->next", - [list.firstListObject->next->object isEqual: strings[1]]) - - TEST(@"-[lastListObject]", - [list.lastListObject->object isEqual: strings[2]]) - - TEST(@"-[lastListObject]->previous", - [list.lastListObject->previous->object isEqual: strings[1]]) - - TEST(@"-[removeListObject:]", - R([list removeListObject: list.lastListObject]) && - [list.lastListObject->object isEqual: strings[1]] && - R([list removeListObject: list.firstListObject]) && - [list.firstListObject->object isEqual: list.lastListObject->object]) - - TEST(@"-[insertObject:beforeListObject:]", - [list insertObject: strings[0] - beforeListObject: list.lastListObject] && - [list.lastListObject->previous->object isEqual: strings[0]]) - - TEST(@"-[insertObject:afterListObject:]", + TEST(@"-[firstListItem]", + [list.firstListItem->object isEqual: strings[0]]) + + TEST(@"-[firstListItem]->next", + [list.firstListItem->next->object isEqual: strings[1]]) + + TEST(@"-[lastListItem]", + [list.lastListItem->object isEqual: strings[2]]) + + TEST(@"-[lastListItem]->previous", + [list.lastListItem->previous->object isEqual: strings[1]]) + + TEST(@"-[removeListItem:]", + R([list removeListItem: list.lastListItem]) && + [list.lastListItem->object isEqual: strings[1]] && + R([list removeListItem: list.firstListItem]) && + [list.firstListItem->object isEqual: list.lastListItem->object]) + + TEST(@"-[insertObject:beforeListItem:]", + [list insertObject: strings[0] beforeListItem: list.lastListItem] && + [list.lastListItem->previous->object isEqual: strings[0]]) + + TEST(@"-[insertObject:afterListItem:]", [list insertObject: strings[2] - afterListObject: list.firstListObject->next] && - [list.lastListObject->object isEqual: strings[2]]) + afterListItem: list.firstListItem->next] && + [list.lastListItem->object isEqual: strings[2]]) TEST(@"-[count]", list.count == 3) TEST(@"-[containsObject:]", [list containsObject: strings[1]] && @@ -78,53 +77,53 @@ [list containsObjectIdenticalTo: strings[1]] && ![list containsObjectIdenticalTo: [OFString stringWithString: strings[1]]]) TEST(@"-[copy]", (list = [[list copy] autorelease]) && - [list.firstListObject->object isEqual: strings[0]] && - [list.firstListObject->next->object isEqual: strings[1]] && - [list.lastListObject->object isEqual: strings[2]]) + [list.firstListItem->object isEqual: strings[0]] && + [list.firstListItem->next->object isEqual: strings[1]] && + [list.lastListItem->object isEqual: strings[2]]) TEST(@"-[isEqual:]", [list isEqual: [[list copy] autorelease]]) TEST(@"-[description]", [list.description isEqual: @"[\n\tFoo,\n\tBar,\n\tBaz\n]"]) TEST(@"-[objectEnumerator]", (enumerator = [list objectEnumerator])) - loe = list.firstListObject; + iter = list.firstListItem; i = 0; ok = true; while ((obj = [enumerator nextObject]) != nil) { - if (![obj isEqual: loe->object]) + if (![obj isEqual: iter->object]) ok = false; - loe = loe->next; + iter = iter->next; i++; } if (list.count != i) ok = false; TEST(@"OFEnumerator's -[nextObject]", ok); - [list removeListObject: list.firstListObject]; + [list removeListItem: list.firstListItem]; EXPECT_EXCEPTION(@"Detection of mutation during enumeration", OFEnumerationMutationException, [enumerator nextObject]) [list prependObject: strings[0]]; - loe = list.firstListObject; + iter = list.firstListItem; i = 0; ok = true; for (OFString *object in list) { - if (![object isEqual: loe->object]) + if (![object isEqual: iter->object]) ok = false; - loe = loe->next; + iter = iter->next; i++; } if (list.count != i) ok = false; @@ -134,11 +133,11 @@ ok = false; @try { for (OFString *object in list) { (void)object; - [list removeListObject: list.lastListObject]; + [list removeListItem: list.lastListItem]; } } @catch (OFEnumerationMutationException *e) { ok = true; }