Differences From Artifact [6c2deedb05]:
- File
src/runtime/selector.m
— part of check-in
[ef6d69931e]
at
2019-02-07 00:46:41
on branch trunk
— Make style consistent between ObjFW and ObjFW_RT
ObjFW_RT used to be a separate project that followed the BSD style, as
it was written in pure C, while ObjFW's style is based on the BSD style
with changes to make it a better fit for Objective-C. This commit
changes ObjFW_RT to use the same style as ObjFW. (user: js, size: 3503) [annotate] [blame] [check-ins using]
To Artifact [97ce324a27]:
- File src/runtime/selector.m — part of check-in [754bf24742] at 2019-02-07 21:31:16 on branch trunk — More style improvements (user: js, size: 3652) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
37 38 39 40 41 42 43 | static struct objc_hashtable *selectors = NULL; static uint32_t selectorsCount = 0; static struct objc_sparsearray *selectorNames = NULL; static void **freeList = NULL; static size_t freeListCount = 0; void | | | | > | | | | | | > < | | | | | | | | | | | | > | | 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | static struct objc_hashtable *selectors = NULL; static uint32_t selectorsCount = 0; static struct objc_sparsearray *selectorNames = NULL; static void **freeList = NULL; static size_t freeListCount = 0; void objc_register_selector(struct objc_abi_selector *rawSelector) { struct objc_selector *selector; const char *name; if (selectorsCount > SEL_MAX) OBJC_ERROR("Out of selector slots!"); if (selectors == NULL) selectors = objc_hashtable_new( objc_hash_string, objc_equal_string, 2); else if ((selector = objc_hashtable_get(selectors, rawSelector->name)) != NULL) { ((struct objc_selector *)rawSelector)->UID = selector->UID; return; } if (selectorNames == NULL) selectorNames = objc_sparsearray_new(SEL_SIZE); name = rawSelector->name; selector = (struct objc_selector *)rawSelector; selector->UID = selectorsCount++; objc_hashtable_set(selectors, name, selector); objc_sparsearray_set(selectorNames, (uint32_t)selector->UID, (void *)name); } SEL sel_registerName(const char *name) { struct objc_abi_selector *rawSelector; objc_global_mutex_lock(); if (selectors != NULL && (rawSelector= objc_hashtable_get(selectors, name)) != NULL) { objc_global_mutex_unlock(); return (SEL)rawSelector; } if ((rawSelector = malloc(sizeof(*rawSelector))) == NULL) OBJC_ERROR("Not enough memory to allocate selector!"); if ((rawSelector->name = of_strdup(name)) == NULL) OBJC_ERROR("Not enough memory to allocate selector!"); rawSelector->typeEncoding = NULL; if ((freeList = realloc(freeList, sizeof(void *) * (freeListCount + 2))) == NULL) OBJC_ERROR("Not enough memory to allocate selector!"); freeList[freeListCount++] = rawSelector; freeList[freeListCount++] = (char *)rawSelector->name; objc_register_selector(rawSelector); objc_global_mutex_unlock(); return (SEL)rawSelector; } void objc_register_all_selectors(struct objc_abi_symtab *symtab) { struct objc_abi_selector *rawSelector; if (symtab->selectorRefs == NULL) return; for (rawSelector = symtab->selectorRefs; rawSelector->name != NULL; rawSelector++) objc_register_selector(rawSelector); } const char * sel_getName(SEL selector) { const char *ret; |
︙ | ︙ |