Index: src/api.cc |
diff --git a/src/api.cc b/src/api.cc |
index a4c38b72c248be34fdf0be53056438aae663c9e6..1a018131e87810c5ebb22c4778b47a99a95d0cd0 100644 |
--- a/src/api.cc |
+++ b/src/api.cc |
@@ -776,18 +776,13 @@ void FunctionTemplate::SetCallHandler(InvocationCallback callback, |
} |
-void FunctionTemplate::AddInstancePropertyAccessor( |
+static i::Handle<i::AccessorInfo> MakeAccessorInfo( |
v8::Handle<String> name, |
AccessorGetter getter, |
AccessorSetter setter, |
v8::Handle<Value> data, |
v8::AccessControl settings, |
v8::PropertyAttribute attributes) { |
- if (IsDeadCheck("v8::FunctionTemplate::AddInstancePropertyAccessor()")) { |
- return; |
- } |
- ENTER_V8; |
- HandleScope scope; |
i::Handle<i::AccessorInfo> obj = i::Factory::NewAccessorInfo(); |
ASSERT(getter != NULL); |
obj->set_getter(*FromCData(getter)); |
@@ -799,7 +794,26 @@ void FunctionTemplate::AddInstancePropertyAccessor( |
if (settings & ALL_CAN_WRITE) obj->set_all_can_write(true); |
if (settings & PROHIBITS_OVERWRITING) obj->set_prohibits_overwriting(true); |
obj->set_property_attributes(static_cast<PropertyAttributes>(attributes)); |
+ return obj; |
+} |
+ |
+ |
+void FunctionTemplate::AddInstancePropertyAccessor( |
+ v8::Handle<String> name, |
+ AccessorGetter getter, |
+ AccessorSetter setter, |
+ v8::Handle<Value> data, |
+ v8::AccessControl settings, |
+ v8::PropertyAttribute attributes) { |
+ if (IsDeadCheck("v8::FunctionTemplate::AddInstancePropertyAccessor()")) { |
+ return; |
+ } |
+ ENTER_V8; |
+ HandleScope scope; |
+ i::Handle<i::AccessorInfo> obj = MakeAccessorInfo(name, |
+ getter, setter, data, |
+ settings, attributes); |
i::Handle<i::Object> list(Utils::OpenHandle(this)->property_accessors()); |
if (list->IsUndefined()) { |
list = NeanderArray().value(); |
@@ -2354,6 +2368,23 @@ bool v8::Object::Has(uint32_t index) { |
} |
+bool Object::SetAccessor(Handle<String> name, |
+ AccessorGetter getter, |
+ AccessorSetter setter, |
+ v8::Handle<Value> data, |
+ AccessControl settings, |
+ PropertyAttribute attributes) { |
+ ON_BAILOUT("v8::Object::SetAccessor()", return false); |
+ ENTER_V8; |
+ HandleScope scope; |
+ i::Handle<i::AccessorInfo> info = MakeAccessorInfo(name, |
+ getter, setter, data, |
+ settings, attributes); |
+ i::Handle<i::Object> result = i::SetAccessor(Utils::OpenHandle(this), info); |
+ return !result.is_null() && !result->IsUndefined(); |
+} |
+ |
+ |
bool v8::Object::HasRealNamedProperty(Handle<String> key) { |
ON_BAILOUT("v8::Object::HasRealNamedProperty()", return false); |
return Utils::OpenHandle(this)->HasRealNamedProperty( |