Overview
Comment: | Key Value Coding: Add -[setNilValueForKey:] |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
7bb4cae9db8326f4b8d6551615810f06 |
User & Date: | js on 2016-06-05 15:51:12 |
Other Links: | manifest | tags |
Context
2016-06-05
| ||
16:00 | Key Value Coding: Add fallback to isFoo check-in: 10fbb20fd6 user: js tags: trunk | |
15:51 | Key Value Coding: Add -[setNilValueForKey:] check-in: 7bb4cae9db user: js tags: trunk | |
15:50 | Fix OFDictionaryTests check-in: 4ad79a7f67 user: js tags: trunk | |
Changes
Modified src/OFKeyValueCoding.h from [a76365edf5] to [d63616901c].
︙ | ︙ | |||
64 65 66 67 68 69 70 71 72 73 | * By default, this throws an @ref OFUndefinedKeyException. * * @param value The value for the specified undefined key * @param key The undefined key of the value to set */ - (void)setValue: (nullable id)value forUndefinedKey: (OFString*)key; @end OF_ASSUME_NONNULL_END | > > > > > > > > > > | 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | * By default, this throws an @ref OFUndefinedKeyException. * * @param value The value for the specified undefined key * @param key The undefined key of the value to set */ - (void)setValue: (nullable id)value forUndefinedKey: (OFString*)key; /*! * @brief This is called by @ref setValue:forKey: if the specified key is a * scalar, but the value specified is `nil`. * * By default, this throws an @ref OFInvalidArgumentException. * * @param key The key for which the value `nil` was specified */ - (void)setNilValueForKey: (OFString*)key; @end OF_ASSUME_NONNULL_END |
Modified src/OFObject+KeyValueCoding.m from [a1b8c4dfd4] to [08642a6afa].
︙ | ︙ | |||
20 21 22 23 24 25 26 27 28 29 30 31 32 33 | #include <ctype.h> #import "OFObject.h" #import "OFObject+KeyValueCoding.h" #import "OFString.h" #import "OFNumber.h" #import "OFOutOfMemoryException.h" #import "OFUndefinedKeyException.h" int _OFObject_KeyValueCoding_reference; static char OF_INLINE nextType(const char **typeEncoding) | > | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | #include <ctype.h> #import "OFObject.h" #import "OFObject+KeyValueCoding.h" #import "OFString.h" #import "OFNumber.h" #import "OFInvalidArgumentException.h" #import "OFOutOfMemoryException.h" #import "OFUndefinedKeyException.h" int _OFObject_KeyValueCoding_reference; static char OF_INLINE nextType(const char **typeEncoding) |
︙ | ︙ | |||
135 136 137 138 139 140 141 142 143 144 145 146 147 148 | valueType = nextType(&typeEncoding); if (*typeEncoding != 0) { [self setValue: value forUndefinedKey: key]; return; } switch (valueType) { case '@': case '#': { void (*setter)(id, SEL, id) = (void(*)(id, SEL, id)) [self methodForSelector: selector]; | > > > > > | 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | valueType = nextType(&typeEncoding); if (*typeEncoding != 0) { [self setValue: value forUndefinedKey: key]; return; } if (valueType != '@' && valueType != '#' && value == nil) { [self setNilValueForKey: key]; return; } switch (valueType) { case '@': case '#': { void (*setter)(id, SEL, id) = (void(*)(id, SEL, id)) [self methodForSelector: selector]; |
︙ | ︙ | |||
182 183 184 185 186 187 188 189 | - (void)setValue: (id)value forUndefinedKey: (OFString*)key { @throw [OFUndefinedKeyException exceptionWithObject: self key: key value: value]; } @end | > > > > > | 188 189 190 191 192 193 194 195 196 197 198 199 200 | - (void)setValue: (id)value forUndefinedKey: (OFString*)key { @throw [OFUndefinedKeyException exceptionWithObject: self key: key value: value]; } - (void)setNilValueForKey: (OFString*)key { @throw [OFInvalidArgumentException exception]; } @end |
Modified tests/OFObjectTests.m from [e7dc8eb450] to [e6767683b4].
︙ | ︙ | |||
16 17 18 19 20 21 22 23 24 25 26 27 28 29 | #include "config.h" #import "OFString.h" #import "OFNumber.h" #import "OFAutoreleasePool.h" #import "OFMemoryNotPartOfObjectException.h" #import "OFOutOfMemoryException.h" #import "OFUndefinedKeyException.h" #import "TestsAppDelegate.h" #if (defined(OF_DRAGONFLYBSD) && defined(__LP64__)) || defined(OF_NINTENDO_3DS) | > | 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | #include "config.h" #import "OFString.h" #import "OFNumber.h" #import "OFAutoreleasePool.h" #import "OFInvalidArgumentException.h" #import "OFMemoryNotPartOfObjectException.h" #import "OFOutOfMemoryException.h" #import "OFUndefinedKeyException.h" #import "TestsAppDelegate.h" #if (defined(OF_DRAGONFLYBSD) && defined(__LP64__)) || defined(OF_NINTENDO_3DS) |
︙ | ︙ | |||
250 251 252 253 254 255 256 257 258 259 260 | [m unsignedCharValue] == 60 && [m unsignedShortValue] == 70 && [m unsignedIntValue] == 80 && [m unsignedLongValue] == 90 && [m unsignedLongLongValue] == 100 && [m floatValue] == 110 && [m doubleValue] == 120) [pool drain]; } @end | > > > > | 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 | [m unsignedCharValue] == 60 && [m unsignedShortValue] == 70 && [m unsignedIntValue] == 80 && [m unsignedLongValue] == 90 && [m unsignedLongLongValue] == 100 && [m floatValue] == 110 && [m doubleValue] == 120) EXPECT_EXCEPTION(@"Catch -[setValue:forKey:] with nil key for scalar", OFInvalidArgumentException, [m setValue: nil forKey: @"intValue"]) [pool drain]; } @end |