-
Notifications
You must be signed in to change notification settings - Fork 119
/
builtin_classes.c
106 lines (97 loc) · 3.3 KB
/
builtin_classes.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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
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
#include "protocol.h"
#include "class.h"
#include "method.h"
#include "loader.h"
OBJC_PUBLIC struct objc_class _OBJC_CLASS_Object;
static struct objc_class _OBJC_METACLASS_Object = {
.isa = NULL,
.name = "Object",
.info = objc_class_flag_meta,
};
OBJC_PUBLIC struct objc_class _OBJC_CLASS_Object = {
.isa = &_OBJC_METACLASS_Object,
.super_class = NULL,
.name = "Object",
};
static struct objc_class _OBJC_METACLASS_Protocol = {
.isa = &_OBJC_METACLASS_Object,
.super_class = &_OBJC_METACLASS_Object,
.name = "Protocol",
.info = objc_class_flag_meta,
};
static struct objc_class _OBJC_METACLASS_ProtocolGCC = {
.isa = &_OBJC_METACLASS_Object,
.super_class = &_OBJC_METACLASS_Object,
.name = "ProtocolGCC",
.info = objc_class_flag_meta,
};
static struct objc_class _OBJC_METACLASS_ProtocolGSv1 = {
.isa = &_OBJC_METACLASS_Object,
.super_class = &_OBJC_METACLASS_Object,
.name = "ProtocolGSv2",
.info = objc_class_flag_meta,
};
static struct objc_class _OBJC_METACLASS___IncompleteProtocol = {
.isa = &_OBJC_METACLASS_Object,
.super_class = &_OBJC_METACLASS_Object,
.name = "ProtocolGCC",
.info = objc_class_flag_meta,
};
OBJC_PUBLIC struct objc_class _OBJC_CLASS_Protocol = {
.isa = &_OBJC_METACLASS_Protocol,
.super_class = &_OBJC_CLASS_Object,
.name = "Protocol",
.info = objc_class_flag_permanent_instances,
};
OBJC_PUBLIC struct objc_class _OBJC_CLASS_ProtocolGCC = {
.isa = &_OBJC_METACLASS_ProtocolGCC,
.super_class = &_OBJC_CLASS_Protocol,
.name = "ProtocolGCC",
.info = objc_class_flag_permanent_instances,
};
OBJC_PUBLIC struct objc_class _OBJC_CLASS___IncompleteProtocol = {
.isa = &_OBJC_METACLASS_Protocol,
.super_class = &_OBJC_CLASS_Protocol,
.name = "__IncompleteProtocol",
.info = objc_class_flag_permanent_instances,
};
OBJC_PUBLIC struct objc_class _OBJC_CLASS_ProtocolGSv1 = {
.isa = &_OBJC_METACLASS_Protocol,
.super_class = &_OBJC_CLASS_Protocol,
.name = "ProtocolGSv1",
.info = objc_class_flag_permanent_instances,
};
#ifdef OLDABI_COMPAT
static struct objc_class _OBJC_METACLASS___ObjC_Protocol_Holder_Ugly_Hack = {
.isa = NULL,
.name = "__ObjC_Protocol_Holder_Ugly_Hack",
.info = objc_class_flag_meta,
};
OBJC_PUBLIC struct objc_class _OBJC_CLASS__ObjC_Protocol_Holder_Ugly_Hack = {
.isa = &_OBJC_METACLASS___ObjC_Protocol_Holder_Ugly_Hack,
.super_class = NULL,
.name = "__ObjC_Protocol_Holder_Ugly_Hack",
};
#endif
PRIVATE void init_builtin_classes(void)
{
// Load the classes that are compiled into the runtime.
objc_load_class(&_OBJC_CLASS_Object);
objc_load_class(&_OBJC_CLASS_Protocol);
objc_load_class(&_OBJC_CLASS_ProtocolGCC);
objc_load_class(&_OBJC_CLASS_ProtocolGSv1);
objc_load_class(&_OBJC_CLASS___IncompleteProtocol);
objc_resolve_class(&_OBJC_CLASS_Object);
objc_resolve_class(&_OBJC_CLASS_Protocol);
objc_resolve_class(&_OBJC_CLASS_ProtocolGCC);
objc_resolve_class(&_OBJC_CLASS_ProtocolGSv1);
objc_resolve_class(&_OBJC_CLASS___IncompleteProtocol);
// Fix up the sizes of the various protocol classes that we will use.
_OBJC_CLASS_Object.instance_size = sizeof(void*);
_OBJC_CLASS_Protocol.instance_size = sizeof(struct objc_protocol);
_OBJC_CLASS___IncompleteProtocol.instance_size = sizeof(struct objc_protocol);
#ifdef OLDABI_COMPAT
objc_load_class(&_OBJC_CLASS__ObjC_Protocol_Holder_Ugly_Hack);
objc_resolve_class(&_OBJC_CLASS__ObjC_Protocol_Holder_Ugly_Hack);
#endif
}