205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
|
return class_getMethodImplementation(self, selector);
#else
return method_get_imp(class_get_instance_method(self, selector));
#endif
}
+ (IMP)setImplementation: (IMP)newimp
forMethod: (SEL)selector
{
#ifdef OF_APPLE_RUNTIME
Method method;
if ((method = class_getInstanceMethod(self, selector)) == NULL)
@throw [OFInvalidArgumentException newWithClass: self
selector: _cmd];
|
|
|
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
|
return class_getMethodImplementation(self, selector);
#else
return method_get_imp(class_get_instance_method(self, selector));
#endif
}
+ (IMP)setImplementation: (IMP)newimp
forInstanceMethod: (SEL)selector
{
#ifdef OF_APPLE_RUNTIME
Method method;
if ((method = class_getInstanceMethod(self, selector)) == NULL)
@throw [OFInvalidArgumentException newWithClass: self
selector: _cmd];
|
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
|
sarray_at_put_safe(((Class)self)->dtable,
(sidx)method->method_name->sel_id, method->method_imp);
return oldimp;
#endif
}
+ (IMP)replaceMethod: (SEL)selector
withMethodFromClass: (Class)class;
{
IMP newimp;
#ifdef OF_APPLE_RUNTIME
newimp = class_getMethodImplementation(class, selector);
#else
newimp = method_get_imp(class_get_instance_method(class, selector));
#endif
return [self setImplementation: newimp
forMethod: selector];
}
- init
{
return self;
}
|
|
|
|
|
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
|
sarray_at_put_safe(((Class)self)->dtable,
(sidx)method->method_name->sel_id, method->method_imp);
return oldimp;
#endif
}
+ (IMP)replaceInstanceMethod: (SEL)selector
withInstanceMethodFromClass: (Class)class;
{
IMP newimp;
#ifdef OF_APPLE_RUNTIME
newimp = class_getMethodImplementation(class, selector);
#else
newimp = method_get_imp(class_get_instance_method(class, selector));
#endif
return [self setImplementation: newimp
forInstanceMethod: selector];
}
- init
{
return self;
}
|