mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 08:26:27 +00:00
Add check of method types in -methodSignatureForSelector:
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@27135 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
cb0c2e65fe
commit
0ac29f22e7
2 changed files with 15 additions and 0 deletions
|
@ -1,3 +1,9 @@
|
|||
2008-11-24 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSObject.m: ([methodSignatureForSelector:]) Check that the
|
||||
types of the selector (if known) and the types of the actual method
|
||||
match. Raise an NSInternalInconsistencyException if they don't.
|
||||
|
||||
2008-11-23 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/Additions/unicode/gsm0338.h: Add more mappings from unicode
|
||||
|
|
|
@ -1599,6 +1599,7 @@ GSDescriptionForClassMethod(pcl self, SEL aSel)
|
|||
*/
|
||||
- (NSMethodSignature*) methodSignatureForSelector: (SEL)aSelector
|
||||
{
|
||||
const char *selTypes;
|
||||
const char *types;
|
||||
struct objc_method *mth;
|
||||
Class c;
|
||||
|
@ -1607,6 +1608,7 @@ GSDescriptionForClassMethod(pcl self, SEL aSel)
|
|||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"%@ null selector given", NSStringFromSelector(_cmd)];
|
||||
|
||||
selTypes = sel_get_type(aSelector);
|
||||
c = (GSObjCIsInstance(self) ? GSObjCClass(self) : (Class)self);
|
||||
mth = GSGetMethod(c, aSelector, GSObjCIsInstance(self), YES);
|
||||
|
||||
|
@ -1663,6 +1665,13 @@ GSDescriptionForClassMethod(pcl self, SEL aSel)
|
|||
{
|
||||
return nil;
|
||||
}
|
||||
else if (selTypes != 0 && GSSelectorTypesMatch(selTypes, types) == NO)
|
||||
{
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"[%@%c%@] selector types (%s) don't match method types (%s)",
|
||||
NSStringFromClass(c), (GSObjCIsInstance(self) ? '-' : '+'),
|
||||
NSStringFromSelector(aSelector), selTypes, types];
|
||||
}
|
||||
return [NSMethodSignature signatureWithObjCTypes: types];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue