| OLD | NEW |
| 1 //------------------------------------------------------------------------------
--------- | 1 //------------------------------------------------------------------------------
--------- |
| 2 // $Id$ | 2 // $Id$ |
| 3 // Copyright (c) 2009 by Mulle Kybernetik. See License file for details. | 3 // Copyright (c) 2009 by Mulle Kybernetik. See License file for details. |
| 4 //------------------------------------------------------------------------------
--------- | 4 //------------------------------------------------------------------------------
--------- |
| 5 | 5 |
| 6 #import <objc/runtime.h> | 6 #import <objc/runtime.h> |
| 7 #import "OCPartialMockRecorder.h" | 7 #import "OCPartialMockRecorder.h" |
| 8 #import "OCPartialMockObject.h" | 8 #import "OCPartialMockObject.h" |
| 9 | 9 |
| 10 | 10 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 realObject = nil; | 84 realObject = nil; |
| 85 } | 85 } |
| 86 | 86 |
| 87 | 87 |
| 88 #pragma mark Subclass management | 88 #pragma mark Subclass management |
| 89 | 89 |
| 90 - (void)setupSubclassForObject:(id)anObject | 90 - (void)setupSubclassForObject:(id)anObject |
| 91 { | 91 { |
| 92 Class realClass = [anObject class]; | 92 Class realClass = [anObject class]; |
| 93 double timestamp = [NSDate timeIntervalSinceReferenceDate]; | 93 double timestamp = [NSDate timeIntervalSinceReferenceDate]; |
| 94 » const char *className = [[NSString stringWithFormat:@"%@-%p-%f", realCla
ss, anObject, timestamp] cString]; | 94 » const char *className = [[NSString stringWithFormat:@"%@-%p-%f", realCla
ss, anObject, timestamp] UTF8String]; |
| 95 Class subclass = objc_allocateClassPair(realClass, className, 0); | 95 Class subclass = objc_allocateClassPair(realClass, className, 0); |
| 96 objc_registerClassPair(subclass); | 96 objc_registerClassPair(subclass); |
| 97 object_setClass(anObject, subclass); | 97 object_setClass(anObject, subclass); |
| 98 | 98 |
| 99 Method forwardInvocationMethod = class_getInstanceMethod([self class], @
selector(forwardInvocationForRealObject:)); | 99 Method forwardInvocationMethod = class_getInstanceMethod([self class], @
selector(forwardInvocationForRealObject:)); |
| 100 IMP forwardInvocationImp = method_getImplementation(forwardInvocationMet
hod); | 100 IMP forwardInvocationImp = method_getImplementation(forwardInvocationMet
hod); |
| 101 const char *forwardInvocationTypes = method_getTypeEncoding(forwardInvoc
ationMethod); | 101 const char *forwardInvocationTypes = method_getTypeEncoding(forwardInvoc
ationMethod); |
| 102 class_addMethod(subclass, @selector(forwardInvocation:), forwardInvocati
onImp, forwardInvocationTypes); | 102 class_addMethod(subclass, @selector(forwardInvocation:), forwardInvocati
onImp, forwardInvocationTypes); |
| 103 } | 103 } |
| 104 | 104 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 133 return [[[OCPartialMockRecorder alloc] initWithSignatureResolver:self] a
utorelease]; | 133 return [[[OCPartialMockRecorder alloc] initWithSignatureResolver:self] a
utorelease]; |
| 134 } | 134 } |
| 135 | 135 |
| 136 - (void)handleUnRecordedInvocation:(NSInvocation *)anInvocation | 136 - (void)handleUnRecordedInvocation:(NSInvocation *)anInvocation |
| 137 { | 137 { |
| 138 [anInvocation invokeWithTarget:realObject]; | 138 [anInvocation invokeWithTarget:realObject]; |
| 139 } | 139 } |
| 140 | 140 |
| 141 | 141 |
| 142 @end | 142 @end |
| OLD | NEW |