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

Unified Diff: samples/process.cc

Issue 467013003: Add interceptor support for symbols (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Updated to filter out non-symbol keys from for-in enumeration Created 6 years, 4 months 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 4db7eeb7b87c426f1efd8f39a54fe1b1b2993600..b0663925dcbb96ab20c72dd00086a30572736911 100644
--- a/samples/process.cc
+++ b/samples/process.cc
@@ -116,9 +116,9 @@ class JsHttpRequestProcessor : public HttpRequestProcessor {
const PropertyCallbackInfo<Value>& info);
// Callbacks that access maps
- static void MapGet(Local<String> name,
+ static void MapGet(Local<Name> name,
const PropertyCallbackInfo<Value>& info);
- static void MapSet(Local<String> name,
+ static void MapSet(Local<Name> name,
Local<Value> value,
const PropertyCallbackInfo<Value>& info);
@@ -359,13 +359,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);
@@ -381,14 +383,16 @@ void JsHttpRequestProcessor::MapGet(Local<String> name,
}
-void JsHttpRequestProcessor::MapSet(Local<String> name,
+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.
« 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