Revision: 12520
Author: [email protected]
Date: Fri Sep 14 09:13:23 2012
Log: Let the embedder store arbitrary Values via Context::SetData
In WebKit, we would like to store a void* to a data structure that contains
lots of exciting per-context data. The current API restricts us to storing
only
Strings, which is less useful.
I've also cleaned up the implementation of GetData to be less convoluted.
Review URL: https://codereview.chromium.org/10907189
Patch from Adam Barth <[email protected]>.
http://code.google.com/p/v8/source/detail?r=12520
Modified:
/branches/bleeding_edge/include/v8.h
/branches/bleeding_edge/src/api.cc
=======================================
--- /branches/bleeding_edge/include/v8.h Wed Sep 12 04:29:50 2012
+++ /branches/bleeding_edge/include/v8.h Fri Sep 14 09:13:23 2012
@@ -3718,7 +3718,7 @@
* with the debugger to provide additional information on the context
through
* the debugger API.
*/
- void SetData(Handle<String> data);
+ void SetData(Handle<Value> data);
Local<Value> GetData();
/**
=======================================
--- /branches/bleeding_edge/src/api.cc Fri Sep 14 04:43:46 2012
+++ /branches/bleeding_edge/src/api.cc Fri Sep 14 09:13:23 2012
@@ -765,7 +765,7 @@
}
-void Context::SetData(v8::Handle<String> data) {
+void Context::SetData(v8::Handle<Value> data) {
i::Handle<i::Context> env = Utils::OpenHandle(this);
i::Isolate* isolate = env->GetIsolate();
if (IsDeadCheck(isolate, "v8::Context::SetData()")) return;
@@ -781,16 +781,13 @@
i::Handle<i::Context> env = Utils::OpenHandle(this);
i::Isolate* isolate = env->GetIsolate();
if (IsDeadCheck(isolate, "v8::Context::GetData()")) {
- return v8::Local<Value>();
+ return Local<Value>();
}
- i::Object* raw_result = NULL;
ASSERT(env->IsNativeContext());
- if (env->IsNativeContext()) {
- raw_result = env->data();
- } else {
+ if (!env->IsNativeContext()) {
return Local<Value>();
}
- i::Handle<i::Object> result(raw_result, isolate);
+ i::Handle<i::Object> result(env->data(), isolate);
return Utils::ToLocal(result);
}
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev