blob: 7c0a7db14e57fa18156246840e9146d6c351aa86 [file] [log] [blame]
//---------------------------------------------------------------------------------------
// $Id$
// Copyright (c) 2010 by Mulle Kybernetik. See License file for details.
//---------------------------------------------------------------------------------------
#import <objc/runtime.h>
#import "OCPartialMockObject.h"
#import "OCMRealObjectForwarder.h"
@implementation OCMRealObjectForwarder
- (void)handleInvocation:(NSInvocation *)anInvocation
{
id invocationTarget = [anInvocation target];
SEL invocationSelector = [anInvocation selector];
SEL aliasedSelector = NSSelectorFromString([OCMRealMethodAliasPrefix stringByAppendingString:NSStringFromSelector(invocationSelector)]);
[anInvocation setSelector:aliasedSelector];
if([invocationTarget isProxy] && (class_getInstanceMethod([invocationTarget class], @selector(realObject))))
{
// the method has been invoked on the mock, we need to change the target to the real object
[anInvocation setTarget:[(OCPartialMockObject *)invocationTarget realObject]];
}
[anInvocation invoke];
}
@end