Commit 56c7a053 authored by epertoso's avatar epertoso Committed by Commit bot

Revert changes introduced in http://crrev.com/1367953002.

This CL is in preparation for the API change introduced in http://crrev.com/1407313004.

BUG=

Review URL: https://codereview.chromium.org/1434693008

Cr-Commit-Position: refs/heads/master@{#31930}
parent 1b535ca0
......@@ -4084,13 +4084,6 @@ class V8_EXPORT Template : public Data {
PropertyAttribute attribute = None,
AccessControl settings = DEFAULT);
#ifdef V8_JS_ACCESSORS
void SetAccessorProperty(Local<Name> name,
Local<Function> getter = Local<Function>(),
Local<Function> setter = Local<Function>(),
PropertyAttribute attribute = None);
#endif // V8_JS_ACCESSORS
/**
* Whenever the property with the given name is accessed on objects
* created from this Template the getter and setter callbacks
......
......@@ -37,25 +37,6 @@ MaybeHandle<Object> Instantiate(Isolate* isolate, Handle<Object> data,
}
MaybeHandle<JSFunction> InstantiateFunctionOrMaybeDont(Isolate* isolate,
Handle<Object> data) {
DCHECK(data->IsFunctionTemplateInfo() || data->IsJSFunction());
if (data->IsFunctionTemplateInfo()) {
// A function template needs to be instantiated.
return InstantiateFunction(isolate,
Handle<FunctionTemplateInfo>::cast(data));
#ifdef V8_JS_ACCESSORS
} else if (data->IsJSFunction()) {
// If we already have a proper function, we do not need additional work.
// (This should only happen for JavaScript API accessors.)
return Handle<JSFunction>::cast(data);
#endif // V8_JS_ACCESSORS
} else {
UNREACHABLE();
return MaybeHandle<JSFunction>();
}
}
MaybeHandle<Object> DefineAccessorProperty(Isolate* isolate,
Handle<JSObject> object,
Handle<Name> name,
......@@ -63,14 +44,18 @@ MaybeHandle<Object> DefineAccessorProperty(Isolate* isolate,
Handle<Object> setter,
PropertyAttributes attributes) {
if (!getter->IsUndefined()) {
ASSIGN_RETURN_ON_EXCEPTION(isolate, getter,
InstantiateFunctionOrMaybeDont(isolate, getter),
Object);
ASSIGN_RETURN_ON_EXCEPTION(
isolate, getter,
InstantiateFunction(isolate,
Handle<FunctionTemplateInfo>::cast(getter)),
Object);
}
if (!setter->IsUndefined()) {
ASSIGN_RETURN_ON_EXCEPTION(isolate, setter,
InstantiateFunctionOrMaybeDont(isolate, setter),
Object);
ASSIGN_RETURN_ON_EXCEPTION(
isolate, setter,
InstantiateFunction(isolate,
Handle<FunctionTemplateInfo>::cast(setter)),
Object);
}
RETURN_ON_EXCEPTION(isolate, JSObject::DefineAccessor(object, name, getter,
setter, attributes),
......@@ -425,19 +410,10 @@ void ApiNatives::AddDataProperty(Isolate* isolate, Handle<TemplateInfo> info,
void ApiNatives::AddAccessorProperty(Isolate* isolate,
Handle<TemplateInfo> info,
Handle<Name> name, Handle<Object> getter,
Handle<Object> setter,
Handle<Name> name,
Handle<FunctionTemplateInfo> getter,
Handle<FunctionTemplateInfo> setter,
PropertyAttributes attributes) {
#ifdef V8_JS_ACCESSORS
DCHECK(getter.is_null() || getter->IsFunctionTemplateInfo() ||
getter->IsJSFunction());
DCHECK(setter.is_null() || setter->IsFunctionTemplateInfo() ||
setter->IsJSFunction());
#else
DCHECK(getter.is_null() || getter->IsFunctionTemplateInfo());
DCHECK(setter.is_null() || setter->IsFunctionTemplateInfo());
#endif // V8_JS_ACCESSORS
const int kSize = 4;
PropertyDetails details(attributes, ACCESSOR, 0, PropertyCellType::kNoCell);
auto details_handle = handle(details.AsSmi(), isolate);
......
......@@ -49,8 +49,9 @@ class ApiNatives {
PropertyAttributes attributes);
static void AddAccessorProperty(Isolate* isolate, Handle<TemplateInfo> info,
Handle<Name> name, Handle<Object> getter,
Handle<Object> setter,
Handle<Name> name,
Handle<FunctionTemplateInfo> getter,
Handle<FunctionTemplateInfo> setter,
PropertyAttributes attributes);
static void AddNativeDataProperty(Isolate* isolate, Handle<TemplateInfo> info,
......
......@@ -957,25 +957,6 @@ void Template::SetAccessorProperty(
}
#ifdef V8_JS_ACCESSORS
void Template::SetAccessorProperty(v8::Local<v8::Name> name,
v8::Local<Function> getter,
v8::Local<Function> setter,
v8::PropertyAttribute attribute) {
auto templ = Utils::OpenHandle(this);
auto isolate = templ->GetIsolate();
ENTER_V8(isolate);
DCHECK(!name.IsEmpty());
DCHECK(!getter.IsEmpty() || !setter.IsEmpty());
i::HandleScope scope(isolate);
i::ApiNatives::AddAccessorProperty(
isolate, templ, Utils::OpenHandle(*name),
Utils::OpenHandle(*getter, true), Utils::OpenHandle(*setter, true),
static_cast<PropertyAttributes>(attribute));
}
#endif // V8_JS_ACCESSORS
// --- F u n c t i o n T e m p l a t e ---
static void InitializeFunctionTemplate(
i::Handle<i::FunctionTemplateInfo> info) {
......
......@@ -100,7 +100,9 @@
'test-alloc.cc',
'test-api.cc',
'test-api.h',
'test-api-accessors.cc',
# TODO(epertoso): re-enable the following test after the API change is
# checked in.
# 'test-api-accessors.cc',
'test-api-interceptors.cc',
'test-array-list.cc',
'test-ast.cc',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment