Add size to the property list.

It should now be possible to support newer ABIs.
main
David Chisnall 8 years ago
parent 8b6793aa52
commit 44a85a401a

@ -244,7 +244,7 @@ struct legacy_gnustep_objc_class
* List of declared properties on this class (NULL if none). This contains * List of declared properties on this class (NULL if none). This contains
* the accessor methods for each property. * the accessor methods for each property.
*/ */
struct objc_property_list *properties; struct objc_property_list_legacy *properties;
/** /**
* GC / ARC ABI: Fields below this point only exist if abi_version is >= 1. * GC / ARC ABI: Fields below this point only exist if abi_version is >= 1.

@ -5,6 +5,7 @@
#include "objc/runtime.h" #include "objc/runtime.h"
#include "objc/encoding.h" #include "objc/encoding.h"
#include "ivar.h" #include "ivar.h"
#include "properties.h"
#include "class.h" #include "class.h"
#include "loader.h" #include "loader.h"
@ -82,6 +83,20 @@ static struct objc_method_list *upgradeMethodList(struct objc_method_list_legacy
return l; return l;
} }
static struct objc_property_list *upgradePropertyList(struct objc_property_list_legacy *l)
{
if (l == NULL)
{
return NULL;
}
size_t data_size = l->count * sizeof(struct objc_property);
struct objc_property_list *n = calloc(1, sizeof(struct objc_property_list) + data_size);
n->count = l->count;
n->size = sizeof(struct objc_property);
memcpy(n->properties, l->properties, data_size);
return n;
}
static int legacy_key; static int legacy_key;
PRIVATE struct legacy_gnustep_objc_class* objc_legacy_class_for_class(Class cls) PRIVATE struct legacy_gnustep_objc_class* objc_legacy_class_for_class(Class cls)
@ -102,7 +117,7 @@ PRIVATE Class objc_upgrade_class(struct legacy_gnustep_objc_class *oldClass)
cls->methods = upgradeMethodList(oldClass->methods); cls->methods = upgradeMethodList(oldClass->methods);
cls->protocols = oldClass->protocols; cls->protocols = oldClass->protocols;
cls->abi_version = oldClass->abi_version; cls->abi_version = oldClass->abi_version;
cls->properties = oldClass->properties; cls->properties = upgradePropertyList(oldClass->properties);
objc_register_selectors_from_class(cls); objc_register_selectors_from_class(cls);
if (!objc_test_class_flag(cls, objc_class_flag_meta)) if (!objc_test_class_flag(cls, objc_class_flag_meta))
{ {

@ -133,6 +133,25 @@ struct objc_property
const char *setter_types; const char *setter_types;
}; };
/**
* List of property introspection data.
*/
struct objc_property_list_legacy
{
/**
* Number of properties in this array.
*/
int count;
/*
* The next property in a linked list.
*/
struct objc_property_list *next;
/**
* List of properties.
*/
struct objc_property properties[];
};
/** /**
* List of property introspection data. * List of property introspection data.
*/ */
@ -142,6 +161,12 @@ struct objc_property_list
* Number of properties in this array. * Number of properties in this array.
*/ */
int count; int count;
/**
* Size of `struct objc_property`. This allows the runtime to
* transparently support newer ABIs with more fields in the property
* metadata.
*/
int size;
/* /*
* The next property in a linked list. * The next property in a linked list.
*/ */

@ -671,6 +671,7 @@ BOOL class_addProperty(Class cls,
struct objc_property_list *l = calloc(1, sizeof(struct objc_property_list) struct objc_property_list *l = calloc(1, sizeof(struct objc_property_list)
+ sizeof(struct objc_property)); + sizeof(struct objc_property));
l->count = 1; l->count = 1;
l->size = sizeof(struct objc_property);
memcpy(&l->properties, &p, sizeof(struct objc_property)); memcpy(&l->properties, &p, sizeof(struct objc_property));
LOCK_RUNTIME_FOR_SCOPE(); LOCK_RUNTIME_FOR_SCOPE();
l->next = cls->properties; l->next = cls->properties;

Loading…
Cancel
Save