1 // TEST_CONFIG MEM=gc SDK=macos
5 #include <objc/objc-runtime.h>
9 void printlayout(const char *name, const uint8_t *layout)
11 testprintf("%s: ", name);
19 for (c = layout; *c; c++) {
20 testprintf("%02x ", *c);
27 @interface Super { id isa; } @end
28 @implementation Super @end
31 // strong: 0c 00 (0a00 without structs)
33 @interface AllScanned : Super {
37 __strong intptr_t *i1;
48 @implementation AllScanned @end
51 // weak: 1b 00 (18 00 without structs)
52 @interface AllWeak : Super {
67 @implementation AllWeak @end
71 @interface NoScanned { long i; } @end
72 @implementation NoScanned @end
76 const uint8_t *layout;
78 layout = class_getIvarLayout(objc_getClass("AllScanned"));
79 printlayout("AllScanned", layout);
80 layout = class_getWeakIvarLayout(objc_getClass("AllScanned"));
81 printlayout("AllScanned weak", layout);
82 // testassert(0 == strcmp(layout, "\x0a"));
84 layout = class_getIvarLayout(objc_getClass("AllWeak"));
85 printlayout("AllWeak", layout);
86 layout = class_getWeakIvarLayout(objc_getClass("AllWeak"));
87 printlayout("AllWeak weak", layout);
88 // testassert(0 == strcmp(layout, ""));
90 layout = class_getIvarLayout(objc_getClass("NoScanned"));
91 printlayout("NoScanned", layout);
92 // testassert(0 == strcmp(layout, ""));