I want to create two (or more) separate context scopes, and in my code be able to switch back and forth between them as necessary. I've read the "Embedder's Guide" documentation which seems to say this is possible, but I can't figure out how to do it cleanly.
For instance, I can do: v8::Handle<v8::ObjectTemplate> my_global = v8::ObjectTemplate::New(); v8::Handle<v8::ObjectTemplate> my_global_2 = v8::ObjectTemplate::New(); v8::Handle<v8::Context> my_context = v8::Context::New(NULL, engine_global); v8::Handle<v8::Context> my_context_2 = v8::Context::New(NULL, engine_global_2); v8::Context::Scope my_scope(my_context); // now, do some V8 stuff in `my_context` via `my_scope` v8::Context::Scope my_scope_2(my_context_2); // now, do some V8 stuff in `my_context_2` via `my_scope_2` ... v8::Context::Scope my_scope_again (my_context); // ** no other way to switch back?? // back to `my_context` for a little bit (via new `my_scope_again` instead of `my_scope`) v8::Context::Scope my_scope_2_again (my_context_2); // ** no other way to switch back?? // back to `my_context_2` for a little bit (via new `my_scope_2_again` instead of `my_scope_2`) See how each time I need to switch scopes, I have to declare a new variable name for the `Scope` instantiation call? I can't directly use that same call with the same name or the compiler complains about redeclaration of the variable. How can I just reuse the same unique name for each of my unique scopes? I tried: my_scope = v8::Context::Scope::New(my_context); But that didn't work, saying `New` didn't exist. -- v8-users mailing list [email protected] http://groups.google.com/group/v8-users
