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

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

Issue 611953003: Canvas2D Performance: fix the bottleneck of hasInstance during JS binding -- overloading (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: update auto-generated code for test cases I added, the change in JS binding is applied Created 6 years, 2 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
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 735 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 # • an interface type that V implements 746 # • an interface type that V implements
747 # (Unlike most of these tests, this can return multiple methods, since we 747 # (Unlike most of these tests, this can return multiple methods, since we
748 # test if it implements an interface. Thus we need a for loop, not a next.) 748 # test if it implements an interface. Thus we need a for loop, not a next.)
749 # (We distinguish wrapper types from built-in interface types.) 749 # (We distinguish wrapper types from built-in interface types.)
750 for idl_type, method in ((idl_type, method) 750 for idl_type, method in ((idl_type, method)
751 for idl_type, method in idl_types_methods 751 for idl_type, method in idl_types_methods
752 if idl_type.is_wrapper_type): 752 if idl_type.is_wrapper_type):
753 test = 'V8{idl_type}::hasInstance({cpp_value}, info.GetIsolate())'.forma t(idl_type=idl_type.base_type, cpp_value=cpp_value) 753 test = 'V8{idl_type}::hasInstance({cpp_value}, info.GetIsolate())'.forma t(idl_type=idl_type.base_type, cpp_value=cpp_value)
754 yield test, method 754 yield test, method
755 755
756 for argument, method in arguments_methods:
Jens Widell 2014/10/10 10:14:53 Could you add a comment before this code explainin
yunchao 2014/10/10 11:40:48 Done.
757 if argument['idl_type_object'].is_wrapper_type and method['number_of_req uired_arguments'] == method['number_of_arguments']:
Jens Widell 2014/10/10 10:14:53 You can use argument['is_wrapper_type'] here inste
yunchao 2014/10/10 11:40:48 Acknowledged.
758 argument['type_checked_already'] = True
759
760
756 # 8. Otherwise: if V is any kind of object except for a native Date object, 761 # 8. Otherwise: if V is any kind of object except for a native Date object,
757 # a native RegExp object, and there is an entry in S that has one of the 762 # a native RegExp object, and there is an entry in S that has one of the
758 # following types at position i of its type list, 763 # following types at position i of its type list,
759 # • an array type 764 # • an array type
760 # • a sequence type 765 # • a sequence type
761 # ... 766 # ...
762 # • a dictionary 767 # • a dictionary
763 # 768 #
764 # FIXME: 769 # FIXME:
765 # We don't strictly follow the algorithm here. The algorithm says "remove 770 # We don't strictly follow the algorithm here. The algorithm says "remove
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
905 'ConstructorCallWith', 'Document'), 910 'ConstructorCallWith', 'Document'),
906 'is_call_with_execution_context': 911 'is_call_with_execution_context':
907 # [ConstructorCallWith=ExecutionContext] 912 # [ConstructorCallWith=ExecutionContext]
908 has_extended_attribute_value(interface, 913 has_extended_attribute_value(interface,
909 'ConstructorCallWith', 'ExecutionContext'), 914 'ConstructorCallWith', 'ExecutionContext'),
910 'is_constructor': True, 915 'is_constructor': True,
911 'is_named_constructor': False, 916 'is_named_constructor': False,
912 'is_raises_exception': is_constructor_raises_exception, 917 'is_raises_exception': is_constructor_raises_exception,
913 'number_of_required_arguments': 918 'number_of_required_arguments':
914 number_of_required_arguments(constructor), 919 number_of_required_arguments(constructor),
920 'number_of_arguments': len(constructor.arguments),
Jens Widell 2014/10/10 10:14:53 Move up a bit; the list should be sorted alphabeti
yunchao 2014/10/10 11:40:48 Done.
915 } 921 }
916 922
917 923
918 # [NamedConstructor] 924 # [NamedConstructor]
919 def named_constructor_context(interface): 925 def named_constructor_context(interface):
920 extended_attributes = interface.extended_attributes 926 extended_attributes = interface.extended_attributes
921 if 'NamedConstructor' not in extended_attributes: 927 if 'NamedConstructor' not in extended_attributes:
922 return None 928 return None
923 # FIXME: parser should return named constructor separately; 929 # FIXME: parser should return named constructor separately;
924 # included in constructors (and only name stored in extended attribute) 930 # included in constructors (and only name stored in extended attribute)
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
1133 deleter = next( 1139 deleter = next(
1134 method 1140 method
1135 for method in interface.operations 1141 for method in interface.operations
1136 if ('deleter' in method.specials and 1142 if ('deleter' in method.specials and
1137 len(method.arguments) == 1 and 1143 len(method.arguments) == 1 and
1138 str(method.arguments[0].idl_type) == 'DOMString')) 1144 str(method.arguments[0].idl_type) == 'DOMString'))
1139 except StopIteration: 1145 except StopIteration:
1140 return None 1146 return None
1141 1147
1142 return property_deleter(deleter) 1148 return property_deleter(deleter)
OLDNEW
« no previous file with comments | « no previous file | Source/bindings/scripts/v8_methods.py » ('j') | Source/bindings/scripts/v8_methods.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698