5 #include <objc/runtime.h>
8 @interface Super { id isa; } @end
11 +class { return self; }
12 +new { return class_createInstance(self, 0); }
13 -(void)dealloc { object_dispose(self); }
16 @interface Sub1 : Super {
22 @implementation Sub1 @end
24 @interface Sub2 : Sub1 {
25 // id isa // 0..4 0..8
26 // BOOL b // 4..5 8..9
27 BOOL b2; // 5..6 9..10
31 @implementation Sub2 @end
33 @interface Sub3 : Sub1 {
34 // id isa; // 0..4 0..8
35 // BOOL b; // 4..5 8..9
37 BOOL b2; // 12..13 24..25
40 @implementation Sub3 @end
44 testassert(sizeof(id) == class_getInstanceSize([Super class]));
45 testassert(2*sizeof(id) == class_getInstanceSize([Sub1 class]));
46 testassert(3*sizeof(id) == class_getInstanceSize([Sub2 class]));
47 testassert(4*sizeof(id) == class_getInstanceSize([Sub3 class]));
52 testassert(object_getIndexedIvars(o) == (char *)o + class_getInstanceSize(o->isa));
55 testassert(object_getIndexedIvars(o) == (char *)o + class_getInstanceSize(o->isa));
58 testassert(object_getIndexedIvars(o) == (char *)o + class_getInstanceSize(o->isa));
61 testassert(object_getIndexedIvars(o) == (char *)o + class_getInstanceSize(o->isa));