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
72 @interface NoScanned { long i; } @end
73 @implementation NoScanned @end
77 const uint8_t *layout;
79 layout = class_getIvarLayout(objc_getClass("AllScanned"));
80 printlayout("AllScanned", layout);
81 layout = class_getWeakIvarLayout(objc_getClass("AllScanned"));
82 printlayout("AllScanned weak", layout);
83 // testassert(0 == strcmp(layout, "\x0a"));
85 layout = class_getIvarLayout(objc_getClass("AllWeak"));
86 printlayout("AllWeak", layout);
87 layout = class_getWeakIvarLayout(objc_getClass("AllWeak"));
88 printlayout("AllWeak weak", layout);
89 // testassert(0 == strcmp(layout, ""));
91 layout = class_getIvarLayout(objc_getClass("NoScanned"));
92 printlayout("NoScanned", layout);
93 // testassert(0 == strcmp(layout, ""));