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

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

Issue 807263007: IDL: Add forEach() method to iterable<>/maplike<>/setlike<> interfaces (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: remove FIXMEs about missing forEach() Created 5 years, 11 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
Index: Source/bindings/scripts/v8_interface.py
diff --git a/Source/bindings/scripts/v8_interface.py b/Source/bindings/scripts/v8_interface.py
index bcabae0c603b847ad2388216ded702052f809359..e87a4d2b2c965c3016771fe610395a4c07c4abc4 100644
--- a/Source/bindings/scripts/v8_interface.py
+++ b/Source/bindings/scripts/v8_interface.py
@@ -37,7 +37,7 @@ import itertools
from operator import itemgetter
import idl_definitions
-from idl_definitions import IdlOperation
+from idl_definitions import IdlOperation, IdlArgument
import idl_types
from idl_types import IdlType, inherits_interface
import v8_attributes
@@ -332,6 +332,16 @@ def interface_context(interface):
operation.extended_attributes.update(extended_attributes)
return v8_methods.method_context(interface, operation)
+ def generated_argument(idl_type, name, is_optional=False, default_value=None, extended_attributes=None):
haraken 2015/01/27 01:56:30 It looks like default_value is unused.
Jens Widell 2015/01/27 07:19:23 Yes, not needed at the moment. Not on the radar th
+ argument = IdlArgument(interface.idl_name)
+ argument.idl_type = idl_type
+ argument.name = name
+ argument.is_optional = is_optional
+ argument.default_value = default_value
+ if extended_attributes:
+ argument.extended_attributes.update(extended_attributes)
+ return argument
+
# [Iterable], iterable<>, maplike<> and setlike<>
iterator_method = None
# FIXME: support Iterable in partial interfaces. However, we don't
@@ -361,6 +371,11 @@ def interface_context(interface):
'CallWith': 'ScriptState',
})
+ forEach_extended_attributes = used_extended_attributes.copy()
haraken 2015/01/27 01:56:30 Can't we just use used_extended_attributes? In oth
Jens Widell 2015/01/27 07:19:23 I am essentially using used_extended_attributes. I
+ forEach_extended_attributes.update({
+ 'CallWith': ['ScriptState', 'ThisValue'],
+ })
+
def generated_iterator_method(name):
return generated_method(
return_type=IdlType('Iterator'),
@@ -374,6 +389,14 @@ def interface_context(interface):
generated_iterator_method('keys'),
generated_iterator_method('values'),
generated_iterator_method('entries'),
+
+ # void forEach(Function callback, [Default=Undefined] optional any thisArg)
+ generated_method(IdlType('void'), 'forEach',
+ arguments=[generated_argument(IdlType('Function'), 'callback'),
+ generated_argument(IdlType('any'), 'thisArg',
+ is_optional=True,
+ extended_attributes={'Default': 'Undefined'})],
+ extended_attributes=forEach_extended_attributes),
])
# FIXME: maplike<> and setlike<> should also imply the presence of a

Powered by Google App Engine
This is Rietveld 408576698