From 976f74bcc09e8e4725c428bed5b3b899e6be6ef1 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Tue, 29 Jul 2008 17:23:00 +0200 Subject: SEND-BY-NAME: Cosmetic changes. --- MLKRoot.m | 49 ++++++++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 21 deletions(-) (limited to 'MLKRoot.m') diff --git a/MLKRoot.m b/MLKRoot.m index 4b8356f..d483b41 100644 --- a/MLKRoot.m +++ b/MLKRoot.m @@ -499,6 +499,7 @@ static id truify (BOOL value) NSInvocation *invocation; SEL selector; NSMethodSignature *signature; + const char *returnType; int i; selector = NSSelectorFromString (methodName); @@ -528,33 +529,39 @@ 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) + returnType = [signature methodReturnType]; + if (strcmp (returnType, @encode(void)) == 0) { return [NSArray array]; } - 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 { - [NSException raise:@"MLKInvalidReturnTypeError" - format:@"Cannot handle an Objective-C return type of \"%s\" \ + char retbuf[[signature methodReturnLength]]; + + [invocation getReturnValue:&retbuf]; + +#define IF_TYPE_RETURN(TYPE, VALUE_NAME, VALUE) \ + if (strcmp (returnType, @encode(TYPE)) == 0) \ + { \ + TYPE VALUE_NAME = *(TYPE*)retbuf; \ + RETURN_VALUE (VALUE); \ + } + + 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 + { + [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; + methodName, object, returnType]; + return nil; + } } } @end -- cgit v1.2.3