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
164
165
166
|
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);
|
|
<
|
<
<
|
|
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);
|
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
|
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);
|
<
|
|
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);
|
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
264
265
266
267
268
269
270
271
|
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
|
<
|
|
<
|
<
|
<
|
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
|