This is my source code, i set env2 global to evn1 global, but result is "v 
= undefined".


#include <v8.h>

using namespace v8;
static inline v8::Local<v8::String> v8_str(const char* x)
{
        return v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), x);
}
static inline v8::Local<v8::Value> CompileRun(const char* source)
{
        return v8::Script::Compile(v8_str(source))->Run();
}


int main(int argc, char* argv[])
{
        v8::V8::Initialize();
        Isolate* isolate = Isolate::New();
        {
                Isolate::Scope isolate_scope(isolate);
                v8::HandleScope scope(isolate);

                v8::Handle<Context> env1 = Context::New(isolate);

                {
                        Context::Scope scope(env1);
                        env1->Global()->Set(v8_str("v"), v8_num(1));
                }


                Local<Object> global = env1->Global();
                v8::Handle<Context> env2 = Context::New(isolate, NULL, 
Handle<ObjectTemplate>(), global);
                env2->SetSecurityToken(env1->GetSecurityToken());

                {
                        Context::Scope scope(env2);
                        Local<Value> value = 
env2->Global()->Get(v8_str("v"));
                        printf("v = %s\n", *String::Utf8Value(value));
                }
        }
        isolate->Dispose();
        v8::V8::Dispose();
        return 0;
}

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
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 v8-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to