Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(607)

Unified Diff: samples/process.cc

Issue 760883002: Add interceptor support for symbols (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix test Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/v8.h ('k') | src/api.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samples/process.cc
diff --git a/samples/process.cc b/samples/process.cc
index fada73dcbdc090d122a932617ff9db8ccd970f4f..f44797066b821bddcd3e6bc70581352d08d63571 100644
--- a/samples/process.cc
+++ b/samples/process.cc
@@ -112,10 +112,8 @@ class JsHttpRequestProcessor : public HttpRequestProcessor {
const PropertyCallbackInfo<Value>& info);
// Callbacks that access maps
- static void MapGet(Local<String> name,
- const PropertyCallbackInfo<Value>& info);
- static void MapSet(Local<String> name,
- Local<Value> value,
+ static void MapGet(Local<Name> name, const PropertyCallbackInfo<Value>& info);
+ static void MapSet(Local<Name> name, Local<Value> value,
const PropertyCallbackInfo<Value>& info);
// Utility methods for wrapping C++ objects as JavaScript objects,
@@ -355,13 +353,15 @@ string ObjectToString(Local<Value> value) {
}
-void JsHttpRequestProcessor::MapGet(Local<String> name,
+void JsHttpRequestProcessor::MapGet(Local<Name> name,
const PropertyCallbackInfo<Value>& info) {
+ if (name->IsSymbol()) return;
+
// Fetch the map wrapped by this object.
map<string, string>* obj = UnwrapMap(info.Holder());
// Convert the JavaScript string to a std::string.
- string key = ObjectToString(name);
+ string key = ObjectToString(Local<String>::Cast(name));
// Look up the value if it exists using the standard STL ideom.
map<string, string>::iterator iter = obj->find(key);
@@ -377,14 +377,15 @@ void JsHttpRequestProcessor::MapGet(Local<String> name,
}
-void JsHttpRequestProcessor::MapSet(Local<String> name,
- Local<Value> value_obj,
+void JsHttpRequestProcessor::MapSet(Local<Name> name, Local<Value> value_obj,
const PropertyCallbackInfo<Value>& info) {
+ if (name->IsSymbol()) return;
+
// Fetch the map wrapped by this object.
map<string, string>* obj = UnwrapMap(info.Holder());
// Convert the key and value to std::strings.
- string key = ObjectToString(name);
+ string key = ObjectToString(Local<String>::Cast(name));
string value = ObjectToString(value_obj);
// Update the map.
@@ -401,7 +402,7 @@ Handle<ObjectTemplate> JsHttpRequestProcessor::MakeMapTemplate(
Local<ObjectTemplate> result = ObjectTemplate::New(isolate);
result->SetInternalFieldCount(1);
- result->SetNamedPropertyHandler(MapGet, MapSet);
+ result->SetHandler(NamedPropertyHandlerConfiguration(MapGet, MapSet));
// Again, return the result through the current handle scope.
return handle_scope.Escape(result);
« no previous file with comments | « include/v8.h ('k') | src/api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698