mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Fixed -respondsToSelector: and +instancesRespondToSelector: to check
+resolveInstanceMethod: and +resolveClassMethod: as documented in Cocoa NSObject API. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@37614 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
1e64ca1adf
commit
354ab0f46f
2 changed files with 37 additions and 2 deletions
|
@ -1,3 +1,9 @@
|
|||
2014-01-18 Quentin Mathe <quentin.mathe@gmail.com>
|
||||
|
||||
* Source/NSObject.m (-respondsToSelector,
|
||||
+instancesRespondToSelector:): Fixed to check +resolveInstanceMethod: and
|
||||
+resolveClassMethod: as documented in Cocoa NSObject API.
|
||||
|
||||
2014-01-16 Niels Grewe <niels.grewe@halbordnung.de>
|
||||
|
||||
* Source/NSScanner.m: Implement -scanInteger: by conditionally
|
||||
|
|
|
@ -1519,7 +1519,22 @@ static id gs_weak_load(id obj)
|
|||
}
|
||||
return NO;
|
||||
}
|
||||
return class_respondsToSelector(self, aSelector) ? YES : NO;
|
||||
|
||||
if (class_respondsToSelector(self, aSelector))
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
if (class_isMetaClass(self))
|
||||
{
|
||||
/* It seems convoluted to attempt to access the class from the
|
||||
metaclass just to call +resolveClassMethod: in this rare case. */
|
||||
return NO;
|
||||
}
|
||||
else
|
||||
{
|
||||
return [self resolveInstanceMethod: aSelector];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2111,6 +2126,8 @@ static id gs_weak_load(id obj)
|
|||
*/
|
||||
- (BOOL) respondsToSelector: (SEL)aSelector
|
||||
{
|
||||
Class cls = object_getClass(self);
|
||||
|
||||
if (aSelector == 0)
|
||||
{
|
||||
if (GSPrivateDefaultsFlag(GSMacOSXCompatible))
|
||||
|
@ -2122,7 +2139,19 @@ static id gs_weak_load(id obj)
|
|||
return NO;
|
||||
}
|
||||
|
||||
return class_respondsToSelector(object_getClass(self), aSelector) ? YES : NO;
|
||||
if (class_respondsToSelector(cls, aSelector))
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
if (class_isMetaClass(cls))
|
||||
{
|
||||
return [(Class)self resolveClassMethod: aSelector];
|
||||
}
|
||||
else
|
||||
{
|
||||
return [cls resolveInstanceMethod: aSelector];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue