Index: src/OFDictionary.h ================================================================== --- src/OFDictionary.h +++ src/OFDictionary.h @@ -30,10 +30,12 @@ typedef id (^of_dictionary_map_block_t)(id key, id object); #endif /** * \brief An abstract class for storing objects in a dictionary. + * + * Keys are copied and thus must conform to the OFCopying protocol. * * Note: Fast enumeration on a dictionary enumerates through the keys of the * dictionary. */ @interface OFDictionary: OFObject )key; + forKey: (id)key; /** * \brief Creates a new OFDictionary with the specified keys and objects. * * \param keys An array of keys @@ -77,11 +79,11 @@ * \brief Creates a new OFDictionary with the specified keys objects. * * \param firstKey The first key * \return A new autoreleased OFDictionary */ -+ dictionaryWithKeysAndObjects: (id )firstKey, ...; ++ dictionaryWithKeysAndObjects: (id)firstKey, ...; /** * \brief Initializes an already allocated OFDictionary. * * \return An initialized OFDictionary @@ -104,11 +106,11 @@ * \param key The key * \param object The object * \return A new initialized OFDictionary */ - initWithObject: (id)object - forKey: (id )key; + forKey: (id)key; /** * \brief Initializes an already allocated OFDictionary with the specified keys * and objects. * @@ -124,21 +126,21 @@ * and objects. * * \param firstKey The first key * \return A new initialized OFDictionary */ -- initWithKeysAndObjects: (id )firstKey, ...; +- initWithKeysAndObjects: (id)firstKey, ...; /** * \brief Initializes an already allocated OFDictionary with the specified key * and va_list. * * \param firstKey The first key * \param arguments A va_list of the other arguments * \return A new initialized OFDictionary */ -- initWithKey: (id )firstKey +- initWithKey: (id)firstKey arguments: (va_list)arguments; /** * \brief Returns the object for the given key or nil if the key was not found. * @@ -146,11 +148,11 @@ * reasons! * * \param key The key whose object should be returned * \return The object for the given key or nil if the key was not found */ -- (id)objectForKey: (id )key; +- (id)objectForKey: (id)key; /** * \brief Checks whether the dictionary contains an object with the specified * address. * Index: src/OFDictionary.m ================================================================== --- src/OFDictionary.m +++ src/OFDictionary.m @@ -44,11 +44,11 @@ return (id)[[OFDictionary_hashtable alloc] initWithDictionary: dictionary]; } - initWithObject: (id)object - forKey: (id )key + forKey: (id)key { return (id)[[OFDictionary_hashtable alloc] initWithObject: object forKey: key]; } @@ -131,11 +131,11 @@ { return [[[self alloc] initWithDictionary: dictionary] autorelease]; } + dictionaryWithObject: (id)object - forKey: (id )key + forKey: (id)key { return [[[self alloc] initWithObject: object forKey: key] autorelease]; } @@ -144,11 +144,11 @@ { return [[[self alloc] initWithObjects: objects forKeys: keys] autorelease]; } -+ dictionaryWithKeysAndObjects: (id )firstKey, ... ++ dictionaryWithKeysAndObjects: (id)firstKey, ... { id ret; va_list arguments; va_start(arguments, firstKey); @@ -179,11 +179,11 @@ @throw [OFNotImplementedException newWithClass: c selector: _cmd]; } - initWithObject: (id)object - forKey: (id )key + forKey: (id)key { return [self initWithKeysAndObjects: key, object, nil]; } - initWithObjects: (OFArray*)objects @@ -193,11 +193,11 @@ [self release]; @throw [OFNotImplementedException newWithClass: c selector: _cmd]; } -- initWithKeysAndObjects: (id )firstKey, ... +- initWithKeysAndObjects: (id)firstKey, ... { id ret; va_list arguments; va_start(arguments, firstKey); @@ -206,11 +206,11 @@ va_end(arguments); return ret; } -- initWithKey: (id )firstKey +- initWithKey: (id)firstKey arguments: (va_list)arguments { Class c = isa; [self release]; @throw [OFNotImplementedException newWithClass: c @@ -223,11 +223,11 @@ [self release]; @throw [OFNotImplementedException newWithClass: c selector: _cmd]; } -- (id)objectForKey: (id )key +- (id)objectForKey: (id)key { @throw [OFNotImplementedException newWithClass: isa selector: _cmd]; } @@ -249,11 +249,11 @@ - (BOOL)isEqual: (id)dictionary { OFAutoreleasePool *pool; OFEnumerator *enumerator; - id key; + id key; if ([dictionary count] != [self count]) return NO; pool = [[OFAutoreleasePool alloc] init]; @@ -313,13 +313,13 @@ - (OFArray*)allKeys { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; id *cArray = [self allocMemoryForNItems: [self count] withSize: sizeof(id)]; + OFArray *ret; OFEnumerator *enumerator; - id key; - OFArray *ret; + id key; size_t i = 0; pool = [[OFAutoreleasePool alloc] init]; enumerator = [self keyEnumerator]; @@ -343,13 +343,13 @@ - (OFArray*)allObjects { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; id *cArray = [self allocMemoryForNItems: [self count] withSize: sizeof(id)]; + OFArray *ret; OFEnumerator *enumerator; id object; - OFArray *ret; size_t i = 0; pool = [[OFAutoreleasePool alloc] init]; enumerator = [self objectEnumerator]; @@ -394,11 +394,11 @@ - (void)enumerateKeysAndObjectsUsingBlock: (of_dictionary_enumeration_block_t)block { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFEnumerator *enumerator = [self keyEnumerator]; - id key; + id key; BOOL stop = NO; while (!stop && (key = [enumerator nextObject]) != nil) block(key, [self objectForKey: key], &stop); @@ -440,11 +440,11 @@ - (uint32_t)hash { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFEnumerator *enumerator = [self keyEnumerator]; - id key; + id key; uint32_t hash = 0; while ((key = [enumerator nextObject]) != nil) { hash += [key hash]; hash += [[self objectForKey: key] hash]; @@ -500,11 +500,11 @@ { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFAutoreleasePool *pool2; OFXMLElement *element; OFEnumerator *keyEnumerator, *objectEnumerator; - id key, object; + id key, object; if ([self isKindOfClass: [OFMutableDictionary class]]) element = [OFXMLElement elementWithName: @"OFMutableDictionary" namespace: OF_SERIALIZATION_NS]; else Index: src/OFDictionary_hashtable.h ================================================================== --- src/OFDictionary_hashtable.h +++ src/OFDictionary_hashtable.h @@ -16,12 +16,11 @@ #import "OFDictionary.h" struct of_dictionary_hashtable_bucket { - id key; - id object; + id key, object; uint32_t hash; }; @interface OFDictionary_hashtable: OFDictionary { Index: src/OFDictionary_hashtable.m ================================================================== --- src/OFDictionary_hashtable.m +++ src/OFDictionary_hashtable.m @@ -127,11 +127,11 @@ self = [super init]; @try { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFEnumerator *enumerator; - id key; + id key; uint32_t i, newSize; count = [dictionary count]; if (count > UINT32_MAX) @@ -201,11 +201,11 @@ return self; } - initWithObject: (id)object - forKey: (id )key + forKey: (id)key { self = [super init]; @try { uint32_t i; @@ -299,11 +299,11 @@ /* Key not in dictionary */ if (j >= last || data[j] == NULL || ![data[j]->key isEqual: keysCArray[i]]) { struct of_dictionary_hashtable_bucket *bucket; - id key; + id key; last = size; j = hash & (size - 1); for (; j < last && data[j] != NULL; j++); @@ -363,11 +363,11 @@ } return self; } -- initWithKey: (id )firstKey +- initWithKey: (id)firstKey arguments: (va_list)arguments { self = [super init]; @try { @@ -429,11 +429,11 @@ data[j] = bucket; for (i = 1; i < count; i++) { uint32_t last; - key = va_arg(arguments, id ); + key = va_arg(arguments, id); object = va_arg(arguments, id); if (key == nil || object == nil) @throw [OFInvalidArgumentException newWithClass: isa @@ -580,11 +580,11 @@ } return self; } -- (id)objectForKey: (id )key +- (id)objectForKey: (id)key { uint32_t i, hash, last; if (key == nil) @throw [OFInvalidArgumentException newWithClass: isa Index: src/OFEnumerator.h ================================================================== --- src/OFEnumerator.h +++ src/OFEnumerator.h @@ -19,11 +19,11 @@ @class OFEnumerator; /** * \brief A protocol for getting an enumerator for the object. */ -@protocol OFEnumerating +@protocol OFEnumerating /** * \brief Returns an OFEnumerator to enumerate through all objects of the * collection. * * \returns An OFEnumerator to enumerate through all objects of the collection Index: src/OFMutableDictionary.h ================================================================== --- src/OFMutableDictionary.h +++ src/OFMutableDictionary.h @@ -31,18 +31,18 @@ * * \param key The key to set * \param object The object to set the key to */ - (void)setObject: (id)object - forKey: (id )key; + forKey: (id)key; /** * \brief Removes the object for the specified key from the dictionary. * * \param key The key whose object should be removed */ -- (void)removeObjectForKey: (id )key; +- (void)removeObjectForKey: (id)key; #ifdef OF_HAVE_BLOCKS /** * \brief Replaces each object with the object returned by the block. * Index: src/OFMutableDictionary.m ================================================================== --- src/OFMutableDictionary.m +++ src/OFMutableDictionary.m @@ -38,11 +38,11 @@ return (id)[[OFMutableDictionary_hashtable alloc] initWithDictionary: dictionary]; } - initWithObject: (id)object - forKey: (id )key + forKey: (id)key { return (id)[[OFMutableDictionary_hashtable alloc] initWithObject: object forKey: key]; } @@ -52,11 +52,11 @@ return (id)[[OFMutableDictionary_hashtable alloc] initWithObjects: objects forKeys: keys]; } -- initWithKeysAndObjects: (id )firstKey, ... +- initWithKeysAndObjects: (id)firstKey, ... { id ret; va_list arguments; va_start(arguments, firstKey); Index: src/OFMutableDictionary_hashtable.m ================================================================== --- src/OFMutableDictionary_hashtable.m +++ src/OFMutableDictionary_hashtable.m @@ -187,18 +187,18 @@ data[i]->object = [object retain]; [old release]; } - (void)setObject: (id)object - forKey: (id )key + forKey: (id)key { [self _setObject: object forKey: key copyKey: YES]; } -- (void)removeObjectForKey: (id )key +- (void)removeObjectForKey: (id)key { uint32_t i, hash, last; if (key == nil) @throw [OFInvalidArgumentException newWithClass: isa Index: src/OFObject.h ================================================================== --- src/OFObject.h +++ src/OFObject.h @@ -576,11 +576,11 @@ @end /** * \brief A protocol for the creation of copies. */ -@protocol OFCopying +@protocol OFCopying /** * \brief Copies the object. * * For classes which can be immutable or mutable, this returns an immutable * copy. If only a mutable version of the class exists, it creates a mutable @@ -595,11 +595,11 @@ * \brief A protocol for the creation of mutable copies. * * This protocol is implemented by objects that can be mutable and immutable * and allows returning a mutable copy. */ -@protocol OFMutableCopying +@protocol OFMutableCopying /** * \brief Creates a mutable copy of the object. * * \return A mutable copy of the object */ Index: src/OFSerialization.h ================================================================== --- src/OFSerialization.h +++ src/OFSerialization.h @@ -21,11 +21,11 @@ @class OFXMLElement; /** * \brief A protocol for serializing objects. */ -@protocol OFSerialization +@protocol OFSerialization /** * \brief Initializes the object with the specified XML element serialization. * * \param element An OFXMLElement with the serialized object * \return An initialized object Index: src/OFXMLElement+Serialization.m ================================================================== --- src/OFXMLElement+Serialization.m +++ src/OFXMLElement+Serialization.m @@ -32,11 +32,11 @@ @implementation OFXMLElement (Serialization) - (id)objectByDeserializing { OFAutoreleasePool *pool; Class class; - id object; + id object; pool = [[OFAutoreleasePool alloc] init]; if ((class = objc_lookUpClass([name cString])) == Nil) @throw [OFNotImplementedException newWithClass: Nil];