Add a size field to the ivar list struct, for forward compatibility.

main
David Chisnall 10 years ago committed by David Chisnall
parent d52db3491a
commit f9421d02a8

@ -22,6 +22,11 @@ PRIVATE void objc_compute_ivar_offsets(Class class)
legacy = (struct objc_ivar_list_legacy *)class->ivars;
class->ivars = upgradeIvarList(class, legacy);
}
if (class->ivars->size != sizeof(struct objc_ivar))
{
fprintf(stderr, "Downgrading ivar struct not yet implemented");
abort();
}
int i = 0;
/* If this class was compiled with support for late-bound ivars, the
* instance_size field will contain 0 - {the size of the instance variables
@ -159,6 +164,7 @@ static struct objc_ivar_list *upgradeIvarList(Class cls, struct objc_ivar_list_l
}
struct objc_ivar_list *n = calloc(1, sizeof(struct objc_ivar_list) +
l->count*sizeof(struct objc_ivar));
n->size = sizeof(struct objc_ivar);
n->count = l->count;
for (int i=0 ; i<l->count ; i++)
{

@ -27,7 +27,7 @@ struct objc_ivar
/**
* Flags for this instance variable.
*/
int flags;
long flags;
};
/**
@ -107,6 +107,12 @@ struct objc_ivar_list
* The number of instance variables in this list.
*/
int count;
/**
* The size of a `struct objc_ivar`. This allows the runtime to load
* versions of this that come from a newer compiler, if we ever need to do
* so.
*/
size_t size;
/**
* An array of instance variable metadata structures. Note that this array
* has count elements.

@ -129,6 +129,7 @@ BOOL class_addIvar(Class cls, const char *name, size_t size, uint8_t alignment,
if (NULL == ivarlist)
{
cls->ivars = malloc(sizeof(struct objc_ivar_list) + sizeof(struct objc_ivar));
cls->ivars->size = sizeof(struct objc_ivar);
cls->ivars->count = 1;
}
else

Loading…
Cancel
Save