Chromium Code Reviews| Index: src/api.cc |
| diff --git a/src/api.cc b/src/api.cc |
| index e5bcd24bd7b7ff4238a5266ea038d3d2ad9c68e0..d6a60251b358eeff918d0281a93f1d622d7c47cf 100644 |
| --- a/src/api.cc |
| +++ b/src/api.cc |
| @@ -3867,15 +3867,27 @@ Local<Object> v8::Object::FindInstanceInPrototypeChain( |
| return Utils::ToLocal(i::handle(iter.GetCurrent<i::JSObject>(), isolate)); |
| } |
| - |
| MaybeLocal<Array> v8::Object::GetPropertyNames(Local<Context> context) { |
| + return GetPropertyNames( |
| + context, v8::KeyCollectionMode::INCLUDE_PROTOS, |
| + static_cast<v8::PropertyFilter>(ONLY_ENUMERABLE | SKIP_SYMBOLS), |
| + v8::IndexFilter::INCLUDE_INDICES); |
| +} |
| + |
| +MaybeLocal<Array> v8::Object::GetPropertyNames(Local<Context> context, |
| + KeyCollectionMode mode, |
| + PropertyFilter property_filter, |
| + IndexFilter index_filter) { |
| PREPARE_FOR_EXECUTION(context, Object, GetPropertyNames, Array); |
| auto self = Utils::OpenHandle(this); |
| i::Handle<i::FixedArray> value; |
| - has_pending_exception = !i::KeyAccumulator::GetKeys(self, i::INCLUDE_PROTOS, |
| - i::ENUMERABLE_STRINGS) |
| - .ToHandle(&value); |
| + i::KeyAccumulator accumulator( |
| + isolate, static_cast<i::KeyCollectionMode>(mode), |
|
Igor Sheludko
2016/05/27 13:53:41
We need STATIC_ASSERTs that v8::KeyCollectionMode
|
| + static_cast<i::PropertyFilter>(property_filter)); |
|
Igor Sheludko
2016/05/27 13:53:42
Same here.
|
| + accumulator.set_skip_indices(index_filter == IndexFilter::SKIP_INDICES); |
| + has_pending_exception = accumulator.CollectKeys(self, self).IsNothing(); |
| RETURN_ON_FAILED_EXECUTION(Array); |
| + value = accumulator.GetKeys(i::GetKeysConversion::CONVERT_TO_STRING); |
| DCHECK(self->map()->EnumLength() == i::kInvalidEnumCacheSentinel || |
| self->map()->EnumLength() == 0 || |
| self->map()->instance_descriptors()->GetEnumCache() != *value); |
| @@ -3901,19 +3913,8 @@ Local<Array> v8::Object::GetOwnPropertyNames() { |
| MaybeLocal<Array> v8::Object::GetOwnPropertyNames(Local<Context> context, |
| PropertyFilter filter) { |
| - PREPARE_FOR_EXECUTION(context, Object, GetOwnPropertyNames, Array); |
| - auto self = Utils::OpenHandle(this); |
| - i::Handle<i::FixedArray> value; |
| - has_pending_exception = |
| - !i::KeyAccumulator::GetKeys(self, i::OWN_ONLY, |
| - static_cast<i::PropertyFilter>(filter)) |
| - .ToHandle(&value); |
| - RETURN_ON_FAILED_EXECUTION(Array); |
| - DCHECK(self->map()->EnumLength() == i::kInvalidEnumCacheSentinel || |
| - self->map()->EnumLength() == 0 || |
| - self->map()->instance_descriptors()->GetEnumCache() != *value); |
| - auto result = isolate->factory()->NewJSArrayWithElements(value); |
| - RETURN_ESCAPED(Utils::ToLocal(result)); |
| + return GetPropertyNames(context, KeyCollectionMode::OWN_ONLY, filter, |
| + v8::IndexFilter::INCLUDE_INDICES); |
| } |
| MaybeLocal<String> v8::Object::ObjectProtoToString(Local<Context> context) { |