Differences From Artifact [d4b85d6121]:
- File src/OFObject+KeyValueCoding.m — part of check-in [cca678886f] at 2017-05-06 19:43:55 on branch trunk — Clean up a few includes (user: js, size: 5669) [annotate] [blame] [check-ins using]
To Artifact [30955b0805]:
- File
src/OFObject+KeyValueCoding.m
— part of check-in
[4af49a13c3]
at
2017-05-07 20:10:13
on branch trunk
— Small code style change
Casts are now written like types in variable declarations. (user: js, size: 5677) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
37 38 39 40 41 42 43 | while (**typeEncoding >= '0' && **typeEncoding <= '9') (*typeEncoding)++; return ret; } @implementation OFObject (KeyValueCoding) | | | 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | while (**typeEncoding >= '0' && **typeEncoding <= '9') (*typeEncoding)++; return ret; } @implementation OFObject (KeyValueCoding) - (id)valueForKey: (OFString *)key { SEL selector = sel_registerName([key UTF8String]); const char *typeEncoding = [self typeEncodingForSelector: selector]; id ret; if (typeEncoding == NULL) { size_t keyLength; |
︙ | ︙ | |||
81 82 83 84 85 86 87 | case '@': case '#': ret = [self performSelector: selector]; break; #define CASE(encoding, type, method) \ case encoding: \ { \ | | | 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | case '@': case '#': ret = [self performSelector: selector]; break; #define CASE(encoding, type, method) \ case encoding: \ { \ type (*getter)(id, SEL) = (type (*)(id, SEL)) \ [self methodForSelector: selector]; \ ret = [OFNumber method getter(self, selector)]; \ } \ break; CASE('B', bool, numberWithBool:) CASE('c', char, numberWithChar:) CASE('s', short, numberWithShort:) |
︙ | ︙ | |||
111 112 113 114 115 116 117 | if (nextType(&typeEncoding) != '@' || nextType(&typeEncoding) != ':' || *typeEncoding != 0) return [self valueForUndefinedKey: key]; return ret; } | | | | 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | if (nextType(&typeEncoding) != '@' || nextType(&typeEncoding) != ':' || *typeEncoding != 0) return [self valueForUndefinedKey: key]; return ret; } - (id)valueForUndefinedKey: (OFString *)key { @throw [OFUndefinedKeyException exceptionWithObject: self key: key]; } - (void)setValue: (id)value forKey: (OFString *)key { size_t keyLength; char *name; SEL selector; const char *typeEncoding; char valueType; |
︙ | ︙ | |||
174 175 176 177 178 179 180 | return; } switch (valueType) { case '@': case '#': { | | | | 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | return; } switch (valueType) { case '@': case '#': { void (*setter)(id, SEL, id) = (void (*)(id, SEL, id)) [self methodForSelector: selector]; setter(self, selector, value); } break; #define CASE(encoding, type, method) \ case encoding: \ { \ void (*setter)(id, SEL, type) = \ (void (*)(id, SEL, type)) \ [self methodForSelector: selector]; \ setter(self, selector, [value method]); \ } \ break; CASE('B', bool, boolValue) CASE('c', char, charValue) CASE('s', short, shortValue) |
︙ | ︙ | |||
210 211 212 213 214 215 216 | [self setValue: value forUndefinedKey: key]; return; } } - (void)setValue: (id)value | | | | 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | [self setValue: value forUndefinedKey: key]; return; } } - (void)setValue: (id)value forUndefinedKey: (OFString *)key { @throw [OFUndefinedKeyException exceptionWithObject: self key: key value: value]; } - (void)setNilValueForKey: (OFString *)key { @throw [OFInvalidArgumentException exception]; } @end |