1 // See instructions in weak.h
5 #include <objc/objc-internal.h>
9 static void *noop_fn(void *self, SEL _cmd __unused) {
12 static id __unsafe_unretained retain_fn(id __unsafe_unretained self, SEL _cmd __unused) {
13 return _objc_rootRetain(self);
15 static void release_fn(id __unsafe_unretained self, SEL _cmd __unused) {
16 _objc_rootRelease(self);
18 static void autorelease_fn(id __unsafe_unretained self, SEL _cmd __unused) {
19 _objc_rootAutorelease(self);
24 @implementation MissingRoot
25 +(void) initialize { }
26 +(Class) class { return self; }
27 +(id) alloc { return _objc_rootAlloc(self); }
28 +(id) allocWithZone:(void*)zone { return _objc_rootAllocWithZone(self, (malloc_zone_t *)zone); }
29 -(id) init { return self; }
30 -(void) dealloc { _objc_rootDealloc(self); }
31 +(int) method { return 10; }
33 class_addMethod(self, sel_registerName("retain"), (IMP)retain_fn, "");
34 class_addMethod(self, sel_registerName("release"), (IMP)release_fn, "");
35 class_addMethod(self, sel_registerName("autorelease"), (IMP)autorelease_fn, "");
37 class_addMethod(object_getClass(self), sel_registerName("retain"), (IMP)noop_fn, "");
38 class_addMethod(object_getClass(self), sel_registerName("release"), (IMP)noop_fn, "");
39 class_addMethod(object_getClass(self), sel_registerName("autorelease"), (IMP)noop_fn, "");
45 @implementation MissingSuper
46 +(int) method { return 1+[super method]; }
47 -(id) init { self = [super init]; ivar = 100; return self; }
48 +(void) load { state++; }
53 @implementation NotMissingRoot
54 +(void) initialize { }
55 +(Class) class { return self; }
56 +(id) alloc { return _objc_rootAlloc(self); }
57 +(id) allocWithZone:(void*)zone { return _objc_rootAllocWithZone(self, (malloc_zone_t *)zone); }
58 -(id) init { return self; }
59 -(void) dealloc { _objc_rootDealloc(self); }
60 +(int) method { return 20; }
62 class_addMethod(self, sel_registerName("retain"), (IMP)retain_fn, "");
63 class_addMethod(self, sel_registerName("release"), (IMP)release_fn, "");
64 class_addMethod(self, sel_registerName("autorelease"), (IMP)autorelease_fn, "");
66 class_addMethod(object_getClass(self), sel_registerName("retain"), (IMP)noop_fn, "");
67 class_addMethod(object_getClass(self), sel_registerName("release"), (IMP)noop_fn, "");
68 class_addMethod(object_getClass(self), sel_registerName("autorelease"), (IMP)noop_fn, "");
74 @implementation NotMissingSuper
75 +(int) method { return 1+[super method]; }
76 -(id) init { self = [super init]; ivar = 200; return self; }
77 +(void) load { state++; }