Commit 47f9d3ed authored by verwaest@chromium.org's avatar verwaest@chromium.org

Restore DefineApiAccessorProperty

BUG=
R=ishell@chromium.org

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

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22659 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent ea31635e
...@@ -104,10 +104,10 @@ function ConfigureTemplateInstance(obj, data) { ...@@ -104,10 +104,10 @@ function ConfigureTemplateInstance(obj, data) {
// TODO(verwaest): The 5th value used to be access_control. Remove once // TODO(verwaest): The 5th value used to be access_control. Remove once
// the bindings are updated. // the bindings are updated.
var name = properties[i + 1]; var name = properties[i + 1];
var getter = Instantiate(properties[i + 2]); var getter = properties[i + 2];
var setter = Instantiate(properties[i + 3]); var setter = properties[i + 3];
var attribute = properties[i + 4]; var attribute = properties[i + 4];
%DefineAccessorPropertyUnchecked(obj, name, getter, setter, attribute); %DefineApiAccessorProperty(obj, name, getter, setter, attribute);
} else { } else {
throw "Bad properties array"; throw "Bad properties array";
} }
......
...@@ -4927,6 +4927,37 @@ static bool IsValidAccessor(Handle<Object> obj) { ...@@ -4927,6 +4927,37 @@ static bool IsValidAccessor(Handle<Object> obj) {
} }
// Transform getter or setter into something DefineAccessor can handle.
static Handle<Object> InstantiateAccessorComponent(Isolate* isolate,
Handle<Object> component) {
if (component->IsUndefined()) return isolate->factory()->null_value();
Handle<FunctionTemplateInfo> info =
Handle<FunctionTemplateInfo>::cast(component);
return Utils::OpenHandle(*Utils::ToLocal(info)->GetFunction());
}
RUNTIME_FUNCTION(Runtime_DefineApiAccessorProperty) {
HandleScope scope(isolate);
ASSERT(args.length() == 5);
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);
RUNTIME_ASSERT(getter->IsUndefined() || getter->IsFunctionTemplateInfo());
RUNTIME_ASSERT(setter->IsUndefined() || setter->IsFunctionTemplateInfo());
RUNTIME_ASSERT(PropertyDetails::AttributesField::is_valid(
static_cast<PropertyAttributes>(attribute)));
RETURN_FAILURE_ON_EXCEPTION(
isolate, JSObject::DefineAccessor(
object, name, InstantiateAccessorComponent(isolate, getter),
InstantiateAccessorComponent(isolate, setter),
static_cast<PropertyAttributes>(attribute)));
return isolate->heap()->undefined_value();
}
// Implements part of 8.12.9 DefineOwnProperty. // Implements part of 8.12.9 DefineOwnProperty.
// There are 3 cases that lead here: // There are 3 cases that lead here:
// Step 4b - define a new accessor property. // Step 4b - define a new accessor property.
......
...@@ -228,6 +228,7 @@ namespace internal { ...@@ -228,6 +228,7 @@ namespace internal {
F(AddNamedProperty, 4, 1) \ F(AddNamedProperty, 4, 1) \
F(AddPropertyForTemplate, 4, 1) \ F(AddPropertyForTemplate, 4, 1) \
F(SetProperty, 4, 1) \ F(SetProperty, 4, 1) \
F(DefineApiAccessorProperty, 5, 1) \
F(DefineDataPropertyUnchecked, 4, 1) \ F(DefineDataPropertyUnchecked, 4, 1) \
F(DefineAccessorPropertyUnchecked, 5, 1) \ F(DefineAccessorPropertyUnchecked, 5, 1) \
F(GetDataProperty, 2, 1) \ F(GetDataProperty, 2, 1) \
......
// Copyright 2014 the V8 project authors. All rights reserved. // Copyright 2014 the V8 project authors. All rights reserved.
// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY // AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY
// Flags: --allow-natives-syntax --harmony // Flags: --allow-natives-syntax --harmony
var _object = new Array(); var _array = new Array();
%EstimateNumberOfElements(_object); %EstimateNumberOfElements(_array);
...@@ -47,8 +47,8 @@ EXPAND_MACROS = [ ...@@ -47,8 +47,8 @@ EXPAND_MACROS = [
# that the parser doesn't bit-rot. Change the values as needed when you add, # that the parser doesn't bit-rot. Change the values as needed when you add,
# remove or change runtime functions, but make sure we don't lose our ability # remove or change runtime functions, but make sure we don't lose our ability
# to parse them! # to parse them!
EXPECTED_FUNCTION_COUNT = 421 EXPECTED_FUNCTION_COUNT = 422
EXPECTED_FUZZABLE_COUNT = 335 EXPECTED_FUZZABLE_COUNT = 336
EXPECTED_CCTEST_COUNT = 8 EXPECTED_CCTEST_COUNT = 8
EXPECTED_UNKNOWN_COUNT = 4 EXPECTED_UNKNOWN_COUNT = 4
EXPECTED_BUILTINS_COUNT = 815 EXPECTED_BUILTINS_COUNT = 815
...@@ -245,7 +245,7 @@ CUSTOM_KNOWN_GOOD_INPUT = { ...@@ -245,7 +245,7 @@ CUSTOM_KNOWN_GOOD_INPUT = {
"NumberToRadixString": [None, "2", None], "NumberToRadixString": [None, "2", None],
"ParseJson": ["\"{}\"", 1], "ParseJson": ["\"{}\"", 1],
"RegExpExecMultiple": [None, None, "['a']", "['a']", None], "RegExpExecMultiple": [None, None, "['a']", "['a']", None],
"DefineAccessorProperty": [None, None, "undefined", "undefined", None, None], "DefineApiAccessorProperty": [None, None, "undefined", "undefined", None, None],
"SetIteratorInitialize": [None, None, "2", None], "SetIteratorInitialize": [None, None, "2", None],
"SetDebugEventListener": ["undefined", None, None], "SetDebugEventListener": ["undefined", None, None],
"SetFunctionBreakPoint": [None, 200, None, None], "SetFunctionBreakPoint": [None, 200, None, None],
......
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