Move context retrieval method around. Use delegation for implementation.
This is a refactoring of https://code.google.com/p/v8/source/detail?r=14146. Review URL: https://codereview.chromium.org/13940003 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14171 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
741ce3b1a2
commit
d04de1fe1a
@ -3036,6 +3036,9 @@ class V8EXPORT Isolate {
|
||||
*/
|
||||
CpuProfiler* GetCpuProfiler();
|
||||
|
||||
/** Returns the context that is on the top of the stack. */
|
||||
Local<Context> GetCurrentContext();
|
||||
|
||||
private:
|
||||
Isolate();
|
||||
Isolate(const Isolate&);
|
||||
@ -3890,9 +3893,9 @@ class V8EXPORT Context {
|
||||
/** Returns the last entered context. */
|
||||
static Local<Context> GetEntered();
|
||||
|
||||
/** Returns the context that is on the top of the stack. */
|
||||
// TODO(svenpanne) Actually deprecate this.
|
||||
/** Deprecated. Use Isolate::GetCurrentContext instead. */
|
||||
static Local<Context> GetCurrent();
|
||||
static Local<Context> GetCurrent(Isolate* isolate);
|
||||
|
||||
/**
|
||||
* Returns the context of the calling JavaScript code. That is the
|
||||
|
24
src/api.cc
24
src/api.cc
@ -5007,20 +5007,7 @@ v8::Local<v8::Context> Context::GetCurrent() {
|
||||
if (IsDeadCheck(isolate, "v8::Context::GetCurrent()")) {
|
||||
return Local<Context>();
|
||||
}
|
||||
i::Handle<i::Object> current = isolate->native_context();
|
||||
if (current.is_null()) return Local<Context>();
|
||||
i::Handle<i::Context> context = i::Handle<i::Context>::cast(current);
|
||||
return Utils::ToLocal(context);
|
||||
}
|
||||
|
||||
|
||||
v8::Local<v8::Context> Context::GetCurrent(Isolate* exported_isolate) {
|
||||
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(exported_isolate);
|
||||
ASSERT(isolate == i::Isolate::Current());
|
||||
i::Handle<i::Object> current = isolate->native_context();
|
||||
if (current.is_null()) return Local<Context>();
|
||||
i::Handle<i::Context> context = i::Handle<i::Context>::cast(current);
|
||||
return Utils::ToLocal(context);
|
||||
return reinterpret_cast<Isolate*>(isolate)->GetCurrentContext();
|
||||
}
|
||||
|
||||
|
||||
@ -5825,6 +5812,15 @@ CpuProfiler* Isolate::GetCpuProfiler() {
|
||||
}
|
||||
|
||||
|
||||
v8::Local<v8::Context> Isolate::GetCurrentContext() {
|
||||
i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(this);
|
||||
i::Handle<i::Object> current = internal_isolate->native_context();
|
||||
if (current.is_null()) return Local<Context>();
|
||||
i::Handle<i::Context> context = i::Handle<i::Context>::cast(current);
|
||||
return Utils::ToLocal(context);
|
||||
}
|
||||
|
||||
|
||||
void V8::SetGlobalGCPrologueCallback(GCCallback callback) {
|
||||
i::Isolate* isolate = i::Isolate::Current();
|
||||
if (IsDeadCheck(isolate, "v8::V8::SetGlobalGCPrologueCallback()")) return;
|
||||
|
@ -13410,7 +13410,7 @@ v8::Persistent<Context> calling_context2;
|
||||
static v8::Handle<Value> GetCallingContextCallback(const v8::Arguments& args) {
|
||||
ApiTestFuzzer::Fuzz();
|
||||
CHECK(Context::GetCurrent() == calling_context0);
|
||||
CHECK(Context::GetCurrent(args.GetIsolate()) == calling_context0);
|
||||
CHECK(args.GetIsolate()->GetCurrentContext() == calling_context0);
|
||||
CHECK(Context::GetCalling() == calling_context1);
|
||||
CHECK(Context::GetEntered() == calling_context2);
|
||||
return v8::Integer::New(42);
|
||||
|
Loading…
Reference in New Issue
Block a user