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 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 argument = IdlArgument(interface.idl_name) | 346 argument = IdlArgument(interface.idl_name) |
347 argument.idl_type = idl_type | 347 argument.idl_type = idl_type |
348 argument.name = name | 348 argument.name = name |
349 argument.is_optional = is_optional | 349 argument.is_optional = is_optional |
350 if extended_attributes: | 350 if extended_attributes: |
351 argument.extended_attributes.update(extended_attributes) | 351 argument.extended_attributes.update(extended_attributes) |
352 return argument | 352 return argument |
353 | 353 |
354 # [Iterable], iterable<>, maplike<> and setlike<> | 354 # [Iterable], iterable<>, maplike<> and setlike<> |
355 iterator_method = None | 355 iterator_method = None |
| 356 has_array_iterator = False |
| 357 |
356 # FIXME: support Iterable in partial interfaces. However, we don't | 358 # FIXME: support Iterable in partial interfaces. However, we don't |
357 # need to support iterator overloads between interface and | 359 # need to support iterator overloads between interface and |
358 # partial interface definitions. | 360 # partial interface definitions. |
359 # http://heycam.github.io/webidl/#idl-overloading | 361 # http://heycam.github.io/webidl/#idl-overloading |
360 if (not interface.is_partial | 362 if (not interface.is_partial |
361 and (interface.iterable or interface.maplike or interface.setlike | 363 and (interface.iterable or interface.maplike or interface.setlike |
362 or 'Iterable' in extended_attributes)): | 364 or interface.has_indexed_elements or 'Iterable' in extended_attribu
tes)): |
363 | 365 |
364 used_extended_attributes = {} | 366 used_extended_attributes = {} |
365 | 367 |
366 if interface.iterable: | 368 if interface.iterable: |
367 used_extended_attributes.update(interface.iterable.extended_attribut
es) | 369 used_extended_attributes.update(interface.iterable.extended_attribut
es) |
368 elif interface.maplike: | 370 elif interface.maplike: |
369 used_extended_attributes.update(interface.maplike.extended_attribute
s) | 371 used_extended_attributes.update(interface.maplike.extended_attribute
s) |
370 elif interface.setlike: | 372 elif interface.setlike: |
371 used_extended_attributes.update(interface.setlike.extended_attribute
s) | 373 used_extended_attributes.update(interface.setlike.extended_attribute
s) |
372 | 374 |
(...skipping 12 matching lines...) Expand all Loading... |
385 'CallWith': ['ScriptState', 'ThisValue'], | 387 'CallWith': ['ScriptState', 'ThisValue'], |
386 }) | 388 }) |
387 | 389 |
388 def generated_iterator_method(name, implemented_as=None): | 390 def generated_iterator_method(name, implemented_as=None): |
389 return generated_method( | 391 return generated_method( |
390 return_type=IdlType('Iterator'), | 392 return_type=IdlType('Iterator'), |
391 name=name, | 393 name=name, |
392 extended_attributes=used_extended_attributes, | 394 extended_attributes=used_extended_attributes, |
393 implemented_as=implemented_as) | 395 implemented_as=implemented_as) |
394 | 396 |
395 iterator_method = generated_iterator_method('iterator', implemented_as='
iterator') | 397 if interface.iterable or interface.maplike or interface.setlike or 'Iter
able' in extended_attributes: |
| 398 iterator_method = generated_iterator_method('iterator', implemented_
as='iterator') |
| 399 elif interface.has_indexed_elements: |
| 400 has_array_iterator = True |
396 | 401 |
397 if interface.iterable or interface.maplike or interface.setlike: | 402 if interface.iterable or interface.maplike or interface.setlike: |
398 implicit_methods = [ | 403 implicit_methods = [ |
399 generated_iterator_method('keys'), | 404 generated_iterator_method('keys'), |
400 generated_iterator_method('values'), | 405 generated_iterator_method('values'), |
401 generated_iterator_method('entries'), | 406 generated_iterator_method('entries'), |
402 | 407 |
403 # void forEach(Function callback, [Default=Undefined] optional a
ny thisArg) | 408 # void forEach(Function callback, [Default=Undefined] optional a
ny thisArg) |
404 generated_method(IdlType('void'), 'forEach', | 409 generated_method(IdlType('void'), 'forEach', |
405 arguments=[generated_argument(IdlType('Function
'), 'callback'), | 410 arguments=[generated_argument(IdlType('Function
'), 'callback'), |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 | 563 |
559 context.update({ | 564 context.update({ |
560 'conditionally_enabled_methods': conditionally_enabled_methods, | 565 'conditionally_enabled_methods': conditionally_enabled_methods, |
561 'custom_registration_methods': custom_registration_methods, | 566 'custom_registration_methods': custom_registration_methods, |
562 'has_origin_safe_method_setter': any( | 567 'has_origin_safe_method_setter': any( |
563 method['is_check_security_for_frame'] and not method['is_read_only'] | 568 method['is_check_security_for_frame'] and not method['is_read_only'] |
564 for method in methods), | 569 for method in methods), |
565 'has_private_script': any(attribute['is_implemented_in_private_script']
for attribute in attributes) or | 570 'has_private_script': any(attribute['is_implemented_in_private_script']
for attribute in attributes) or |
566 any(method['is_implemented_in_private_script'] for method in methods
), | 571 any(method['is_implemented_in_private_script'] for method in methods
), |
567 'iterator_method': iterator_method, | 572 'iterator_method': iterator_method, |
| 573 'has_array_iterator': has_array_iterator, |
568 'method_configuration_methods': method_configuration_methods, | 574 'method_configuration_methods': method_configuration_methods, |
569 'methods': methods, | 575 'methods': methods, |
570 }) | 576 }) |
571 | 577 |
572 # Conditionally enabled members | 578 # Conditionally enabled members |
573 has_conditional_attributes_on_instance = any( | 579 has_conditional_attributes_on_instance = any( |
574 attribute['exposed_test'] and attribute['on_instance'] | 580 attribute['exposed_test'] and attribute['on_instance'] |
575 for attribute in attributes) | 581 for attribute in attributes) |
576 has_conditional_attributes_on_prototype = any( | 582 has_conditional_attributes_on_prototype = any( |
577 attribute['exposed_test'] and attribute['on_prototype'] | 583 attribute['exposed_test'] and attribute['on_prototype'] |
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1375 | 1381 |
1376 extended_attributes = deleter.extended_attributes | 1382 extended_attributes = deleter.extended_attributes |
1377 idl_type = deleter.idl_type | 1383 idl_type = deleter.idl_type |
1378 is_call_with_script_state = v8_utilities.has_extended_attribute_value(delete
r, 'CallWith', 'ScriptState') | 1384 is_call_with_script_state = v8_utilities.has_extended_attribute_value(delete
r, 'CallWith', 'ScriptState') |
1379 return { | 1385 return { |
1380 'is_call_with_script_state': is_call_with_script_state, | 1386 'is_call_with_script_state': is_call_with_script_state, |
1381 'is_custom': 'Custom' in extended_attributes, | 1387 'is_custom': 'Custom' in extended_attributes, |
1382 'is_raises_exception': 'RaisesException' in extended_attributes, | 1388 'is_raises_exception': 'RaisesException' in extended_attributes, |
1383 'name': cpp_name(deleter), | 1389 'name': cpp_name(deleter), |
1384 } | 1390 } |
OLD | NEW |