blob: d98b59c9956b19d5aa1bfc279e0d7ae30ded125d [file] [log] [blame]
//---------------------------------------------------------------------------------------
// $Id$
// Copyright (c) 2009 by Mulle Kybernetik. See License file for details.
//---------------------------------------------------------------------------------------
#import "NSMethodSignature+OCMAdditions.h"
#import "OCMReturnValueProvider.h"
@implementation OCMReturnValueProvider
- (id)initWithValue:(id)aValue
{
self = [super init];
returnValue = [aValue retain];
return self;
}
- (void)dealloc
{
[returnValue release];
[super dealloc];
}
- (void)handleInvocation:(NSInvocation *)anInvocation
{
const char *returnType = [[anInvocation methodSignature] methodReturnTypeWithoutQualifiers];
if(strcmp(returnType, @encode(id)) != 0)
@throw [NSException exceptionWithName:NSInvalidArgumentException reason:@"Expected invocation with object return type. Did you mean to use andReturnValue: instead?" userInfo:nil];
[anInvocation setReturnValue:&returnValue];
}
@end