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

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

Issue 338893004: Extend ScalarValueString handling to include constructors. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Tweaks Created 6 years, 6 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
« no previous file with comments | « Source/bindings/scripts/v8_attributes.py ('k') | Source/bindings/scripts/v8_methods.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 720 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 # already generated tests for them. 731 # already generated tests for them.
732 test = '%s->IsObject()' % cpp_value 732 test = '%s->IsObject()' % cpp_value
733 yield test, method 733 yield test, method
734 except StopIteration: 734 except StopIteration:
735 pass 735 pass
736 736
737 # (Check for exact type matches before performing automatic type conversion; 737 # (Check for exact type matches before performing automatic type conversion;
738 # only needed if distinguishing between primitive types.) 738 # only needed if distinguishing between primitive types.)
739 if len([idl_type.is_primitive_type for idl_type in idl_types]) > 1: 739 if len([idl_type.is_primitive_type for idl_type in idl_types]) > 1:
740 # (Only needed if match in step 11, otherwise redundant.) 740 # (Only needed if match in step 11, otherwise redundant.)
741 if any(idl_type.name == 'String' or idl_type.is_enum 741 if any(idl_type.is_string_type or idl_type.is_enum
742 for idl_type in idl_types): 742 for idl_type in idl_types):
743 # 10. Otherwise: if V is a Number value, and there is an entry in S 743 # 10. Otherwise: if V is a Number value, and there is an entry in S
744 # that has one of the following types at position i of its type 744 # that has one of the following types at position i of its type
745 # list, 745 # list,
746 # • a numeric type 746 # • a numeric type
747 try: 747 try:
748 method = next(method for idl_type, method in idl_types_methods 748 method = next(method for idl_type, method in idl_types_methods
749 if idl_type.is_numeric_type) 749 if idl_type.is_numeric_type)
750 test = '%s->IsNumber()' % cpp_value 750 test = '%s->IsNumber()' % cpp_value
751 yield test, method 751 yield test, method
752 except StopIteration: 752 except StopIteration:
753 pass 753 pass
754 754
755 # (Perform automatic type conversion, in order. If any of these match, 755 # (Perform automatic type conversion, in order. If any of these match,
756 # that’s the end, and no other tests are needed.) To keep this code simple, 756 # that’s the end, and no other tests are needed.) To keep this code simple,
757 # we rely on the C++ compiler's dead code elimination to deal with the 757 # we rely on the C++ compiler's dead code elimination to deal with the
758 # redundancy if both cases below trigger. 758 # redundancy if both cases below trigger.
759 759
760 # 11. Otherwise: if there is an entry in S that has one of the following 760 # 11. Otherwise: if there is an entry in S that has one of the following
761 # types at position i of its type list, 761 # types at position i of its type list,
762 # • DOMString 762 # • DOMString
763 # • ByteString
764 # • ScalarValueString [a DOMString typedef, per definition.]
763 # • an enumeration type 765 # • an enumeration type
764 # * ByteString
765 # Blink: ScalarValueString is a pending Web IDL addition
766 try: 766 try:
767 method = next(method for idl_type, method in idl_types_methods 767 method = next(method for idl_type, method in idl_types_methods
768 if idl_type.name in ('String', 768 if idl_type.is_string_type or idl_type.is_enum)
769 'ByteString',
770 'ScalarValueString') or
771 idl_type.is_enum)
772 yield 'true', method 769 yield 'true', method
773 except StopIteration: 770 except StopIteration:
774 pass 771 pass
775 772
776 # 12. Otherwise: if there is an entry in S that has one of the following 773 # 12. Otherwise: if there is an entry in S that has one of the following
777 # types at position i of its type list, 774 # types at position i of its type list,
778 # • a numeric type 775 # • a numeric type
779 try: 776 try:
780 method = next(method for idl_type, method in idl_types_methods 777 method = next(method for idl_type, method in idl_types_methods
781 if idl_type.is_numeric_type) 778 if idl_type.is_numeric_type)
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 'cpp_type': cpp_template_type( 845 'cpp_type': cpp_template_type(
849 cpp_ptr_type('RefPtr', 'RawPtr', gc_type(interface)), 846 cpp_ptr_type('RefPtr', 'RawPtr', gc_type(interface)),
850 cpp_name(interface)), 847 cpp_name(interface)),
851 'cpp_value': v8_methods.cpp_value( 848 'cpp_value': v8_methods.cpp_value(
852 interface, constructor, len(constructor.arguments)), 849 interface, constructor, len(constructor.arguments)),
853 'has_exception_state': 850 'has_exception_state':
854 # [RaisesException=Constructor] 851 # [RaisesException=Constructor]
855 interface.extended_attributes.get('RaisesException') == 'Constructor ' or 852 interface.extended_attributes.get('RaisesException') == 'Constructor ' or
856 any(argument for argument in constructor.arguments 853 any(argument for argument in constructor.arguments
857 if argument.idl_type.name == 'SerializedScriptValue' or 854 if argument.idl_type.name == 'SerializedScriptValue' or
858 argument.idl_type.is_integer_type), 855 argument.idl_type.may_raise_exception_on_conversion),
859 'is_constructor': True, 856 'is_constructor': True,
860 'is_named_constructor': False, 857 'is_named_constructor': False,
861 'number_of_required_arguments': 858 'number_of_required_arguments':
862 number_of_required_arguments(constructor), 859 number_of_required_arguments(constructor),
863 } 860 }
864 861
865 862
866 # [NamedConstructor] 863 # [NamedConstructor]
867 def generate_named_constructor(interface): 864 def generate_named_constructor(interface):
868 extended_attributes = interface.extended_attributes 865 extended_attributes = interface.extended_attributes
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
1078 deleter = next( 1075 deleter = next(
1079 method 1076 method
1080 for method in interface.operations 1077 for method in interface.operations
1081 if ('deleter' in method.specials and 1078 if ('deleter' in method.specials and
1082 len(method.arguments) == 1 and 1079 len(method.arguments) == 1 and
1083 str(method.arguments[0].idl_type) == 'DOMString')) 1080 str(method.arguments[0].idl_type) == 'DOMString'))
1084 except StopIteration: 1081 except StopIteration:
1085 return None 1082 return None
1086 1083
1087 return property_deleter(deleter) 1084 return property_deleter(deleter)
OLDNEW
« no previous file with comments | « Source/bindings/scripts/v8_attributes.py ('k') | Source/bindings/scripts/v8_methods.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698