Chromium Code Reviews| Index: third_party/WebKit/Source/bindings/scripts/v8_interface.py |
| diff --git a/third_party/WebKit/Source/bindings/scripts/v8_interface.py b/third_party/WebKit/Source/bindings/scripts/v8_interface.py |
| index 867e7598d6f33fd96c07cd6c48d277603546ccf0..7f15a170cf673e56011daa5a3267011484877b13 100644 |
| --- a/third_party/WebKit/Source/bindings/scripts/v8_interface.py |
| +++ b/third_party/WebKit/Source/bindings/scripts/v8_interface.py |
| @@ -374,11 +374,12 @@ def interface_context(interface, interfaces): |
| }) |
| # Methods |
| - methods, iterator_method = methods_context(interface) |
| + methods, iterator_method, iterator_method_alias = methods_context(interface) |
| context.update({ |
| 'has_origin_safe_method_setter': any(method['is_cross_origin'] and not method['is_unforgeable'] |
| for method in methods), |
| 'iterator_method': iterator_method, |
| + 'iterator_method_alias': iterator_method_alias, |
| 'methods': methods, |
| 'conditionally_enabled_methods': v8_methods.filter_conditionally_enabled(methods, interface.is_partial), |
| }) |
| @@ -507,7 +508,9 @@ def methods_context(interface): |
| interface: An interface to create contexts for |
| Returns: |
| - A list of method contexts, and an iterator context if available or None |
| + A list of method contexts, an iterator context if available or None, |
| + and string that can also be used to refer to the @@iterator symbol or |
| + None. |
| """ |
| methods = [] |
| @@ -552,6 +555,10 @@ def methods_context(interface): |
| # iterable<>, maplike<> and setlike<> |
| iterator_method = None |
| + # Depending on the declaration, @@iterator may be a synonym for e.g. |
| + # 'entries' or 'values'. |
| + iterator_method_alias = None |
| + |
| # FIXME: support Iterable in partial interfaces. However, we don't |
| # need to support iterator overloads between interface and |
| # partial interface definitions. |
| @@ -602,11 +609,19 @@ def methods_context(interface): |
| # For value iterators, the |entries|, |forEach|, |keys| and |values| are originally set |
| # to corresponding properties in %ArrayPrototype%. |
| + # For pair iterators and maplike declarations, |entries| is an alias for @@iterator |
| + # itself. For setlike declarations, |values| is an alias for @@iterator. |
| if not is_value_iterator: |
| + if not interface.setlike: |
| + iterator_method_alias = 'entries' |
| + entries_or_values_method = generated_iterator_method('values') |
| + else: |
| + iterator_method_alias = 'values' |
| + entries_or_values_method = generated_iterator_method('entries') |
| + |
| non_overridable_methods.extend([ |
| generated_iterator_method('keys'), |
| - generated_iterator_method('values'), |
| - generated_iterator_method('entries'), |
| + entries_or_values_method, |
| # void forEach(Function callback, [Default=Undefined] optional any thisArg) |
| generated_method(IdlType('void'), 'forEach', |
| @@ -733,7 +748,7 @@ def methods_context(interface): |
| method['length'] = (method['overloads']['length'] if 'overloads' in method else |
| method['number_of_required_arguments']) |
| - return methods, iterator_method |
| + return methods, iterator_method, iterator_method_alias |
|
bashi
2017/05/21 23:27:48
nit: I'd prefer to use a dict here.
Raphael Kubo da Costa (rakuco)
2017/05/22 09:29:52
Makes total sense :) Done in patch v3, which I'll
|
| def reflected_name(constant_name): |