diff --git a/Protocol2.m b/Protocol2.m new file mode 100644 index 0000000..8db46c3 --- /dev/null +++ b/Protocol2.m @@ -0,0 +1,36 @@ +#include "objc/runtime.h" +#include "protocol.h" +#include "class.h" +#include +#include + +@implementation Protocol2 ++ (void)load +{ + objc_clear_class_flag(self, objc_class_flag_plane_aware); +} +@end +@implementation Protocol ++ (void)load +{ + objc_clear_class_flag(self, objc_class_flag_plane_aware); +} +// FIXME: This needs removing, but it's included for now because GNUstep's +// implementation of +[NSObject conformsToProtocol:] calls it. +- (BOOL)conformsTo: (Protocol*)p +{ + return protocol_conformsToProtocol(self, p); +} +@end + +/** + * This class exists for the sole reason that the legacy GNU ABI did not + * provide a way of registering protocols with the runtime. With the new ABI, + * every protocol in a compilation unit that is not referenced should be added + * in a category on this class. This ensures that the runtime sees every + * protocol at least once and can perform uniquing. + */ +@interface __ObjC_Protocol_Holder_Ugly_Hack { id isa; } @end +@implementation __ObjC_Protocol_Holder_Ugly_Hack @end + +@implementation Object @end diff --git a/protocol.h b/protocol.h index d4b49ce..be1021f 100644 --- a/protocol.h +++ b/protocol.h @@ -15,20 +15,22 @@ struct objc_method_description_list struct objc_selector methods[1]; }; + +#ifdef __OBJC__ +@interface Object { id isa; } @end /** * Definition of the Protocol type. Protocols are objects, but are rarely used * as such. */ -#ifdef __OBJC__ -@interface Protocol +@interface Protocol : Object { @public #else struct objc_protocol { -#endif /** Class pointer. */ id isa; +#endif /** * The name of this protocol. Two protocols are regarded as identical if * they have the same name.