diff --git a/Protocol2.m b/Protocol2.m index 154403ba..61ef6ba8 100644 --- a/Protocol2.m +++ b/Protocol2.m @@ -22,24 +22,12 @@ - (id)self { return self; } @interface __IncompleteProtocol : Protocol @end @implementation __IncompleteProtocol @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 -@implementation ProtocolGCC @end @implementation ProtocolGSv1 @end PRIVATE void link_protocol_classes(void) { [Protocol class]; - [ProtocolGCC class]; [ProtocolGSv1 class]; } diff --git a/abi_version.c b/abi_version.c index cfddfe0e..75c09ff7 100644 --- a/abi_version.c +++ b/abi_version.c @@ -32,7 +32,6 @@ struct objc_abi_version enum { - gcc_abi = 8, gnustep_abi = 9, gc_abi = 10 }; @@ -42,12 +41,10 @@ enum */ static struct objc_abi_version known_abis[] = { - /* GCC ABI. */ - {gcc_abi, gcc_abi, gnustep_abi, sizeof(struct objc_module_abi_8)}, /* Non-fragile ABI. */ - {gnustep_abi, gcc_abi, gc_abi, sizeof(struct objc_module_abi_8)}, + {gnustep_abi, gnustep_abi, gc_abi, sizeof(struct objc_module_abi_8)}, /* GC ABI. Adds a field describing the GC mode. */ - {gc_abi, gcc_abi, gc_abi, sizeof(struct objc_module_abi_10)} + {gc_abi, gnustep_abi, gc_abi, sizeof(struct objc_module_abi_10)} }; static int known_abi_count = diff --git a/category.h b/category.h index 4a3b685c..c228d05a 100644 --- a/category.h +++ b/category.h @@ -37,26 +37,26 @@ struct objc_category struct objc_property_list *class_properties; }; -struct objc_category_gcc +struct objc_category_gsv1 { - /** - * The name of this category. - */ - const char *name; - /** - * The name of the class to which this category should be applied. - */ - const char *class_name; - /** - * The list of instance methods to add to the class. - */ - struct objc_method_list_gcc *instance_methods; - /** - * The list of class methods to add to the class. - */ - struct objc_method_list_gcc *class_methods; - /** - * The list of protocols adopted by this category. - */ - struct objc_protocol_list *protocols; + /** + * The name of this category. + */ + const char *name; + /** + * The name of the class to which this category should be applied. + */ + const char *class_name; + /** + * The list of instance methods to add to the class. + */ + struct objc_method_list_gsv1 *instance_methods; + /** + * The list of class methods to add to the class. + */ + struct objc_method_list_gsv1 *class_methods; + /** + * The list of protocols adopted by this category. + */ + struct objc_protocol_list *protocols; }; diff --git a/class.h b/class.h index 0910d0b7..a22e3f1f 100644 --- a/class.h +++ b/class.h @@ -184,12 +184,12 @@ struct objc_class_gsv1 /** * Metadata describing the instance variables in this class. */ - struct objc_ivar_list_gcc *ivars; + struct objc_ivar_list_gsv1 *ivars; /** * Metadata for for defining the mappings from selectors to IMPs. Linked * list of method list structures, one per class and one per category. */ - struct objc_method_list_gcc *methods; + struct objc_method_list_gsv1 *methods; /** * The dispatch table for this class. Intialized and maintained by the * runtime. @@ -274,29 +274,6 @@ struct objc_class_gsv1 uintptr_t weak_pointers; }; -/** - * Structure representing the GCC ABI class structure. This is only ever - * required so that we can take its size - struct objc_class begins with the - * same fields, and you can test the new abi flag to tell whether it is safe to - * access the subsequent fields. - */ -struct objc_class_gcc -{ - Class isa; - Class super_class; - const char *name; - long version; - unsigned long info; - long instance_size; - struct objc_ivar_list_gcc *ivars; - struct objc_method_list *methods; - void *dtable; - Class subclass_list; - Class sibling_class; - struct objc_protocol_list *protocols; - void *gc_object_type; -}; - /** * An enumerated type describing all of the valid flags that may be used in the diff --git a/ivar.h b/ivar.h index 67abd0c4..1637cca0 100644 --- a/ivar.h +++ b/ivar.h @@ -125,7 +125,7 @@ static inline objc_ivar_ownership ivarGetOwnership(Ivar ivar) /** * Legacy ivar structure, inherited from the GCC ABI. */ -struct objc_ivar_gcc +struct objc_ivar_gsv1 { /** * Name of this instance variable. @@ -189,7 +189,7 @@ static inline struct objc_ivar *ivar_at_index(struct objc_ivar_list *l, int i) /** * Legacy version of the ivar list */ -struct objc_ivar_list_gcc +struct objc_ivar_list_gsv1 { /** * The number of instance variables in this list. @@ -199,6 +199,6 @@ struct objc_ivar_list_gcc * An array of instance variable metadata structures. Note that this array * has count elements. */ - struct objc_ivar_gcc ivar_list[]; + struct objc_ivar_gsv1 ivar_list[]; }; diff --git a/legacy.c b/legacy.c index 51ae17b3..19eaee8d 100644 --- a/legacy.c +++ b/legacy.c @@ -66,7 +66,7 @@ static objc_ivar_ownership ownershipForIvar(struct objc_class_gsv1 *cls, int idx static struct objc_ivar_list *upgradeIvarList(struct objc_class_gsv1 *cls) { - struct objc_ivar_list_gcc *l = cls->ivars; + struct objc_ivar_list_gsv1 *l = cls->ivars; if (l == NULL) { return NULL; @@ -135,7 +135,7 @@ static struct objc_ivar_list *upgradeIvarList(struct objc_class_gsv1 *cls) return n; } -static struct objc_method_list *upgradeMethodList(struct objc_method_list_gcc *old) +static struct objc_method_list *upgradeMethodList(struct objc_method_list_gsv1 *old) { if (old == NULL) { @@ -367,10 +367,11 @@ PRIVATE Class objc_upgrade_class(struct objc_class_gsv1 *oldClass) } return cls; } -PRIVATE struct objc_category *objc_upgrade_category(struct objc_category_gcc *old) + +PRIVATE struct objc_category *objc_upgrade_category(struct objc_category_gsv1 *old) { struct objc_category *cat = calloc(1, sizeof(struct objc_category)); - memcpy(cat, old, sizeof(struct objc_category_gcc)); + memcpy(cat, old, sizeof(struct objc_category_gsv1)); cat->instance_methods = upgradeMethodList(old->instance_methods); cat->class_methods = upgradeMethodList(old->class_methods); if (cat->instance_methods != NULL) @@ -389,7 +390,7 @@ PRIVATE struct objc_category *objc_upgrade_category(struct objc_category_gcc *ol } static struct objc_protocol_method_description_list* -upgrade_protocol_method_list_gcc(struct objc_protocol_method_description_list_gcc *l) +upgrade_protocol_method_list_gsv1(struct objc_protocol_method_description_list_gsv1 *l) { if ((l == NULL) || (l->count == 0)) { @@ -408,27 +409,6 @@ upgrade_protocol_method_list_gcc(struct objc_protocol_method_description_list_gc return n; } -PRIVATE struct objc_protocol *objc_upgrade_protocol_gcc(struct objc_protocol_gcc *p) -{ - // If the protocol has already been upgraded, the don't try to upgrade it twice. - if (p->isa == objc_getClass("ProtocolGCC")) - { - return objc_getProtocol(p->name); - } - p->isa = objc_getClass("ProtocolGCC"); - Protocol *proto = - (Protocol*)class_createInstance((Class)objc_getClass("Protocol"), - sizeof(struct objc_protocol) - sizeof(id)); - proto->name = p->name; - // Aliasing of this between the new and old structures means that when this - // returns these will all be updated. - proto->protocol_list = p->protocol_list; - proto->instance_methods = upgrade_protocol_method_list_gcc(p->instance_methods); - proto->class_methods = upgrade_protocol_method_list_gcc(p->class_methods); - assert(proto->isa); - return proto; -} - PRIVATE struct objc_protocol *objc_upgrade_protocol_gsv1(struct objc_protocol_gsv1 *p) { // If the protocol has already been upgraded, the don't try to upgrade it twice. @@ -439,19 +419,19 @@ PRIVATE struct objc_protocol *objc_upgrade_protocol_gsv1(struct objc_protocol_gs Protocol *n = (Protocol*)class_createInstance((Class)objc_getClass("Protocol"), sizeof(struct objc_protocol) - sizeof(id)); - n->instance_methods = upgrade_protocol_method_list_gcc(p->instance_methods); + n->instance_methods = upgrade_protocol_method_list_gsv1(p->instance_methods); // Aliasing of this between the new and old structures means that when this // returns these will all be updated. n->name = p->name; n->protocol_list = p->protocol_list; - n->class_methods = upgrade_protocol_method_list_gcc(p->class_methods); + n->class_methods = upgrade_protocol_method_list_gsv1(p->class_methods); n->properties = upgradePropertyList(p->properties); n->optional_properties = upgradePropertyList(p->optional_properties); n->isa = objc_getClass("Protocol"); // We do in-place upgrading of these, because they might be referenced // directly - p->instance_methods = (struct objc_protocol_method_description_list_gcc*)n->instance_methods; - p->class_methods = (struct objc_protocol_method_description_list_gcc*)n->class_methods; + p->instance_methods = (struct objc_protocol_method_description_list_gsv1*)n->instance_methods; + p->class_methods = (struct objc_protocol_method_description_list_gsv1*)n->class_methods; p->properties = (struct objc_property_list_gsv1*)n->properties; p->optional_properties = (struct objc_property_list_gsv1*)n->optional_properties; p->isa = objc_getClass("ProtocolGSv1"); diff --git a/legacy.h b/legacy.h index a1326195..432382b0 100644 --- a/legacy.h +++ b/legacy.h @@ -6,10 +6,6 @@ #include "protocol.h" PRIVATE Class objc_upgrade_class(struct objc_class_gsv1 *oldClass); -PRIVATE struct objc_category *objc_upgrade_category(struct objc_category_gcc *); - +PRIVATE struct objc_category *objc_upgrade_category(struct objc_category_gsv1 *old); PRIVATE struct objc_class_gsv1* objc_legacy_class_for_class(Class); - -PRIVATE struct objc_protocol *objc_upgrade_protocol_gcc(struct objc_protocol_gcc*); PRIVATE struct objc_protocol *objc_upgrade_protocol_gsv1(struct objc_protocol_gsv1*); - diff --git a/method.h b/method.h index 4e2997bf..04c7912d 100644 --- a/method.h +++ b/method.h @@ -21,7 +21,7 @@ struct objc_method }; // end: objc_method -struct objc_method_gcc +struct objc_method_gsv1 { /** * Selector used to send messages to this method. The type encoding of @@ -86,12 +86,12 @@ static inline struct objc_method *method_at_index(struct objc_method_list *l, in /** * Legacy version of the method list. */ -struct objc_method_list_gcc +struct objc_method_list_gsv1 { /** * The next group of methods in the list. */ - struct objc_method_list_gcc *next; + struct objc_method_list_gsv1 *next; /** * The number of methods in this list. */ @@ -99,5 +99,5 @@ struct objc_method_list_gcc /** * An array of methods. Note that the actual size of this is count. */ - struct objc_method_gcc methods[]; + struct objc_method_gsv1 methods[]; }; diff --git a/protocol.c b/protocol.c index e0144e24..5f00befd 100644 --- a/protocol.c +++ b/protocol.c @@ -57,10 +57,6 @@ static id incompleteProtocolClass(void) return IncompleteProtocolClass; } -/** - * Class used for legacy GCC protocols (`ProtocolGCC`). - */ -static id protocol_class_gcc; /** * Class used for legacy GNUstep V1 ABI protocols (`ProtocolGSv1`). */ @@ -72,10 +68,6 @@ static id protocol_class_gsv2; static BOOL init_protocol_classes(void) { - if (nil == protocol_class_gcc) - { - protocol_class_gcc = objc_getClass("ProtocolGCC"); - } if (nil == protocol_class_gsv1) { protocol_class_gsv1 = objc_getClass("ProtocolGSv1"); @@ -84,8 +76,7 @@ static BOOL init_protocol_classes(void) { protocol_class_gsv2 = objc_getClass("Protocol"); } - if ((nil == protocol_class_gcc) || - (nil == protocol_class_gsv1) || + if ((nil == protocol_class_gsv1) || (nil == protocol_class_gsv2)) { return NO; @@ -108,10 +99,6 @@ static BOOL protocol_hasOptionalMethodsAndProperties(struct objc_protocol *p) { return NO; } - if (p->isa == protocol_class_gcc) - { - return NO; - } return YES; } @@ -207,8 +194,7 @@ static BOOL init_protocols(struct objc_protocol_list *protocols) { struct objc_protocol *aProto = protocols->list[i]; // Don't initialise a protocol twice - if ((aProto->isa == protocol_class_gcc) || - (aProto->isa == protocol_class_gsv1) || + if ((aProto->isa == protocol_class_gsv1) || (aProto->isa == protocol_class_gsv2)) { continue; @@ -224,12 +210,6 @@ static BOOL init_protocols(struct objc_protocol_list *protocols) fprintf(stderr, "Unknown protocol version"); abort(); #ifdef OLDABI_COMPAT - case protocol_version_gcc: - protocols->list[i] = objc_upgrade_protocol_gcc((struct objc_protocol_gcc *)aProto); - assert(aProto->isa == protocol_class_gcc); - assert(protocols->list[i]->isa == protocol_class_gsv2); - aProto = protocols->list[i]; - break; case protocol_version_gsv1: protocols->list[i] = objc_upgrade_protocol_gsv1((struct objc_protocol_gsv1 *)aProto); assert(aProto->isa == protocol_class_gsv1); diff --git a/protocol.h b/protocol.h index 15a0838a..afe98798 100644 --- a/protocol.h +++ b/protocol.h @@ -5,7 +5,7 @@ #include #include -struct objc_protocol_method_description_list_gcc +struct objc_protocol_method_description_list_gsv1 { /** * Number of method descriptions in this list. @@ -25,10 +25,6 @@ struct objc_protocol_method_description_list_gcc */ enum protocol_version { - /** - * Legacy (GCC-compatible) protocol version. - */ - protocol_version_gcc = 2, /** * GNUstep V1 ABI protocol. */ @@ -152,11 +148,11 @@ struct objc_protocol_gcc /** * List of instance methods required by this protocol. */ - struct objc_protocol_method_description_list_gcc *instance_methods; + struct objc_protocol_method_description_list_gsv1 *instance_methods; /** * List of class methods required by this protocol. */ - struct objc_protocol_method_description_list_gcc *class_methods; + struct objc_protocol_method_description_list_gsv1 *class_methods; }; struct objc_protocol_gsv1 @@ -167,16 +163,16 @@ struct objc_protocol_gsv1 id isa; char *name; struct objc_protocol_list *protocol_list; - struct objc_protocol_method_description_list_gcc *instance_methods; - struct objc_protocol_method_description_list_gcc *class_methods; + struct objc_protocol_method_description_list_gsv1 *instance_methods; + struct objc_protocol_method_description_list_gsv1 *class_methods; /** * Instance methods that are declared as optional for this protocol. */ - struct objc_protocol_method_description_list_gcc *optional_instance_methods; + struct objc_protocol_method_description_list_gsv1 *optional_instance_methods; /** * Class methods that are declared as optional for this protocol. */ - struct objc_protocol_method_description_list_gcc *optional_class_methods; + struct objc_protocol_method_description_list_gsv1 *optional_class_methods; /** * Properties that are required by this protocol. */ @@ -196,9 +192,6 @@ struct objc_protocol_gsv1 @interface Protocol : Object @end -@interface ProtocolGCC : Protocol -@end - @interface ProtocolGSv1 : Protocol @end