Correctly upgrade categories.

This was hidden by a compiler bug where the new version was generated in
the same format as the old, so upgrading in the wrong place worked.
main
David Chisnall 8 years ago
parent d11a0311e0
commit 0f1385e1b1

@ -14,8 +14,6 @@ static void register_methods(struct objc_class *cls, struct objc_method_list *l)
{
if (NULL == l) { return; }
// Replace the method names with selectors.
objc_register_selectors_from_list(l);
// Add the method list at the head of the list of lists.
l->next = cls->methods;
cls->methods = l;

@ -110,6 +110,10 @@ static struct objc_method_list *upgradeMethodList(struct objc_method_list_gcc *o
{
return NULL;
}
if (old->count == 0)
{
return NULL;
}
struct objc_method_list *l = calloc(sizeof(struct objc_method_list) + old->count * sizeof(struct objc_method), 1);
l->count = old->count;
if (old->next)
@ -309,13 +313,20 @@ PRIVATE Class objc_upgrade_class(struct objc_class_gsv1 *oldClass)
}
return cls;
}
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_gcc));
cat->instance_methods = upgradeMethodList(old->instance_methods);
cat->class_methods = upgradeMethodList(old->class_methods);
if (cat->instance_methods != NULL)
{
objc_register_selectors_from_list(cat->instance_methods);
}
if (cat->class_methods != NULL)
{
objc_register_selectors_from_list(cat->class_methods);
}
for (int i=0 ; i<cat->protocols->count ; i++)
{
objc_init_protocols(cat->protocols);

Loading…
Cancel
Save