Open adrientetar opened 7 years ago
Thanks for posting the issue @adrientetar . The snippet you had there looks fine and doesn't give me any problem when I was trying something like,
runScript("function a(x) {return x}");
callFunction("a", ["HelloWorld"]);
Can you send me a small repo so that I can look at what exactly went wrong? Also, if your script exposes a single function, you can parse the script into a JsValueRef handle using JsParseScript
and then pass the returned handle to JsCallFunction
.
The first element in "jsArguments" should be the object who holds the function . which is "global" in your code. It took me 2 days to figure this out.
Yep @JohnMasen the first element in arguments
for JsCallFunction (which resembles Function.Prototype.call) is thisArg, which is documented here. Sorry it took you two days :/. Any suggestion to make it more discoverable?
Suggestions: arguments: The arguments to the call (Requires thisArg as first argument of arguments.)
Remarks: The first parameter of arguments should be the object which holds the function. Use the result of JsGetGlobalObject(or JavaScriptValue.GlobalObject in c# wrapper) if this function is a global function.
use Undefined works same as GlobalObject, however it may confuse the user that the first parameter should be a place holder.
Thanks @JohnMasen . I add a note in the Parameters section.
(C#/UWP)
I would like to:
For 1. I just use
ChakraCore.runScript(..)
. For 2. I wrote thisChakraCore.callFunction(..)
:This fails with "couldn't execute function: InvalidArgument". Please advise, JsRT documentation is (afaict) lackluster.