Differences From Artifact [973ed6f5e5]:
- File
src/runtime/class.m
— part of check-in
[482698c5be]
at
2018-05-06 21:39:06
on branch trunk
— runtime: Make Amiga library work with -fbaserel
This currently uses __saveds on all exported functions for simplicity.
As an optimization, __saveds can be removed from some functions later
after careful verification that no code path starting from that function
accesses any data. (user: js, size: 20233) [annotate] [blame] [check-ins using]
To Artifact [3cdd278d3a]:
- File src/runtime/class.m — part of check-in [95e1ba8d63] at 2018-05-13 02:09:02 on branch trunk — runtime: Port Amiga library to MorphOS (user: js, size: 19481) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
412 413 414 415 416 417 418 | } else cls->info |= OBJC_CLASS_INFO_LOADED; } process_load_queue(); } | | | < < | 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 | } else cls->info |= OBJC_CLASS_INFO_LOADED; } process_load_queue(); } Class objc_allocateClassPair(Class superclass, const char *name, size_t extra_bytes) { struct objc_class *cls, *metaclass; Class iter, rootclass = Nil; if (extra_bytes > LONG_MAX) OBJC_ERROR("extra_bytes out of range!") |
︙ | ︙ | |||
448 449 450 451 452 453 454 | metaclass->info = OBJC_CLASS_INFO_CLASS; metaclass->instance_size = (superclass != Nil ? superclass->isa->instance_size : 0) + (long)extra_bytes; return cls; } | | | | 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 | metaclass->info = OBJC_CLASS_INFO_CLASS; metaclass->instance_size = (superclass != Nil ? superclass->isa->instance_size : 0) + (long)extra_bytes; return cls; } void objc_registerClassPair(Class cls) { objc_global_mutex_lock(); register_class((struct objc_abi_class *)cls); if (cls->superclass != Nil) { add_subclass(cls); |
︙ | ︙ | |||
525 526 527 528 529 530 531 | Class objc_get_class(const char *name) { return objc_getRequiredClass(name); } | | | < | 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 | Class objc_get_class(const char *name) { return objc_getRequiredClass(name); } unsigned int objc_getClassList(Class *buf, unsigned int count) { unsigned int j; objc_global_mutex_lock(); if (buf == NULL) return classes_cnt; |
︙ | ︙ | |||
566 567 568 569 570 571 572 | } objc_global_mutex_unlock(); return j; } | | | | 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 | } objc_global_mutex_unlock(); return j; } Class * objc_copyClassList(unsigned int *len) { Class *ret; unsigned int count; objc_global_mutex_lock(); if ((ret = malloc((classes_cnt + 1) * sizeof(Class))) == NULL) |
︙ | ︙ | |||
590 591 592 593 594 595 596 | *len = count; objc_global_mutex_unlock(); return ret; } | | | | | | | | | | | < | 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 | *len = count; objc_global_mutex_unlock(); return ret; } bool class_isMetaClass(Class cls) { if (cls == Nil) return false; return (cls->info & OBJC_CLASS_INFO_METACLASS); } const char * class_getName(Class cls) { if (cls == Nil) return ""; return cls->name; } Class class_getSuperclass(Class cls) { if (cls == Nil) return Nil; return cls->superclass; } unsigned long class_getInstanceSize(Class cls) { if (cls == Nil) return 0; return cls->instance_size; } IMP class_getMethodImplementation(Class cls, SEL sel) { /* * We use a dummy object here so that the normal lookup is used, even * though we don't have an object. Doing so is safe, as objc_msg_lookup * does not access the object, but only its class. * * Just looking it up in the dispatch table could result in returning |
︙ | ︙ | |||
651 652 653 654 655 656 657 | if (cls == Nil) return NULL; dummy.isa = cls; return objc_msg_lookup((id)&dummy, sel); } | | | < | 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 | if (cls == Nil) return NULL; dummy.isa = cls; return objc_msg_lookup((id)&dummy, sel); } IMP class_getMethodImplementation_stret(Class cls, SEL sel) { /* * Same as above, but use objc_msg_lookup_stret instead, so that the * correct forwarding handler is returned. */ struct { Class isa; |
︙ | ︙ | |||
719 720 721 722 723 724 725 | ml->methods[0].imp = imp; cls->methodlist = ml; objc_update_dtable(cls); } | | | < | 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 | ml->methods[0].imp = imp; cls->methodlist = ml; objc_update_dtable(cls); } const char * class_getMethodTypeEncoding(Class cls, SEL sel) { struct objc_method *method; if (cls == Nil) return NULL; objc_global_mutex_lock(); |
︙ | ︙ | |||
744 745 746 747 748 749 750 | if (cls->superclass != Nil) return class_getMethodTypeEncoding(cls->superclass, sel); return NULL; } | | | < | | < | | | | | | | 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 | if (cls->superclass != Nil) return class_getMethodTypeEncoding(cls->superclass, sel); return NULL; } bool class_addMethod(Class cls, SEL sel, IMP imp, const char *types) { bool ret; objc_global_mutex_lock(); if (get_method(cls, sel) == NULL) { add_method(cls, sel, imp, types); ret = true; } else ret = false; objc_global_mutex_unlock(); return ret; } IMP class_replaceMethod(Class cls, SEL sel, IMP newimp, const char *types) { struct objc_method *method; IMP oldimp; objc_global_mutex_lock(); if ((method = get_method(cls, sel)) != NULL) { oldimp = method->imp; method->imp = newimp; objc_update_dtable(cls); } else { oldimp = NULL; add_method(cls, sel, newimp, types); } objc_global_mutex_unlock(); return oldimp; } Class object_getClass(id obj_) { struct objc_object *obj; if (obj_ == nil) return Nil; obj = (struct objc_object *)obj_; return obj->isa; } Class object_setClass(id obj_, Class cls) { struct objc_object *obj; Class old; if (obj_ == nil) return Nil; obj = (struct objc_object *)obj_; old = obj->isa; obj->isa = cls; return old; } const char * object_getClassName(id obj) { return class_getName(object_getClass(obj)); } static void unregister_class(Class rcls) { |
︙ | ︙ |