diff options
author | Matthias Andreas Benkard <matthias@benkard.de> | 2008-07-29 16:49:29 +0200 |
---|---|---|
committer | Matthias Andreas Benkard <matthias@benkard.de> | 2008-07-29 16:49:29 +0200 |
commit | 5c87cf0c61aaf71f4380457d84416b82575e7f04 (patch) | |
tree | 2ad195828cb392bc421944b15b87435456ebf1f4 | |
parent | 04fd4986f83c8bf623578511e075376c671c3555 (diff) |
SEND-BY-NAME: Support more return types.
-rw-r--r-- | MLKRoot.m | 30 |
1 files changed, 21 insertions, 9 deletions
@@ -528,21 +528,33 @@ static id truify (BOOL value) [invocation invoke]; + +#define IF_TYPE_RETURN(TYPE, VALUE_NAME, VALUE) \ + if (strcmp ([signature methodReturnType], @encode(TYPE)) == 0) \ + { \ + TYPE VALUE_NAME; \ + [invocation getReturnValue:&VALUE_NAME]; \ + RETURN_VALUE (VALUE); \ + } + if (strcmp ([signature methodReturnType], @encode(void)) == 0) { return [NSArray array]; } - else if (strcmp ([signature methodReturnType], @encode(BOOL)) == 0) - { - BOOL returnValue; - [invocation getReturnValue:&returnValue]; - RETURN_VALUE (truify (returnValue)); - } + else IF_TYPE_RETURN (BOOL, retval, truify (retval)) + else IF_TYPE_RETURN (id, retval, retval) + else IF_TYPE_RETURN (Class, retval, retval) + else IF_TYPE_RETURN (NSException *, retval, retval) + else IF_TYPE_RETURN (int, retval, [MLKInteger integerWithInt:retval]) + else IF_TYPE_RETURN (unsigned int, retval, [MLKInteger integerWithInt:retval]) //FIXME + else IF_TYPE_RETURN (unichar, retval, [MLKCharacter characterWithUnichar:retval]) else { - id returnValue; - [invocation getReturnValue:&returnValue]; - RETURN_VALUE (returnValue); + [NSException raise:@"MLKInvalidReturnTypeError" + format:@"Cannot handle an Objective-C return type of \"%s\" \ +as provided by method %@ of object %@", + methodName, object, [signature methodReturnType]]; + return nil; } } @end |