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

Side by Side Diff: third_party/WebKit/Source/bindings/scripts/v8_interface.py

Issue 1381413003: [bindings] add support for integer-indexed @@iterator (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix some bugs, put @@iterator on instance for [Global]/[PrimaryGlobal], more tests Created 5 years, 2 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 unified diff | Download patch
OLDNEW
1 # Copyright (C) 2013 Google Inc. All rights reserved. 1 # Copyright (C) 2013 Google Inc. All rights reserved.
2 # coding=utf-8 2 # coding=utf-8
3 # 3 #
4 # Redistribution and use in source and binary forms, with or without 4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are 5 # modification, are permitted provided that the following conditions are
6 # met: 6 # met:
7 # 7 #
8 # * Redistributions of source code must retain the above copyright 8 # * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer. 9 # notice, this list of conditions and the following disclaimer.
10 # * Redistributions in binary form must reproduce the above 10 # * Redistributions in binary form must reproduce the above
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 is_active_dom_object = 'ActiveDOMObject' in extended_attributes 115 is_active_dom_object = 'ActiveDOMObject' in extended_attributes
116 116
117 # [CheckSecurity] 117 # [CheckSecurity]
118 is_check_security = 'CheckSecurity' in extended_attributes 118 is_check_security = 'CheckSecurity' in extended_attributes
119 if is_check_security: 119 if is_check_security:
120 includes.add('bindings/core/v8/BindingSecurity.h') 120 includes.add('bindings/core/v8/BindingSecurity.h')
121 121
122 # [DependentLifetime] 122 # [DependentLifetime]
123 is_dependent_lifetime = 'DependentLifetime' in extended_attributes 123 is_dependent_lifetime = 'DependentLifetime' in extended_attributes
124 124
125 # [Global] and [PrimaryGlibal]
126 is_global = any(name in extended_attributes for name in ['Global', 'PrimaryG lobal'])
127
125 # [MeasureAs] 128 # [MeasureAs]
126 is_measure_as = 'MeasureAs' in extended_attributes 129 is_measure_as = 'MeasureAs' in extended_attributes
127 if is_measure_as: 130 if is_measure_as:
128 includes.add('core/frame/UseCounter.h') 131 includes.add('core/frame/UseCounter.h')
129 132
130 # [SetWrapperReferenceFrom] 133 # [SetWrapperReferenceFrom]
131 set_wrapper_reference_from = extended_attributes.get('SetWrapperReferenceFro m') 134 set_wrapper_reference_from = extended_attributes.get('SetWrapperReferenceFro m')
132 if set_wrapper_reference_from: 135 if set_wrapper_reference_from:
133 includes.update(['bindings/core/v8/V8GCController.h', 136 includes.update(['bindings/core/v8/V8GCController.h',
134 'core/dom/Element.h']) 137 'core/dom/Element.h'])
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 'has_custom_legacy_call_as_function': has_extended_attribute_value(inter face, 'Custom', 'LegacyCallAsFunction'), # [Custom=LegacyCallAsFunction] 179 'has_custom_legacy_call_as_function': has_extended_attribute_value(inter face, 'Custom', 'LegacyCallAsFunction'), # [Custom=LegacyCallAsFunction]
177 'has_partial_interface': len(interface.partial_interfaces) > 0, 180 'has_partial_interface': len(interface.partial_interfaces) > 0,
178 'has_visit_dom_wrapper': has_visit_dom_wrapper, 181 'has_visit_dom_wrapper': has_visit_dom_wrapper,
179 'header_includes': header_includes, 182 'header_includes': header_includes,
180 'interface_name': interface.name, 183 'interface_name': interface.name,
181 'is_active_dom_object': is_active_dom_object, 184 'is_active_dom_object': is_active_dom_object,
182 'is_array_buffer_or_view': is_array_buffer_or_view, 185 'is_array_buffer_or_view': is_array_buffer_or_view,
183 'is_check_security': is_check_security, 186 'is_check_security': is_check_security,
184 'is_event_target': is_event_target, 187 'is_event_target': is_event_target,
185 'is_exception': interface.is_exception, 188 'is_exception': interface.is_exception,
189 'is_global': is_global,
186 'is_node': inherits_interface(interface.name, 'Node'), 190 'is_node': inherits_interface(interface.name, 'Node'),
187 'is_partial': interface.is_partial, 191 'is_partial': interface.is_partial,
188 'is_typed_array_type': is_typed_array_type, 192 'is_typed_array_type': is_typed_array_type,
189 'lifetime': 'Dependent' 193 'lifetime': 'Dependent'
190 if (has_visit_dom_wrapper or 194 if (has_visit_dom_wrapper or
191 is_active_dom_object or 195 is_active_dom_object or
192 is_dependent_lifetime) 196 is_dependent_lifetime)
193 else 'Independent', 197 else 'Independent',
194 'measure_as': v8_utilities.measure_as(interface, None), # [MeasureAs] 198 'measure_as': v8_utilities.measure_as(interface, None), # [MeasureAs]
195 'parent_interface': parent_interface, 199 'parent_interface': parent_interface,
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 argument = IdlArgument(interface.idl_name) 345 argument = IdlArgument(interface.idl_name)
342 argument.idl_type = idl_type 346 argument.idl_type = idl_type
343 argument.name = name 347 argument.name = name
344 argument.is_optional = is_optional 348 argument.is_optional = is_optional
345 if extended_attributes: 349 if extended_attributes:
346 argument.extended_attributes.update(extended_attributes) 350 argument.extended_attributes.update(extended_attributes)
347 return argument 351 return argument
348 352
349 # [Iterable], iterable<>, maplike<> and setlike<> 353 # [Iterable], iterable<>, maplike<> and setlike<>
350 iterator_method = None 354 iterator_method = None
355 has_array_iterator = False
356
351 # FIXME: support Iterable in partial interfaces. However, we don't 357 # FIXME: support Iterable in partial interfaces. However, we don't
352 # need to support iterator overloads between interface and 358 # need to support iterator overloads between interface and
353 # partial interface definitions. 359 # partial interface definitions.
354 # http://heycam.github.io/webidl/#idl-overloading 360 # http://heycam.github.io/webidl/#idl-overloading
355 if (not interface.is_partial 361 if (not interface.is_partial
356 and (interface.iterable or interface.maplike or interface.setlike 362 and (interface.iterable or interface.maplike or interface.setlike
357 or 'Iterable' in extended_attributes)): 363 or interface.has_indexed_elements or 'Iterable' in extended_attribu tes)):
358 364
359 used_extended_attributes = {} 365 used_extended_attributes = {}
360 366
361 if interface.iterable: 367 if interface.iterable:
362 used_extended_attributes.update(interface.iterable.extended_attribut es) 368 used_extended_attributes.update(interface.iterable.extended_attribut es)
363 elif interface.maplike: 369 elif interface.maplike:
364 used_extended_attributes.update(interface.maplike.extended_attribute s) 370 used_extended_attributes.update(interface.maplike.extended_attribute s)
365 elif interface.setlike: 371 elif interface.setlike:
366 used_extended_attributes.update(interface.setlike.extended_attribute s) 372 used_extended_attributes.update(interface.setlike.extended_attribute s)
367 373
(...skipping 12 matching lines...) Expand all
380 'CallWith': ['ScriptState', 'ThisValue'], 386 'CallWith': ['ScriptState', 'ThisValue'],
381 }) 387 })
382 388
383 def generated_iterator_method(name, implemented_as=None): 389 def generated_iterator_method(name, implemented_as=None):
384 return generated_method( 390 return generated_method(
385 return_type=IdlType('Iterator'), 391 return_type=IdlType('Iterator'),
386 name=name, 392 name=name,
387 extended_attributes=used_extended_attributes, 393 extended_attributes=used_extended_attributes,
388 implemented_as=implemented_as) 394 implemented_as=implemented_as)
389 395
390 iterator_method = generated_iterator_method('iterator', implemented_as=' iterator') 396 if interface.iterable or interface.maplike or interface.setlike or 'Iter able' in extended_attributes:
397 iterator_method = generated_iterator_method('iterator', implemented_ as='iterator')
398 elif interface.has_indexed_elements:
399 has_array_iterator = True
391 400
392 if interface.iterable or interface.maplike or interface.setlike: 401 if interface.iterable or interface.maplike or interface.setlike:
393 implicit_methods = [ 402 implicit_methods = [
394 generated_iterator_method('keys'), 403 generated_iterator_method('keys'),
395 generated_iterator_method('values'), 404 generated_iterator_method('values'),
396 generated_iterator_method('entries'), 405 generated_iterator_method('entries'),
397 406
398 # void forEach(Function callback, [Default=Undefined] optional a ny thisArg) 407 # void forEach(Function callback, [Default=Undefined] optional a ny thisArg)
399 generated_method(IdlType('void'), 'forEach', 408 generated_method(IdlType('void'), 'forEach',
400 arguments=[generated_argument(IdlType('Function '), 'callback'), 409 arguments=[generated_argument(IdlType('Function '), 'callback'),
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 562
554 context.update({ 563 context.update({
555 'conditionally_enabled_methods': conditionally_enabled_methods, 564 'conditionally_enabled_methods': conditionally_enabled_methods,
556 'custom_registration_methods': custom_registration_methods, 565 'custom_registration_methods': custom_registration_methods,
557 'has_origin_safe_method_setter': any( 566 'has_origin_safe_method_setter': any(
558 method['is_check_security_for_frame'] and not method['is_read_only'] 567 method['is_check_security_for_frame'] and not method['is_read_only']
559 for method in methods), 568 for method in methods),
560 'has_private_script': any(attribute['is_implemented_in_private_script'] for attribute in attributes) or 569 'has_private_script': any(attribute['is_implemented_in_private_script'] for attribute in attributes) or
561 any(method['is_implemented_in_private_script'] for method in methods ), 570 any(method['is_implemented_in_private_script'] for method in methods ),
562 'iterator_method': iterator_method, 571 'iterator_method': iterator_method,
572 'has_array_iterator': has_array_iterator,
563 'method_configuration_methods': method_configuration_methods, 573 'method_configuration_methods': method_configuration_methods,
564 'methods': methods, 574 'methods': methods,
565 }) 575 })
566 576
567 # Conditionally enabled members 577 # Conditionally enabled members
568 has_conditional_attributes_on_instance = any( 578 has_conditional_attributes_on_instance = any(
569 attribute['exposed_test'] and attribute['on_instance'] 579 attribute['exposed_test'] and attribute['on_instance']
570 for attribute in attributes) 580 for attribute in attributes)
571 has_conditional_attributes_on_prototype = any( 581 has_conditional_attributes_on_prototype = any(
572 attribute['exposed_test'] and attribute['on_prototype'] 582 attribute['exposed_test'] and attribute['on_prototype']
(...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after
1367 1377
1368 extended_attributes = deleter.extended_attributes 1378 extended_attributes = deleter.extended_attributes
1369 idl_type = deleter.idl_type 1379 idl_type = deleter.idl_type
1370 is_call_with_script_state = v8_utilities.has_extended_attribute_value(delete r, 'CallWith', 'ScriptState') 1380 is_call_with_script_state = v8_utilities.has_extended_attribute_value(delete r, 'CallWith', 'ScriptState')
1371 return { 1381 return {
1372 'is_call_with_script_state': is_call_with_script_state, 1382 'is_call_with_script_state': is_call_with_script_state,
1373 'is_custom': 'Custom' in extended_attributes, 1383 'is_custom': 'Custom' in extended_attributes,
1374 'is_raises_exception': 'RaisesException' in extended_attributes, 1384 'is_raises_exception': 'RaisesException' in extended_attributes,
1375 'name': cpp_name(deleter), 1385 'name': cpp_name(deleter),
1376 } 1386 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698