From 2f6c120a86e417e6c741d0781fda9197c0741f10 Mon Sep 17 00:00:00 2001 From: CaS Date: Fri, 4 Jul 2003 11:18:51 +0000 Subject: [PATCH] Quick runtime fix git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@17099 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 1 + Source/NSObject.m | 66 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/ChangeLog b/ChangeLog index 8e049fe83..50360ec23 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,6 +9,7 @@ Fri Jul 4 11:09:37 2003 Nicola Pero * Source/NSObject.m: ([methodSignatureForSelector:]) modified to take into account any protocols that the receiver conforms to, so the returned signature has the fullest possible type information. + Category Protocol(Fixup) ... evil hack to work around runtime bug. * Source/GSFFCallInvocation.m: Fetch method signature from receiver in preference to using other info. Ensures we have correct info for the object we are sending the message to. diff --git a/Source/NSObject.m b/Source/NSObject.m index 638a90971..77bf403bf 100644 --- a/Source/NSObject.m +++ b/Source/NSObject.m @@ -687,6 +687,72 @@ static IMP autorelease_imp; static BOOL double_release_check_enabled = NO; + +@implementation Protocol (Fixup) +struct objc_method_description_list { + int count; + struct objc_method_description list[1]; +}; + +- (struct objc_method_description *) descriptionForInstanceMethod:(SEL)aSel +{ + int i; + struct objc_protocol_list* proto_list; + const char* name = sel_get_name (aSel); + struct objc_method_description *result; + + if (instance_methods != 0) + { + for (i = 0; i < instance_methods->count; i++) + { + if (!strcmp ((char*)instance_methods->list[i].name, name)) + return &(instance_methods->list[i]); + } + } + for (proto_list = protocol_list; proto_list; proto_list = proto_list->next) + { + size_t j; + for (j=0; j < proto_list->count; j++) + { + if ((result = [proto_list->list[j] + descriptionForInstanceMethod: aSel])) + return result; + } + } + + return NULL; +} + +- (struct objc_method_description *) descriptionForClassMethod:(SEL)aSel; +{ + int i; + struct objc_protocol_list* proto_list; + const char* name = sel_get_name (aSel); + struct objc_method_description *result; + + if (class_methods != 0) + { + for (i = 0; i < class_methods->count; i++) + { + if (!strcmp ((char*)class_methods->list[i].name, name)) + return &(class_methods->list[i]); + } + } + for (proto_list = protocol_list; proto_list; proto_list = proto_list->next) + { + size_t j; + for (j=0; j < proto_list->count; j++) + { + if ((result = [proto_list->list[j] + descriptionForClassMethod: aSel])) + return result; + } + } + + return NULL; +} + +@end /** *