[iOS] jsb.reflection.callStaticMethod supports to call objective-c method with NSNumber* and supports to pass undefined/null from JS. (#1010)

This commit is contained in:
James Chen
2017-11-23 14:26:03 +08:00
committed by GitHub
parent 7c4eeecdde
commit f5f94ac857
@@ -163,6 +163,11 @@ bool JavaScriptObjCBridge::CallInfo::execute(const se::ValueArray& argv, se::Val
unsigned char val = arg.toUint8();
[invocation setArgument:&val atIndex:i];
}
else if (argumentType == "@")
{ // NSNumber*
NSNumber* number = [NSNumber numberWithDouble:arg.toNumber()];
[invocation setArgument:&number atIndex:i];
}
else
{
NSLog(@"Unsupported argument type: %s", argumentType.c_str());
@@ -189,6 +194,10 @@ bool JavaScriptObjCBridge::CallInfo::execute(const se::ValueArray& argv, se::Val
return false;
}
}
else if (arg.isNullOrUndefined())
{
// Don't call [invocation setArgument] will pass nil to relevant Objective-C argument.
}
else
{
NSLog(@"Unsupported argument type, se::Value::Type: %d", (int)arg.getType());