X-Git-Url: https://git.saurik.com/apple/objc4.git/blobdiff_plain/7257e56cc9570231fcb1a302702a85f51f9a9790..refs/heads/master:/runtime/Protocol.mm diff --git a/runtime/Protocol.mm b/runtime/Protocol.mm index 137eac9..9432267 100644 --- a/runtime/Protocol.mm +++ b/runtime/Protocol.mm @@ -36,22 +36,29 @@ #include #include "Protocol.h" +#include "NSObject.h" -#if __OBJC2__ -@interface __IncompleteProtocol : NSObject @end -@implementation __IncompleteProtocol -// fixme hack - make __IncompleteProtocol a non-lazy class -+ (void) load { } +// __IncompleteProtocol is used as the return type of objc_allocateProtocol(). + +// Old ABI uses NSObject as the superclass even though Protocol uses Object +// because the R/R implementation for class Protocol is added at runtime +// by CF, so __IncompleteProtocol would be left without an R/R implementation +// otherwise, which would break ARC. + +@interface __IncompleteProtocol : NSObject @end + +#if __OBJC2__ +__attribute__((objc_nonlazy_class)) #endif +@implementation __IncompleteProtocol +@end -@implementation Protocol #if __OBJC2__ -// fixme hack - make Protocol a non-lazy class -+ (void) load { } +__attribute__((objc_nonlazy_class)) #endif - +@implementation Protocol - (BOOL) conformsTo: (Protocol *)aProtocolObj { @@ -93,7 +100,7 @@ // check isKindOf: Class cls; Class protoClass = objc_getClass("Protocol"); - for (cls = object_getClass(other); cls; cls = cls->superclass) { + for (cls = object_getClass(other); cls; cls = cls->getSuperclass()) { if (cls == protoClass) break; } if (!cls) return NO;