Commit 6130b025 authored by dcarney's avatar dcarney Committed by Commit bot

convert more object functions to return maybes

R=svenpanne@chromium.org

BUG=v8:3929
LOG=y

Review URL: https://codereview.chromium.org/972623003

Cr-Commit-Position: refs/heads/master@{#26952}
parent a3465838
...@@ -2587,6 +2587,7 @@ class V8_EXPORT Object : public Value { ...@@ -2587,6 +2587,7 @@ class V8_EXPORT Object : public Value {
* Note: Private properties are inherited. Do not rely on this, since it may * Note: Private properties are inherited. Do not rely on this, since it may
* change. * change.
*/ */
// TODO(dcarney): convert these or remove?
bool HasPrivate(Handle<Private> key); bool HasPrivate(Handle<Private> key);
bool SetPrivate(Handle<Private> key, Handle<Value> value); bool SetPrivate(Handle<Private> key, Handle<Value> value);
bool DeletePrivate(Handle<Private> key); bool DeletePrivate(Handle<Private> key);
...@@ -2598,14 +2599,18 @@ class V8_EXPORT Object : public Value { ...@@ -2598,14 +2599,18 @@ class V8_EXPORT Object : public Value {
* array returned by this method contains the same values as would * array returned by this method contains the same values as would
* be enumerated by a for-in statement over this object. * be enumerated by a for-in statement over this object.
*/ */
// TODO(dcarney): deprecate
Local<Array> GetPropertyNames(); Local<Array> GetPropertyNames();
MaybeLocal<Array> GetPropertyNames(Local<Context> context);
/** /**
* This function has the same functionality as GetPropertyNames but * This function has the same functionality as GetPropertyNames but
* the returned array doesn't contain the names of properties from * the returned array doesn't contain the names of properties from
* prototype objects. * prototype objects.
*/ */
// TODO(dcarney): deprecate
Local<Array> GetOwnPropertyNames(); Local<Array> GetOwnPropertyNames();
MaybeLocal<Array> GetOwnPropertyNames(Local<Context> context);
/** /**
* Get the prototype object. This does not skip objects marked to * Get the prototype object. This does not skip objects marked to
...@@ -2619,7 +2624,9 @@ class V8_EXPORT Object : public Value { ...@@ -2619,7 +2624,9 @@ class V8_EXPORT Object : public Value {
* be skipped by __proto__ and it does not consult the security * be skipped by __proto__ and it does not consult the security
* handler. * handler.
*/ */
// TODO(dcarney): deprecate
bool SetPrototype(Handle<Value> prototype); bool SetPrototype(Handle<Value> prototype);
Maybe<bool> SetPrototype(Local<Context> context, Local<Value> prototype);
/** /**
* Finds an instance of the given function template in the prototype * Finds an instance of the given function template in the prototype
...@@ -2632,6 +2639,7 @@ class V8_EXPORT Object : public Value { ...@@ -2632,6 +2639,7 @@ class V8_EXPORT Object : public Value {
* This is different from Value::ToString() that may call * This is different from Value::ToString() that may call
* user-defined toString function. This one does not. * user-defined toString function. This one does not.
*/ */
// TODO(dcarney): convert this - needs recursion currently.
Local<String> ObjectProtoToString(); Local<String> ObjectProtoToString();
/** /**
...@@ -2675,38 +2683,59 @@ class V8_EXPORT Object : public Value { ...@@ -2675,38 +2683,59 @@ class V8_EXPORT Object : public Value {
void SetAlignedPointerInInternalField(int index, void* value); void SetAlignedPointerInInternalField(int index, void* value);
// Testers for local properties. // Testers for local properties.
// TODO(dcarney): deprecate
bool HasOwnProperty(Handle<String> key); bool HasOwnProperty(Handle<String> key);
Maybe<bool> HasOwnProperty(Local<Context> context, Local<Name> key);
// TODO(dcarney): deprecate
bool HasRealNamedProperty(Handle<String> key); bool HasRealNamedProperty(Handle<String> key);
Maybe<bool> HasRealNamedProperty(Local<Context> context, Local<Name> key);
// TODO(dcarney): deprecate
bool HasRealIndexedProperty(uint32_t index); bool HasRealIndexedProperty(uint32_t index);
Maybe<bool> HasRealIndexedProperty(Local<Context> context, uint32_t index);
// TODO(dcarney): deprecate
bool HasRealNamedCallbackProperty(Handle<String> key); bool HasRealNamedCallbackProperty(Handle<String> key);
Maybe<bool> HasRealNamedCallbackProperty(Local<Context> context,
Local<Name> key);
/** /**
* If result.IsEmpty() no real property was located in the prototype chain. * If result.IsEmpty() no real property was located in the prototype chain.
* This means interceptors in the prototype chain are not called. * This means interceptors in the prototype chain are not called.
*/ */
// TODO(dcarney): deprecate
Local<Value> GetRealNamedPropertyInPrototypeChain(Handle<String> key); Local<Value> GetRealNamedPropertyInPrototypeChain(Handle<String> key);
MaybeLocal<Value> GetRealNamedPropertyInPrototypeChain(Local<Context> context,
Local<Name> key);
/** /**
* Gets the property attributes of a real property in the prototype chain, * Gets the property attributes of a real property in the prototype chain,
* which can be None or any combination of ReadOnly, DontEnum and DontDelete. * which can be None or any combination of ReadOnly, DontEnum and DontDelete.
* Interceptors in the prototype chain are not called. * Interceptors in the prototype chain are not called.
*/ */
// TODO(dcarney): deprecate
Maybe<PropertyAttribute> GetRealNamedPropertyAttributesInPrototypeChain( Maybe<PropertyAttribute> GetRealNamedPropertyAttributesInPrototypeChain(
Handle<String> key); Handle<String> key);
Maybe<PropertyAttribute> GetRealNamedPropertyAttributesInPrototypeChain(
Local<Context> context, Local<Name> key);
/** /**
* If result.IsEmpty() no real property was located on the object or * If result.IsEmpty() no real property was located on the object or
* in the prototype chain. * in the prototype chain.
* This means interceptors in the prototype chain are not called. * This means interceptors in the prototype chain are not called.
*/ */
// TODO(dcarney): deprecate
Local<Value> GetRealNamedProperty(Handle<String> key); Local<Value> GetRealNamedProperty(Handle<String> key);
MaybeLocal<Value> GetRealNamedProperty(Local<Context> context,
Local<Name> key);
/** /**
* Gets the property attributes of a real property which can be * Gets the property attributes of a real property which can be
* None or any combination of ReadOnly, DontEnum and DontDelete. * None or any combination of ReadOnly, DontEnum and DontDelete.
* Interceptors in the prototype chain are not called. * Interceptors in the prototype chain are not called.
*/ */
// TODO(dcarney): deprecate
Maybe<PropertyAttribute> GetRealNamedPropertyAttributes(Handle<String> key); Maybe<PropertyAttribute> GetRealNamedPropertyAttributes(Handle<String> key);
Maybe<PropertyAttribute> GetRealNamedPropertyAttributes(
Local<Context> context, Local<Name> key);
/** Tests for a named lookup interceptor.*/ /** Tests for a named lookup interceptor.*/
bool HasNamedLookupInterceptor(); bool HasNamedLookupInterceptor();
...@@ -2719,6 +2748,7 @@ class V8_EXPORT Object : public Value { ...@@ -2719,6 +2748,7 @@ class V8_EXPORT Object : public Value {
* a template that has access check callbacks. If an object has no * a template that has access check callbacks. If an object has no
* access check info, the object cannot be accessed by anyone. * access check info, the object cannot be accessed by anyone.
*/ */
// TODO(dcarney): deprecate
void TurnOnAccessCheck(); void TurnOnAccessCheck();
/** /**
...@@ -2736,6 +2766,7 @@ class V8_EXPORT Object : public Value { ...@@ -2736,6 +2766,7 @@ class V8_EXPORT Object : public Value {
* C++ API. Hidden properties introduced by V8 internally (for example the * C++ API. Hidden properties introduced by V8 internally (for example the
* identity hash) are prefixed with "v8::". * identity hash) are prefixed with "v8::".
*/ */
// TODO(dcarney): convert these?
bool SetHiddenValue(Handle<String> key, Handle<Value> value); bool SetHiddenValue(Handle<String> key, Handle<Value> value);
Local<Value> GetHiddenValue(Handle<String> key); Local<Value> GetHiddenValue(Handle<String> key);
bool DeleteHiddenValue(Handle<String> key); bool DeleteHiddenValue(Handle<String> key);
...@@ -2744,6 +2775,7 @@ class V8_EXPORT Object : public Value { ...@@ -2744,6 +2775,7 @@ class V8_EXPORT Object : public Value {
* Clone this object with a fast but shallow copy. Values will point * Clone this object with a fast but shallow copy. Values will point
* to the same values as the original object. * to the same values as the original object.
*/ */
// TODO(dcarney): convert this?
Local<Object> Clone(); Local<Object> Clone();
/** /**
......
...@@ -3481,43 +3481,40 @@ Local<Value> v8::Object::GetOwnPropertyDescriptor(Local<String> key) { ...@@ -3481,43 +3481,40 @@ Local<Value> v8::Object::GetOwnPropertyDescriptor(Local<String> key) {
Local<Value> v8::Object::GetPrototype() { Local<Value> v8::Object::GetPrototype() {
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); auto isolate = Utils::OpenHandle(this)->GetIsolate();
ON_BAILOUT(isolate, "v8::Object::GetPrototype()", return Local<v8::Value>()); auto self = Utils::OpenHandle(this);
ENTER_V8(isolate);
i::Handle<i::Object> self = Utils::OpenHandle(this);
i::PrototypeIterator iter(isolate, self); i::PrototypeIterator iter(isolate, self);
return Utils::ToLocal(i::PrototypeIterator::GetCurrent(iter)); return Utils::ToLocal(i::PrototypeIterator::GetCurrent(iter));
} }
bool v8::Object::SetPrototype(Handle<Value> value) { Maybe<bool> v8::Object::SetPrototype(Local<Context> context,
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); Local<Value> value) {
ON_BAILOUT(isolate, "v8::Object::SetPrototype()", return false); PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::SetPrototype()", bool);
ENTER_V8(isolate); auto self = Utils::OpenHandle(this);
i::Handle<i::JSObject> self = Utils::OpenHandle(this); auto value_obj = Utils::OpenHandle(*value);
i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
// We do not allow exceptions thrown while setting the prototype // We do not allow exceptions thrown while setting the prototype
// to propagate outside. // to propagate outside.
TryCatch try_catch; TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate));
EXCEPTION_PREAMBLE(isolate); auto result = i::JSObject::SetPrototype(self, value_obj, false);
i::MaybeHandle<i::Object> result =
i::JSObject::SetPrototype(self, value_obj, false);
has_pending_exception = result.is_null(); has_pending_exception = result.is_null();
EXCEPTION_BAILOUT_CHECK(isolate, false); RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
return true; return Just(true);
}
bool v8::Object::SetPrototype(Handle<Value> value) {
auto context = ContextFromHeapObject(Utils::OpenHandle(this));
return SetPrototype(context, value).FromMaybe(false);
} }
Local<Object> v8::Object::FindInstanceInPrototypeChain( Local<Object> v8::Object::FindInstanceInPrototypeChain(
v8::Handle<FunctionTemplate> tmpl) { v8::Handle<FunctionTemplate> tmpl) {
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); auto isolate = Utils::OpenHandle(this)->GetIsolate();
ON_BAILOUT(isolate,
"v8::Object::FindInstanceInPrototypeChain()",
return Local<v8::Object>());
ENTER_V8(isolate);
i::PrototypeIterator iter(isolate, *Utils::OpenHandle(this), i::PrototypeIterator iter(isolate, *Utils::OpenHandle(this),
i::PrototypeIterator::START_AT_RECEIVER); i::PrototypeIterator::START_AT_RECEIVER);
i::FunctionTemplateInfo* tmpl_info = *Utils::OpenHandle(*tmpl); auto tmpl_info = *Utils::OpenHandle(*tmpl);
while (!tmpl_info->IsTemplateFor(iter.GetCurrent())) { while (!tmpl_info->IsTemplateFor(iter.GetCurrent())) {
iter.Advance(); iter.Advance();
if (iter.IsAtEnd()) { if (iter.IsAtEnd()) {
...@@ -3529,47 +3526,47 @@ Local<Object> v8::Object::FindInstanceInPrototypeChain( ...@@ -3529,47 +3526,47 @@ Local<Object> v8::Object::FindInstanceInPrototypeChain(
} }
Local<Array> v8::Object::GetPropertyNames() { MaybeLocal<Array> v8::Object::GetPropertyNames(Local<Context> context) {
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); PREPARE_FOR_EXECUTION(context, "v8::Object::GetPropertyNames()", Array);
ON_BAILOUT(isolate, "v8::Object::GetPropertyNames()", auto self = Utils::OpenHandle(this);
return Local<v8::Array>());
ENTER_V8(isolate);
i::HandleScope scope(isolate);
i::Handle<i::JSObject> self = Utils::OpenHandle(this);
EXCEPTION_PREAMBLE(isolate);
i::Handle<i::FixedArray> value; i::Handle<i::FixedArray> value;
has_pending_exception = !i::JSReceiver::GetKeys( has_pending_exception = !i::JSReceiver::GetKeys(
self, i::JSReceiver::INCLUDE_PROTOS).ToHandle(&value); self, i::JSReceiver::INCLUDE_PROTOS).ToHandle(&value);
EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Array>()); RETURN_ON_FAILED_EXECUTION(Array);
// Because we use caching to speed up enumeration it is important // Because we use caching to speed up enumeration it is important
// to never change the result of the basic enumeration function so // to never change the result of the basic enumeration function so
// we clone the result. // we clone the result.
i::Handle<i::FixedArray> elms = isolate->factory()->CopyFixedArray(value); auto elms = isolate->factory()->CopyFixedArray(value);
i::Handle<i::JSArray> result = auto result = isolate->factory()->NewJSArrayWithElements(elms);
isolate->factory()->NewJSArrayWithElements(elms); RETURN_ESCAPED(Utils::ToLocal(result));
return Utils::ToLocal(scope.CloseAndEscape(result));
} }
Local<Array> v8::Object::GetOwnPropertyNames() { Local<Array> v8::Object::GetPropertyNames() {
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); auto context = ContextFromHeapObject(Utils::OpenHandle(this));
ON_BAILOUT(isolate, "v8::Object::GetOwnPropertyNames()", RETURN_TO_LOCAL_UNCHECKED(GetPropertyNames(context), Array);
return Local<v8::Array>()); }
ENTER_V8(isolate);
i::HandleScope scope(isolate);
i::Handle<i::JSObject> self = Utils::OpenHandle(this); MaybeLocal<Array> v8::Object::GetOwnPropertyNames(Local<Context> context) {
EXCEPTION_PREAMBLE(isolate); PREPARE_FOR_EXECUTION(context, "v8::Object::GetOwnPropertyNames()", Array);
auto self = Utils::OpenHandle(this);
i::Handle<i::FixedArray> value; i::Handle<i::FixedArray> value;
has_pending_exception = !i::JSReceiver::GetKeys( has_pending_exception = !i::JSReceiver::GetKeys(
self, i::JSReceiver::OWN_ONLY).ToHandle(&value); self, i::JSReceiver::OWN_ONLY).ToHandle(&value);
EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Array>()); RETURN_ON_FAILED_EXECUTION(Array);
// Because we use caching to speed up enumeration it is important // Because we use caching to speed up enumeration it is important
// to never change the result of the basic enumeration function so // to never change the result of the basic enumeration function so
// we clone the result. // we clone the result.
i::Handle<i::FixedArray> elms = isolate->factory()->CopyFixedArray(value); auto elms = isolate->factory()->CopyFixedArray(value);
i::Handle<i::JSArray> result = auto result = isolate->factory()->NewJSArrayWithElements(elms);
isolate->factory()->NewJSArrayWithElements(elms); RETURN_ESCAPED(Utils::ToLocal(result));
return Utils::ToLocal(scope.CloseAndEscape(result)); }
Local<Array> v8::Object::GetOwnPropertyNames() {
auto context = ContextFromHeapObject(Utils::OpenHandle(this));
RETURN_TO_LOCAL_UNCHECKED(GetOwnPropertyNames(context), Array);
} }
...@@ -3821,157 +3818,197 @@ void Object::SetAccessorProperty(Local<Name> name, ...@@ -3821,157 +3818,197 @@ void Object::SetAccessorProperty(Local<Name> name,
} }
Maybe<bool> v8::Object::HasOwnProperty(Local<Context> context,
Local<Name> key) {
PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::HasOwnProperty()",
bool);
auto self = Utils::OpenHandle(this);
auto key_val = Utils::OpenHandle(*key);
auto result = i::JSReceiver::HasOwnProperty(self, key_val);
has_pending_exception = result.IsNothing();
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
return result;
}
bool v8::Object::HasOwnProperty(Handle<String> key) { bool v8::Object::HasOwnProperty(Handle<String> key) {
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); auto context = ContextFromHeapObject(Utils::OpenHandle(this));
ON_BAILOUT(isolate, "v8::Object::HasOwnProperty()", return HasOwnProperty(context, key).FromMaybe(false);
return false); }
EXCEPTION_PREAMBLE(isolate);
Maybe<bool> maybe = i::JSReceiver::HasOwnProperty(Utils::OpenHandle(this),
Utils::OpenHandle(*key)); Maybe<bool> v8::Object::HasRealNamedProperty(Local<Context> context,
has_pending_exception = !maybe.IsJust(); Local<Name> key) {
EXCEPTION_BAILOUT_CHECK(isolate, false); PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::HasRealNamedProperty()",
return maybe.FromJust(); bool);
auto self = Utils::OpenHandle(this);
auto key_val = Utils::OpenHandle(*key);
auto result = i::JSObject::HasRealNamedProperty(self, key_val);
has_pending_exception = result.IsNothing();
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
return result;
} }
bool v8::Object::HasRealNamedProperty(Handle<String> key) { bool v8::Object::HasRealNamedProperty(Handle<String> key) {
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); auto context = ContextFromHeapObject(Utils::OpenHandle(this));
ON_BAILOUT(isolate, "v8::Object::HasRealNamedProperty()", return HasRealNamedProperty(context, key).FromMaybe(false);
return false); }
EXCEPTION_PREAMBLE(isolate);
Maybe<bool> maybe = i::JSObject::HasRealNamedProperty(
Utils::OpenHandle(this), Utils::OpenHandle(*key)); Maybe<bool> v8::Object::HasRealIndexedProperty(Local<Context> context,
has_pending_exception = !maybe.IsJust(); uint32_t index) {
EXCEPTION_BAILOUT_CHECK(isolate, false); PREPARE_FOR_EXECUTION_PRIMITIVE(context,
return maybe.FromJust(); "v8::Object::HasRealIndexedProperty()", bool);
auto self = Utils::OpenHandle(this);
auto result = i::JSObject::HasRealElementProperty(self, index);
has_pending_exception = result.IsNothing();
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
return result;
} }
bool v8::Object::HasRealIndexedProperty(uint32_t index) { bool v8::Object::HasRealIndexedProperty(uint32_t index) {
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); auto context = ContextFromHeapObject(Utils::OpenHandle(this));
ON_BAILOUT(isolate, "v8::Object::HasRealIndexedProperty()", return HasRealIndexedProperty(context, index).FromMaybe(false);
return false); }
EXCEPTION_PREAMBLE(isolate);
Maybe<bool> maybe =
i::JSObject::HasRealElementProperty(Utils::OpenHandle(this), index); Maybe<bool> v8::Object::HasRealNamedCallbackProperty(Local<Context> context,
has_pending_exception = !maybe.IsJust(); Local<Name> key) {
EXCEPTION_BAILOUT_CHECK(isolate, false); PREPARE_FOR_EXECUTION_PRIMITIVE(
return maybe.FromJust(); context, "v8::Object::HasRealNamedCallbackProperty()", bool);
auto self = Utils::OpenHandle(this);
auto key_val = Utils::OpenHandle(*key);
auto result = i::JSObject::HasRealNamedCallbackProperty(self, key_val);
has_pending_exception = result.IsNothing();
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
return result;
} }
bool v8::Object::HasRealNamedCallbackProperty(Handle<String> key) { bool v8::Object::HasRealNamedCallbackProperty(Handle<String> key) {
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); auto context = ContextFromHeapObject(Utils::OpenHandle(this));
ON_BAILOUT(isolate, return HasRealNamedCallbackProperty(context, key).FromMaybe(false);
"v8::Object::HasRealNamedCallbackProperty()",
return false);
ENTER_V8(isolate);
EXCEPTION_PREAMBLE(isolate);
Maybe<bool> maybe = i::JSObject::HasRealNamedCallbackProperty(
Utils::OpenHandle(this), Utils::OpenHandle(*key));
has_pending_exception = !maybe.IsJust();
EXCEPTION_BAILOUT_CHECK(isolate, false);
return maybe.FromJust();
} }
bool v8::Object::HasNamedLookupInterceptor() { bool v8::Object::HasNamedLookupInterceptor() {
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); auto self = Utils::OpenHandle(this);
ON_BAILOUT(isolate, "v8::Object::HasNamedLookupInterceptor()", return self->HasNamedInterceptor();
return false);
return Utils::OpenHandle(this)->HasNamedInterceptor();
} }
bool v8::Object::HasIndexedLookupInterceptor() { bool v8::Object::HasIndexedLookupInterceptor() {
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); auto self = Utils::OpenHandle(this);
ON_BAILOUT(isolate, "v8::Object::HasIndexedLookupInterceptor()", return self->HasIndexedInterceptor();
return false);
return Utils::OpenHandle(this)->HasIndexedInterceptor();
} }
static Local<Value> GetPropertyByLookup(i::LookupIterator* it) { MaybeLocal<Value> v8::Object::GetRealNamedPropertyInPrototypeChain(
// If the property being looked up is a callback, it can throw an exception. Local<Context> context, Local<Name> key) {
EXCEPTION_PREAMBLE(it->isolate()); PREPARE_FOR_EXECUTION(
i::Handle<i::Object> result; context, "v8::Object::GetRealNamedPropertyInPrototypeChain()", Value);
has_pending_exception = !i::Object::GetProperty(it).ToHandle(&result); auto self = Utils::OpenHandle(this);
EXCEPTION_BAILOUT_CHECK(it->isolate(), Local<Value>()); auto key_obj = Utils::OpenHandle(*key);
i::PrototypeIterator iter(isolate, self);
if (it->IsFound()) return Utils::ToLocal(result); if (iter.IsAtEnd()) return MaybeLocal<Value>();
return Local<Value>(); auto proto = i::PrototypeIterator::GetCurrent(iter);
i::LookupIterator it(self, key_obj, i::Handle<i::JSReceiver>::cast(proto),
i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR);
if (!it.IsFound()) return MaybeLocal<Value>();
Local<Value> result;
has_pending_exception = !ToLocal<Value>(i::Object::GetProperty(&it), &result);
RETURN_ON_FAILED_EXECUTION(Value);
RETURN_ESCAPED(result);
} }
static Maybe<PropertyAttribute> GetPropertyAttributesByLookup( Local<Value> v8::Object::GetRealNamedPropertyInPrototypeChain(
i::LookupIterator* it) { Handle<String> key) {
Maybe<PropertyAttributes> attr = i::JSReceiver::GetPropertyAttributes(it); auto context = ContextFromHeapObject(Utils::OpenHandle(this));
return it->IsFound() ? Just<PropertyAttribute>( RETURN_TO_LOCAL_UNCHECKED(GetRealNamedPropertyInPrototypeChain(context, key),
static_cast<PropertyAttribute>(attr.FromJust())) Value);
: Nothing<PropertyAttribute>();
} }
Local<Value> v8::Object::GetRealNamedPropertyInPrototypeChain( Maybe<PropertyAttribute>
Handle<String> key) { v8::Object::GetRealNamedPropertyAttributesInPrototypeChain(
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); Local<Context> context, Local<Name> key) {
ON_BAILOUT(isolate, PREPARE_FOR_EXECUTION_PRIMITIVE(
"v8::Object::GetRealNamedPropertyInPrototypeChain()", context, "v8::Object::GetRealNamedPropertyAttributesInPrototypeChain()",
return Local<Value>()); PropertyAttribute);
ENTER_V8(isolate); auto self = Utils::OpenHandle(this);
i::Handle<i::JSObject> self_obj = Utils::OpenHandle(this); auto key_obj = Utils::OpenHandle(*key);
i::Handle<i::String> key_obj = Utils::OpenHandle(*key); i::PrototypeIterator iter(isolate, self);
i::PrototypeIterator iter(isolate, self_obj); if (iter.IsAtEnd()) return Nothing<PropertyAttribute>();
if (iter.IsAtEnd()) return Local<Value>(); auto proto = i::PrototypeIterator::GetCurrent(iter);
i::Handle<i::Object> proto = i::PrototypeIterator::GetCurrent(iter); i::LookupIterator it(self, key_obj, i::Handle<i::JSReceiver>::cast(proto),
i::LookupIterator it(self_obj, key_obj, i::Handle<i::JSReceiver>::cast(proto),
i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR);
return GetPropertyByLookup(&it); if (!it.IsFound()) return Nothing<PropertyAttribute>();
auto result = i::JSReceiver::GetPropertyAttributes(&it);
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(PropertyAttribute);
if (result.FromJust() == ABSENT) {
return Just(static_cast<PropertyAttribute>(NONE));
}
return Just<PropertyAttribute>(
static_cast<PropertyAttribute>(result.FromJust()));
} }
Maybe<PropertyAttribute> Maybe<PropertyAttribute>
v8::Object::GetRealNamedPropertyAttributesInPrototypeChain(Handle<String> key) { v8::Object::GetRealNamedPropertyAttributesInPrototypeChain(Handle<String> key) {
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); auto context = ContextFromHeapObject(Utils::OpenHandle(this));
ON_BAILOUT(isolate, return GetRealNamedPropertyAttributesInPrototypeChain(context, key);
"v8::Object::GetRealNamedPropertyAttributesInPrototypeChain()", }
return Nothing<PropertyAttribute>());
ENTER_V8(isolate);
i::Handle<i::JSObject> self_obj = Utils::OpenHandle(this); MaybeLocal<Value> v8::Object::GetRealNamedProperty(Local<Context> context,
i::Handle<i::String> key_obj = Utils::OpenHandle(*key); Local<Name> key) {
i::PrototypeIterator iter(isolate, self_obj); PREPARE_FOR_EXECUTION(
if (iter.IsAtEnd()) return Nothing<PropertyAttribute>(); context, "v8::Object::GetRealNamedPropertyInPrototypeChain()", Value);
i::Handle<i::Object> proto = i::PrototypeIterator::GetCurrent(iter); auto self = Utils::OpenHandle(this);
i::LookupIterator it(self_obj, key_obj, i::Handle<i::JSReceiver>::cast(proto), auto key_obj = Utils::OpenHandle(*key);
i::LookupIterator it(self, key_obj,
i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR);
return GetPropertyAttributesByLookup(&it); if (!it.IsFound()) return MaybeLocal<Value>();
Local<Value> result;
has_pending_exception = !ToLocal<Value>(i::Object::GetProperty(&it), &result);
RETURN_ON_FAILED_EXECUTION(Value);
RETURN_ESCAPED(result);
} }
Local<Value> v8::Object::GetRealNamedProperty(Handle<String> key) { Local<Value> v8::Object::GetRealNamedProperty(Handle<String> key) {
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); auto context = ContextFromHeapObject(Utils::OpenHandle(this));
ON_BAILOUT(isolate, "v8::Object::GetRealNamedProperty()", RETURN_TO_LOCAL_UNCHECKED(GetRealNamedProperty(context, key), Value);
return Local<Value>()); }
ENTER_V8(isolate);
i::Handle<i::JSObject> self_obj = Utils::OpenHandle(this);
i::Handle<i::String> key_obj = Utils::OpenHandle(*key); Maybe<PropertyAttribute> v8::Object::GetRealNamedPropertyAttributes(
i::LookupIterator it(self_obj, key_obj, Local<Context> context, Local<Name> key) {
PREPARE_FOR_EXECUTION_PRIMITIVE(
context, "v8::Object::GetRealNamedPropertyAttributes()",
PropertyAttribute);
auto self = Utils::OpenHandle(this);
auto key_obj = Utils::OpenHandle(*key);
i::LookupIterator it(self, key_obj,
i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR);
return GetPropertyByLookup(&it); if (!it.IsFound()) return Nothing<PropertyAttribute>();
auto result = i::JSReceiver::GetPropertyAttributes(&it);
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(PropertyAttribute);
if (result.FromJust() == ABSENT) {
return Just(static_cast<PropertyAttribute>(NONE));
}
return Just<PropertyAttribute>(
static_cast<PropertyAttribute>(result.FromJust()));
} }
Maybe<PropertyAttribute> v8::Object::GetRealNamedPropertyAttributes( Maybe<PropertyAttribute> v8::Object::GetRealNamedPropertyAttributes(
Handle<String> key) { Handle<String> key) {
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); auto context = ContextFromHeapObject(Utils::OpenHandle(this));
ON_BAILOUT(isolate, "v8::Object::GetRealNamedPropertyAttributes()", return GetRealNamedPropertyAttributes(context, key);
return Nothing<PropertyAttribute>());
ENTER_V8(isolate);
i::Handle<i::JSObject> self_obj = Utils::OpenHandle(this);
i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
i::LookupIterator it(self_obj, key_obj,
i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR);
return GetPropertyAttributesByLookup(&it);
} }
...@@ -3980,7 +4017,6 @@ Maybe<PropertyAttribute> v8::Object::GetRealNamedPropertyAttributes( ...@@ -3980,7 +4017,6 @@ Maybe<PropertyAttribute> v8::Object::GetRealNamedPropertyAttributes(
// the old map of this object will fail. // the old map of this object will fail.
void v8::Object::TurnOnAccessCheck() { void v8::Object::TurnOnAccessCheck() {
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
ON_BAILOUT(isolate, "v8::Object::TurnOnAccessCheck()", return);
ENTER_V8(isolate); ENTER_V8(isolate);
i::HandleScope scope(isolate); i::HandleScope scope(isolate);
i::Handle<i::JSObject> obj = Utils::OpenHandle(this); i::Handle<i::JSObject> obj = Utils::OpenHandle(this);
...@@ -4010,22 +4046,16 @@ Local<v8::Object> v8::Object::Clone() { ...@@ -4010,22 +4046,16 @@ Local<v8::Object> v8::Object::Clone() {
Local<v8::Context> v8::Object::CreationContext() { Local<v8::Context> v8::Object::CreationContext() {
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); auto self = Utils::OpenHandle(this);
ON_BAILOUT(isolate, auto context = handle(self->GetCreationContext());
"v8::Object::CreationContext()", return Local<v8::Context>()); return Utils::ToLocal(context);
ENTER_V8(isolate);
i::Handle<i::JSObject> self = Utils::OpenHandle(this);
i::Context* context = self->GetCreationContext();
return Utils::ToLocal(i::Handle<i::Context>(context));
} }
int v8::Object::GetIdentityHash() { int v8::Object::GetIdentityHash() {
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); auto isolate = Utils::OpenHandle(this)->GetIsolate();
ON_BAILOUT(isolate, "v8::Object::GetIdentityHash()", return 0);
ENTER_V8(isolate);
i::HandleScope scope(isolate); i::HandleScope scope(isolate);
i::Handle<i::JSObject> self = Utils::OpenHandle(this); auto self = Utils::OpenHandle(this);
return i::JSReceiver::GetOrCreateIdentityHash(self)->value(); return i::JSReceiver::GetOrCreateIdentityHash(self)->value();
} }
...@@ -4033,7 +4063,6 @@ int v8::Object::GetIdentityHash() { ...@@ -4033,7 +4063,6 @@ int v8::Object::GetIdentityHash() {
bool v8::Object::SetHiddenValue(v8::Handle<v8::String> key, bool v8::Object::SetHiddenValue(v8::Handle<v8::String> key,
v8::Handle<v8::Value> value) { v8::Handle<v8::Value> value) {
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
ON_BAILOUT(isolate, "v8::Object::SetHiddenValue()", return false);
if (value.IsEmpty()) return DeleteHiddenValue(key); if (value.IsEmpty()) return DeleteHiddenValue(key);
ENTER_V8(isolate); ENTER_V8(isolate);
i::HandleScope scope(isolate); i::HandleScope scope(isolate);
...@@ -4050,8 +4079,6 @@ bool v8::Object::SetHiddenValue(v8::Handle<v8::String> key, ...@@ -4050,8 +4079,6 @@ bool v8::Object::SetHiddenValue(v8::Handle<v8::String> key,
v8::Local<v8::Value> v8::Object::GetHiddenValue(v8::Handle<v8::String> key) { v8::Local<v8::Value> v8::Object::GetHiddenValue(v8::Handle<v8::String> key) {
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
ON_BAILOUT(isolate, "v8::Object::GetHiddenValue()",
return Local<v8::Value>());
ENTER_V8(isolate); ENTER_V8(isolate);
i::Handle<i::JSObject> self = Utils::OpenHandle(this); i::Handle<i::JSObject> self = Utils::OpenHandle(this);
i::Handle<i::String> key_obj = Utils::OpenHandle(*key); i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
...@@ -4065,7 +4092,6 @@ v8::Local<v8::Value> v8::Object::GetHiddenValue(v8::Handle<v8::String> key) { ...@@ -4065,7 +4092,6 @@ v8::Local<v8::Value> v8::Object::GetHiddenValue(v8::Handle<v8::String> key) {
bool v8::Object::DeleteHiddenValue(v8::Handle<v8::String> key) { bool v8::Object::DeleteHiddenValue(v8::Handle<v8::String> key) {
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
ON_BAILOUT(isolate, "v8::DeleteHiddenValue()", return false);
ENTER_V8(isolate); ENTER_V8(isolate);
i::HandleScope scope(isolate); i::HandleScope scope(isolate);
i::Handle<i::JSObject> self = Utils::OpenHandle(this); i::Handle<i::JSObject> self = Utils::OpenHandle(this);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment