Revision: 13397
Author: [email protected]
Date: Wed Jan 16 04:11:43 2013
Log: Implement Context::GetIsolate()
BUG=
TEST=test-api.cc (IsolateOfContext)
Review URL: https://codereview.chromium.org/11968011
http://code.google.com/p/v8/source/detail?r=13397
Modified:
/branches/bleeding_edge/include/v8.h
/branches/bleeding_edge/src/api.cc
/branches/bleeding_edge/test/cctest/test-api.cc
=======================================
--- /branches/bleeding_edge/include/v8.h Wed Jan 16 02:10:53 2013
+++ /branches/bleeding_edge/include/v8.h Wed Jan 16 04:11:43 2013
@@ -3796,6 +3796,9 @@
/** Returns true if V8 has a current context. */
static bool InContext();
+ /** Returns an isolate associated with a current context. */
+ v8::Isolate* GetIsolate();
+
/**
* Gets the embedder data with the given index, which must have been set
by a
* previous call to SetEmbedderData with the same index. Note that index
0
=======================================
--- /branches/bleeding_edge/src/api.cc Wed Jan 16 02:10:53 2013
+++ /branches/bleeding_edge/src/api.cc Wed Jan 16 04:11:43 2013
@@ -4680,6 +4680,12 @@
bool Context::InContext() {
return i::Isolate::Current()->context() != NULL;
}
+
+
+v8::Isolate* Context::GetIsolate() {
+ i::Handle<i::Context> env = Utils::OpenHandle(this);
+ return reinterpret_cast<Isolate*>(env->GetIsolate());
+}
v8::Local<v8::Context> Context::GetEntered() {
=======================================
--- /branches/bleeding_edge/test/cctest/test-api.cc Mon Jan 14 07:17:56 2013
+++ /branches/bleeding_edge/test/cctest/test-api.cc Wed Jan 16 04:11:43 2013
@@ -166,6 +166,23 @@
local_env->Exit();
}
+
+
+THREADED_TEST(IsolateOfContext) {
+ v8::HandleScope scope;
+ v8::Persistent<Context> env = Context::New();
+
+ CHECK(!env->InContext());
+ CHECK(env->GetIsolate() == v8::Isolate::GetCurrent());
+ env->Enter();
+ CHECK(env->InContext());
+ CHECK(env->GetIsolate() == v8::Isolate::GetCurrent());
+ env->Exit();
+ CHECK(!env->InContext());
+ CHECK(env->GetIsolate() == v8::Isolate::GetCurrent());
+
+ env.Dispose();
+}
THREADED_TEST(ReceiverSignature) {
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev