Overview
Comment: | runtime: New API for internal unregister methods. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
b4231b1df931db0b56aa8c9ce9068aa0 |
User & Date: | js on 2013-12-19 20:15:36 |
Other Links: | manifest | tags |
Context
2013-12-19
| ||
22:21 | runtime: Add objc_{get,copy}ClassList(). check-in: 035fa09270 user: js tags: trunk | |
20:15 | runtime: New API for internal unregister methods. check-in: b4231b1df9 user: js tags: trunk | |
2013-12-16
| ||
03:31 | Add a few files to DISTCLEAN which were missing. check-in: ee4e1a8fac user: js tags: trunk | |
Changes
Modified src/runtime/category.m from [58afce4465] to [1f2f7da047].
︙ | ︙ | |||
112 113 114 115 116 117 118 | return NULL; return (struct objc_category**)objc_hashtable_get(categories, cls->name); } void | | | 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | return NULL; return (struct objc_category**)objc_hashtable_get(categories, cls->name); } void objc_unregister_all_categories(void) { uint32_t i; if (categories == NULL) return; for (i = 0; i <= categories->last_idx; i++) if (categories->data[i] != NULL) free((void*)categories->data[i]->obj); objc_hashtable_free(categories); categories = NULL; } |
Modified src/runtime/class.m from [e9b6e354b6] to [3ec80df1e8].
︙ | ︙ | |||
310 311 312 313 314 315 316 | 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); | | | 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 | 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); if (!(super->info & OBJC_CLASS_INFO_SETUP)) return; |
︙ | ︙ | |||
653 654 655 656 657 658 659 | cls->methodlist = ml; objc_update_dtable(cls); objc_global_mutex_unlock(); | | | 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 | cls->methodlist = ml; objc_update_dtable(cls); objc_global_mutex_unlock(); return NULL; } Class object_getClass(id obj_) { struct objc_object *obj = (struct objc_object*)obj_; |
︙ | ︙ | |||
682 683 684 685 686 687 688 | const char* object_getClassName(id obj) { return object_getClass(obj)->name; } | | | > > > > > > > | | < | 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 | const char* object_getClassName(id obj) { return object_getClass(obj)->name; } static void unregister_class(Class rcls) { struct objc_abi_class *cls = (struct objc_abi_class*)rcls; if (rcls->subclass_list != NULL) { free(rcls->subclass_list); rcls->subclass_list = NULL; } if (rcls->dtable != NULL && rcls->dtable != empty_dtable) objc_sparsearray_free(rcls->dtable); rcls->dtable = NULL; if (rcls->superclass != Nil) cls->superclass = rcls->superclass->name; objc_hashtable_set(classes, cls->name, NULL); } void objc_unregister_class(Class cls) { unregister_class(cls); unregister_class(cls->isa); } static void free_sparsearray(struct sparsearray *sa, size_t depth) { uint_fast16_t i; if (sa == NULL || depth == 0) return; for (i = 0; i < 256; i++) free_sparsearray(sa->next[i], depth - 1); free(sa); } void objc_unregister_all_classes(void) { uint_fast32_t i; if (classes == NULL) return; for (i = 0; i <= classes->last_idx; i++) { if (classes->data[i] != NULL) { Class cls = (Class)classes->data[i]->obj; if (cls == Nil || (uintptr_t)cls & 1) continue; objc_unregister_class(cls); } } if (empty_dtable != NULL) { objc_sparsearray_free(empty_dtable); empty_dtable = NULL; } |
︙ | ︙ |
Modified src/runtime/init.m from [1cd48f10fe] to [ca2ec26efb].
︙ | ︙ | |||
33 34 35 36 37 38 39 | } void objc_exit(void) { objc_global_mutex_lock(); | | | | > | 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | } void objc_exit(void) { objc_global_mutex_lock(); objc_unregister_all_categories(); objc_unregister_all_classes(); objc_unregister_all_selectors(); objc_forget_pending_static_instances(); objc_sparsearray_cleanup(); objc_global_mutex_unlock(); objc_global_mutex_free(); } |
Modified src/runtime/runtime-private.h from [d3d6b58a3c] to [448c2c1e1b].
︙ | ︙ | |||
118 119 120 121 122 123 124 | struct objc_sparsearray_level2 { const void *buckets[256]; }; #endif extern void objc_register_all_categories(struct objc_abi_symtab*); extern struct objc_category** objc_categories_for_class(Class); | | | | | > | 118 119 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 | struct objc_sparsearray_level2 { const void *buckets[256]; }; #endif extern void objc_register_all_categories(struct objc_abi_symtab*); extern struct objc_category** objc_categories_for_class(Class); extern void objc_unregister_all_categories(void); extern void objc_initialize_class(Class); extern void objc_update_dtable(Class); extern void objc_register_all_classes(struct objc_abi_symtab*); extern Class objc_classname_to_class(const char*, bool); extern void objc_unregister_class(Class); extern void objc_unregister_all_classes(void); extern uint32_t objc_hash_string(const char*); extern struct objc_hashtable* objc_hashtable_new(uint32_t); extern void objc_hashtable_set(struct objc_hashtable*, const char*, const void*); extern void* objc_hashtable_get(struct objc_hashtable*, const char*); extern void objc_hashtable_free(struct objc_hashtable *h); extern void objc_register_selector(struct objc_abi_selector*); extern void objc_register_all_selectors(struct objc_abi_symtab*); extern void objc_unregister_all_selectors(void); extern struct objc_sparsearray* objc_sparsearray_new(void); extern void objc_sparsearray_copy(struct objc_sparsearray*, struct objc_sparsearray*); extern void objc_sparsearray_set(struct objc_sparsearray*, uint32_t, const void*); extern void objc_sparsearray_free(struct objc_sparsearray*); extern void objc_sparsearray_cleanup(void); extern void objc_init_static_instances(struct objc_abi_symtab*); extern void objc_forget_pending_static_instances(void); extern void __objc_exec_class(struct objc_abi_module*); #ifdef OF_HAVE_THREADS extern void objc_global_mutex_lock(void); extern void objc_global_mutex_unlock(void); extern void objc_global_mutex_free(void); #else # define objc_global_mutex_lock() |
︙ | ︙ |
Modified src/runtime/runtime.h from [b39bf61658] to [dda778658d].
︙ | ︙ | |||
12 13 14 15 16 17 18 19 20 21 22 23 24 25 | * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #ifndef __OBJFW_RUNTIME_H__ #define __OBJFW_RUNTIME_H__ #include <stdint.h> #include <stdbool.h> #ifndef __has_feature # define __has_feature(x) 0 #endif | > | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #ifndef __OBJFW_RUNTIME_H__ #define __OBJFW_RUNTIME_H__ #include <stdint.h> #include <stdbool.h> #ifndef __has_feature # define __has_feature(x) 0 #endif |
︙ | ︙ |
Modified src/runtime/selector.m from [743b892159] to [95506f87f9].
︙ | ︙ | |||
124 125 126 127 128 129 130 | bool sel_isEqual(SEL sel1, SEL sel2) { return (sel1->uid == sel2->uid); } void | | | 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | bool sel_isEqual(SEL sel1, SEL sel2) { return (sel1->uid == sel2->uid); } void objc_unregister_all_selectors(void) { objc_hashtable_free(selectors); objc_sparsearray_free(selector_names); if (free_list != NULL) { size_t i; |
︙ | ︙ |
Modified src/runtime/static-instances.m from [172bc47cd5] to [c67bef4763].
︙ | ︙ | |||
87 88 89 90 91 92 93 | OBJC_ERROR("Not enough memory for list of " "static instances!"); static_instances[static_instances_cnt++] = *si; } } } | > > > > > > > > | 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | OBJC_ERROR("Not enough memory for list of " "static instances!"); static_instances[static_instances_cnt++] = *si; } } } void objc_forget_pending_static_instances() { free(static_instances); static_instances = NULL; static_instances_cnt = 0; } |
Modified tests/plugin/TestPlugin.m from [ecd648908c] to [d6d9940b82].
︙ | ︙ | |||
20 21 22 23 24 25 26 | #ifdef OF_OBJFW_RUNTIME # import "runtime-private.h" static void __attribute__((destructor)) unload(void) { | | < < < < | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | #ifdef OF_OBJFW_RUNTIME # import "runtime-private.h" static void __attribute__((destructor)) unload(void) { objc_unregister_class(objc_getClass("TestPlugin")); } #endif @implementation TestPlugin - (int)test: (int)num { return num * 2; |
︙ | ︙ |