|
| 1 | +#include "protocol.h" |
| 2 | +#include "class.h" |
| 3 | +#include "method.h" |
| 4 | +#include "loader.h" |
| 5 | + |
| 6 | +OBJC_PUBLIC struct objc_class _OBJC_CLASS_Object; |
| 7 | + |
| 8 | +static struct objc_class _OBJC_METACLASS_Object = { |
| 9 | + .isa = NULL, |
| 10 | + .name = "Object", |
| 11 | + .info = objc_class_flag_meta, |
| 12 | +}; |
| 13 | +OBJC_PUBLIC struct objc_class _OBJC_CLASS_Object = { |
| 14 | + .isa = &_OBJC_METACLASS_Object, |
| 15 | + .super_class = NULL, |
| 16 | + .name = "Object", |
| 17 | +}; |
| 18 | + |
| 19 | +static struct objc_class _OBJC_METACLASS_Protocol = { |
| 20 | + .isa = &_OBJC_METACLASS_Object, |
| 21 | + .super_class = &_OBJC_METACLASS_Object, |
| 22 | + .name = "Protocol", |
| 23 | + .info = objc_class_flag_meta, |
| 24 | +}; |
| 25 | +static struct objc_class _OBJC_METACLASS_ProtocolGCC = { |
| 26 | + .isa = &_OBJC_METACLASS_Object, |
| 27 | + .super_class = &_OBJC_METACLASS_Object, |
| 28 | + .name = "ProtocolGCC", |
| 29 | + .info = objc_class_flag_meta, |
| 30 | +}; |
| 31 | +static struct objc_class _OBJC_METACLASS_ProtocolGSv1 = { |
| 32 | + .isa = &_OBJC_METACLASS_Object, |
| 33 | + .super_class = &_OBJC_METACLASS_Object, |
| 34 | + .name = "ProtocolGSv2", |
| 35 | + .info = objc_class_flag_meta, |
| 36 | +}; |
| 37 | +static struct objc_class _OBJC_METACLASS___IncompleteProtocol = { |
| 38 | + .isa = &_OBJC_METACLASS_Object, |
| 39 | + .super_class = &_OBJC_METACLASS_Object, |
| 40 | + .name = "ProtocolGCC", |
| 41 | + .info = objc_class_flag_meta, |
| 42 | +}; |
| 43 | + |
| 44 | +OBJC_PUBLIC struct objc_class _OBJC_CLASS_Protocol = { |
| 45 | + .isa = &_OBJC_METACLASS_Protocol, |
| 46 | + .super_class = &_OBJC_CLASS_Object, |
| 47 | + .name = "Protocol", |
| 48 | + .info = objc_class_flag_permanent_instances, |
| 49 | +}; |
| 50 | + |
| 51 | +OBJC_PUBLIC struct objc_class _OBJC_CLASS_ProtocolGCC = { |
| 52 | + .isa = &_OBJC_METACLASS_ProtocolGCC, |
| 53 | + .super_class = &_OBJC_CLASS_Protocol, |
| 54 | + .name = "ProtocolGCC", |
| 55 | + .info = objc_class_flag_permanent_instances, |
| 56 | +}; |
| 57 | + |
| 58 | +OBJC_PUBLIC struct objc_class _OBJC_CLASS___IncompleteProtocol = { |
| 59 | + .isa = &_OBJC_METACLASS_Protocol, |
| 60 | + .super_class = &_OBJC_CLASS_Protocol, |
| 61 | + .name = "__IncompleteProtocol", |
| 62 | + .info = objc_class_flag_permanent_instances, |
| 63 | +}; |
| 64 | + |
| 65 | +OBJC_PUBLIC struct objc_class _OBJC_CLASS_ProtocolGSv1 = { |
| 66 | + .isa = &_OBJC_METACLASS_Protocol, |
| 67 | + .super_class = &_OBJC_CLASS_Protocol, |
| 68 | + .name = "ProtocolGSv1", |
| 69 | + .info = objc_class_flag_permanent_instances, |
| 70 | +}; |
| 71 | + |
| 72 | +#ifdef OLDABI_COMPAT |
| 73 | +static struct objc_class _OBJC_METACLASS___ObjC_Protocol_Holder_Ugly_Hack = { |
| 74 | + .isa = NULL, |
| 75 | + .name = "__ObjC_Protocol_Holder_Ugly_Hack", |
| 76 | + .info = objc_class_flag_meta, |
| 77 | +}; |
| 78 | +OBJC_PUBLIC struct objc_class _OBJC_CLASS__ObjC_Protocol_Holder_Ugly_Hack = { |
| 79 | + .isa = &_OBJC_METACLASS___ObjC_Protocol_Holder_Ugly_Hack, |
| 80 | + .super_class = NULL, |
| 81 | + .name = "__ObjC_Protocol_Holder_Ugly_Hack", |
| 82 | +}; |
| 83 | +#endif |
| 84 | + |
| 85 | +PRIVATE void init_builtin_classes(void) |
| 86 | +{ |
| 87 | + // Load the classes that are compiled into the runtime. |
| 88 | + objc_load_class(&_OBJC_CLASS_Object); |
| 89 | + objc_load_class(&_OBJC_CLASS_Protocol); |
| 90 | + objc_load_class(&_OBJC_CLASS_ProtocolGCC); |
| 91 | + objc_load_class(&_OBJC_CLASS_ProtocolGSv1); |
| 92 | + objc_load_class(&_OBJC_CLASS___IncompleteProtocol); |
| 93 | + objc_resolve_class(&_OBJC_CLASS_Object); |
| 94 | + objc_resolve_class(&_OBJC_CLASS_Protocol); |
| 95 | + objc_resolve_class(&_OBJC_CLASS_ProtocolGCC); |
| 96 | + objc_resolve_class(&_OBJC_CLASS_ProtocolGSv1); |
| 97 | + objc_resolve_class(&_OBJC_CLASS___IncompleteProtocol); |
| 98 | + // Fix up the sizes of the various protocol classes that we will use. |
| 99 | + _OBJC_CLASS_Object.instance_size = sizeof(void*); |
| 100 | + _OBJC_CLASS_Protocol.instance_size = sizeof(struct objc_protocol); |
| 101 | + _OBJC_CLASS___IncompleteProtocol.instance_size = sizeof(struct objc_protocol); |
| 102 | +#ifdef OLDABI_COMPAT |
| 103 | + objc_load_class(&_OBJC_CLASS__ObjC_Protocol_Holder_Ugly_Hack); |
| 104 | + objc_resolve_class(&_OBJC_CLASS__ObjC_Protocol_Holder_Ugly_Hack); |
| 105 | +#endif |
| 106 | +} |
0 commit comments