5 // - that on launch we don't have NSCoding, NSSecureCoding, or NSDictionary, ie, libSystem doesn't contain those
6 // - that after dlopening CF, we get NSDictionary and it conforms to NSSecureCoding which conforms to NSCoding
7 // - that our NSCoding will be used if we ask either NSSecureCoding or NSDictionary if they conform to our test protocol
9 @protocol NewNSCodingSuperProto
12 @protocol NSCoding <NewNSCodingSuperProto>
17 // Before we dlopen, make sure we are using our NSCoding, not the shared cache version
18 Protocol* codingSuperProto = objc_getProtocol("NewNSCodingSuperProto");
19 Protocol* codingProto = objc_getProtocol("NSCoding");
20 if (@protocol(NewNSCodingSuperProto) != codingSuperProto) fail("Protocol mismatch");
21 if (@protocol(NSCoding) != codingProto) fail("Protocol mismatch");
22 if (!protocol_conformsToProtocol(codingProto, codingSuperProto)) fail("Our NSCoding should conform to NewNSCodingSuperProto");
24 // Also make sure we don't yet have an NSSecureCoding or NSDictionary
25 if (objc_getProtocol("NSSecureCoding")) fail("Test assumes we don't have NSSecureCoding yet");
26 if (objc_getClass("NSDictionary")) fail("Test assumes we don't have NSDictionary yet");
28 void *dl = dlopen("/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation", RTLD_LAZY);
29 if (!dl) fail("couldn't open CoreFoundation");
31 // We should now have NSSecureCoding and NSDictionary
32 Protocol* secureCodingProto = objc_getProtocol("NSSecureCoding");
33 id dictionaryClass = objc_getClass("NSDictionary");
34 if (!secureCodingProto) fail("Should have got NSSecureCoding from CoreFoundation");
35 if (!dictionaryClass) fail("Should have got NSDictionary from CoreFoundation");
37 // Now make sure that NSDictionary and NSSecureCoding find our new protocols
38 if (!protocol_conformsToProtocol(secureCodingProto, codingProto)) fail("NSSecureCoding should conform to our NSCoding");
39 if (!protocol_conformsToProtocol(secureCodingProto, codingSuperProto)) fail("NSSecureCoding should conform to our NewNSCodingSuperProto");
40 if (!class_conformsToProtocol(dictionaryClass, codingProto)) fail("NSDictionary should conform to our NSCoding");
41 if (!class_conformsToProtocol(dictionaryClass, codingSuperProto)) fail("NSDictionary should conform to our NewNSCodingSuperProto");