On Sun, Apr 14, 2013 at 11:44 PM, Amy <[email protected]> wrote: > Hey, > > I just read though the Embedder's Guide, and taken a look inside v8.h. I am > still confused about why we need separate Context and even a context stack > (I remembered I saw it in the guide). Is that for the third-party javascript > problem? > > And what is scope for? In the hello world example, it creates a scope by > "Context::Scope context_scope(context);" but the scope is not used at all. > Why does it bother to create that?
A Context is a kind of script isolation. It's an environment for a script to run in that is separated from other Contexts (i.e. other scripts or other instances of the same script). A Context has its own set of global classes like Array, Date, etc. Every Script runs inside a Context, that is why you have to create a default one at program start. What's more, most V8 API functions can only be called when a Context is active, and that's what the Context::Scope class is for: it calls context->Enter() when it's created and context->Exit() when destroyed. -- -- 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/groups/opt_out.
