Differences From Artifact [99b2d0f965]:
- File
src/runtime/selector.m
— part of check-in
[79fe29dbf4]
at
2019-06-17 00:38:44
on branch trunk
— Remove underscores from library & framework names
This is more compatible with the various conventions used on various
systems. (user: js, size: 3651) [annotate] [blame] [check-ins using]
To Artifact [b2795ffb4b]:
- File src/runtime/selector.m — part of check-in [c6d2de4312] at 2019-11-24 22:23:10 on branch trunk — runtime: Remove duplicate structs for ABI (user: js, size: 3530) [annotate] [blame] [check-ins using] [more...]
︙ | ︙ | |||
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 | 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_selector *selector) { SEL existingSelector; 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 ((existingSelector = objc_hashtable_get(selectors, (const char *)selector->UID)) != NULL) { selector->UID = existingSelector->UID; return; } if (selectorNames == NULL) selectorNames = objc_sparsearray_new(SEL_SIZE); name = (const char *)selector->UID; 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_selector *selector; objc_global_mutex_lock(); if (selectors != NULL && (selector = objc_hashtable_get(selectors, name)) != NULL) { objc_global_mutex_unlock(); return (SEL)selector; } if ((selector = malloc(sizeof(*selector))) == NULL) OBJC_ERROR("Not enough memory to allocate selector!"); if ((selector->UID = (uintptr_t)of_strdup(name)) == 0) OBJC_ERROR("Not enough memory to allocate selector!"); selector->typeEncoding = NULL; if ((freeList = realloc(freeList, sizeof(void *) * (freeListCount + 2))) == NULL) OBJC_ERROR("Not enough memory to allocate selector!"); freeList[freeListCount++] = selector; freeList[freeListCount++] = (char *)selector->UID; objc_register_selector(selector); objc_global_mutex_unlock(); return (SEL)selector; } void objc_register_all_selectors(struct objc_symtab *symtab) { struct objc_selector *selector; if (symtab->selectorRefs == NULL) return; for (selector = symtab->selectorRefs; selector->UID != 0; selector++) objc_register_selector(selector); } const char * sel_getName(SEL selector) { const char *ret; |
︙ | ︙ |