Differences From Artifact [a5e62b6d57]:
- File
src/runtime/class.m
— part of check-in
[44f45c2e35]
at
2017-01-09 17:36:36
on branch trunk
— Update copyright
Forgot to add 2017, even though I already did quite some changes in
2017. (user: js, size: 19418) [annotate] [blame] [check-ins using]
To Artifact [bb8140f5e4]:
- File
src/runtime/class.m
— part of check-in
[4af49a13c3]
at
2017-05-07 20:10:13
on branch trunk
— Small code style change
Casts are now written like types in variable declarations. (user: js, size: 19431) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
68 69 70 71 72 73 74 | register_selectors(struct objc_abi_class *cls) { struct objc_abi_method_list *ml; for (ml = cls->methodlist; ml != NULL; ml = ml->next) for (unsigned int i = 0; i < ml->count; i++) objc_register_selector( | | | 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | register_selectors(struct objc_abi_class *cls) { struct objc_abi_method_list *ml; for (ml = cls->methodlist; ml != NULL; ml = ml->next) for (unsigned int i = 0; i < ml->count; i++) objc_register_selector( (struct objc_abi_selector *)&ml->methods[i]); } Class objc_classname_to_class(const char *name, bool cache) { Class cls; |
︙ | ︙ | |||
131 132 133 134 135 136 137 | { SEL selector = sel_registerName(method); for (struct objc_method_list *ml = cls->isa->methodlist; ml != NULL; ml = ml->next) for (unsigned int i = 0; i < ml->count; i++) if (sel_isEqual((SEL)&ml->methods[i].sel, selector)) | | | 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | { SEL selector = sel_registerName(method); for (struct objc_method_list *ml = cls->isa->methodlist; ml != NULL; ml = ml->next) for (unsigned int i = 0; i < ml->count; i++) if (sel_isEqual((SEL)&ml->methods[i].sel, selector)) ((void (*)(id, SEL))ml->methods[i].imp)(cls, selector); } static bool has_load(Class cls) { SEL selector = sel_registerName("load"); |
︙ | ︙ | |||
268 269 270 271 272 273 274 | setup_class(Class cls) { const char *superclass; if (cls->info & OBJC_CLASS_INFO_SETUP) return; | | | 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 | setup_class(Class cls) { const char *superclass; if (cls->info & OBJC_CLASS_INFO_SETUP) return; if ((superclass = ((struct objc_abi_class *)cls)->superclass) != NULL) { Class super = objc_classname_to_class(superclass, false); if (super == Nil) return; setup_class(super); |
︙ | ︙ | |||
381 382 383 384 385 386 387 | } void objc_register_all_classes(struct objc_abi_symtab *symtab) { for (uint16_t i = 0; i < symtab->cls_def_cnt; i++) { struct objc_abi_class *cls = | | | 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 | } void objc_register_all_classes(struct objc_abi_symtab *symtab) { for (uint16_t i = 0; i < symtab->cls_def_cnt; i++) { struct objc_abi_class *cls = (struct objc_abi_class *)symtab->defs[i]; register_class(cls); register_selectors(cls); register_selectors(cls->metaclass); } for (uint16_t i = 0; i < symtab->cls_def_cnt; i++) { |
︙ | ︙ | |||
452 453 454 455 456 457 458 | } void objc_registerClassPair(Class cls) { objc_global_mutex_lock(); | | | 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 | } void objc_registerClassPair(Class cls) { objc_global_mutex_lock(); register_class((struct objc_abi_class *)cls); if (cls->superclass != Nil) { add_subclass(cls); add_subclass(cls->isa); } cls->info |= OBJC_CLASS_INFO_SETUP; |
︙ | ︙ | |||
564 565 566 567 568 569 570 | } objc_global_mutex_unlock(); return j; } | | | 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(); |
︙ | ︙ | |||
597 598 599 600 601 602 603 | { if (cls == Nil) return false; return (cls->info & OBJC_CLASS_INFO_METACLASS); } | | | 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 | { 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; } |
︙ | ︙ | |||
666 667 668 669 670 671 672 | if (cls == Nil) return NULL; dummy.isa = cls; return objc_msg_lookup_stret((id)&dummy, sel); } | | | 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 | if (cls == Nil) return NULL; dummy.isa = cls; return objc_msg_lookup_stret((id)&dummy, sel); } static struct objc_method * get_method(Class cls, SEL sel) { struct objc_method_list *ml; struct objc_category **cats; for (ml = cls->methodlist; ml != NULL; ml = ml->next) for (unsigned int i = 0; i < ml->count; i++) |
︙ | ︙ | |||
715 716 717 718 719 720 721 | ml->methods[0].imp = imp; cls->methodlist = ml; objc_update_dtable(cls); } | | | 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; |
︙ | ︙ | |||
787 788 789 790 791 792 793 | object_getClass(id obj_) { struct objc_object *obj; if (obj_ == nil) return Nil; | | | | | | 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 824 825 826 827 828 829 830 831 832 | 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) { struct objc_abi_class *cls = (struct objc_abi_class *)rcls; if ((rcls->info & OBJC_CLASS_INFO_SETUP) && rcls->superclass != Nil && rcls->superclass->subclass_list != NULL) { size_t i = SIZE_MAX, count = 0; Class *tmp; |
︙ | ︙ |