Skip to content

Commit

Permalink
Rename legacy types.
Browse files Browse the repository at this point in the history
For consistency, each now has a `_gcc` or `_gsv1` suffix indicating
whether they were inherited from the GCC or GNUstep v1 ABI.
  • Loading branch information
davidchisnall committed Mar 29, 2018
1 parent 48967e5 commit 64ab2d5
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 33 deletions.
6 changes: 3 additions & 3 deletions category.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ struct objc_category
struct objc_property_list *class_properties;
};

struct objc_category_legacy
struct objc_category_gcc
{
/**
* The name of this category.
Expand All @@ -50,11 +50,11 @@ struct objc_category_legacy
/**
* The list of instance methods to add to the class.
*/
struct objc_method_list_legacy *instance_methods;
struct objc_method_list_gcc *instance_methods;
/**
* The list of class methods to add to the class.
*/
struct objc_method_list_legacy *class_methods;
struct objc_method_list_gcc *class_methods;
/**
* The list of protocols adopted by this category.
*/
Expand Down
14 changes: 7 additions & 7 deletions class.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ struct objc_class
};
// end: objc_class

struct legacy_gnustep_objc_class
struct objc_class_gsv1
{
/**
* Pointer to the metaclass for this class. The metaclass defines the
Expand Down Expand Up @@ -187,12 +187,12 @@ struct legacy_gnustep_objc_class
/**
* Metadata describing the instance variables in this class.
*/
struct objc_ivar_list_legacy *ivars;
struct objc_ivar_list_gcc *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_legacy *methods;
struct objc_method_list_gcc *methods;
/**
* The dispatch table for this class. Intialized and maintained by the
* runtime.
Expand Down Expand Up @@ -283,15 +283,15 @@ struct legacy_gnustep_objc_class
* same fields, and you can test the new abi flag to tell whether it is safe to
* access the subsequent fields.
*/
struct legacy_gcc_objc_class
struct objc_class_gcc
{
struct objc_class *isa;
struct objc_class *super_class;
const char *name;
long version;
unsigned long info;
long instance_size;
struct objc_ivar_list_legacy *ivars;
struct objc_ivar_list_gcc *ivars;
struct objc_method_list *methods;
void *dtable;
struct objc_class *subclass_list;
Expand Down Expand Up @@ -375,7 +375,7 @@ static inline BOOL objc_test_class_flag(struct objc_class *aClass,
return (aClass->info & (unsigned long)flag) == (unsigned long)flag;
}

static inline BOOL objc_test_class_flag_legacy(struct legacy_gnustep_objc_class *aClass,
static inline BOOL objc_test_class_flag_legacy(struct objc_class_gsv1 *aClass,
enum objc_class_flags flag)
{
return (aClass->info & (unsigned long)flag) == (unsigned long)flag;
Expand All @@ -396,7 +396,7 @@ static inline int objc_get_class_version(struct objc_class *aClass)
return aClass->abi_version + 1;
}

static inline int objc_get_class_version_legacy(struct legacy_gnustep_objc_class *aClass)
static inline int objc_get_class_version_legacy(struct objc_class_gsv1 *aClass)
{
if (!objc_test_class_flag_legacy(aClass, objc_class_flag_new_abi))
{
Expand Down
4 changes: 2 additions & 2 deletions class_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ PRIVATE BOOL objc_resolve_class(Class cls)
}
else
{
struct legacy_gnustep_objc_class *ocls = objc_legacy_class_for_class(cls);
struct objc_class_gsv1 *ocls = objc_legacy_class_for_class(cls);
if (ocls != NULL)
{
const char *super_name = (const char*)ocls->super_class;
Expand Down Expand Up @@ -258,7 +258,7 @@ PRIVATE BOOL objc_resolve_class(Class cls)

// Fix up the ivar offsets
objc_compute_ivar_offsets(cls);
struct legacy_gnustep_objc_class *oldCls = objc_legacy_class_for_class(cls);
struct objc_class_gsv1 *oldCls = objc_legacy_class_for_class(cls);
if (oldCls)
{
oldCls->super_class = cls->super_class;
Expand Down
2 changes: 1 addition & 1 deletion ivar.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ PRIVATE void objc_compute_ivar_offsets(Class class)
}
// If we have a legacy ivar list, update the offset in it too -
// code from older compilers may access this directly!
struct legacy_gnustep_objc_class* legacy = objc_legacy_class_for_class(class);
struct objc_class_gsv1* legacy = objc_legacy_class_for_class(class);
if (legacy)
{
for (i = 0 ; i < class->ivars->count ; i++)
Expand Down
6 changes: 3 additions & 3 deletions ivar.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ static inline ivar_ownership ivarGetOwnership(Ivar ivar)
/**
* Legacy ivar structure, inherited from the GCC ABI.
*/
struct objc_ivar_legacy
struct objc_ivar_gcc
{
/**
* Name of this instance variable.
Expand Down Expand Up @@ -123,7 +123,7 @@ struct objc_ivar_list
/**
* Legacy version of the ivar list
*/
struct objc_ivar_list_legacy
struct objc_ivar_list_gcc
{
/**
* The number of instance variables in this list.
Expand All @@ -133,6 +133,6 @@ struct objc_ivar_list_legacy
* An array of instance variable metadata structures. Note that this array
* has count elements.
*/
struct objc_ivar_legacy ivar_list[];
struct objc_ivar_gcc ivar_list[];
};

20 changes: 10 additions & 10 deletions legacy.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

PRIVATE size_t lengthOfTypeEncoding(const char *types);

static ivar_ownership ownershipForIvar(struct legacy_gnustep_objc_class *cls, int idx)
static ivar_ownership ownershipForIvar(struct objc_class_gsv1 *cls, int idx)
{
if (objc_get_class_version_legacy(cls) < 2)
{
Expand All @@ -29,9 +29,9 @@ static ivar_ownership ownershipForIvar(struct legacy_gnustep_objc_class *cls, in
return ownership_unsafe;
}

static struct objc_ivar_list *upgradeIvarList(struct legacy_gnustep_objc_class *cls)
static struct objc_ivar_list *upgradeIvarList(struct objc_class_gsv1 *cls)
{
struct objc_ivar_list_legacy *l = cls->ivars;
struct objc_ivar_list_gcc *l = cls->ivars;
if (l == NULL)
{
return NULL;
Expand Down Expand Up @@ -69,7 +69,7 @@ static struct objc_ivar_list *upgradeIvarList(struct legacy_gnustep_objc_class *
return n;
}

static struct objc_method_list *upgradeMethodList(struct objc_method_list_legacy *old)
static struct objc_method_list *upgradeMethodList(struct objc_method_list_gcc *old)
{
if (old == NULL)
{
Expand Down Expand Up @@ -246,12 +246,12 @@ static struct objc_property_list *upgradePropertyList(struct objc_property_list_

static int legacy_key;

PRIVATE struct legacy_gnustep_objc_class* objc_legacy_class_for_class(Class cls)
PRIVATE struct objc_class_gsv1* objc_legacy_class_for_class(Class cls)
{
return (struct legacy_gnustep_objc_class*)objc_getAssociatedObject((id)cls, &legacy_key);
return (struct objc_class_gsv1*)objc_getAssociatedObject((id)cls, &legacy_key);
}

PRIVATE Class objc_upgrade_class(struct legacy_gnustep_objc_class *oldClass)
PRIVATE Class objc_upgrade_class(struct objc_class_gsv1 *oldClass)
{
Class cls = calloc(sizeof(struct objc_class), 1);
cls->isa = oldClass->isa;
Expand All @@ -268,16 +268,16 @@ PRIVATE Class objc_upgrade_class(struct legacy_gnustep_objc_class *oldClass)
objc_register_selectors_from_class(cls);
if (!objc_test_class_flag(cls, objc_class_flag_meta))
{
cls->isa = objc_upgrade_class((struct legacy_gnustep_objc_class*)cls->isa);
cls->isa = objc_upgrade_class((struct objc_class_gsv1*)cls->isa);
objc_setAssociatedObject((id)cls, &legacy_key, (id)oldClass, OBJC_ASSOCIATION_ASSIGN);
}
return cls;
}

PRIVATE struct objc_category *objc_upgrade_category(struct objc_category_legacy *old)
PRIVATE struct objc_category *objc_upgrade_category(struct objc_category_gcc *old)
{
struct objc_category *cat = calloc(1, sizeof(struct objc_category));
memcpy(cat, old, sizeof(struct objc_category_legacy));
memcpy(cat, old, sizeof(struct objc_category_gcc));
cat->instance_methods = upgradeMethodList(old->instance_methods);
cat->class_methods = upgradeMethodList(old->class_methods);
return cat;
Expand Down
6 changes: 3 additions & 3 deletions legacy.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
#include "category.h"
#include "protocol.h"

PRIVATE Class objc_upgrade_class(struct legacy_gnustep_objc_class *oldClass);
PRIVATE struct objc_category *objc_upgrade_category(struct objc_category_legacy *);
PRIVATE Class objc_upgrade_class(struct objc_class_gsv1 *oldClass);
PRIVATE struct objc_category *objc_upgrade_category(struct objc_category_gcc *);

PRIVATE struct legacy_gnustep_objc_class* objc_legacy_class_for_class(Class);
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*);
Expand Down
8 changes: 4 additions & 4 deletions method_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ struct objc_method
const char *types;
};

struct objc_method_legacy
struct objc_method_gcc
{
/**
* Selector used to send messages to this method. The type encoding of
Expand Down Expand Up @@ -66,18 +66,18 @@ struct objc_method_list
/**
* Legacy version of the method list.
*/
struct objc_method_list_legacy
struct objc_method_list_gcc
{
/**
* The next group of methods in the list.
*/
struct objc_method_list_legacy *next;
struct objc_method_list_gcc *next;
/**
* The number of methods in this list.
*/
int count;
/**
* An array of methods. Note that the actual size of this is count.
*/
struct objc_method_legacy methods[];
struct objc_method_gcc methods[];
};

0 comments on commit 64ab2d5

Please sign in to comment.