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

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: forgot something 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
« no previous file with comments | « src/runtime.h ('k') | test/cctest/test-accessors.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index 057e268f7ad0e6ec9f830b449b7963a5eda30934..0ce62905412f424ea1fd64ebffe8d70c8695fe72 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -1664,6 +1664,14 @@ static bool CheckAccessException(Object* callback,
(access_type == v8::ACCESS_GET && info->all_can_read()) ||
(access_type == v8::ACCESS_SET && info->all_can_write());
}
+ if (callback->IsAccessorPair()) {
+ AccessorPair* info = AccessorPair::cast(callback);
+ return
+ (access_type == v8::ACCESS_HAS &&
+ (info->all_can_read() || info->all_can_write())) ||
+ (access_type == v8::ACCESS_GET && info->all_can_read()) ||
+ (access_type == v8::ACCESS_SET && info->all_can_write());
+ }
return false;
}
@@ -1945,6 +1953,41 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_EnableAccessChecks) {
}
+RUNTIME_FUNCTION(MaybeObject*, Runtime_SetAccessorProperty) {
+ HandleScope scope(isolate);
+ ASSERT(args.length() == 6);
+ CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
+ CONVERT_ARG_HANDLE_CHECKED(Name, name, 1);
+ CONVERT_ARG_HANDLE_CHECKED(Object, getter, 2);
+ CONVERT_ARG_HANDLE_CHECKED(Object, setter, 3);
+ CONVERT_SMI_ARG_CHECKED(attribute, 4);
+ CONVERT_SMI_ARG_CHECKED(access_control, 5);
+ // Transform getter into something DefineAccessor can handle.
+ if (getter->IsUndefined()) {
Sven Panne 2013/08/22 08:52:51 Tiny nit: Can we extract this if/then/else into a
+ 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,
+ static_cast<PropertyAttributes>(attribute),
+ static_cast<v8::AccessControl>(access_control));
+ return isolate->heap()->undefined_value();
+}
+
+
static Failure* ThrowRedeclarationError(Isolate* isolate,
const char* type,
Handle<String> name) {
« no previous file with comments | « src/runtime.h ('k') | test/cctest/test-accessors.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698