| 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 constant['origin_trial_feature_name']] | 91 constant['origin_trial_feature_name']] |
| 92 | 92 |
| 93 | 93 |
| 94 def constant_filters(): | 94 def constant_filters(): |
| 95 return {'has_constant_configuration': filter_has_constant_configuration, | 95 return {'has_constant_configuration': filter_has_constant_configuration, |
| 96 'has_special_getter': filter_has_special_getter, | 96 'has_special_getter': filter_has_special_getter, |
| 97 'runtime_enabled_constants': filter_runtime_enabled, | 97 'runtime_enabled_constants': filter_runtime_enabled, |
| 98 'origin_trial_enabled_constants': filter_origin_trial_enabled} | 98 'origin_trial_enabled_constants': filter_origin_trial_enabled} |
| 99 | 99 |
| 100 | 100 |
| 101 def origin_trial_feature_names(constants, attributes): | 101 def origin_trial_feature_names(interface, constants, attributes, methods): |
| 102 """ Returns a list of the names of each origin trial feature used in this in
terface. | 102 """ Returns a list of the names of each origin trial feature used in this in
terface. |
| 103 | 103 |
| 104 This list is the union of the sets of names used for constants and attribute
s. | 104 This list is the union of the sets of names used for constants, attributes a
nd methods. |
| 105 """ | 105 """ |
| 106 | 106 |
| 107 feature_names = set( | 107 feature_names = set( |
| 108 [constant['origin_trial_feature_name'] for constant in constants if cons
tant['origin_trial_feature_name']] + | 108 [constant['origin_trial_feature_name'] for constant in constants if cons
tant['origin_trial_feature_name']] + |
| 109 [attribute['origin_trial_feature_name'] for attribute in attributes if a
ttribute['origin_trial_feature_name']] | 109 [attribute['origin_trial_feature_name'] for attribute in attributes if a
ttribute['origin_trial_feature_name']] + |
| 110 [method['origin_trial_feature_name'] for method in methods if ( |
| 111 v8_methods.method_is_visible(method, interface.is_partial) and |
| 112 method['origin_trial_feature_name'])] |
| 110 ) | 113 ) |
| 111 return sorted(feature_names) | 114 return sorted(feature_names) |
| 112 | 115 |
| 113 | 116 |
| 114 def interface_context(interface): | 117 def interface_context(interface): |
| 115 includes.clear() | 118 includes.clear() |
| 116 includes.update(INTERFACE_CPP_INCLUDES) | 119 includes.update(INTERFACE_CPP_INCLUDES) |
| 117 header_includes = set(INTERFACE_H_INCLUDES) | 120 header_includes = set(INTERFACE_H_INCLUDES) |
| 118 | 121 |
| 119 if interface.is_partial: | 122 if interface.is_partial: |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 elif stringifier.operation: | 505 elif stringifier.operation: |
| 503 implemented_as = stringifier.operation.name | 506 implemented_as = stringifier.operation.name |
| 504 else: | 507 else: |
| 505 implemented_as = 'toString' | 508 implemented_as = 'toString' |
| 506 methods.append(generated_method( | 509 methods.append(generated_method( |
| 507 return_type=IdlType('DOMString'), | 510 return_type=IdlType('DOMString'), |
| 508 name='toString', | 511 name='toString', |
| 509 extended_attributes=stringifier_ext_attrs, | 512 extended_attributes=stringifier_ext_attrs, |
| 510 implemented_as=implemented_as)) | 513 implemented_as=implemented_as)) |
| 511 | 514 |
| 512 conditionally_enabled_methods = [] | |
| 513 custom_registration_methods = [] | |
| 514 method_configuration_methods = [] | |
| 515 | |
| 516 for method in methods: | |
| 517 # Skip all but one method in each set of overloaded methods. | |
| 518 if 'overload_index' in method and 'overloads' not in method: | |
| 519 continue | |
| 520 | |
| 521 if 'overloads' in method: | |
| 522 overloads = method['overloads'] | |
| 523 if not overloads['visible']: | |
| 524 continue | |
| 525 # original interface will register instead of partial interface. | |
| 526 if overloads['has_partial_overloads'] and interface.is_partial: | |
| 527 continue | |
| 528 conditionally_exposed_function = overloads['exposed_test_all'] | |
| 529 runtime_enabled_function = overloads['runtime_enabled_function_all'] | |
| 530 has_custom_registration = (overloads['has_custom_registration_all']
or | |
| 531 overloads['runtime_determined_lengths']) | |
| 532 else: | |
| 533 if not method['visible']: | |
| 534 continue | |
| 535 conditionally_exposed_function = method['exposed_test'] | |
| 536 runtime_enabled_function = method['runtime_enabled_function'] | |
| 537 has_custom_registration = method['has_custom_registration'] | |
| 538 | |
| 539 if has_custom_registration: | |
| 540 custom_registration_methods.append(method) | |
| 541 continue | |
| 542 if conditionally_exposed_function: | |
| 543 conditionally_enabled_methods.append(method) | |
| 544 continue | |
| 545 if runtime_enabled_function: | |
| 546 custom_registration_methods.append(method) | |
| 547 continue | |
| 548 if method['should_be_exposed_to_script']: | |
| 549 method_configuration_methods.append(method) | |
| 550 | |
| 551 for method in methods: | 515 for method in methods: |
| 552 # The value of the Function object’s “length” property is a Number | 516 # The value of the Function object’s “length” property is a Number |
| 553 # determined as follows: | 517 # determined as follows: |
| 554 # 1. Let S be the effective overload set for regular operations (if the | 518 # 1. Let S be the effective overload set for regular operations (if the |
| 555 # operation is a regular operation) or for static operations (if the | 519 # operation is a regular operation) or for static operations (if the |
| 556 # operation is a static operation) with identifier id on interface I and | 520 # operation is a static operation) with identifier id on interface I and |
| 557 # with argument count 0. | 521 # with argument count 0. |
| 558 # 2. Return the length of the shortest argument list of the entries in S
. | 522 # 2. Return the length of the shortest argument list of the entries in S
. |
| 559 # FIXME: This calculation doesn't take into account whether runtime | 523 # FIXME: This calculation doesn't take into account whether runtime |
| 560 # enabled overloads are actually enabled, so length may be incorrect. | 524 # enabled overloads are actually enabled, so length may be incorrect. |
| 561 # E.g., [RuntimeEnabled=Foo] void f(); void f(long x); | 525 # E.g., [RuntimeEnabled=Foo] void f(); void f(long x); |
| 562 # should have length 1 if Foo is not enabled, but length 0 if it is. | 526 # should have length 1 if Foo is not enabled, but length 0 if it is. |
| 563 method['length'] = (method['overloads']['length'] if 'overloads' in meth
od else | 527 method['length'] = (method['overloads']['length'] if 'overloads' in meth
od else |
| 564 method['number_of_required_arguments']) | 528 method['number_of_required_arguments']) |
| 565 | 529 |
| 566 context.update({ | 530 context.update({ |
| 567 'conditionally_enabled_methods': conditionally_enabled_methods, | |
| 568 'custom_registration_methods': custom_registration_methods, | |
| 569 'has_origin_safe_method_setter': is_global and any( | 531 'has_origin_safe_method_setter': is_global and any( |
| 570 method['is_check_security_for_receiver'] and not method['is_unforgea
ble'] | 532 method['is_check_security_for_receiver'] and not method['is_unforgea
ble'] |
| 571 for method in methods), | 533 for method in methods), |
| 572 'has_private_script': (any(attribute['is_implemented_in_private_script']
for attribute in attributes) or | 534 'has_private_script': (any(attribute['is_implemented_in_private_script']
for attribute in attributes) or |
| 573 any(method['is_implemented_in_private_script'] fo
r method in methods)), | 535 any(method['is_implemented_in_private_script'] fo
r method in methods)), |
| 574 'iterator_method': iterator_method, | 536 'iterator_method': iterator_method, |
| 575 'has_array_iterator': has_array_iterator, | 537 'has_array_iterator': has_array_iterator, |
| 576 'method_configuration_methods': method_configuration_methods, | |
| 577 'methods': methods, | 538 'methods': methods, |
| 578 }) | 539 }) |
| 579 | 540 |
| 580 # Conditionally enabled members | 541 # Conditionally enabled members |
| 581 has_conditional_attributes_on_instance = any( | 542 has_conditional_attributes_on_instance = any( |
| 582 attribute['exposed_test'] and attribute['on_instance'] | 543 attribute['exposed_test'] and attribute['on_instance'] |
| 583 for attribute in attributes) | 544 for attribute in attributes) |
| 584 has_conditional_attributes_on_prototype = any( | 545 has_conditional_attributes_on_prototype = any( |
| 585 attribute['exposed_test'] and attribute['on_prototype'] | 546 attribute['exposed_test'] and attribute['on_prototype'] |
| 586 for attribute in attributes) | 547 for attribute in attributes) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 599 'named_property_getter': property_getter(interface.named_property_getter
, ['propertyName']), | 560 'named_property_getter': property_getter(interface.named_property_getter
, ['propertyName']), |
| 600 'named_property_setter': property_setter(interface.named_property_setter
, interface), | 561 'named_property_setter': property_setter(interface.named_property_setter
, interface), |
| 601 'named_property_deleter': property_deleter(interface.named_property_dele
ter), | 562 'named_property_deleter': property_deleter(interface.named_property_dele
ter), |
| 602 }) | 563 }) |
| 603 context.update({ | 564 context.update({ |
| 604 'has_named_properties_object': is_global and context['named_property_get
ter'], | 565 'has_named_properties_object': is_global and context['named_property_get
ter'], |
| 605 }) | 566 }) |
| 606 | 567 |
| 607 # Origin Trials | 568 # Origin Trials |
| 608 context.update({ | 569 context.update({ |
| 609 'origin_trial_feature_names': origin_trial_feature_names(context['consta
nts'], context['attributes']), | 570 'origin_trial_feature_names': origin_trial_feature_names(interface, cont
ext['constants'], context['attributes'], context['methods']), |
| 610 }) | 571 }) |
| 611 return context | 572 return context |
| 612 | 573 |
| 613 | 574 |
| 614 # [DeprecateAs], [OriginTrialEnabled], [Reflect], [RuntimeEnabled] | 575 # [DeprecateAs], [OriginTrialEnabled], [Reflect], [RuntimeEnabled] |
| 615 def constant_context(constant, interface): | 576 def constant_context(constant, interface): |
| 616 extended_attributes = constant.extended_attributes | 577 extended_attributes = constant.extended_attributes |
| 617 | 578 |
| 618 return { | 579 return { |
| 619 'cpp_class': extended_attributes.get('PartialInterfaceImplementedAs'), | 580 'cpp_class': extended_attributes.get('PartialInterfaceImplementedAs'), |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 def overloads_context(interface, overloads): | 640 def overloads_context(interface, overloads): |
| 680 """Returns |overloads| template values for a single name. | 641 """Returns |overloads| template values for a single name. |
| 681 | 642 |
| 682 Sets |method.overload_index| in place for |method| in |overloads| | 643 Sets |method.overload_index| in place for |method| in |overloads| |
| 683 and returns dict of overall overload template values. | 644 and returns dict of overall overload template values. |
| 684 """ | 645 """ |
| 685 assert len(overloads) > 1 # only apply to overloaded names | 646 assert len(overloads) > 1 # only apply to overloaded names |
| 686 for index, method in enumerate(overloads, 1): | 647 for index, method in enumerate(overloads, 1): |
| 687 method['overload_index'] = index | 648 method['overload_index'] = index |
| 688 | 649 |
| 650 # [OriginTrialEnabled] |
| 651 # TODO(iclelland): Allow origin trials on method overloads |
| 652 # (crbug.com/621641) |
| 653 if any(method.get('origin_trial_feature_name') for method in overloads): |
| 654 raise Exception('[OriginTrialEnabled] cannot be specified on ' |
| 655 'overloaded methods: %s.%s' % (interface.name, overloads
[0]['name'])) |
| 656 |
| 689 effective_overloads_by_length = effective_overload_set_by_length(overloads) | 657 effective_overloads_by_length = effective_overload_set_by_length(overloads) |
| 690 lengths = [length for length, _ in effective_overloads_by_length] | 658 lengths = [length for length, _ in effective_overloads_by_length] |
| 691 name = overloads[0].get('name', '<constructor>') | 659 name = overloads[0].get('name', '<constructor>') |
| 692 | 660 |
| 693 runtime_determined_lengths = None | 661 runtime_determined_lengths = None |
| 694 function_length = lengths[0] | 662 function_length = lengths[0] |
| 695 runtime_determined_maxargs = None | 663 runtime_determined_maxargs = None |
| 696 maxarg = lengths[-1] | 664 maxarg = lengths[-1] |
| 697 | 665 |
| 698 # The special case handling below is not needed if all overloads are | 666 # The special case handling below is not needed if all overloads are |
| (...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1401 extended_attributes = deleter.extended_attributes | 1369 extended_attributes = deleter.extended_attributes |
| 1402 is_call_with_script_state = v8_utilities.has_extended_attribute_value(delete
r, 'CallWith', 'ScriptState') | 1370 is_call_with_script_state = v8_utilities.has_extended_attribute_value(delete
r, 'CallWith', 'ScriptState') |
| 1403 is_ce_reactions = 'CEReactions' in extended_attributes | 1371 is_ce_reactions = 'CEReactions' in extended_attributes |
| 1404 return { | 1372 return { |
| 1405 'is_call_with_script_state': is_call_with_script_state, | 1373 'is_call_with_script_state': is_call_with_script_state, |
| 1406 'is_ce_reactions': is_ce_reactions, | 1374 'is_ce_reactions': is_ce_reactions, |
| 1407 'is_custom': 'Custom' in extended_attributes, | 1375 'is_custom': 'Custom' in extended_attributes, |
| 1408 'is_raises_exception': 'RaisesException' in extended_attributes, | 1376 'is_raises_exception': 'RaisesException' in extended_attributes, |
| 1409 'name': cpp_name(deleter), | 1377 'name': cpp_name(deleter), |
| 1410 } | 1378 } |
| OLD | NEW |