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 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 # determined as follows: | 551 # determined as follows: |
552 # 1. Let S be the effective overload set for regular operations (if the | 552 # 1. Let S be the effective overload set for regular operations (if the |
553 # operation is a regular operation) or for static operations (if the | 553 # operation is a regular operation) or for static operations (if the |
554 # operation is a static operation) with identifier id on interface I and | 554 # operation is a static operation) with identifier id on interface I and |
555 # with argument count 0. | 555 # with argument count 0. |
556 # 2. Return the length of the shortest argument list of the entries in S
. | 556 # 2. Return the length of the shortest argument list of the entries in S
. |
557 # FIXME: This calculation doesn't take into account whether runtime | 557 # FIXME: This calculation doesn't take into account whether runtime |
558 # enabled overloads are actually enabled, so length may be incorrect. | 558 # enabled overloads are actually enabled, so length may be incorrect. |
559 # E.g., [RuntimeEnabled=Foo] void f(); void f(long x); | 559 # E.g., [RuntimeEnabled=Foo] void f(); void f(long x); |
560 # should have length 1 if Foo is not enabled, but length 0 if it is. | 560 # should have length 1 if Foo is not enabled, but length 0 if it is. |
561 method['length'] = (method['overloads']['minarg'] if 'overloads' in meth
od else | 561 method['length'] = (method['overloads']['length'] if 'overloads' in meth
od else |
562 method['number_of_required_arguments']) | 562 method['number_of_required_arguments']) |
563 | 563 |
564 context.update({ | 564 context.update({ |
565 'conditionally_enabled_methods': conditionally_enabled_methods, | 565 'conditionally_enabled_methods': conditionally_enabled_methods, |
566 'custom_registration_methods': custom_registration_methods, | 566 'custom_registration_methods': custom_registration_methods, |
567 'has_origin_safe_method_setter': any( | 567 'has_origin_safe_method_setter': any( |
568 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'] |
569 for method in methods), | 569 for method in methods), |
570 '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 |
571 any(method['is_implemented_in_private_script'] for method in methods
), | 571 any(method['is_implemented_in_private_script'] for method in methods
), |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
655 and returns dict of overall overload template values. | 655 and returns dict of overall overload template values. |
656 """ | 656 """ |
657 assert len(overloads) > 1 # only apply to overloaded names | 657 assert len(overloads) > 1 # only apply to overloaded names |
658 for index, method in enumerate(overloads, 1): | 658 for index, method in enumerate(overloads, 1): |
659 method['overload_index'] = index | 659 method['overload_index'] = index |
660 | 660 |
661 effective_overloads_by_length = effective_overload_set_by_length(overloads) | 661 effective_overloads_by_length = effective_overload_set_by_length(overloads) |
662 lengths = [length for length, _ in effective_overloads_by_length] | 662 lengths = [length for length, _ in effective_overloads_by_length] |
663 name = overloads[0].get('name', '<constructor>') | 663 name = overloads[0].get('name', '<constructor>') |
664 | 664 |
665 # Check if all overloads with the shortest acceptable arguments list are | 665 runtime_determined_lengths = None |
666 # runtime enabled, in which case we need to have a runtime determined | 666 function_length = lengths[0] |
667 # Function.length. The exception is if all overloads are controlled by the | 667 runtime_determined_maxargs = None |
668 # same runtime enabled feature, in which case there would be no function | 668 maxarg = lengths[-1] |
669 # object at all if it is not enabled. | 669 |
670 shortest_overloads = effective_overloads_by_length[0][1] | 670 # The special case handling below is not needed if all overloads are |
671 if (all(method.get('runtime_enabled_function') | 671 # runtime enabled by the same feature. |
672 for method, _, _ in shortest_overloads) and | 672 if not common_value(overloads, 'runtime_enabled_function'): |
673 not common_value(overloads, 'runtime_enabled_function')): | 673 # Check if all overloads with the shortest acceptable arguments list are |
674 # Generate a list of (length, runtime_enabled_functions) tuples. | 674 # runtime enabled, in which case we need to have a runtime determined |
675 runtime_determined_lengths = [] | 675 # Function.length. |
676 for length, effective_overloads in effective_overloads_by_length: | 676 shortest_overloads = effective_overloads_by_length[0][1] |
677 runtime_enabled_functions = set( | 677 if (all(method.get('runtime_enabled_function') |
678 method['runtime_enabled_function'] | 678 for method, _, _ in shortest_overloads)): |
679 for method, _, _ in effective_overloads | 679 # Generate a list of (length, runtime_enabled_functions) tuples. |
680 if method.get('runtime_enabled_function')) | 680 runtime_determined_lengths = [] |
681 if not runtime_enabled_functions: | 681 for length, effective_overloads in effective_overloads_by_length: |
682 # This "length" is unconditionally enabled, so stop here. | 682 runtime_enabled_functions = set( |
683 runtime_determined_lengths.append((length, [None])) | 683 method['runtime_enabled_function'] |
684 break | 684 for method, _, _ in effective_overloads |
685 runtime_determined_lengths.append( | 685 if method.get('runtime_enabled_function')) |
686 (length, sorted(runtime_enabled_functions))) | 686 if not runtime_enabled_functions: |
687 length = ('%sV8Internal::%sMethodLength()' | 687 # This "length" is unconditionally enabled, so stop here. |
688 % (cpp_name_or_partial(interface), name)) | 688 runtime_determined_lengths.append((length, [None])) |
689 else: | 689 break |
690 runtime_determined_lengths = None | 690 runtime_determined_lengths.append( |
691 length = lengths[0] | 691 (length, sorted(runtime_enabled_functions))) |
| 692 function_length = ('%sV8Internal::%sMethodLength()' |
| 693 % (cpp_name_or_partial(interface), name)) |
| 694 |
| 695 # Check if all overloads with the longest required arguments list are |
| 696 # runtime enabled, in which case we need to have a runtime determined |
| 697 # maximum distinguishing argument index. |
| 698 longest_overloads = effective_overloads_by_length[-1][1] |
| 699 if (not common_value(overloads, 'runtime_enabled_function') and |
| 700 all(method.get('runtime_enabled_function') |
| 701 for method, _, _ in longest_overloads)): |
| 702 # Generate a list of (length, runtime_enabled_functions) tuples. |
| 703 runtime_determined_maxargs = [] |
| 704 for length, effective_overloads in reversed(effective_overloads_by_l
ength): |
| 705 runtime_enabled_functions = set( |
| 706 method['runtime_enabled_function'] |
| 707 for method, _, _ in effective_overloads |
| 708 if method.get('runtime_enabled_function')) |
| 709 if not runtime_enabled_functions: |
| 710 # This "length" is unconditionally enabled, so stop here. |
| 711 runtime_determined_maxargs.append((length, [None])) |
| 712 break |
| 713 runtime_determined_maxargs.append( |
| 714 (length, sorted(runtime_enabled_functions))) |
| 715 maxarg = ('%sV8Internal::%sMethodMaxArg()' |
| 716 % (cpp_name_or_partial(interface), name)) |
692 | 717 |
693 # Check and fail if overloads disagree on any of the extended attributes | 718 # Check and fail if overloads disagree on any of the extended attributes |
694 # that affect how the method should be registered. | 719 # that affect how the method should be registered. |
695 # Skip the check for overloaded constructors, since they don't support any | 720 # Skip the check for overloaded constructors, since they don't support any |
696 # of the extended attributes in question. | 721 # of the extended attributes in question. |
697 if not overloads[0].get('is_constructor'): | 722 if not overloads[0].get('is_constructor'): |
698 overload_extended_attributes = [ | 723 overload_extended_attributes = [ |
699 method['custom_registration_extended_attributes'] | 724 method['custom_registration_extended_attributes'] |
700 for method in overloads] | 725 for method in overloads] |
701 for extended_attribute in v8_methods.CUSTOM_REGISTRATION_EXTENDED_ATTRIB
UTES: | 726 for extended_attribute in v8_methods.CUSTOM_REGISTRATION_EXTENDED_ATTRIB
UTES: |
(...skipping 19 matching lines...) Expand all Loading... |
721 has_overload_not_visible = True | 746 has_overload_not_visible = True |
722 | 747 |
723 # If some overloads are not visible and others are visible, | 748 # If some overloads are not visible and others are visible, |
724 # the method is overloaded between core and modules. | 749 # the method is overloaded between core and modules. |
725 has_partial_overloads = has_overload_visible and has_overload_not_visible | 750 has_partial_overloads = has_overload_visible and has_overload_not_visible |
726 | 751 |
727 return { | 752 return { |
728 'deprecate_all_as': common_value(overloads, 'deprecate_as'), # [Depreca
teAs] | 753 'deprecate_all_as': common_value(overloads, 'deprecate_as'), # [Depreca
teAs] |
729 'exposed_test_all': common_value(overloads, 'exposed_test'), # [Exposed
] | 754 'exposed_test_all': common_value(overloads, 'exposed_test'), # [Exposed
] |
730 'has_custom_registration_all': common_value(overloads, 'has_custom_regis
tration'), | 755 'has_custom_registration_all': common_value(overloads, 'has_custom_regis
tration'), |
731 'length': length, | 756 'length': function_length, |
732 'length_tests_methods': length_tests_methods(effective_overloads_by_leng
th), | 757 'length_tests_methods': length_tests_methods(effective_overloads_by_leng
th), |
733 # 1. Let maxarg be the length of the longest type list of the | 758 # 1. Let maxarg be the length of the longest type list of the |
734 # entries in S. | 759 # entries in S. |
735 'maxarg': lengths[-1], | 760 'maxarg': maxarg, |
736 'measure_all_as': common_value(overloads, 'measure_as'), # [MeasureAs] | 761 'measure_all_as': common_value(overloads, 'measure_as'), # [MeasureAs] |
737 'minarg': lengths[0], | |
738 'returns_promise_all': promise_overload_count > 0, | 762 'returns_promise_all': promise_overload_count > 0, |
739 'runtime_determined_lengths': runtime_determined_lengths, | 763 'runtime_determined_lengths': runtime_determined_lengths, |
| 764 'runtime_determined_maxargs': runtime_determined_maxargs, |
740 'runtime_enabled_function_all': common_value(overloads, 'runtime_enabled
_function'), # [RuntimeEnabled] | 765 'runtime_enabled_function_all': common_value(overloads, 'runtime_enabled
_function'), # [RuntimeEnabled] |
741 'valid_arities': lengths | 766 'valid_arities': lengths |
742 # Only need to report valid arities if there is a gap in the | 767 # Only need to report valid arities if there is a gap in the |
743 # sequence of possible lengths, otherwise invalid length means | 768 # sequence of possible lengths, otherwise invalid length means |
744 # "not enough arguments". | 769 # "not enough arguments". |
745 if lengths[-1] - lengths[0] != len(lengths) - 1 else None, | 770 if lengths[-1] - lengths[0] != len(lengths) - 1 else None, |
746 'visible': has_overload_visible, | 771 'visible': has_overload_visible, |
747 'has_partial_overloads': has_partial_overloads, | 772 'has_partial_overloads': has_partial_overloads, |
748 } | 773 } |
749 | 774 |
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1333 | 1358 |
1334 extended_attributes = deleter.extended_attributes | 1359 extended_attributes = deleter.extended_attributes |
1335 idl_type = deleter.idl_type | 1360 idl_type = deleter.idl_type |
1336 is_call_with_script_state = v8_utilities.has_extended_attribute_value(delete
r, 'CallWith', 'ScriptState') | 1361 is_call_with_script_state = v8_utilities.has_extended_attribute_value(delete
r, 'CallWith', 'ScriptState') |
1337 return { | 1362 return { |
1338 'is_call_with_script_state': is_call_with_script_state, | 1363 'is_call_with_script_state': is_call_with_script_state, |
1339 'is_custom': 'Custom' in extended_attributes, | 1364 'is_custom': 'Custom' in extended_attributes, |
1340 'is_raises_exception': 'RaisesException' in extended_attributes, | 1365 'is_raises_exception': 'RaisesException' in extended_attributes, |
1341 'name': cpp_name(deleter), | 1366 'name': cpp_name(deleter), |
1342 } | 1367 } |
OLD | NEW |