Patch to permit null selectors

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@15995 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
CaS 2003-02-18 11:43:57 +00:00
parent c5a763be4c
commit bd9e478b7b
2 changed files with 28 additions and 11 deletions

View file

@ -1,3 +1,9 @@
2003-02-18 Richard Frith-Macdonald <rfm@gnu.org>
* NSObject.m: ([+instancesRespondToSelector:]),([-respondsToSelector])
Return NO when given a null selector unless in MacOS-X compatibility
mode. rewritten from patch by Willem Rein Oudshoorn.
2003-02-16 Adam Fedor <fedor@gnu.org> 2003-02-16 Adam Fedor <fedor@gnu.org>
* Version 1.5.2 * Version 1.5.2

View file

@ -1124,18 +1124,22 @@ static BOOL double_release_check_enabled = NO;
* where a subclass implements -forwardInvocation: to respond to * where a subclass implements -forwardInvocation: to respond to
* selectors not normally handled ... in these cases the subclass * selectors not normally handled ... in these cases the subclass
* may override this method to handle it. * may override this method to handle it.
* <br />Raises NSInvalidArgumentException if given a null selector. * <br />If given a null selector, raises NSInvalidArgumentException when
* in MacOS-X compatibility more, or returns NO otherwise.
*/ */
+ (BOOL) instancesRespondToSelector: (SEL)aSelector + (BOOL) instancesRespondToSelector: (SEL)aSelector
{ {
if (aSelector == 0) if (aSelector == 0)
[NSException raise: NSInvalidArgumentException {
format: @"%@ null selector given", NSStringFromSelector(_cmd)]; if (GSUserDefaultsFlag(GSMacOSXCompatible))
#if 0 {
return (class_get_instance_method(self, aSelector) != METHOD_NULL); [NSException raise: NSInvalidArgumentException
#else format: @"%@ null selector given",
NSStringFromSelector(_cmd)];
}
return NO;
}
return __objc_responds_to((id)&self, aSelector); return __objc_responds_to((id)&self, aSelector);
#endif
} }
/** /**
@ -1659,14 +1663,21 @@ static BOOL double_release_check_enabled = NO;
* where a subclass implements -forwardInvocation: to respond to * where a subclass implements -forwardInvocation: to respond to
* selectors not normally handled ... in these cases the subclass * selectors not normally handled ... in these cases the subclass
* may override this method to handle it. * may override this method to handle it.
* <br />Raises NSInvalidArgumentException if given a null selector. * <br />If given a null selector, raises NSInvalidArgumentException when
* in MacOS-X compatibility more, or returns NO otherwise.
*/ */
- (BOOL) respondsToSelector: (SEL)aSelector - (BOOL) respondsToSelector: (SEL)aSelector
{ {
if (aSelector == 0) if (aSelector == 0)
[NSException raise: NSInvalidArgumentException {
format: @"%@ null selector given", NSStringFromSelector(_cmd)]; if (GSUserDefaultsFlag(GSMacOSXCompatible))
{
[NSException raise: NSInvalidArgumentException
format: @"%@ null selector given",
NSStringFromSelector(_cmd)];
}
return NO;
}
return __objc_responds_to(self, aSelector); return __objc_responds_to(self, aSelector);
} }