Revision: 20178
Author: dcar...@chromium.org
Date: Mon Mar 24 08:41:59 2014 UTC
Log: add setaccessorproperty to object
R=svenpa...@chromium.org
LOG=N
BUG=v8:2964
Review URL: https://codereview.chromium.org/209853002
http://code.google.com/p/v8/source/detail?r=20178
Modified:
/branches/bleeding_edge/include/v8.h
/branches/bleeding_edge/src/api.cc
/branches/bleeding_edge/test/cctest/test-api.cc
=======================================
--- /branches/bleeding_edge/include/v8.h Fri Mar 21 15:24:36 2014 UTC
+++ /branches/bleeding_edge/include/v8.h Mon Mar 24 08:41:59 2014 UTC
@@ -2205,6 +2205,12 @@
PropertyAttribute attribute = None,
AccessControl settings = DEFAULT);
+ void SetAccessorProperty(Local<String> name,
+ Local<Function> getter,
+ Handle<Function> setter = Handle<Function>(),
+ PropertyAttribute attribute = None,
+ AccessControl settings = DEFAULT);
+
/**
* Functionality for private properties.
* This is an experimental feature, use at your own risk.
=======================================
--- /branches/bleeding_edge/src/api.cc Thu Mar 20 12:27:36 2014 UTC
+++ /branches/bleeding_edge/src/api.cc Mon Mar 24 08:41:59 2014 UTC
@@ -3486,6 +3486,27 @@
return ObjectSetAccessor(
this, name, descriptor, null, null, settings, attributes);
}
+
+
+void Object::SetAccessorProperty(Local<String> name,
+ Local<Function> getter,
+ Handle<Function> setter,
+ PropertyAttribute attribute,
+ AccessControl settings) {
+ i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
+ ON_BAILOUT(isolate, "v8::Object::SetAccessorProperty()", return);
+ ENTER_V8(isolate);
+ i::HandleScope scope(isolate);
+ i::Handle<i::Object> getter_i = v8::Utils::OpenHandle(*getter);
+ i::Handle<i::Object> setter_i = v8::Utils::OpenHandle(*setter, true);
+ if (setter_i.is_null()) setter_i = isolate->factory()->null_value();
+ i::JSObject::DefineAccessor(v8::Utils::OpenHandle(this),
+ v8::Utils::OpenHandle(*name),
+ getter_i,
+ setter_i,
+ static_cast<PropertyAttributes>(attribute),
+ settings);
+}
bool v8::Object::HasOwnProperty(Handle<String> key) {
=======================================
--- /branches/bleeding_edge/test/cctest/test-api.cc Thu Mar 20 18:14:33
2014 UTC
+++ /branches/bleeding_edge/test/cctest/test-api.cc Mon Mar 24 08:41:59
2014 UTC
@@ -21961,25 +21961,6 @@
count++;
info.GetReturnValue().Set(v8_str("returned"));
}
-
- // TODO(dcarney): move this to v8.h
- static void SetAccessorProperty(Local<Object> object,
- Local<String> name,
- Local<Function> getter,
- Local<Function> setter =
Local<Function>()) {
- i::Isolate* isolate = CcTest::i_isolate();
- v8::AccessControl settings = v8::DEFAULT;
- v8::PropertyAttribute attribute = v8::None;
- i::Handle<i::Object> getter_i = v8::Utils::OpenHandle(*getter);
- i::Handle<i::Object> setter_i = v8::Utils::OpenHandle(*setter, true);
- if (setter_i.is_null()) setter_i = isolate->factory()->null_value();
- i::JSObject::DefineAccessor(v8::Utils::OpenHandle(*object),
- v8::Utils::OpenHandle(*name),
- getter_i,
- setter_i,
- static_cast<PropertyAttributes>(attribute),
- settings);
- }
public:
enum SignatureType {
@@ -22049,9 +22030,9 @@
global_holder = Local<Object>::Cast(global_holder->GetPrototype());
}
global_holder->Set(v8_str("g_f"), function);
- SetAccessorProperty(global_holder, v8_str("g_acc"), function,
function);
+ global_holder->SetAccessorProperty(v8_str("g_acc"), function,
function);
function_holder->Set(v8_str("f"), function);
- SetAccessorProperty(function_holder, v8_str("acc"), function,
function);
+ function_holder->SetAccessorProperty(v8_str("acc"), function,
function);
// Initialize expected values.
callee = function;
count = 0;
--
--
v8-dev mailing list
v8-dev@googlegroups.com
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to v8-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.