Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 341 argument = IdlArgument(interface.idl_name) | 341 argument = IdlArgument(interface.idl_name) |
| 342 argument.idl_type = idl_type | 342 argument.idl_type = idl_type |
| 343 argument.name = name | 343 argument.name = name |
| 344 argument.is_optional = is_optional | 344 argument.is_optional = is_optional |
| 345 if extended_attributes: | 345 if extended_attributes: |
| 346 argument.extended_attributes.update(extended_attributes) | 346 argument.extended_attributes.update(extended_attributes) |
| 347 return argument | 347 return argument |
| 348 | 348 |
| 349 # [Iterable], iterable<>, maplike<> and setlike<> | 349 # [Iterable], iterable<>, maplike<> and setlike<> |
| 350 iterator_method = None | 350 iterator_method = None |
| 351 has_array_iterator = False | |
| 352 | |
| 351 # FIXME: support Iterable in partial interfaces. However, we don't | 353 # FIXME: support Iterable in partial interfaces. However, we don't |
| 352 # need to support iterator overloads between interface and | 354 # need to support iterator overloads between interface and |
| 353 # partial interface definitions. | 355 # partial interface definitions. |
| 354 # http://heycam.github.io/webidl/#idl-overloading | 356 # http://heycam.github.io/webidl/#idl-overloading |
| 355 if (not interface.is_partial | 357 if (not interface.is_partial |
| 356 and (interface.iterable or interface.maplike or interface.setlike | 358 and (interface.iterable or interface.maplike or interface.setlike |
| 357 or 'Iterable' in extended_attributes)): | 359 or interface.has_indexed_elements or 'Iterable' in extended_attribu tes)): |
| 358 | 360 |
| 359 used_extended_attributes = {} | 361 used_extended_attributes = {} |
| 360 | 362 |
| 361 if interface.iterable: | 363 if interface.iterable: |
| 362 used_extended_attributes.update(interface.iterable.extended_attribut es) | 364 used_extended_attributes.update(interface.iterable.extended_attribut es) |
| 363 elif interface.maplike: | 365 elif interface.maplike: |
| 364 used_extended_attributes.update(interface.maplike.extended_attribute s) | 366 used_extended_attributes.update(interface.maplike.extended_attribute s) |
| 365 elif interface.setlike: | 367 elif interface.setlike: |
| 366 used_extended_attributes.update(interface.setlike.extended_attribute s) | 368 used_extended_attributes.update(interface.setlike.extended_attribute s) |
| 367 | 369 |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 380 'CallWith': ['ScriptState', 'ThisValue'], | 382 'CallWith': ['ScriptState', 'ThisValue'], |
| 381 }) | 383 }) |
| 382 | 384 |
| 383 def generated_iterator_method(name, implemented_as=None): | 385 def generated_iterator_method(name, implemented_as=None): |
| 384 return generated_method( | 386 return generated_method( |
| 385 return_type=IdlType('Iterator'), | 387 return_type=IdlType('Iterator'), |
| 386 name=name, | 388 name=name, |
| 387 extended_attributes=used_extended_attributes, | 389 extended_attributes=used_extended_attributes, |
| 388 implemented_as=implemented_as) | 390 implemented_as=implemented_as) |
| 389 | 391 |
| 390 iterator_method = generated_iterator_method('iterator', implemented_as=' iterator') | 392 if (interface.iterable or interface.maplike or interface.setlike or 'Ite rable' in extended_attributes): |
|
Jens Widell
2015/10/05 05:57:11
Minor nit: in Python you typically don't have pare
| |
| 393 iterator_method = generated_iterator_method('iterator', implemented_ as='iterator') | |
| 394 elif interface.has_indexed_elements: | |
| 395 has_array_iterator = True | |
| 391 | 396 |
| 392 if interface.iterable or interface.maplike or interface.setlike: | 397 if interface.iterable or interface.maplike or interface.setlike: |
| 393 implicit_methods = [ | 398 implicit_methods = [ |
| 394 generated_iterator_method('keys'), | 399 generated_iterator_method('keys'), |
| 395 generated_iterator_method('values'), | 400 generated_iterator_method('values'), |
| 396 generated_iterator_method('entries'), | 401 generated_iterator_method('entries'), |
| 397 | 402 |
| 398 # void forEach(Function callback, [Default=Undefined] optional a ny thisArg) | 403 # void forEach(Function callback, [Default=Undefined] optional a ny thisArg) |
| 399 generated_method(IdlType('void'), 'forEach', | 404 generated_method(IdlType('void'), 'forEach', |
| 400 arguments=[generated_argument(IdlType('Function '), 'callback'), | 405 arguments=[generated_argument(IdlType('Function '), 'callback'), |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 553 | 558 |
| 554 context.update({ | 559 context.update({ |
| 555 'conditionally_enabled_methods': conditionally_enabled_methods, | 560 'conditionally_enabled_methods': conditionally_enabled_methods, |
| 556 'custom_registration_methods': custom_registration_methods, | 561 'custom_registration_methods': custom_registration_methods, |
| 557 'has_origin_safe_method_setter': any( | 562 'has_origin_safe_method_setter': any( |
| 558 method['is_check_security_for_frame'] and not method['is_read_only'] | 563 method['is_check_security_for_frame'] and not method['is_read_only'] |
| 559 for method in methods), | 564 for method in methods), |
| 560 'has_private_script': any(attribute['is_implemented_in_private_script'] for attribute in attributes) or | 565 '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 ), | 566 any(method['is_implemented_in_private_script'] for method in methods ), |
| 562 'iterator_method': iterator_method, | 567 'iterator_method': iterator_method, |
| 568 'has_array_iterator': has_array_iterator, | |
| 563 'method_configuration_methods': method_configuration_methods, | 569 'method_configuration_methods': method_configuration_methods, |
| 564 'methods': methods, | 570 'methods': methods, |
| 565 }) | 571 }) |
| 566 | 572 |
| 567 # Conditionally enabled members | 573 # Conditionally enabled members |
| 568 has_conditional_attributes_on_instance = any( | 574 has_conditional_attributes_on_instance = any( |
| 569 attribute['exposed_test'] and attribute['on_instance'] | 575 attribute['exposed_test'] and attribute['on_instance'] |
| 570 for attribute in attributes) | 576 for attribute in attributes) |
| 571 has_conditional_attributes_on_prototype = any( | 577 has_conditional_attributes_on_prototype = any( |
| 572 attribute['exposed_test'] and attribute['on_prototype'] | 578 attribute['exposed_test'] and attribute['on_prototype'] |
| (...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1367 | 1373 |
| 1368 extended_attributes = deleter.extended_attributes | 1374 extended_attributes = deleter.extended_attributes |
| 1369 idl_type = deleter.idl_type | 1375 idl_type = deleter.idl_type |
| 1370 is_call_with_script_state = v8_utilities.has_extended_attribute_value(delete r, 'CallWith', 'ScriptState') | 1376 is_call_with_script_state = v8_utilities.has_extended_attribute_value(delete r, 'CallWith', 'ScriptState') |
| 1371 return { | 1377 return { |
| 1372 'is_call_with_script_state': is_call_with_script_state, | 1378 'is_call_with_script_state': is_call_with_script_state, |
| 1373 'is_custom': 'Custom' in extended_attributes, | 1379 'is_custom': 'Custom' in extended_attributes, |
| 1374 'is_raises_exception': 'RaisesException' in extended_attributes, | 1380 'is_raises_exception': 'RaisesException' in extended_attributes, |
| 1375 'name': cpp_name(deleter), | 1381 'name': cpp_name(deleter), |
| 1376 } | 1382 } |
| OLD | NEW |