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

Unified Diff: src/runtime.cc

Issue 22903012: js accessor creation on Template (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 4 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
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index f6da37176bdf19ad127de7a99e805931619d9c4d..1e1570f7db297009f90d188e23d853e3b8f74d54 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -1944,6 +1944,43 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_EnableAccessChecks) {
}
+RUNTIME_FUNCTION(MaybeObject*, Runtime_DefineJsAccessor) {
+ HandleScope scope(isolate);
+ ASSERT(args.length() == 3);
+ CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
+ CONVERT_ARG_HANDLE_CHECKED(Object, array_object, 1);
+ CONVERT_SMI_ARG_CHECKED(offset, 2);
+ // Order of array contents is determined in Template::SetAccessor.
+ NeanderArray array(array_object);
+ Handle<String> name(String::cast(array.get(offset++)), isolate);
+ Handle<Object> getter(array.get(offset++), isolate);
+ Handle<Object> setter(array.get(offset++), isolate);
+ v8::AccessControl access_control =
+ static_cast<v8::AccessControl>(Smi::cast(array.get(offset++))->value());
+ PropertyAttributes attributes =
+ static_cast<PropertyAttributes>(Smi::cast(array.get(offset++))->value());
+ // Transform getter into something DefineAccessor can handle.
+ if (getter->IsUndefined()) {
+ getter = isolate->factory()->null_value();
+ } else {
+ Handle<FunctionTemplateInfo> info =
+ Handle<FunctionTemplateInfo>::cast(getter);
+ getter = Utils::OpenHandle(*Utils::ToLocal(info)->GetFunction());
+ }
+ // Transform getter into something DefineAccessor can handle.
+ if (setter->IsUndefined()) {
+ setter = isolate->factory()->null_value();
+ } else {
+ Handle<FunctionTemplateInfo> info =
+ Handle<FunctionTemplateInfo>::cast(setter);
+ setter = Utils::OpenHandle(*Utils::ToLocal(info)->GetFunction());
+ }
+ JSObject::DefineAccessor(
+ object, name, getter, setter, attributes, access_control);
+ return isolate->heap()->undefined_value();
+}
+
+
static Failure* ThrowRedeclarationError(Isolate* isolate,
const char* type,
Handle<String> name) {
« src/objects-inl.h ('K') | « src/runtime.h ('k') | test/cctest/test-accessors.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698