Differences From Artifact [c563fc5512]:
- File
src/OFObject.m
— part of check-in
[fbee44d38e]
at
2011-07-31 19:45:37
on branch trunk
— Cleaner -[setImplementation:...] for old GNU runtime.
Still work needed to correctly update the dtable. (user: js, size: 26486) [annotate] [blame] [check-ins using]
To Artifact [7f71e00414]:
- File src/OFObject.m — part of check-in [df914ca51d] at 2011-07-31 20:03:26 on branch trunk — Correctly update the dtable for the old GNU runtime. (user: js, size: 26946) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
120 121 122 123 124 125 126 127 128 129 130 131 132 133 | } /* References for static linking */ void _references_to_categories_of_OFObject(void) { _OFObject_Serialization_reference = 1; } @implementation OFObject + (void)load { #ifdef NEED_OBJC_SYNC_INIT if (!objc_sync_init()) { fputs("Runtime error: objc_sync_init() failed!\n", stderr); | > > > > > > > > > > > > > > > > > > > > > > > > > > > | 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 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 | } /* References for static linking */ void _references_to_categories_of_OFObject(void) { _OFObject_Serialization_reference = 1; } #ifdef OF_OLD_GNU_RUNTIME /* * The old GNU runtime is missing functions for changing methods at runtime. It * does not even offer a function to update the dtable, so we have to do even * that manually. A well designed runtime would not even allow us to touch the * dtable, but the old GNU runtime is that crappy that it even forces us to * touch it... */ static void update_dtable(Class class) { MethodList_t iter; if (class->super_class != Nil) update_dtable(class->super_class); for (iter = class->methods; iter != NULL; iter = iter->method_next) { int i; for (i = 0; i < iter->method_count; i++) sarray_at_put_safe(class->dtable, (sidx)iter->method_list[i].method_name->sel_id, iter->method_list[i].method_imp); } } #endif @implementation OFObject + (void)load { #ifdef NEED_OBJC_SYNC_INIT if (!objc_sync_init()) { fputs("Runtime error: objc_sync_init() failed!\n", stderr); |
︙ | ︙ | |||
356 357 358 359 360 361 362 | if (sel_eq(iter->method_list[i].method_name, selector)) { IMP oldImp; oldImp = iter->method_list[i].method_imp; iter->method_list[i].method_imp = newImp; | < | < | 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 | if (sel_eq(iter->method_list[i].method_name, selector)) { IMP oldImp; oldImp = iter->method_list[i].method_imp; iter->method_list[i].method_imp = newImp; update_dtable((Class)self->class_pointer); return oldImp; } } assert([self addClassMethod: selector withTypeEncoding: method->method_types |
︙ | ︙ | |||
432 433 434 435 436 437 438 | if (sel_eq(iter->method_list[i].method_name, selector)) { IMP oldImp; oldImp = iter->method_list[i].method_imp; iter->method_list[i].method_imp = newImp; | | < | 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 | if (sel_eq(iter->method_list[i].method_name, selector)) { IMP oldImp; oldImp = iter->method_list[i].method_imp; iter->method_list[i].method_imp = newImp; update_dtable(self); return oldImp; } } assert([self addInstanceMethod: selector withTypeEncoding: method->method_types |
︙ | ︙ | |||
505 506 507 508 509 510 511 | methodList->method_list[0].method_name = selector; methodList->method_list[0].method_types = typeEncoding; methodList->method_list[0].method_imp = implementation; ((Class)self)->methods = methodList; | | < < | 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 | methodList->method_list[0].method_name = selector; methodList->method_list[0].method_types = typeEncoding; methodList->method_list[0].method_imp = implementation; ((Class)self)->methods = methodList; update_dtable(self); return YES; #else @throw [OFNotImplementedException newWithClass: self selector: _cmd]; #endif } |
︙ | ︙ | |||
550 551 552 553 554 555 556 | methodList->method_list[0].method_name = selector; methodList->method_list[0].method_types = typeEncoding; methodList->method_list[0].method_imp = implementation; ((Class)self->class_pointer)->methods = methodList; | < | < | 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 | methodList->method_list[0].method_name = selector; methodList->method_list[0].method_types = typeEncoding; methodList->method_list[0].method_imp = implementation; ((Class)self->class_pointer)->methods = methodList; update_dtable((Class)self->class_pointer); return YES; #else @throw [OFNotImplementedException newWithClass: self selector: _cmd]; #endif } |
︙ | ︙ |