Reviewers: Søren Gjesse, Description: Exposed method for finding global context by traversing context chain to API.
Please review this at http://codereview.chromium.org/112035 SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/ Affected files: M include/v8.h M src/api.cc Index: include/v8.h =================================================================== --- include/v8.h (revision 1998) +++ include/v8.h (working copy) @@ -2227,6 +2227,9 @@ /** Returns the global object of the context. */ Local<Object> Global(); + /** Compute the global context by traversing the context chain.. */ + Local<Context> GlobalContext(); + /** * Detaches the global object from its context before * the global object can be reused to create a new context. Index: src/api.cc =================================================================== --- src/api.cc (revision 1998) +++ src/api.cc (working copy) @@ -2622,6 +2622,16 @@ } +v8::Local<v8::Context> Context::GlobalContext() { + if (IsDeadCheck("v8::Context::GlobalContext()")) return Local<v8::Context>(); + i::Object** ctx = reinterpret_cast<i::Object**>(this); + i::Handle<i::Context> context = + i::Handle<i::Context>::cast(i::Handle<i::Object>(ctx)); + i::Handle<i::Context> global_context(context->global_context()); + return Utils::ToLocal(global_context); +} + + void Context::DetachGlobal() { if (IsDeadCheck("v8::Context::DetachGlobal()")) return; ENTER_V8; --~--~---------~--~----~------------~-------~--~----~ v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev -~----------~----~----~----~------~----~------~--~---
