Commit 9a4872b7 authored by Yuki Shiino's avatar Yuki Shiino Committed by Commit Bot

bind-gen: Fix indexed/named properties of the new bindings generator

Removes regular indexed properties from Window, and moves the
implementation of indexed/named properties to 'api' component.

Bug: 839389
Change-Id: Icb3a92938bc6cdddc01e2323e7f06cbe2f2a5b47
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2145526Reviewed-by: default avatarHitoshi Yoshida <peria@chromium.org>
Commit-Queue: Yuki Shiino <yukishiino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#758763}
parent cc291e32
...@@ -3200,15 +3200,17 @@ def make_cross_origin_indexed_getter_callback(cg_context, function_name): ...@@ -3200,15 +3200,17 @@ def make_cross_origin_indexed_getter_callback(cg_context, function_name):
body.append(TextNode("${throw_security_error}")) body.append(TextNode("${throw_security_error}"))
return func_def return func_def
body.append( bind_return_value(body, cg_context, overriding_args=["${index}"])
body.extend([
TextNode("""\ TextNode("""\
if (${index} >= ${blink_receiver}->length()) { if (${index} >= ${blink_receiver}->length()) {
${throw_security_error} ${throw_security_error}
return; return;
} }
"""),
${class_name}::IndexedPropertyGetterCallback(${index}, ${info}); make_v8_set_return_value(cg_context),
""")) ])
return func_def return func_def
...@@ -3688,14 +3690,16 @@ def make_same_origin_indexed_getter_callback(cg_context, function_name): ...@@ -3688,14 +3690,16 @@ def make_same_origin_indexed_getter_callback(cg_context, function_name):
"SameOriginProperty_IndexedPropertyGetter") "SameOriginProperty_IndexedPropertyGetter")
body = func_def.body body = func_def.body
body.append( bind_return_value(body, cg_context, overriding_args=["${index}"])
body.extend([
TextNode("""\ TextNode("""\
if (${index} >= ${blink_receiver}->length()) { if (${index} >= ${blink_receiver}->length()) {
return; return;
} }
"""),
${class_name}::IndexedPropertyGetterCallback(${index}, ${info}); make_v8_set_return_value(cg_context),
""")) ])
return func_def return func_def
...@@ -5108,7 +5112,8 @@ def make_indexed_and_named_property_callbacks_and_install_node(cg_context): ...@@ -5108,7 +5112,8 @@ def make_indexed_and_named_property_callbacks_and_install_node(cg_context):
install_node = SequenceNode() install_node = SequenceNode()
interface = cg_context.interface interface = cg_context.interface
if not (interface and interface.indexed_and_named_properties): if not (interface and interface.indexed_and_named_properties
and "Global" not in interface.extended_attributes):
return func_decls, func_defs, install_node return func_decls, func_defs, install_node
props = interface.indexed_and_named_properties props = interface.indexed_and_named_properties
...@@ -5125,8 +5130,7 @@ def make_indexed_and_named_property_callbacks_and_install_node(cg_context): ...@@ -5125,8 +5130,7 @@ def make_indexed_and_named_property_callbacks_and_install_node(cg_context):
cg_context = cg_context.make_copy( cg_context = cg_context.make_copy(
v8_callback_type=CodeGenContext.V8_OTHER_CALLBACK) v8_callback_type=CodeGenContext.V8_OTHER_CALLBACK)
if (props.own_named_getter if props.own_named_getter:
and "Global" not in interface.extended_attributes):
add_callback(*make_named_property_getter_callback( add_callback(*make_named_property_getter_callback(
cg_context.make_copy(named_property_getter=props.named_getter), cg_context.make_copy(named_property_getter=props.named_getter),
"NamedPropertyGetterCallback")) "NamedPropertyGetterCallback"))
...@@ -5145,7 +5149,7 @@ def make_indexed_and_named_property_callbacks_and_install_node(cg_context): ...@@ -5145,7 +5149,7 @@ def make_indexed_and_named_property_callbacks_and_install_node(cg_context):
add_callback(*make_named_property_enumerator_callback( add_callback(*make_named_property_enumerator_callback(
cg_context, "NamedPropertyEnumeratorCallback")) cg_context, "NamedPropertyEnumeratorCallback"))
if props.named_getter and "Global" not in interface.extended_attributes: if props.named_getter:
impl_bridge = v8_bridge_class_name( impl_bridge = v8_bridge_class_name(
most_derived_interface( most_derived_interface(
props.named_getter.owner, props.named_setter props.named_getter.owner, props.named_setter
...@@ -5241,6 +5245,11 @@ ${instance_template}->SetHandler( ...@@ -5241,6 +5245,11 @@ ${instance_template}->SetHandler(
impl_bridge=impl_bridge, impl_bridge=impl_bridge,
property_handler_flags=property_handler_flags)) property_handler_flags=property_handler_flags))
func_defs.accumulate(
CodeGenAccumulator.require_include_headers([
"third_party/blink/renderer/bindings/core/v8/v8_set_return_value_for_core.h",
]))
return func_decls, func_defs, install_node return func_decls, func_defs, install_node
...@@ -5339,6 +5348,7 @@ def make_cross_origin_property_callbacks_and_install_node( ...@@ -5339,6 +5348,7 @@ def make_cross_origin_property_callbacks_and_install_node(
CROSS_ORIGIN_INTERFACES = ("Window", "Location") CROSS_ORIGIN_INTERFACES = ("Window", "Location")
if cg_context.interface.identifier not in CROSS_ORIGIN_INTERFACES: if cg_context.interface.identifier not in CROSS_ORIGIN_INTERFACES:
return callback_defs, install_node return callback_defs, install_node
props = cg_context.interface.indexed_and_named_properties
entry_nodes = [] entry_nodes = []
for entry in attribute_entries: for entry in attribute_entries:
...@@ -5434,7 +5444,9 @@ def make_cross_origin_property_callbacks_and_install_node( ...@@ -5434,7 +5444,9 @@ def make_cross_origin_property_callbacks_and_install_node(
make_cross_origin_named_enumerator_callback( make_cross_origin_named_enumerator_callback(
cg_context, "CrossOriginNamedEnumeratorCallback"), cg_context, "CrossOriginNamedEnumeratorCallback"),
make_cross_origin_indexed_getter_callback( make_cross_origin_indexed_getter_callback(
cg_context, "CrossOriginIndexedGetterCallback"), cg_context.make_copy(
indexed_property_getter=(props and props.indexed_getter)),
"CrossOriginIndexedGetterCallback"),
make_cross_origin_indexed_setter_callback( make_cross_origin_indexed_setter_callback(
cg_context, "CrossOriginIndexedSetterCallback"), cg_context, "CrossOriginIndexedSetterCallback"),
make_cross_origin_indexed_deleter_callback( make_cross_origin_indexed_deleter_callback(
...@@ -5490,7 +5502,9 @@ ${instance_template}->SetAccessCheckCallbackAndHandler( ...@@ -5490,7 +5502,9 @@ ${instance_template}->SetAccessCheckCallbackAndHandler(
func_defs = [ func_defs = [
make_same_origin_indexed_getter_callback( make_same_origin_indexed_getter_callback(
cg_context, "SameOriginIndexedGetterCallback"), cg_context.make_copy(
indexed_property_getter=(props and props.indexed_getter)),
"SameOriginIndexedGetterCallback"),
make_same_origin_indexed_setter_callback( make_same_origin_indexed_setter_callback(
cg_context, "SameOriginIndexedSetterCallback"), cg_context, "SameOriginIndexedSetterCallback"),
make_same_origin_indexed_deleter_callback( make_same_origin_indexed_deleter_callback(
...@@ -6258,14 +6272,16 @@ def generate_interface(interface): ...@@ -6258,14 +6272,16 @@ def generate_interface(interface):
indexed_and_named_property_decls, indexed_and_named_property_decls,
EmptyNode(), EmptyNode(),
]) ])
api_source_blink_ns.body.extend([
indexed_and_named_property_defs,
EmptyNode(),
])
impl_source_blink_ns.body.extend([ impl_source_blink_ns.body.extend([
CxxNamespaceNode(name="", body=callback_defs), CxxNamespaceNode(name="", body=callback_defs),
EmptyNode(), EmptyNode(),
installer_function_defs, installer_function_defs,
EmptyNode(), EmptyNode(),
indexed_and_named_property_defs,
EmptyNode(),
]) ])
# Write down to the files. # Write down to the files.
......
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