]> git.saurik.com Git - apple/objc4.git/blobdiff - runtime/Protocol.mm
objc4-818.2.tar.gz
[apple/objc4.git] / runtime / Protocol.mm
index 137eac9b01b749bf37cc792937e81076285bbbf3..94322677ecb259638a86cda08c2bae63165c9291 100644 (file)
 #include <mach-o/ldsyms.h>
 
 #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
 {
     // 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;