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

Unified Diff: src/api.cc

Issue 1167473002: Also expose DefineOwnProperty (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 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 | « include/v8.h ('k') | src/v8natives.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index 9464cdfaa33c54e29758178bb4af2e97831dee63..69d2e05c041f955e2121e9dfe64a4ba7fbfd3863 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -3550,15 +3550,9 @@ Maybe<bool> v8::Object::CreateDataProperty(v8::Local<v8::Context> context,
size_t length =
i::NumberToSize(isolate, i::Handle<i::JSArray>::cast(self)->length());
if (index >= length) {
- i::Handle<i::Object> args[] = {
- self, isolate->factory()->Uint32ToString(index), value_obj};
- i::Handle<i::Object> result;
- has_pending_exception =
- !CallV8HeapFunction(isolate, "$objectDefineArrayProperty",
- isolate->factory()->undefined_value(),
- arraysize(args), args).ToHandle(&result);
- RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
- return Just(result->BooleanValue());
+ return DefineOwnProperty(
+ context, Utils::ToLocal(isolate->factory()->Uint32ToString(index)),
+ value, v8::None);
}
}
@@ -3576,6 +3570,38 @@ Maybe<bool> v8::Object::CreateDataProperty(v8::Local<v8::Context> context,
}
+Maybe<bool> v8::Object::DefineOwnProperty(v8::Local<v8::Context> context,
+ v8::Local<Name> key,
+ v8::Local<Value> value,
+ v8::PropertyAttribute attributes) {
+ PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::DefineOwnProperty()",
+ bool);
+ auto self = Utils::OpenHandle(this);
+ auto key_obj = Utils::OpenHandle(*key);
+ auto value_obj = Utils::OpenHandle(*value);
+
+ if (self->IsAccessCheckNeeded() && !isolate->MayAccess(self)) {
+ isolate->ReportFailedAccessCheck(self);
+ return Nothing<bool>();
+ }
+
+ i::Handle<i::FixedArray> desc = isolate->factory()->NewFixedArray(3);
+ desc->set(0, isolate->heap()->ToBoolean(!(attributes & v8::ReadOnly)));
+ desc->set(1, isolate->heap()->ToBoolean(!(attributes & v8::DontEnum)));
+ desc->set(2, isolate->heap()->ToBoolean(!(attributes & v8::DontDelete)));
+ i::Handle<i::JSArray> desc_array =
+ isolate->factory()->NewJSArrayWithElements(desc, i::FAST_ELEMENTS, 3);
+ i::Handle<i::Object> args[] = {self, key_obj, value_obj, desc_array};
+ i::Handle<i::Object> result;
+ has_pending_exception =
+ !CallV8HeapFunction(isolate, "$objectDefineOwnProperty",
+ isolate->factory()->undefined_value(),
+ arraysize(args), args).ToHandle(&result);
+ RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
+ return Just(result->BooleanValue());
+}
+
+
Maybe<bool> v8::Object::ForceSet(v8::Local<v8::Context> context,
v8::Local<Value> key, v8::Local<Value> value,
v8::PropertyAttribute attribs) {
« no previous file with comments | « include/v8.h ('k') | src/v8natives.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698