Revision: 4751
Author: [email protected]
Date: Fri May 28 04:54:58 2010
Log: Make intercepted properties retrievable only by getter to be not enumerable.

Currently if there is no query callback, V8 finds out intercepted properties'
attributes using getter: if getter returns not empty handle V8 treats
such a property as property with NONE attribues which means this property
is enumerable.

However, if there is no enumerator, this property cannot be enumerated.
Thus I think we should treat such properties as not enumerable.

Drawback of this approach is now one has to implement both query and enumerator
callbacks to implement enumerable intercepted properties.

BUG=725

Review URL: http://codereview.chromium.org/2270005
http://code.google.com/p/v8/source/detail?r=4751

Modified:
 /branches/bleeding_edge/src/objects.cc
 /branches/bleeding_edge/test/cctest/test-api.cc

=======================================
--- /branches/bleeding_edge/src/objects.cc      Thu May 27 05:30:45 2010
+++ /branches/bleeding_edge/src/objects.cc      Fri May 28 04:54:58 2010
@@ -2037,7 +2037,7 @@
       VMState state(EXTERNAL);
       result = getter(v8::Utils::ToLocal(name_handle), info);
     }
-    if (!result.IsEmpty()) return NONE;
+    if (!result.IsEmpty()) return DONT_ENUM;
   }
return holder_handle->GetPropertyAttributePostInterceptor(*receiver_handle,
                                                             *name_handle,
=======================================
--- /branches/bleeding_edge/test/cctest/test-api.cc     Wed May 26 07:04:37 2010
+++ /branches/bleeding_edge/test/cctest/test-api.cc     Fri May 28 04:54:58 2010
@@ -7226,6 +7226,18 @@
   CHECK(value->IsInt32());
   CHECK_EQ(42, value->Int32Value());
 }
+
+
+THREADED_TEST(NamedPropertyHandlerGetterAttributes) {
+  v8::HandleScope scope;
+  v8::Handle<v8::FunctionTemplate> templ = v8::FunctionTemplate::New();
+ templ->InstanceTemplate()->SetNamedPropertyHandler(InterceptorLoadXICGetter);
+  LocalContext env;
+  env->Global()->Set(v8_str("obj"),
+                     templ->GetFunction()->NewInstance());
+  ExpectTrue("obj.x === 42");
+  ExpectTrue("!obj.propertyIsEnumerable('x')");
+}


 static v8::Handle<Value> ParentGetter(Local<String> name,

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to