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

Unified Diff: src/accessors.cc

Issue 2397603003: [runtime] Let native setters have a return value. (Closed)
Patch Set: Ouch. Created 4 years, 2 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 | « src/accessors.h ('k') | src/api-arguments.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/accessors.cc
diff --git a/src/accessors.cc b/src/accessors.cc
index b88ebc3d7910cdd41038e5725f53bd04f67f087c..a1b685050e5be7eaee03bf37cd428fa5876cc7e8 100644
--- a/src/accessors.cc
+++ b/src/accessors.cc
@@ -19,13 +19,9 @@
namespace v8 {
namespace internal {
-
Handle<AccessorInfo> Accessors::MakeAccessor(
- Isolate* isolate,
- Handle<Name> name,
- AccessorNameGetterCallback getter,
- AccessorNameSetterCallback setter,
- PropertyAttributes attributes) {
+ Isolate* isolate, Handle<Name> name, AccessorNameGetterCallback getter,
+ AccessorNameBooleanSetterCallback setter, PropertyAttributes attributes) {
Factory* factory = isolate->factory();
Handle<AccessorInfo> info = factory->NewAccessorInfo();
info->set_property_attributes(attributes);
@@ -106,7 +102,7 @@ MUST_USE_RESULT MaybeHandle<Object> ReplaceAccessorWithDataProperty(
void Accessors::ReconfigureToDataProperty(
v8::Local<v8::Name> key, v8::Local<v8::Value> val,
- const v8::PropertyCallbackInfo<void>& info) {
+ const v8::PropertyCallbackInfo<v8::Boolean>& info) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
HandleScope scope(isolate);
Handle<Object> receiver = Utils::OpenHandle(*info.This());
@@ -116,7 +112,11 @@ void Accessors::ReconfigureToDataProperty(
Handle<Object> value = Utils::OpenHandle(*val);
MaybeHandle<Object> result =
ReplaceAccessorWithDataProperty(isolate, receiver, holder, name, value);
- if (result.is_null()) isolate->OptionalRescheduleException(false);
+ if (result.is_null()) {
+ isolate->OptionalRescheduleException(false);
+ } else {
+ info.GetReturnValue().Set(true);
+ }
}
//
@@ -158,11 +158,9 @@ void Accessors::ArrayLengthGetter(
info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(result, isolate)));
}
-
void Accessors::ArrayLengthSetter(
- v8::Local<v8::Name> name,
- v8::Local<v8::Value> val,
- const v8::PropertyCallbackInfo<void>& info) {
+ v8::Local<v8::Name> name, v8::Local<v8::Value> val,
+ const v8::PropertyCallbackInfo<v8::Boolean>& info) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
HandleScope scope(isolate);
@@ -178,17 +176,21 @@ void Accessors::ArrayLengthSetter(
JSArray::SetLength(array, length);
- if (info.ShouldThrowOnError()) {
- uint32_t actual_new_len = 0;
- CHECK(array->length()->ToArrayLength(&actual_new_len));
- // Throw TypeError if there were non-deletable elements.
- if (actual_new_len != length) {
+ uint32_t actual_new_len = 0;
+ CHECK(array->length()->ToArrayLength(&actual_new_len));
+ // Fail if there were non-deletable elements.
+ if (actual_new_len != length) {
+ if (info.ShouldThrowOnError()) {
Factory* factory = isolate->factory();
isolate->Throw(*factory->NewTypeError(
MessageTemplate::kStrictDeleteProperty,
factory->NewNumberFromUint(actual_new_len - 1), array));
isolate->OptionalRescheduleException(false);
+ } else {
+ info.GetReturnValue().Set(false);
}
+ } else {
+ info.GetReturnValue().Set(true);
}
}
@@ -223,7 +225,7 @@ void Accessors::ModuleNamespaceEntryGetter(
void Accessors::ModuleNamespaceEntrySetter(
v8::Local<v8::Name> name, v8::Local<v8::Value> val,
- const v8::PropertyCallbackInfo<void>& info) {
+ const v8::PropertyCallbackInfo<v8::Boolean>& info) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
HandleScope scope(isolate);
Factory* factory = isolate->factory();
@@ -236,7 +238,7 @@ void Accessors::ModuleNamespaceEntrySetter(
i::Object::TypeOf(isolate, holder), holder));
isolate->OptionalRescheduleException(false);
} else {
- info.GetReturnValue().Set(Utils::ToLocal(factory->ToBoolean(false)));
+ info.GetReturnValue().Set(false);
}
}
@@ -742,11 +744,9 @@ void Accessors::FunctionPrototypeGetter(
info.GetReturnValue().Set(Utils::ToLocal(result));
}
-
void Accessors::FunctionPrototypeSetter(
- v8::Local<v8::Name> name,
- v8::Local<v8::Value> val,
- const v8::PropertyCallbackInfo<void>& info) {
+ v8::Local<v8::Name> name, v8::Local<v8::Value> val,
+ const v8::PropertyCallbackInfo<v8::Boolean>& info) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
HandleScope scope(isolate);
Handle<Object> value = Utils::OpenHandle(*val);
@@ -754,6 +754,8 @@ void Accessors::FunctionPrototypeSetter(
Handle<JSFunction>::cast(Utils::OpenHandle(*info.Holder()));
if (SetFunctionPrototype(isolate, object, value).is_null()) {
isolate->OptionalRescheduleException(false);
+ } else {
+ info.GetReturnValue().Set(true);
}
}
@@ -1251,9 +1253,9 @@ void Accessors::ErrorStackGetter(
info.GetReturnValue().Set(value);
}
-void Accessors::ErrorStackSetter(v8::Local<v8::Name> name,
- v8::Local<v8::Value> val,
- const v8::PropertyCallbackInfo<void>& info) {
+void Accessors::ErrorStackSetter(
+ v8::Local<v8::Name> name, v8::Local<v8::Value> val,
+ const v8::PropertyCallbackInfo<v8::Boolean>& info) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
HandleScope scope(isolate);
Handle<JSObject> obj =
« no previous file with comments | « src/accessors.h ('k') | src/api-arguments.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698