Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / ocmock / OCMock / OCMRealObjectForwarder.m
blob7c0a7db14e57fa18156246840e9146d6c351aa86
1 //---------------------------------------------------------------------------------------
2 //  $Id$
3 //  Copyright (c) 2010 by Mulle Kybernetik. See License file for details.
4 //---------------------------------------------------------------------------------------
6 #import <objc/runtime.h>
7 #import "OCPartialMockObject.h"
8 #import "OCMRealObjectForwarder.h"
11 @implementation OCMRealObjectForwarder
13 - (void)handleInvocation:(NSInvocation *)anInvocation 
15         id invocationTarget = [anInvocation target];
16         SEL invocationSelector = [anInvocation selector];
17         SEL aliasedSelector = NSSelectorFromString([OCMRealMethodAliasPrefix stringByAppendingString:NSStringFromSelector(invocationSelector)]);
18         
19         [anInvocation setSelector:aliasedSelector];
20         if([invocationTarget isProxy] && (class_getInstanceMethod([invocationTarget class], @selector(realObject)))) 
21         {
22                 // the method has been invoked on the mock, we need to change the target to the real object
23                 [anInvocation setTarget:[(OCPartialMockObject *)invocationTarget realObject]];
24         } 
25         [anInvocation invoke];
29 @end