Index: src/OFCountedSet_hashtable.m ================================================================== --- src/OFCountedSet_hashtable.m +++ src/OFCountedSet_hashtable.m @@ -146,12 +146,12 @@ if (object == nil || count_ == nil) @throw [OFInvalidFormatException exception]; count = (size_t)[[count_ stringValue] decimalValue]; - [_mapTable setValue: (void*)(uintptr_t)count - forKey: [object objectByDeserializing]]; + [_mapTable setObject: (void*)(uintptr_t)count + forKey: [object objectByDeserializing]]; objc_autoreleasePoolPop(pool2); } objc_autoreleasePoolPop(pool); @@ -163,21 +163,21 @@ return self; } - (size_t)countForObject: (id)object { - return (size_t)(uintptr_t)[_mapTable valueForKey: object]; + return (size_t)(uintptr_t)[_mapTable objectForKey: object]; } #ifdef OF_HAVE_BLOCKS - (void)enumerateObjectsAndCountUsingBlock: (of_counted_set_enumeration_block_t)block { @try { - [_mapTable enumerateKeysAndValuesUsingBlock: - ^ (void *key, void *value, bool *stop) { - block(key, (size_t)(uintptr_t)value, stop); + [_mapTable enumerateKeysAndObjectsUsingBlock: + ^ (void *key, void *object, bool *stop) { + block(key, (size_t)(uintptr_t)object, stop); }]; } @catch (OFEnumerationMutationException *e) { @throw [OFEnumerationMutationException exceptionWithObject: self]; } @@ -184,34 +184,34 @@ } #endif - (void)addObject: (id)object { - size_t count = (size_t)(uintptr_t)[_mapTable valueForKey: object]; + size_t count = (size_t)(uintptr_t)[_mapTable objectForKey: object]; if (SIZE_MAX - count < 1 || UINTPTR_MAX - count < 1) @throw [OFOutOfRangeException exception]; - [_mapTable setValue: (void*)(uintptr_t)(count + 1) - forKey: object]; + [_mapTable setObject: (void*)(uintptr_t)(count + 1) + forKey: object]; } - (void)removeObject: (id)object { - size_t count = (size_t)(uintptr_t)[_mapTable valueForKey: object]; + size_t count = (size_t)(uintptr_t)[_mapTable objectForKey: object]; if (count == 0) return; count--; if (count > 0) - [_mapTable setValue: (void*)(uintptr_t)count - forKey: object]; + [_mapTable setObject: (void*)(uintptr_t)count + forKey: object]; else - [_mapTable removeValueForKey: object]; + [_mapTable removeObjectForKey: object]; } - (void)makeImmutable { } @end Index: src/OFDictionary_hashtable.m ================================================================== --- src/OFDictionary_hashtable.m +++ src/OFDictionary_hashtable.m @@ -29,46 +29,46 @@ #import "OFEnumerationMutationException.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" static void* -copy(void *value) +copy(void *object) { - return [(id)value copy]; + return [(id)object copy]; } static void* -retain(void *value) +retain(void *object) { - return [(id)value retain]; + return [(id)object retain]; } static void -release(void *value) +release(void *object) { - [(id)value release]; + [(id)object release]; } static uint32_t -hash(void *value) +hash(void *object) { - return [(id)value hash]; + return [(id)object hash]; } static bool -equal(void *value1, void *value2) +equal(void *object1, void *object2) { - return [(id)value1 isEqual: (id)value2]; + return [(id)object1 isEqual: (id)object2]; } static const of_map_table_functions_t keyFunctions = { .retain = copy, .release = release, .hash = hash, .equal = equal }; -static const of_map_table_functions_t valueFunctions = { +static const of_map_table_functions_t objectFunctions = { .retain = retain, .release = release, .hash = hash, .equal = equal }; @@ -84,11 +84,11 @@ self = [super init]; @try { _mapTable = [[OFMapTable alloc] initWithKeyFunctions: keyFunctions - valueFunctions: valueFunctions + objectFunctions: objectFunctions capacity: capacity]; } @catch (id e) { [self release]; @throw e; } @@ -136,12 +136,12 @@ keyEnumerator = [dictionary keyEnumerator]; objectEnumerator = [dictionary objectEnumerator]; while ((key = [keyEnumerator nextObject]) != nil && (object = [objectEnumerator nextObject]) != nil) - [_mapTable setValue: object - forKey: key]; + [_mapTable setObject: object + forKey: key]; objc_autoreleasePoolPop(pool); } @catch (id e) { [self release]; @throw e; @@ -154,12 +154,12 @@ forKey: (id)key { self = [self initWithCapacity: 1]; @try { - [_mapTable setValue: object - forKey: key]; + [_mapTable setObject: object + forKey: key]; } @catch (id e) { [self release]; @throw e; } @@ -174,12 +174,12 @@ @try { size_t i; for (i = 0; i < count; i++) - [_mapTable setValue: objects[i] - forKey: keys[i]]; + [_mapTable setObject: objects[i] + forKey: keys[i]]; } @catch (id e) { [self release]; @throw e; } @@ -214,25 +214,25 @@ count /= 2; _mapTable = [[OFMapTable alloc] initWithKeyFunctions: keyFunctions - valueFunctions: valueFunctions + objectFunctions: objectFunctions capacity: count]; - [_mapTable setValue: object - forKey: key]; + [_mapTable setObject: object + forKey: key]; for (i = 1; i < count; i++) { key = va_arg(arguments, id); object = va_arg(arguments, id); if (key == nil || object == nil) @throw [OFInvalidArgumentException exception]; - [_mapTable setValue: object - forKey: key]; + [_mapTable setObject: object + forKey: key]; } } @catch (id e) { [self release]; @throw e; } @@ -258,11 +258,11 @@ if ([keys count] != [objects count]) @throw [OFInvalidFormatException exception]; _mapTable = [[OFMapTable alloc] initWithKeyFunctions: keyFunctions - valueFunctions: valueFunctions + objectFunctions: objectFunctions capacity: [keys count]]; keyEnumerator = [keys objectEnumerator]; objectEnumerator = [objects objectEnumerator]; while ((keyElement = [keyEnumerator nextObject]) != nil && @@ -276,12 +276,12 @@ OF_SERIALIZATION_NS] firstObject]; if (key == nil || object == nil) @throw [OFInvalidFormatException exception]; - [_mapTable setValue: [object objectByDeserializing] - forKey: [key objectByDeserializing]]; + [_mapTable setObject: [object objectByDeserializing] + forKey: [key objectByDeserializing]]; objc_autoreleasePoolPop(pool2); } objc_autoreleasePoolPop(pool); @@ -300,11 +300,11 @@ [super dealloc]; } - (id)objectForKey: (id)key { - return [_mapTable valueForKey: key]; + return [_mapTable objectForKey: key]; } - (size_t)count { return [_mapTable count]; @@ -323,16 +323,16 @@ return [dictionary_->_mapTable isEqual: _mapTable]; } - (bool)containsObject: (id)object { - return [_mapTable containsValue: object]; + return [_mapTable containsObject: object]; } - (bool)containsObjectIdenticalTo: (id)object { - return [_mapTable containsValueIdenticalTo: object]; + return [_mapTable containsObjectIdenticalTo: object]; } - (OFArray*)allKeys { OFArray *ret; @@ -349,11 +349,11 @@ id key; size_t i; i = 0; enumerator = [_mapTable keyEnumerator]; - while ((key = [enumerator nextValue]) != nil) { + while ((key = [enumerator nextObject]) != nil) { assert(i < count); keys[i++] = key; } @@ -383,12 +383,12 @@ OFMapTableEnumerator *enumerator; id object; size_t i; i = 0; - enumerator = [_mapTable valueEnumerator]; - while ((object = [enumerator nextValue]) != nil) { + enumerator = [_mapTable objectEnumerator]; + while ((object = [enumerator nextObject]) != nil) { assert(i < count); objects[i++] = object; } @@ -411,11 +411,11 @@ } - (OFEnumerator*)objectEnumerator { return [[[OFMapTable_EnumeratorWrapper alloc] - initWithEnumerator: [_mapTable valueEnumerator] + initWithEnumerator: [_mapTable objectEnumerator] object: self] autorelease]; } - (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state objects: (id*)objects @@ -429,13 +429,13 @@ #ifdef OF_HAVE_BLOCKS - (void)enumerateKeysAndObjectsUsingBlock: (of_dictionary_enumeration_block_t)block { @try { - [_mapTable enumerateKeysAndValuesUsingBlock: - ^ (void *key, void *value, bool *stop) { - block(key, value, stop); + [_mapTable enumerateKeysAndObjectsUsingBlock: + ^ (void *key, void *object, bool *stop) { + block(key, object, stop); }]; } @catch (OFEnumerationMutationException *e) { @throw [OFEnumerationMutationException exceptionWithObject: self]; } Index: src/OFKernelEventObserver_epoll.m ================================================================== --- src/OFKernelEventObserver_epoll.m +++ src/OFKernelEventObserver_epoll.m @@ -62,11 +62,11 @@ fcntl(_epfd, F_SETFD, flags | FD_CLOEXEC); #endif _FDToEvents = [[OFMapTable alloc] initWithKeyFunctions: mapFunctions - valueFunctions: mapFunctions]; + objectFunctions: mapFunctions]; memset(&event, 0, sizeof(event)); event.events = EPOLLIN; event.data.ptr = [OFNull null]; @@ -94,11 +94,12 @@ events: (int)addEvents { struct epoll_event event; intptr_t events; - events = (intptr_t)[_FDToEvents valueForKey: (void*)((intptr_t)fd + 1)]; + events = (intptr_t)[_FDToEvents + objectForKey: (void*)((intptr_t)fd + 1)]; memset(&event, 0, sizeof(event)); event.events = (int)events | addEvents; event.data.ptr = object; @@ -105,30 +106,31 @@ if (epoll_ctl(_epfd, (events == 0 ? EPOLL_CTL_ADD : EPOLL_CTL_MOD), fd, &event) == -1) @throw [OFObserveFailedException exceptionWithObserver: self errNo: errno]; - [_FDToEvents setValue: (void*)(events | addEvents) - forKey: (void*)((intptr_t)fd + 1)]; + [_FDToEvents setObject: (void*)(events | addEvents) + forKey: (void*)((intptr_t)fd + 1)]; } - (void)OF_removeObject: (id)object fileDescriptor: (int)fd events: (int)removeEvents { intptr_t events; - events = (intptr_t)[_FDToEvents valueForKey: (void*)((intptr_t)fd + 1)]; + events = (intptr_t)[_FDToEvents + objectForKey: (void*)((intptr_t)fd + 1)]; events &= ~removeEvents; if (events == 0) { if (epoll_ctl(_epfd, EPOLL_CTL_DEL, fd, NULL) == -1) @throw [OFObserveFailedException exceptionWithObserver: self errNo: errno]; - [_FDToEvents removeValueForKey: (void*)((intptr_t)fd + 1)]; + [_FDToEvents removeObjectForKey: (void*)((intptr_t)fd + 1)]; } else { struct epoll_event event; memset(&event, 0, sizeof(event)); event.events = (int)events; @@ -137,12 +139,12 @@ if (epoll_ctl(_epfd, EPOLL_CTL_MOD, fd, &event) == -1) @throw [OFObserveFailedException exceptionWithObserver: self errNo: errno]; - [_FDToEvents setValue: (void*)events - forKey: (void*)((intptr_t)fd + 1)]; + [_FDToEvents setObject: (void*)events + forKey: (void*)((intptr_t)fd + 1)]; } } - (void)OF_addObjectForReading: (id )object { Index: src/OFMapTable.h ================================================================== --- src/OFMapTable.h +++ src/OFMapTable.h @@ -25,53 +25,53 @@ * @struct of_map_table_functions_t OFMapTable.h ObjFW/OFMapTable.h * * @brief A struct describing the functions to be used by the map table. */ typedef struct { - /// The function to retain keys / values - void *_Nonnull (*_Nullable retain)(void *value); - /// The function to release keys / values - void (*_Nullable release)(void *value); + /// The function to retain keys / objects + void *_Nonnull (*_Nullable retain)(void *object); + /// The function to release keys / objects + void (*_Nullable release)(void *object); /// The function to hash keys - uint32_t (*_Nullable hash)(void *value); - /// The function to compare keys / values - bool (*_Nullable equal)(void *value1, void *value2); + uint32_t (*_Nullable hash)(void *object); + /// The function to compare keys / objects + bool (*_Nullable equal)(void *object1, void *object2); } of_map_table_functions_t; #ifdef OF_HAVE_BLOCKS /*! * @brief A block for enumerating an OFMapTable. * * @param key The current key - * @param value The current value + * @param object The current object * @param stop A pointer to a variable that can be set to true to stop the * enumeration */ -typedef void (^of_map_table_enumeration_block_t)(void *key, void *value, +typedef void (^of_map_table_enumeration_block_t)(void *key, void *object, bool *stop); /*! - * @brief A block for replacing values in an OFMapTable. + * @brief A block for replacing objects in an OFMapTable. * - * @param key The key of the value to replace - * @param value The value to replace - * @return The value to replace the value with + * @param key The key of the object to replace + * @param object The object to replace + * @return The object to replace the object with */ -typedef void *_Nonnull (^of_map_table_replace_block_t)(void *key, void *value); +typedef void *_Nonnull (^of_map_table_replace_block_t)(void *key, void *object); #endif @class OFMapTableEnumerator; /*! * @class OFMapTable OFMapTable.h ObjFW/OFMapTable.h * * @brief A class similar to OFDictionary, but providing more options how keys - * and values should be retained, released, compared and hashed. + * and objects should be retained, released, compared and hashed. */ @interface OFMapTable: OFObject { - of_map_table_functions_t _keyFunctions, _valueFunctions; + of_map_table_functions_t _keyFunctions, _objectFunctions; struct of_map_table_bucket **_buckets; uint32_t _count, _capacity; uint8_t _rotate; unsigned long _mutations; } @@ -80,63 +80,63 @@ * The key functions used by the map table. */ @property (readonly) of_map_table_functions_t keyFunctions; /*! - * The value functions used by the map table. - */ -@property (readonly) of_map_table_functions_t valueFunctions; - -/*! - * @brief Creates a new OFMapTable with the specified key and value functions. - * - * @param keyFunctions A structure of functions for handling keys - * @param valueFunctions A structure of functions for handling values - * @return A new autoreleased OFMapTable - */ -+ (instancetype)mapTableWithKeyFunctions: (of_map_table_functions_t)keyFunctions - valueFunctions: (of_map_table_functions_t) - valueFunctions; - -/*! - * @brief Creates a new OFMapTable with the specified key functions, value - * functions and capacity. - * - * @param keyFunctions A structure of functions for handling keys - * @param valueFunctions A structure of functions for handling values - * @param capacity A hint about the count of elements expected to be in the map - * table - * @return A new autoreleased OFMapTable - */ -+ (instancetype)mapTableWithKeyFunctions: (of_map_table_functions_t)keyFunctions - valueFunctions: (of_map_table_functions_t) - valueFunctions - capacity: (size_t)capacity; - -/*! - * @brief Initializes an already allocated OFMapTable with the specified key - * and value functions. - * - * @param keyFunctions A structure of functions for handling keys - * @param valueFunctions A structure of functions for handling values - * @return An initialized OFMapTable - */ -- initWithKeyFunctions: (of_map_table_functions_t)keyFunctions - valueFunctions: (of_map_table_functions_t)valueFunctions; - -/*! - * @brief Initializes an already allocated OFMapTable with the specified key - * functions, value functions and capacity. - * - * @param keyFunctions A structure of functions for handling keys - * @param valueFunctions A structure of functions for handling values - * @param capacity A hint about the count of elements expected to be in the map - * table - * @return An initialized OFMapTable - */ -- initWithKeyFunctions: (of_map_table_functions_t)keyFunctions - valueFunctions: (of_map_table_functions_t)valueFunctions + * The object functions used by the map table. + */ +@property (readonly) of_map_table_functions_t objectFunctions; + +/*! + * @brief Creates a new OFMapTable with the specified key and object functions. + * + * @param keyFunctions A structure of functions for handling keys + * @param objectFunctions A structure of functions for handling objects + * @return A new autoreleased OFMapTable + */ ++ (instancetype)mapTableWithKeyFunctions: (of_map_table_functions_t)keyFunctions + objectFunctions: (of_map_table_functions_t) + objectFunctions; + +/*! + * @brief Creates a new OFMapTable with the specified key functions, object + * functions and capacity. + * + * @param keyFunctions A structure of functions for handling keys + * @param objectFunctions A structure of functions for handling objects + * @param capacity A hint about the count of elements expected to be in the map + * table + * @return A new autoreleased OFMapTable + */ ++ (instancetype)mapTableWithKeyFunctions: (of_map_table_functions_t)keyFunctions + objectFunctions: (of_map_table_functions_t) + objectFunctions + capacity: (size_t)capacity; + +/*! + * @brief Initializes an already allocated OFMapTable with the specified key + * and object functions. + * + * @param keyFunctions A structure of functions for handling keys + * @param objectFunctions A structure of functions for handling objects + * @return An initialized OFMapTable + */ +- initWithKeyFunctions: (of_map_table_functions_t)keyFunctions + objectFunctions: (of_map_table_functions_t)objectFunctions; + +/*! + * @brief Initializes an already allocated OFMapTable with the specified key + * functions, object functions and capacity. + * + * @param keyFunctions A structure of functions for handling keys + * @param objectFunctions A structure of functions for handling objects + * @param capacity A hint about the count of elements expected to be in the map + * table + * @return An initialized OFMapTable + */ +- initWithKeyFunctions: (of_map_table_functions_t)keyFunctions + objectFunctions: (of_map_table_functions_t)objectFunctions capacity: (size_t)capacity; /*! * @brief Returns the number of objects in the map table. * @@ -143,56 +143,56 @@ * @return The number of objects in the map table */ - (size_t)count; /*! - * @brief Returns the value for the given key or NULL if the key was not found. + * @brief Returns the object for the given key or NULL if the key was not found. * * @param key The key whose object should be returned - * @return The value for the given key or NULL if the key was not found + * @return The object for the given key or NULL if the key was not found */ -- (nullable void*)valueForKey: (void*)key; +- (nullable void*)objectForKey: (void*)key; /*! - * @brief Sets a value for a key. + * @brief Sets an object for a key. * * @param key The key to set - * @param value The value to set the key to + * @param object The object to set the key to */ -- (void)setValue: (void*)value - forKey: (void*)key; +- (void)setObject: (void*)object + forKey: (void*)key; /*! - * @brief Removes the value for the specified key from the map table. + * @brief Removes the object for the specified key from the map table. * * @param key The key whose object should be removed */ -- (void)removeValueForKey: (void*)key; - -/*! - * @brief Removes all values. - */ -- (void)removeAllValues; - -/*! - * @brief Checks whether the map table contains a value equal to the specified - * value. - * - * @param value The value which is checked for being in the map table - * @return A boolean whether the map table contains the specified value -*/ -- (bool)containsValue: (nullable void*)value; - -/*! - * @brief Checks whether the map table contains a value with the specified +- (void)removeObjectForKey: (void*)key; + +/*! + * @brief Removes all objects. + */ +- (void)removeAllObjects; + +/*! + * @brief Checks whether the map table contains an object equal to the + * specified object. + * + * @param object The object which is checked for being in the map table + * @return A boolean whether the map table contains the specified object +*/ +- (bool)containsObject: (nullable void*)object; + +/*! + * @brief Checks whether the map table contains an object with the specified * address. * - * @param value The value which is checked for being in the map table - * @return A boolean whether the map table contains a value with the specified - * address. + * @param object The object which is checked for being in the map table + * @return A boolean whether the map table contains an object with the + * specified address. */ -- (bool)containsValueIdenticalTo: (nullable void*)value; +- (bool)containsObjectIdenticalTo: (nullable void*)object; /*! * @brief Returns an OFMapTableEnumerator to enumerate through the map table's * keys. * @@ -200,39 +200,39 @@ */ - (OFMapTableEnumerator*)keyEnumerator; /*! * @brief Returns an OFMapTableEnumerator to enumerate through the map table's - * values. + * objects. * - * @return An OFMapTableEnumerator to enumerate through the map table's values + * @return An OFMapTableEnumerator to enumerate through the map table's objects */ -- (OFMapTableEnumerator*)valueEnumerator; +- (OFMapTableEnumerator*)objectEnumerator; #ifdef OF_HAVE_BLOCKS /*! * @brief Executes a block for each key / object pair. * * @param block The block to execute for each key / object pair. */ -- (void)enumerateKeysAndValuesUsingBlock: +- (void)enumerateKeysAndObjectsUsingBlock: (of_map_table_enumeration_block_t)block; /*! - * @brief Replaces each value with the value returned by the block. + * @brief Replaces each object with the object returned by the block. * - * @param block The block which returns a new value for each value + * @param block The block which returns a new object for each object */ -- (void)replaceValuesUsingBlock: (of_map_table_replace_block_t)block; +- (void)replaceObjectsUsingBlock: (of_map_table_replace_block_t)block; #endif @end /*! * @class OFMapTableEnumerator OFMapTable.h ObjFW/OFMapTable.h * * @brief A class which provides methods to enumerate through an OFMapTable's - * keys or values. + * keys or objects. */ @interface OFMapTableEnumerator: OFObject { OFMapTable *_mapTable; struct of_map_table_bucket **_buckets; @@ -241,19 +241,19 @@ unsigned long *_mutationsPtr; uint32_t _position; } /*! - * @brief Returns the next value. + * @brief Returns the next object. * - * @return The next value + * @return The next object */ -- (void*)nextValue; +- (void*)nextObject; /*! * @brief Resets the enumerator, so the next call to nextKey returns the first * key again. */ - (void)reset; @end OF_ASSUME_NONNULL_END Index: src/OFMapTable.m ================================================================== --- src/OFMapTable.m +++ src/OFMapTable.m @@ -30,42 +30,42 @@ #import "OFOutOfRangeException.h" #define MIN_CAPACITY 16 struct of_map_table_bucket { - void *key, *value; + void *key, *object; uint32_t hash; }; static struct of_map_table_bucket deleted = { 0 }; static void* -defaultRetain(void *value) +defaultRetain(void *object) { - return value; + return object; } static void -defaultRelease(void *value) +defaultRelease(void *object) { } static uint32_t -defaultHash(void *value) +defaultHash(void *object) { - return (uint32_t)(uintptr_t)value; + return (uint32_t)(uintptr_t)object; } static bool -defaultEqual(void *value1, void *value2) +defaultEqual(void *object1, void *object2) { - return (value1 == value2); + return (object1 == object2); } @interface OFMapTable () -- (void)OF_setValue: (void*)value - forKey: (void*)key - hash: (uint32_t)hash; +- (void)OF_setObject: (void*)object + forKey: (void*)key + hash: (uint32_t)hash; @end @interface OFMapTableEnumerator () - (instancetype)OF_initWithMapTable: (OFMapTable*)mapTable buckets: (struct of_map_table_bucket**)buckets @@ -74,58 +74,58 @@ @end @interface OFMapTableKeyEnumerator: OFMapTableEnumerator @end -@interface OFMapTableValueEnumerator: OFMapTableEnumerator +@interface OFMapTableObjectEnumerator: OFMapTableEnumerator @end @implementation OFMapTable -@synthesize keyFunctions = _keyFunctions, valueFunctions = _valueFunctions; +@synthesize keyFunctions = _keyFunctions, objectFunctions = _objectFunctions; + (instancetype)mapTableWithKeyFunctions: (of_map_table_functions_t)keyFunctions - valueFunctions: (of_map_table_functions_t) - valueFunctions + objectFunctions: (of_map_table_functions_t) + objectFunctions { return [[[self alloc] initWithKeyFunctions: keyFunctions - valueFunctions: valueFunctions] autorelease]; + objectFunctions: objectFunctions] autorelease]; } + (instancetype)mapTableWithKeyFunctions: (of_map_table_functions_t)keyFunctions - valueFunctions: (of_map_table_functions_t) - valueFunctions + objectFunctions: (of_map_table_functions_t) + objectFunctions capacity: (size_t)capacity { return [[[self alloc] initWithKeyFunctions: keyFunctions - valueFunctions: valueFunctions + objectFunctions: objectFunctions capacity: capacity] autorelease]; } - init { OF_INVALID_INIT_METHOD } - initWithKeyFunctions: (of_map_table_functions_t)keyFunctions - valueFunctions: (of_map_table_functions_t)valueFunctions + objectFunctions: (of_map_table_functions_t)objectFunctions { return [self initWithKeyFunctions: keyFunctions - valueFunctions: valueFunctions + objectFunctions: objectFunctions capacity: 0]; } - initWithKeyFunctions: (of_map_table_functions_t)keyFunctions - valueFunctions: (of_map_table_functions_t)valueFunctions + objectFunctions: (of_map_table_functions_t)objectFunctions capacity: (size_t)capacity { self = [super init]; @try { _keyFunctions = keyFunctions; - _valueFunctions = valueFunctions; + _objectFunctions = objectFunctions; #define SET_DEFAULT(var, value) \ if (var == NULL) \ var = value; @@ -132,14 +132,14 @@ SET_DEFAULT(_keyFunctions.retain, defaultRetain); SET_DEFAULT(_keyFunctions.release, defaultRelease); SET_DEFAULT(_keyFunctions.hash, defaultHash); SET_DEFAULT(_keyFunctions.equal, defaultEqual); - SET_DEFAULT(_valueFunctions.retain, defaultRetain); - SET_DEFAULT(_valueFunctions.release, defaultRelease); - SET_DEFAULT(_valueFunctions.hash, defaultHash); - SET_DEFAULT(_valueFunctions.equal, defaultEqual); + SET_DEFAULT(_objectFunctions.retain, defaultRetain); + SET_DEFAULT(_objectFunctions.release, defaultRelease); + SET_DEFAULT(_objectFunctions.hash, defaultHash); + SET_DEFAULT(_objectFunctions.equal, defaultEqual); #undef SET_DEFAULT if (capacity > UINT32_MAX / sizeof(*_buckets) || capacity > UINT32_MAX / 8) @@ -183,11 +183,11 @@ - (void)dealloc { for (uint32_t i = 0; i < _capacity; i++) { if (_buckets[i] != NULL && _buckets[i] != &deleted) { _keyFunctions.release(_buckets[i]->key); - _valueFunctions.release(_buckets[i]->value); + _objectFunctions.release(_buckets[i]->object); } } [super dealloc]; } @@ -201,18 +201,20 @@ mapTable = object; if (mapTable->_count != _count || mapTable->_keyFunctions.equal != _keyFunctions.equal || - mapTable->_valueFunctions.equal != _valueFunctions.equal) + mapTable->_objectFunctions.equal != _objectFunctions.equal) return false; for (uint32_t i = 0; i < _capacity; i++) { if (_buckets[i] != NULL && _buckets[i] != &deleted) { - void *value = [mapTable valueForKey: _buckets[i]->key]; + void *object = + [mapTable objectForKey: _buckets[i]->key]; - if (!_valueFunctions.equal(value, _buckets[i]->value)) + if (!_objectFunctions.equal(object, + _buckets[i]->object)) return false; } } return true; @@ -223,11 +225,11 @@ uint32_t hash = 0; for (uint32_t i = 0; i < _capacity; i++) { if (_buckets[i] != NULL && _buckets[i] != &deleted) { hash += OF_ROR(_buckets[i]->hash, _rotate); - hash += _valueFunctions.hash(_buckets[i]->value); + hash += _objectFunctions.hash(_buckets[i]->object); } } return hash; } @@ -234,20 +236,20 @@ - copy { OFMapTable *copy = [[OFMapTable alloc] initWithKeyFunctions: _keyFunctions - valueFunctions: _valueFunctions + objectFunctions: _objectFunctions capacity: _capacity]; @try { for (uint32_t i = 0; i < _capacity; i++) if (_buckets[i] != NULL && _buckets[i] != &deleted) - [copy OF_setValue: _buckets[i]->value - forKey: _buckets[i]->key - hash: OF_ROR(_buckets[i]->hash, - _rotate)]; + [copy OF_setObject: _buckets[i]->object + forKey: _buckets[i]->key + hash: OF_ROR(_buckets[i]->hash, + _rotate)]; } @catch (id e) { [copy release]; @throw e; } @@ -257,11 +259,11 @@ - (size_t)count { return _count; } -- (void*)valueForKey: (void*)key +- (void*)objectForKey: (void*)key { uint32_t i, hash, last; if (key == NULL) @throw [OFInvalidArgumentException exception]; @@ -272,11 +274,11 @@ for (i = hash & (_capacity - 1); i < last && _buckets[i] != NULL; i++) { if (_buckets[i] == &deleted) continue; if (_keyFunctions.equal(_buckets[i]->key, key)) - return _buckets[i]->value; + return _buckets[i]->object; } if (i < last) return nil; @@ -286,11 +288,11 @@ for (i = 0; i < last && _buckets[i] != NULL; i++) { if (_buckets[i] == &deleted) continue; if (_keyFunctions.equal(_buckets[i]->key, key)) - return _buckets[i]->value; + return _buckets[i]->object; } return NULL; } @@ -353,18 +355,18 @@ [self freeMemory: _buckets]; _buckets = buckets; _capacity = capacity; } -- (void)OF_setValue: (void*)value - forKey: (void*)key - hash: (uint32_t)hash +- (void)OF_setObject: (void*)object + forKey: (void*)key + hash: (uint32_t)hash { uint32_t i, last; void *old; - if (key == NULL || value == NULL) + if (key == NULL || object == NULL) @throw [OFInvalidArgumentException exception]; hash = OF_ROL(hash, _rotate); last = _capacity; @@ -421,11 +423,11 @@ [self freeMemory: bucket]; @throw e; } @try { - bucket->value = _valueFunctions.retain(value); + bucket->object = _objectFunctions.retain(object); } @catch (id e) { _keyFunctions.release(bucket->key); [self freeMemory: bucket]; @throw e; } @@ -436,24 +438,24 @@ _count++; return; } - old = _buckets[i]->value; - _buckets[i]->value = _valueFunctions.retain(value); - _valueFunctions.release(old); + old = _buckets[i]->object; + _buckets[i]->object = _objectFunctions.retain(object); + _objectFunctions.release(old); } -- (void)setValue: (void*)value - forKey: (void*)key +- (void)setObject: (void*)object + forKey: (void*)key { - [self OF_setValue: value - forKey: key - hash: _keyFunctions.hash(key)]; + [self OF_setObject: object + forKey: key + hash: _keyFunctions.hash(key)]; } -- (void)removeValueForKey: (void*)key +- (void)removeObjectForKey: (void*)key { uint32_t i, hash, last; if (key == NULL) @throw [OFInvalidArgumentException exception]; @@ -467,11 +469,11 @@ if (_keyFunctions.equal(_buckets[i]->key, key)) { _mutations++; _keyFunctions.release(_buckets[i]->key); - _valueFunctions.release(_buckets[i]->value); + _objectFunctions.release(_buckets[i]->object); [self freeMemory: _buckets[i]]; _buckets[i] = &deleted; _count--; @@ -491,11 +493,11 @@ if (_buckets[i] == &deleted) continue; if (_keyFunctions.equal(_buckets[i]->key, key)) { _keyFunctions.release(_buckets[i]->key); - _valueFunctions.release(_buckets[i]->value); + _objectFunctions.release(_buckets[i]->object); [self freeMemory: _buckets[i]]; _buckets[i] = &deleted; _count--; @@ -505,21 +507,21 @@ return; } } } -- (void)removeAllValues +- (void)removeAllObjects { for (uint32_t i = 0; i < _capacity; i++) { if (_buckets[i] != NULL) { if (_buckets[i] == &deleted) { _buckets[i] = NULL; continue; } _keyFunctions.release(_buckets[i]->key); - _valueFunctions.release(_buckets[i]->value); + _objectFunctions.release(_buckets[i]->object); [self freeMemory: _buckets[i]]; _buckets[i] = NULL; } } @@ -542,31 +544,31 @@ #else _rotate = rand() & 31; #endif } -- (bool)containsValue: (void*)value +- (bool)containsObject: (void*)object { - if (value == NULL || _count == 0) + if (object == NULL || _count == 0) return false; for (uint32_t i = 0; i < _capacity; i++) if (_buckets[i] != NULL && _buckets[i] != &deleted) - if (_valueFunctions.equal(_buckets[i]->value, value)) + if (_objectFunctions.equal(_buckets[i]->object, object)) return true; return false; } -- (bool)containsValueIdenticalTo: (void*)value +- (bool)containsObjectIdenticalTo: (void*)object { - if (value == NULL || _count == 0) + if (object == NULL || _count == 0) return false; for (uint32_t i = 0; i < _capacity; i++) if (_buckets[i] != NULL && _buckets[i] != &deleted) - if (_buckets[i]->value == value) + if (_buckets[i]->object == object) return true; return false; } @@ -577,13 +579,13 @@ buckets: _buckets capacity: _capacity mutationsPointer: &_mutations] autorelease]; } -- (OFMapTableEnumerator*)valueEnumerator +- (OFMapTableEnumerator*)objectEnumerator { - return [[[OFMapTableValueEnumerator alloc] + return [[[OFMapTableObjectEnumerator alloc] OF_initWithMapTable: self buckets: _buckets capacity: _capacity mutationsPointer: &_mutations] autorelease]; } @@ -612,11 +614,11 @@ return i; } #ifdef OF_HAVE_BLOCKS -- (void)enumerateKeysAndValuesUsingBlock: +- (void)enumerateKeysAndObjectsUsingBlock: (of_map_table_enumeration_block_t)block { bool stop = false; unsigned long mutations = _mutations; @@ -624,15 +626,15 @@ if (_mutations != mutations) @throw [OFEnumerationMutationException exceptionWithObject: self]; if (_buckets[i] != NULL && _buckets[i] != &deleted) - block(_buckets[i]->key, _buckets[i]->value, &stop); + block(_buckets[i]->key, _buckets[i]->object, &stop); } } -- (void)replaceValuesUsingBlock: (of_map_table_replace_block_t)block +- (void)replaceObjectsUsingBlock: (of_map_table_replace_block_t)block { unsigned long mutations = _mutations; for (size_t i = 0; i < _capacity; i++) { if (_mutations != mutations) @@ -640,18 +642,18 @@ exceptionWithObject: self]; if (_buckets[i] != NULL && _buckets[i] != &deleted) { void *new; - new = block(_buckets[i]->key, _buckets[i]->value); + new = block(_buckets[i]->key, _buckets[i]->object); if (new == NULL) @throw [OFInvalidArgumentException exception]; - if (new != _buckets[i]->value) { - _valueFunctions.release(_buckets[i]->value); - _buckets[i]->value = - _valueFunctions.retain(new); + if (new != _buckets[i]->object) { + _objectFunctions.release(_buckets[i]->object); + _buckets[i]->object = + _objectFunctions.retain(new); } } } } #endif @@ -684,11 +686,11 @@ [_mapTable release]; [super dealloc]; } -- (void*)nextValue +- (void*)nextObject { OF_UNRECOGNIZED_SELECTOR } - (void)reset @@ -700,11 +702,11 @@ _position = 0; } @end @implementation OFMapTableKeyEnumerator -- (void*)nextValue +- (void*)nextObject { if (*_mutationsPtr != _mutations) @throw [OFEnumerationMutationException exceptionWithObject: _mapTable]; @@ -716,22 +718,22 @@ else return NULL; } @end -@implementation OFMapTableValueEnumerator -- (void*)nextValue +@implementation OFMapTableObjectEnumerator +- (void*)nextObject { if (*_mutationsPtr != _mutations) @throw [OFEnumerationMutationException exceptionWithObject: _mapTable]; for (; _position < _capacity && (_buckets[_position] == NULL || _buckets[_position] == &deleted); _position++); if (_position < _capacity) - return _buckets[_position++]->value; + return _buckets[_position++]->object; else return NULL; } @end @@ -758,11 +760,11 @@ - (id)nextObject { id ret; @try { - ret = [_enumerator nextValue]; + ret = [_enumerator nextObject]; } @catch (OFEnumerationMutationException *e) { @throw [OFEnumerationMutationException exceptionWithObject: _object]; } Index: src/OFMutableDictionary_hashtable.m ================================================================== --- src/OFMutableDictionary_hashtable.m +++ src/OFMutableDictionary_hashtable.m @@ -33,31 +33,31 @@ } - (void)setObject: (id)object forKey: (id)key { - [_mapTable setValue: object - forKey: key]; + [_mapTable setObject: object + forKey: key]; } - (void)removeObjectForKey: (id)key { - [_mapTable removeValueForKey: key]; + [_mapTable removeObjectForKey: key]; } - (void)removeAllObjects { - [_mapTable removeAllValues]; + [_mapTable removeAllObjects]; } #ifdef OF_HAVE_BLOCKS - (void)replaceObjectsUsingBlock: (of_dictionary_replace_block_t)block { @try { - [_mapTable replaceValuesUsingBlock: - ^ void* (void *key, void *value) { - return block(key, value); + [_mapTable replaceObjectsUsingBlock: + ^ void* (void *key, void *object) { + return block(key, object); }]; } @catch (OFEnumerationMutationException *e) { @throw [OFEnumerationMutationException exceptionWithObject: self]; } Index: src/OFMutableSet_hashtable.m ================================================================== --- src/OFMutableSet_hashtable.m +++ src/OFMutableSet_hashtable.m @@ -27,19 +27,19 @@ [self inheritMethodsFromClass: [OFSet_hashtable class]]; } - (void)addObject: (id)object { - [_mapTable setValue: (void*)1 - forKey: object]; + [_mapTable setObject: (void*)1 + forKey: object]; } - (void)removeObject: (id)object { - [_mapTable removeValueForKey: object]; + [_mapTable removeObjectForKey: object]; } - (void)makeImmutable { object_setClass(self, [OFSet_hashtable class]); } @end Index: src/OFOptionsParser.m ================================================================== --- src/OFOptionsParser.m +++ src/OFOptionsParser.m @@ -22,19 +22,19 @@ #import "OFMapTable.h" #import "OFInvalidArgumentException.h" static uint32_t -stringHash(void *value) +stringHash(void *object) { - return [(OFString*)value hash]; + return [(OFString*)object hash]; } static bool -stringEqual(void *value1, void *value2) +stringEqual(void *object1, void *object2) { - return [(OFString*)value1 isEqual: (OFString*)value2]; + return [(OFString*)object1 isEqual: (OFString*)object2]; } @implementation OFOptionsParser @synthesize lastOption = _lastOption, lastLongOption = _lastLongOption; @synthesize argument = _argument; @@ -59,11 +59,11 @@ of_options_parser_option_t *iter2; const of_map_table_functions_t keyFunctions = { .hash = stringHash, .equal = stringEqual }; - const of_map_table_functions_t valueFunctions = { NULL }; + const of_map_table_functions_t objectFunctions = { NULL }; /* Count, sanity check, initialize pointers */ for (iter = options; iter->shortOption != '\0' || iter->longOption != nil; iter++) { @@ -85,11 +85,11 @@ count++; } _longOptions = [[OFMapTable alloc] initWithKeyFunctions: keyFunctions - valueFunctions: valueFunctions]; + objectFunctions: objectFunctions]; _options = [self allocMemoryWithSize: sizeof(*_options) count: count + 1]; for (iter = options, iter2 = _options; @@ -104,19 +104,19 @@ if (iter->longOption != nil) { @try { iter2->longOption = [iter->longOption copy]; - if ([_longOptions valueForKey: + if ([_longOptions objectForKey: iter2->longOption] != NULL) @throw [OFInvalidArgumentException exception]; [_longOptions - setValue: iter2 - forKey: iter2->longOption]; + setObject: iter2 + forKey: iter2->longOption]; } @catch (id e) { /* * Make sure we are in a consistent * state where dealloc works. */ @@ -207,11 +207,11 @@ _lastLongOption = [[argument substringWithRange: of_range(2, pos - 2)] copy]; objc_autoreleasePoolPop(pool); - option = [_longOptions valueForKey: _lastLongOption]; + option = [_longOptions objectForKey: _lastLongOption]; if (option == NULL) return '?'; if (option->hasArgument == 1 && _argument == nil) return ':'; Index: src/OFSet_hashtable.m ================================================================== --- src/OFSet_hashtable.m +++ src/OFSet_hashtable.m @@ -27,40 +27,40 @@ #import "OFInvalidArgumentException.h" #import "OFEnumerationMutationException.h" static void* -retain(void *value) +retain(void *object) { - return [(id)value retain]; + return [(id)object retain]; } static void -release(void *value) +release(void *object) { - [(id)value release]; + [(id)object release]; } static uint32_t -hash(void *value) +hash(void *object) { - return [(id)value hash]; + return [(id)object hash]; } static bool -equal(void *value1, void *value2) +equal(void *object1, void *object2) { - return [(id)value1 isEqual: (id)value2]; + return [(id)object1 isEqual: (id)object2]; } static const of_map_table_functions_t keyFunctions = { .retain = retain, .release = release, .hash = hash, .equal = equal }; -static const of_map_table_functions_t valueFunctions = { NULL }; +static const of_map_table_functions_t objectFunctions = { NULL }; @implementation OFSet_hashtable - init { return [self initWithCapacity: 0]; @@ -71,11 +71,11 @@ self = [super init]; @try { _mapTable = [[OFMapTable alloc] initWithKeyFunctions: keyFunctions - valueFunctions: valueFunctions + objectFunctions: objectFunctions capacity: capacity]; } @catch (id e) { [self release]; @throw e; } @@ -99,12 +99,12 @@ self = [self initWithCapacity: count]; @try { for (id object in set) - [_mapTable setValue: (void*)1 - forKey: object]; + [_mapTable setObject: (void*)1 + forKey: object]; } @catch (id e) { [self release]; @throw e; } @@ -127,12 +127,12 @@ self = [self initWithCapacity: count]; @try { for (id object in array) - [_mapTable setValue: (void*)1 - forKey: object]; + [_mapTable setObject: (void*)1 + forKey: object]; } @catch (id e) { [self release]; @throw e; } @@ -144,12 +144,12 @@ { self = [self initWithCapacity: count]; @try { for (size_t i = 0; i < count; i++) - [_mapTable setValue: (void*)1 - forKey: objects[i]]; + [_mapTable setObject: (void*)1 + forKey: objects[i]]; } @catch (id e) { [self release]; @throw e; } @@ -170,19 +170,19 @@ for (count = 1; va_arg(argumentsCopy, id) != nil; count++); _mapTable = [[OFMapTable alloc] initWithKeyFunctions: keyFunctions - valueFunctions: valueFunctions + objectFunctions: objectFunctions capacity: count]; - [_mapTable setValue: (void*)1 - forKey: firstObject]; + [_mapTable setObject: (void*)1 + forKey: firstObject]; while ((object = va_arg(arguments, id)) != nil) - [_mapTable setValue: (void*)1 - forKey: object]; + [_mapTable setObject: (void*)1 + forKey: object]; } @catch (id e) { [self release]; @throw e; } @@ -203,12 +203,12 @@ for (OFXMLElement *child in [element elementsForNamespace: OF_SERIALIZATION_NS]) { void *pool2 = objc_autoreleasePoolPush(); - [_mapTable setValue: (void*)1 - forKey: [child objectByDeserializing]]; + [_mapTable setObject: (void*)1 + forKey: [child objectByDeserializing]]; objc_autoreleasePoolPop(pool2); } objc_autoreleasePoolPop(pool); @@ -235,11 +235,11 @@ - (bool)containsObject: (id)object { if (object == nil) return false; - return ([_mapTable valueForKey: object] != nil); + return ([_mapTable objectForKey: object] != nil); } - (bool)isEqual: (id)object { OFSet_hashtable *set; @@ -257,11 +257,11 @@ - (id)anyObject { void *pool = objc_autoreleasePoolPush(); id object; - object = [[_mapTable keyEnumerator] nextValue]; + object = [[_mapTable keyEnumerator] nextObject]; object = [object retain]; objc_autoreleasePoolPop(pool); return [object autorelease]; @@ -285,16 +285,16 @@ #ifdef OF_HAVE_BLOCKS - (void)enumerateObjectsUsingBlock: (of_set_enumeration_block_t)block { @try { - [_mapTable enumerateKeysAndValuesUsingBlock: - ^ (void *key, void *value, bool *stop) { + [_mapTable enumerateKeysAndObjectsUsingBlock: + ^ (void *key, void *object, bool *stop) { block(key, stop); }]; } @catch (OFEnumerationMutationException *e) { @throw [OFEnumerationMutationException exceptionWithObject: self]; } } #endif @end