Differences From Artifact [8a9fc8e1ab]:
- File
src/OFObject+KeyValueCoding.m
— part of check-in
[627511b032]
at
2020-11-14 12:23:55
on branch trunk
— Rename of_malloc and of_calloc
The new names should be more accurate. (user: js, size: 6808) [annotate] [blame] [check-ins using] [more...]
To Artifact [9c33438270]:
- File src/OFObject+KeyValueCoding.m — part of check-in [1b82d3bf4f] at 2021-03-07 20:25:21 on branch trunk — *.m: Fold methods into one line where it fits (user: js, size: 6668) [annotate] [blame] [check-ins using] [more...]
1 | /* | < < | | 1 2 3 4 5 6 7 8 9 | /* * Copyright (c) 2008-2021 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * |
︙ | ︙ | |||
137 138 139 140 141 142 143 | objc_autoreleasePoolPop(pool); return [ret autorelease]; } - (id)valueForUndefinedKey: (OFString *)key { | | < | < < | | 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | objc_autoreleasePoolPop(pool); return [ret autorelease]; } - (id)valueForUndefinedKey: (OFString *)key { @throw [OFUndefinedKeyException exceptionWithObject: self key: key]; } - (void)setValue: (id)value forKey: (OFString *)key { void *pool = objc_autoreleasePoolPush(); size_t keyLength; char *name; SEL selector; OFMethodSignature *methodSignature; const char *valueType; if ((keyLength = key.UTF8StringLength) < 1) { objc_autoreleasePoolPop(pool); [self setValue: value forUndefinedKey: key]; return; } name = of_alloc(keyLength + 5, 1); @try { memcpy(name, "set", 3); memcpy(name + 3, key.UTF8String, keyLength); |
︙ | ︙ | |||
179 180 181 182 183 184 185 | if (methodSignature == nil || methodSignature.numberOfArguments != 3 || *methodSignature.methodReturnType != 'v' || *[methodSignature argumentTypeAtIndex: 0] != '@' || *[methodSignature argumentTypeAtIndex: 1] != ':') { objc_autoreleasePoolPop(pool); | < | | 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | if (methodSignature == nil || methodSignature.numberOfArguments != 3 || *methodSignature.methodReturnType != 'v' || *[methodSignature argumentTypeAtIndex: 0] != '@' || *[methodSignature argumentTypeAtIndex: 1] != ':') { objc_autoreleasePoolPop(pool); [self setValue: value forUndefinedKey: key]; return; } valueType = [methodSignature argumentTypeAtIndex: 2]; if (*valueType != '@' && *valueType != '#' && value == nil) { objc_autoreleasePoolPop(pool); |
︙ | ︙ | |||
226 227 228 229 230 231 232 | CASE('L', unsigned long, unsignedLongValue) CASE('Q', unsigned long long, unsignedLongLongValue) CASE('f', float, floatValue) CASE('d', double, doubleValue) #undef CASE default: objc_autoreleasePoolPop(pool); | < | | < | < | < | 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 | CASE('L', unsigned long, unsignedLongValue) CASE('Q', unsigned long long, unsignedLongLongValue) CASE('f', float, floatValue) CASE('d', double, doubleValue) #undef CASE default: objc_autoreleasePoolPop(pool); [self setValue: value forUndefinedKey: key]; return; } objc_autoreleasePoolPop(pool); } - (void)setValue: (id)value forKeyPath: (OFString *)keyPath { void *pool = objc_autoreleasePoolPush(); OFArray *keys = [keyPath componentsSeparatedByString: @"."]; size_t keysCount = keys.count; id object = self; size_t i = 0; for (OFString *key in keys) { if (++i == keysCount) [object setValue: value forKey: key]; else object = [object valueForKey: key]; } objc_autoreleasePoolPop(pool); } - (void)setValue: (id)value forUndefinedKey: (OFString *)key { @throw [OFUndefinedKeyException exceptionWithObject: self key: key value: value]; } - (void)setNilValueForKey: (OFString *)key { @throw [OFInvalidArgumentException exception]; } @end |