Skip to content
Browse files

Merge pull request #132 from paulz/master

Fix several issue came up in our project
  • Loading branch information...
2 parents ed1b193 + cb1fd46 commit 3f07bccfecb77a61221dc5fc8a196451b6a64b51 Allen Ding committed Jun 4, 2012
Showing with 16 additions and 18 deletions.
  1. +16 −18 Kiwi/KWMessagePattern.m
View
34 Kiwi/KWMessagePattern.m
@@ -135,28 +135,26 @@ - (BOOL)argumentFiltersMatchInvocationArguments:(NSInvocation *)anInvocation {
continue;
}
- if (KWObjCTypeIsObject(objCType)) {
- if ([argumentFilter isEqual:[KWNull null]]) {
- if (object != nil)
+ if ([argumentFilter conformsToProtocol:@protocol(HCMatcher)]) {
+ id<HCMatcher> matcher = (id<HCMatcher>)argumentFilter;
+ if ([object isKindOfClass:[KWValue class]] && [object isNumeric]) {
+ NSNumber *number = [object numberValue];
+ if (![matcher matches:number]) {
return NO;
- } else if ([argumentFilter respondsToSelector:@selector(matches:)]) {
- return [(id<HCMatcher>)argumentFilter matches:object];
- } else if (![argumentFilter isEqual:object]) {
+ }
+ } else if (![matcher matches:object]) {
return NO;
}
- } else {
- if ([argumentFilter isEqual:[KWNull null]]) {
- if (!KWObjCTypeIsPointerLike(objCType))
- [NSException raise:@"KWMessagePatternException" format:@"nil was specified as an argument filter, but argument is not a pointer"];
-
- void *p = nil;
- [anInvocation getMessageArgument:&p atIndex:i];
-
- if (p != nil)
- return NO;
- } else if (![argumentFilter isEqual:object]) {
- return NO;
+ } else if ([argumentFilter isEqual:[KWNull null]]) {
+ if (!KWObjCTypeIsPointerLike(objCType)) {
+ [NSException raise:@"KWMessagePatternException" format:@"nil was specified as an argument filter, but argument(%d) is not a pointer for @selector(%@)", i + 1, NSStringFromSelector([anInvocation selector])];
}
+ void *p = nil;
+ [anInvocation getMessageArgument:&p atIndex:i];
+ if (p != nil)
+ return NO;
+ } else if (![argumentFilter isEqual:object]) {
+ return NO;
}
}

0 comments on commit 3f07bcc

Please sign in to comment.
Something went wrong with that request. Please try again.