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

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

Issue 21006006: Add forEach() to CSSVariablesMap (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased onto callback change Created 7 years, 3 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 | Annotate | Revision Log
OLDNEW
1 # Copyright (C) 2013 Google Inc. All rights reserved. 1 # Copyright (C) 2013 Google Inc. All rights reserved.
2 # 2 #
3 # Redistribution and use in source and binary forms, with or without 3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are 4 # modification, are permitted provided that the following conditions are
5 # met: 5 # met:
6 # 6 #
7 # * Redistributions of source code must retain the above copyright 7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer. 8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above 9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer 10 # copyright notice, this list of conditions and the following disclaimer
(...skipping 11 matching lines...) Expand all
22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 28
29 """Generate template values for a callback interface.""" 29 """Generate template values for a callback interface."""
30 30
31 from v8_types import cpp_type, cpp_value_to_v8_value, includes_for_type 31 from v8_types import cpp_type, cpp_value_to_v8_value, includes_for_type
32 from v8_utilities import v8_class_name 32 from v8_utilities import v8_class_name, has_extended_attribute_value
33 33
34 CALLBACK_INTERFACE_H_INCLUDES = set([ 34 CALLBACK_INTERFACE_H_INCLUDES = set([
35 'bindings/v8/ActiveDOMCallback.h', 35 'bindings/v8/ActiveDOMCallback.h',
36 'bindings/v8/DOMWrapperWorld.h', 36 'bindings/v8/DOMWrapperWorld.h',
37 'bindings/v8/ScopedPersistent.h', 37 'bindings/v8/ScopedPersistent.h',
38 ]) 38 ])
39 CALLBACK_INTERFACE_CPP_INCLUDES = set([ 39 CALLBACK_INTERFACE_CPP_INCLUDES = set([
40 'core/dom/ScriptExecutionContext.h', 40 'core/dom/ScriptExecutionContext.h',
41 'bindings/v8/V8Binding.h', 41 'bindings/v8/V8Binding.h',
42 'bindings/v8/V8Callback.h', 42 'bindings/v8/V8Callback.h',
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 79
80 80
81 def includes_for_operation(operation): 81 def includes_for_operation(operation):
82 includes = includes_for_type(operation.data_type) 82 includes = includes_for_type(operation.data_type)
83 for argument in operation.arguments: 83 for argument in operation.arguments:
84 includes.update(includes_for_type(argument.data_type)) 84 includes.update(includes_for_type(argument.data_type))
85 return includes 85 return includes
86 86
87 87
88 def generate_method_contents(operation): 88 def generate_method_contents(operation):
89 call_with_this_handle = has_extended_attribute_value(operation.extended_attr ibutes, 'CallWith', 'ThisValue')
89 contents = { 90 contents = {
90 'name': operation.name, 91 'name': operation.name,
91 'return_cpp_type': cpp_type(operation.data_type, 'RefPtr'), 92 'return_cpp_type': cpp_type(operation.data_type, 'RefPtr'),
92 'custom': 'Custom' in operation.extended_attributes, 93 'custom': 'Custom' in operation.extended_attributes,
94 'call_with_this_handle': call_with_this_handle,
93 } 95 }
94 contents.update(generate_arguments_contents(operation.arguments)) 96 contents.update(generate_arguments_contents(operation.arguments, call_with_t his_handle))
95 return contents 97 return contents
96 98
97 99
98 def generate_arguments_contents(arguments): 100 def generate_arguments_contents(arguments, call_with_this_handle):
99 def argument_declaration(argument): 101 def argument_declaration(argument):
100 return '%s %s' % (cpp_type(argument.data_type), argument.name) 102 return '%s %s' % (cpp_type(argument.data_type), argument.name)
101 103
102 def generate_argument(argument): 104 def generate_argument(argument):
103 return { 105 return {
104 'name': argument.name, 106 'name': argument.name,
105 'cpp_to_v8_conversion': cpp_to_v8_conversion(argument.data_type, arg ument.name), 107 'cpp_to_v8_conversion': cpp_to_v8_conversion(argument.data_type, arg ument.name),
106 } 108 }
107 109
110 argument_declarations = [argument_declaration(argument) for argument in argu ments]
111 if call_with_this_handle:
112 argument_declarations.insert(0, 'ScriptValue thisValue')
108 return { 113 return {
109 'argument_declarations': [argument_declaration(argument) for argument in arguments], 114 'argument_declarations': argument_declarations,
110 'arguments': [generate_argument(argument) for argument in arguments], 115 'arguments': [generate_argument(argument) for argument in arguments],
111 'handles': ['%sHandle' % argument.name for argument in arguments], 116 'handles': ['%sHandle' % argument.name for argument in arguments],
112 } 117 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698