3 #include <objc/objc-runtime.h>
7 void printlayout(const char *name, const char *layout)
9 testprintf("%s: ", name);
17 for (c = layout; *c; c++) {
18 testprintf("%02x ", *c);
25 @interface Super { id isa; } @end
26 @implementation Super @end
29 // strong: 0c 00 (0a00 without structs)
31 @interface AllScanned : Super {
46 @implementation AllScanned @end
49 // weak: 1b 00 (18 00 without structs)
50 @interface AllWeak : Super {
65 @implementation AllWeak @end
69 @interface NoScanned { long i; } @end
70 @implementation NoScanned @end
76 layout = class_getIvarLayout(objc_getClass("AllScanned"));
77 printlayout("AllScanned", layout);
78 layout = class_getWeakIvarLayout(objc_getClass("AllScanned"));
79 printlayout("AllScanned weak", layout);
80 // testassert(0 == strcmp(layout, "\x0a"));
82 layout = class_getIvarLayout(objc_getClass("AllWeak"));
83 printlayout("AllWeak", layout);
84 layout = class_getWeakIvarLayout(objc_getClass("AllWeak"));
85 printlayout("AllWeak weak", layout);
86 // testassert(0 == strcmp(layout, ""));
88 layout = class_getIvarLayout(objc_getClass("NoScanned"));
89 printlayout("NoScanned", layout);
90 // testassert(0 == strcmp(layout, ""));