On Tuesday, April 23, 2013 6:47:51 AM UTC-7, Ben Noordhuis wrote: > > On Thu, Apr 4, 2013 at 12:47 PM, Olivier GEORGET > <[email protected] <javascript:>> wrote: > > Hi, > > > > I'm new to V8 and have only fiddled with it. > > Can someone please explain me the main difference between the Context > access > > functions ? There is actually 3 of them : > > > > v8::Context::GetCurrent(); > > v8::Context::GetEntered(); > > v8::Context::GetCalling(); > > > > Can see the purpose of GetCalling, but the 2 first ones sound the same > to > > me, and the doc is very frugal about it :S > > > > In the following code, I would at first expect context == curCtxTest : > > > >> v8::Handle<v8::Context> context = v8::Context::New(NULL, > globalObj); > >> > >> v8::Context::Scope context_scope(context); > >> v8::Handle<v8::Context> curCtxTest = v8::Context::GetCurrent(); > > > > > > Cheers, > > Olivier. > > Say you have three functions: > > * a(), compiled in context A > * b(), compiled in context B > * c(), compiled in context C > > Your native code looks like this: > > Persistent<Context> context_a = ...; > Local<Function> function_a = ...; > context_a->Enter(); > function_a->Call(context_a->Global(), 0, NULL); > context_a->Exit(); > > If a() calls b() which in turn calls c(), then the following is true in > c(): > > Context::GetCurrent() == C > Context::GetCalling() == B > Context::GetEntered() == A > > Why is that useful? I suspect that the primary use case in Chromium > is the ability to look up the right security token, depending on the > context in which a native function is called. >
Hopefully this helps the origina poster, but it confuses me. I understand why Context::GetEntered() == A since we can read context_a->Enter(); but I can't figure out why the other facts are true. jjb -- -- 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.
