71BOOL
OOJSCallObjCObjectMethod(JSContext *context,
id object, NSString *oo_jsClassName, uintN argc, jsval *argv, jsval *outResult)
75 NSString *selectorString =
nil;
77 NSString *paramString =
nil;
79 BOOL haveParameter = NO,
85 OOJSReportError(context,
@"%@.callObjC(): no selector specified.", oo_jsClassName);
91 [PLAYER setScriptTarget:object];
97 if (1 < argc && [selectorString hasSuffix:
@":"])
100 paramString = [NSString concatenationOfStringsFromJavaScriptValues:argv + 1 count:argc - 1 separator:@" " inContext:context];
103 selector = NSSelectorFromString(selectorString);
105 if ([
object respondsToSelector:selector])
112 OOJSReportError(context,
@"%@.callObjC(): method %@ requires a parameter.", oo_jsClassName, selectorString);
117 IMP method = [object methodForSelector:selector];
121 [object performSelector:selector withObject:paramString];
125 result = [object performSelector:selector withObject:paramString];
129 result = [object performSelector:selector];
130 if ([selectorString hasSuffix:
@"_bool"]) result = [NSNumber numberWithBool:OOBooleanFromObject(result, NO)];
134 [object performSelector:selector];
144 result = [NSNumber numberWithLongLong:OOCallIntegerMethod(object, selector, method, (OOShaderUniformType)type)];
148 result = [NSNumber numberWithUnsignedLongLong:OOCallIntegerMethod(object, selector, method, (OOShaderUniformType)type)];
153 result = [NSNumber numberWithDouble:OOCallFloatMethod(object, selector, method, (OOShaderUniformType)type)];
173 OOJSReportError(context,
@"%@.callObjC(): method %@ cannot be called from JavaScript.", oo_jsClassName, selectorString);
179 *outResult = [result oo_jsValueInContext:context];
185 OOJSReportError(context,
@"%@.callObjC(): %@ does not respond to method %@.", oo_jsClassName, [
object shortDescription], selectorString);
BOOL OOJSCallObjCObjectMethod(JSContext *context, id object, NSString *oo_jsClassName, uintN argc, jsval *argv, jsval *outResult)