I'd still point to shell.cc [0].  Essentially, the Isolate based API
creates a contract such that nearly every API call is relevant to a
specific Isolate instance (Isolate::Scope).  So, creating new a global
object requires an Isolate [1][2][3].  If you want each turn of your v8
process to have a pristine global object, you'll need to go through that
process again, AFAIK.  The nodejs people may have figured out how to do
that in another manner.

As for passing parameters, I'd remind you that passing certain parameters
to v8 via v8::V8::SetFlagsFromCommandLine [4] (if you're thinking of
pulling parameters from the command line) or v8::V8::SetFlagsFromString [5]
can be useful.  To then get your parameters to your script on the JS-side,
you have several options:

1) You could add a get-function to your global object (I'm thinking of
something like getenv [6])
2) You could add them to a var or an array on your global object
3) Or you could implement them as argv/argc in a sort of crt0 [7] that
calls your predefined main or start function

1) & 2) are easy to do.  The prime example is, again, in [2].  But it's
sort of a dirty solution especially if you're looking to support things
like passing argv/argc to your script.
3) is left as an exercise for you to figure out.  FYI, I've implemented a
hybrid of 2) & 3) (did #2 because it makes it easier to debug certain
things) where I do the bare minimum in C++ and I compile in a js0 (as I
call it) as char* string that takes over and does the heavy lifting.

[0] https://github.com/v8/v8/blob/master/samples/shell.cc
[1] https://github.com/v8/v8/blob/master/samples/shell.cc#L90
[2] https://github.com/v8/v8/blob/master/samples/shell.cc#L120
[3] https://github.com/v8/v8/blob/master/samples/shell.cc#L96
[4] https://github.com/v8/v8/blob/master/include/v8.h#L5288
[5] https://github.com/v8/v8/blob/master/include/v8.h#L5283
[6] http://linux.die.net/man/3/getenv
[7] http://en.wikipedia.org/wiki/Crt0


On Mon, Nov 3, 2014 at 4:18 PM, Dimitar Dimitrov <[email protected]> wrote:

> The part with the iterations worked!
>
> It was missing the following initialisation code:
>     v8::V8::InitializeICU();
>     v8::Platform* platform = v8::platform::CreateDefaultPlatform();
>     v8::V8::InitializePlatform(platform);
>
> Now another important question, is there a way to protect the global space
> from the executed scripts while keeping React.js there?
> And what is the best way to pass parameters from C++ to the different
> scripts that are going to be executed so that those parameters can be
> easily cleared upon the next script execution?
>
> --
> --
> v8-users mailing list
> [email protected]
> http://groups.google.com/group/v8-users
> ---
> You received this message because you are subscribed to the Google Groups
> "v8-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to