How Can I Include Another Js File File In Today's V8?
Solution 1:
I don't know how to pass to function Include, should I just add this before
const Arguments& args
?
No, you can't modify the signature of functions that will be called from JS, but you don't need to: FunctionCallbackInfo
(which is the replacement for Arguments
) has a GetIsolate()
method.
Script::Compile
takes aContext
object as parameter now
Since you're having a question about this, I'm guessing you're only using a single Context for everything. Just store it in a v8::Persistent
, and create a v8::Local
from it whenever you need it. (For the time being, you can also use the deprecated Isolate::GetCurrentContext()
, but for newly written code I would advise against that, as you'd only create more work for yourself in the future when you have to migrate away from it.)
I don't know where to put the last two line codes
Wherever you're setting up the global object, somewhere in the startup sequence of your app.
All of these questions (and more) could be answered by studying the "shell" sample app that the V8 project maintains: https://chromium.googlesource.com/v8/v8/+/master/samples/shell.cc.
In particular, its Load
function does pretty much what you want.
Post a Comment for "How Can I Include Another Js File File In Today's V8?"