Skip to content

Instantly share code, notes, and snippets.

@bnjbvr
Created February 11, 2015 14:02
Show Gist options
  • Save bnjbvr/2aa99d0e3bd66f5759fa to your computer and use it in GitHub Desktop.
Save bnjbvr/2aa99d0e3bd66f5759fa to your computer and use it in GitHub Desktop.
static bool add (JSContext *cx, unsigned argc, jsval *vp){
JS::CallArgs args = CallArgsFromVp(argc, vp);
std::cout<<(args[0].toInt32()+args[1].toInt32());
RootedFunction func(cx, JS_ValueToFunction(cx, args[2]));
// JSFunction* function;
JS::RootedValue rval(cx);
JS::RootedObject global(cx, JS::CurrentGlobalOrNull(cx));
JS_CallFunction(cx, global, &func, 0, nullptr, &rval);
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment