Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(185)

Unified Diff: Source/bindings/scripts/v8_interface.py

Issue 911433003: IDL: Auto-declare remaining methods implied by maplike<>/setlike<> (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@idl-iterable-continued
Patch Set: common suffix Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/bindings/tests/idls/core/TestInterfaceGarbageCollected.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/scripts/v8_interface.py
diff --git a/Source/bindings/scripts/v8_interface.py b/Source/bindings/scripts/v8_interface.py
index 8b80f3b120428d406e0f0efff62302e9c98c0a72..785afeb9d43fc3505fc27f74794d5d31cc46fdda 100644
--- a/Source/bindings/scripts/v8_interface.py
+++ b/Source/bindings/scripts/v8_interface.py
@@ -322,7 +322,7 @@ def interface_context(interface):
if operation.name])
compute_method_overloads_context(interface, methods)
- def generated_method(return_type, name, arguments=None, extended_attributes=None):
+ def generated_method(return_type, name, arguments=None, extended_attributes=None, implemented_as=None):
operation = IdlOperation(interface.idl_name)
operation.idl_type = return_type
operation.name = name
@@ -330,6 +330,9 @@ def interface_context(interface):
operation.arguments = arguments
if extended_attributes:
operation.extended_attributes.update(extended_attributes)
+ if implemented_as is None:
+ implemented_as = name + 'ForBinding'
+ operation.extended_attributes['ImplementedAs'] = implemented_as
return v8_methods.method_context(interface, operation)
def generated_argument(idl_type, name, is_optional=False, extended_attributes=None):
@@ -375,13 +378,14 @@ def interface_context(interface):
'CallWith': ['ScriptState', 'ThisValue'],
})
- def generated_iterator_method(name):
+ def generated_iterator_method(name, implemented_as=None):
return generated_method(
return_type=IdlType('Iterator'),
name=name,
- extended_attributes=used_extended_attributes)
+ extended_attributes=used_extended_attributes,
+ implemented_as=implemented_as)
- iterator_method = generated_iterator_method('iterator')
+ iterator_method = generated_iterator_method('iterator', implemented_as='iterator')
if interface.iterable or interface.maplike or interface.setlike:
implicit_methods = [
@@ -398,6 +402,52 @@ def interface_context(interface):
extended_attributes=forEach_extended_attributes),
]
+ if interface.maplike:
+ key_argument = generated_argument(interface.maplike.key_type, 'key')
+ value_argument = generated_argument(interface.maplike.value_type, 'value')
+
+ implicit_methods.extend([
+ generated_method(IdlType('boolean'), 'has',
+ arguments=[key_argument],
+ extended_attributes=used_extended_attributes),
+ generated_method(IdlType('any'), 'get',
+ arguments=[key_argument],
+ extended_attributes=used_extended_attributes),
+ ])
+
+ if not interface.maplike.is_read_only:
+ implicit_methods.extend([
+ generated_method(IdlType('void'), 'clear',
+ extended_attributes=used_extended_attributes),
+ generated_method(IdlType('boolean'), 'delete',
+ arguments=[key_argument],
+ extended_attributes=used_extended_attributes),
+ generated_method(IdlType(interface.name), 'set',
+ arguments=[key_argument, value_argument],
+ extended_attributes=used_extended_attributes),
+ ])
+
+ if interface.setlike:
+ value_argument = generated_argument(interface.setlike.value_type, 'value')
+
+ implicit_methods.extend([
+ generated_method(IdlType('boolean'), 'has',
+ arguments=[value_argument],
+ extended_attributes=used_extended_attributes),
+ ])
+
+ if not interface.setlike.is_read_only:
+ implicit_methods.extend([
+ generated_method(IdlType(interface.name), 'add',
+ arguments=[value_argument],
+ extended_attributes=used_extended_attributes),
+ generated_method(IdlType('void'), 'clear',
+ extended_attributes=used_extended_attributes),
+ generated_method(IdlType('boolean'), 'delete',
+ arguments=[value_argument],
+ extended_attributes=used_extended_attributes),
+ ])
+
methods_by_name = {}
for method in methods:
methods_by_name.setdefault(method['name'], []).append(method)
@@ -409,8 +459,7 @@ def interface_context(interface):
methods.append(implicit_method)
# FIXME: maplike<> and setlike<> should also imply the presence of a
- # subset of keys(), values(), entries(), forEach(), has(), get(), add(),
- # set(), delete() and clear(), and a 'size' attribute.
+ # 'size' attribute.
# Stringifier
if interface.stringifier:
@@ -423,7 +472,8 @@ def interface_context(interface):
methods.append(generated_method(
return_type=IdlType('DOMString'),
name='toString',
- extended_attributes=stringifier_ext_attrs))
+ extended_attributes=stringifier_ext_attrs,
+ implemented_as='toString'))
conditionally_enabled_methods = []
custom_registration_methods = []
« no previous file with comments | « no previous file | Source/bindings/tests/idls/core/TestInterfaceGarbageCollected.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698