︙ | | | ︙ | |
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
static Class *loadQueue = NULL;
static size_t loadQueueCount = 0;
static struct objc_dtable *emptyDTable = NULL;
static unsigned lookupsUntilFastPath = 128;
static struct objc_sparsearray *fastPath = NULL;
static void
registerClass(struct objc_abi_class *rawClass)
{
if (classes == NULL)
classes = objc_hashtable_new(
objc_hash_string, objc_equal_string, 2);
objc_hashtable_set(classes, rawClass->name, rawClass);
if (emptyDTable == NULL)
emptyDTable = objc_dtable_new();
rawClass->DTable = emptyDTable;
rawClass->metaclass->DTable = emptyDTable;
if (strcmp(rawClass->name, "Protocol") != 0)
classesCount++;
}
bool
class_registerAlias_np(Class class, const char *name)
{
objc_global_mutex_lock();
|
|
|
|
|
|
|
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
static Class *loadQueue = NULL;
static size_t loadQueueCount = 0;
static struct objc_dtable *emptyDTable = NULL;
static unsigned lookupsUntilFastPath = 128;
static struct objc_sparsearray *fastPath = NULL;
static void
registerClass(Class class)
{
if (classes == NULL)
classes = objc_hashtable_new(
objc_hash_string, objc_equal_string, 2);
objc_hashtable_set(classes, class->name, class);
if (emptyDTable == NULL)
emptyDTable = objc_dtable_new();
class->DTable = emptyDTable;
class->isa->DTable = emptyDTable;
if (strcmp(class->name, "Protocol") != 0)
classesCount++;
}
bool
class_registerAlias_np(Class class, const char *name)
{
objc_global_mutex_lock();
|
︙ | | | ︙ | |
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
objc_global_mutex_unlock();
return YES;
}
static void
registerSelectors(struct objc_abi_class *rawClass)
{
struct objc_abi_method_list *methodList;
for (methodList = rawClass->methodList; methodList != NULL;
methodList = methodList->next)
for (unsigned int i = 0; i < methodList->count; i++)
objc_register_selector((struct objc_abi_selector *)
&methodList->methods[i]);
}
Class
objc_classname_to_class(const char *name, bool cache)
{
Class class;
|
|
|
>
|
<
|
|
<
|
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
objc_global_mutex_unlock();
return YES;
}
static void
registerSelectors(Class class)
{
struct objc_method_list *iter;
unsigned int i;
for (iter = class->methodList; iter != NULL; iter = iter->next)
for (i = 0; i < iter->count; i++)
objc_register_selector(&iter->methods[i].selector);
}
Class
objc_classname_to_class(const char *name, bool cache)
{
Class class;
|
︙ | | | ︙ | |
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
|
setupClass(Class class)
{
const char *superclassName;
if (class->info & OBJC_CLASS_INFO_SETUP)
return;
superclassName = ((struct objc_abi_class *)class)->superclass;
if (superclassName != NULL) {
Class super = objc_classname_to_class(superclassName, false);
if (super == Nil)
return;
setupClass(super);
|
|
|
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
|
setupClass(Class class)
{
const char *superclassName;
if (class->info & OBJC_CLASS_INFO_SETUP)
return;
superclassName = (const char *)class->superclass;
if (superclassName != NULL) {
Class super = objc_classname_to_class(superclassName, false);
if (super == Nil)
return;
setupClass(super);
|
︙ | | | ︙ | |
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
|
if (loadQueue == NULL)
OBJC_ERROR("Not enough memory for load queue!");
}
}
}
void
objc_register_all_classes(struct objc_abi_symtab *symtab)
{
for (uint16_t i = 0; i < symtab->classDefsCount; i++) {
struct objc_abi_class *rawClass =
(struct objc_abi_class *)symtab->defs[i];
registerClass(rawClass);
registerSelectors(rawClass);
registerSelectors(rawClass->metaclass);
}
for (uint16_t i = 0; i < symtab->classDefsCount; i++) {
Class class = (Class)symtab->defs[i];
if (hasLoad(class)) {
setupClass(class);
|
|
<
|
|
|
|
|
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
|
if (loadQueue == NULL)
OBJC_ERROR("Not enough memory for load queue!");
}
}
}
void
objc_register_all_classes(struct objc_symtab *symtab)
{
for (uint16_t i = 0; i < symtab->classDefsCount; i++) {
Class class = (Class)symtab->defs[i];
registerClass(class);
registerSelectors(class);
registerSelectors(class->isa);
}
for (uint16_t i = 0; i < symtab->classDefsCount; i++) {
Class class = (Class)symtab->defs[i];
if (hasLoad(class)) {
setupClass(class);
|
︙ | | | ︙ | |
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
|
}
void
objc_registerClassPair(Class class)
{
objc_global_mutex_lock();
registerClass((struct objc_abi_class *)class);
if (class->superclass != Nil) {
addSubclass(class);
addSubclass(class->isa);
}
class->info |= OBJC_CLASS_INFO_SETUP;
|
|
|
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
|
}
void
objc_registerClassPair(Class class)
{
objc_global_mutex_lock();
registerClass(class);
if (class->superclass != Nil) {
addSubclass(class);
addSubclass(class->isa);
}
class->info |= OBJC_CLASS_INFO_SETUP;
|
︙ | | | ︙ | |
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
|
{
return class_getName(object_getClass(object));
}
static void
unregisterClass(Class class)
{
struct objc_abi_class *rawClass = (struct objc_abi_class *)class;
if ((class->info & OBJC_CLASS_INFO_SETUP) && class->superclass != Nil &&
class->superclass->subclassList != NULL) {
size_t i = SIZE_MAX, count = 0;
Class *tmp;
for (tmp = class->superclass->subclassList;
*tmp != Nil; tmp++) {
|
<
<
|
859
860
861
862
863
864
865
866
867
868
869
870
871
872
|
{
return class_getName(object_getClass(object));
}
static void
unregisterClass(Class class)
{
if ((class->info & OBJC_CLASS_INFO_SETUP) && class->superclass != Nil &&
class->superclass->subclassList != NULL) {
size_t i = SIZE_MAX, count = 0;
Class *tmp;
for (tmp = class->superclass->subclassList;
*tmp != Nil; tmp++) {
|
︙ | | | ︙ | |
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
|
if (class->DTable != NULL && class->DTable != emptyDTable)
objc_dtable_free(class->DTable);
class->DTable = NULL;
if ((class->info & OBJC_CLASS_INFO_SETUP) && class->superclass != Nil)
rawClass->superclass = class->superclass->name;
class->info &= ~OBJC_CLASS_INFO_SETUP;
}
void
objc_unregister_class(Class class)
{
|
|
|
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
|
if (class->DTable != NULL && class->DTable != emptyDTable)
objc_dtable_free(class->DTable);
class->DTable = NULL;
if ((class->info & OBJC_CLASS_INFO_SETUP) && class->superclass != Nil)
class->superclass = (Class)class->superclass->name;
class->info &= ~OBJC_CLASS_INFO_SETUP;
}
void
objc_unregister_class(Class class)
{
|
︙ | | | ︙ | |