Reviewers: Mads Ager, Christian Plesner Hansen, Vitaly, Description: Add another method that allows to lookup for a real named property not only in prototype chain, but in the object itself.
Please review this at http://codereview.chromium.org/235004 SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/ Affected files: M include/v8.h M src/api.cc Index: include/v8.h =================================================================== --- include/v8.h (revision 2967) +++ include/v8.h (working copy) @@ -1207,6 +1207,13 @@ */ Handle<Value> GetRealNamedPropertyInPrototypeChain(Handle<String> key); + /** + * If result.IsEmpty() no real property was located on the object or + * in the prototype chain. + * This means interceptors in the prototype chain are not called. + */ + Handle<Value> GetRealNamedProperty(Handle<String> key); + /** Tests for a named lookup interceptor.*/ bool HasNamedLookupInterceptor(); Index: src/api.cc =================================================================== --- src/api.cc (revision 2967) +++ src/api.cc (working copy) @@ -2142,6 +2142,25 @@ } +Handle<Value> v8::Object::GetRealNamedProperty(Handle<String> key) { + ON_BAILOUT("v8::Object::GetRealNamedProperty()", return Local<Value>()); + ENTER_V8; + i::Handle<i::JSObject> self_obj = Utils::OpenHandle(this); + i::Handle<i::String> key_obj = Utils::OpenHandle(*key); + i::LookupResult lookup; + self_obj->LookupRealNamedProperty(*key_obj, &lookup); + if (lookup.IsValid()) { + PropertyAttributes attributes; + i::Handle<i::Object> result(self_obj->GetProperty(*self_obj, + &lookup, + *key_obj, + &attributes)); + return Utils::ToLocal(result); + } + return Local<Value>(); // No real property was found in prototype chain. +} + + // Turns on access checks by copying the map and setting the check flag. // Because the object gets a new map, existing inline cache caching // the old map of this object will fail. --~--~---------~--~----~------------~-------~--~----~ v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev -~----------~----~----~----~------~----~------~--~---
