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

Side by Side Diff: bindings/scripts/v8_methods.py

Issue 959933002: Move IDLs to 39 roll (Closed) Base URL: https://dart.googlecode.com/svn/third_party/WebCore
Patch Set: Created 5 years, 10 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
« no previous file with comments | « bindings/scripts/v8_interface.py ('k') | bindings/scripts/v8_types.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 # 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 16 matching lines...) Expand all
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 methods. 29 """Generate template values for methods.
30 30
31 Extends IdlArgument with property |default_cpp_value|. 31 Extends IdlArgument with property |default_cpp_value|.
32 Extends IdlTypeBase and IdlUnionType with property |union_arguments|. 32 Extends IdlTypeBase and IdlUnionType with property |union_arguments|.
33 33
34 Design doc: http://www.chromium.org/developers/design-documents/idl-compiler 34 Design doc: http://www.chromium.org/developers/design-documents/idl-compiler
35 """ 35 """
36 36
37 from idl_definitions import IdlArgument 37 from idl_definitions import IdlArgument, IdlOperation
38 from idl_types import IdlTypeBase, IdlUnionType, inherits_interface 38 from idl_types import IdlTypeBase, IdlUnionType, inherits_interface
39 from v8_globals import includes 39 from v8_globals import includes
40 import v8_types 40 import v8_types
41 import v8_utilities 41 import v8_utilities
42 from v8_utilities import has_extended_attribute_value 42 from v8_utilities import has_extended_attribute_value
43 43
44 44
45 # Methods with any of these require custom method registration code in the 45 # Methods with any of these require custom method registration code in the
46 # interface's configure*Template() function. 46 # interface's configure*Template() function.
47 CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES = frozenset([ 47 CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES = frozenset([
48 'DoNotCheckSecurity', 48 'DoNotCheckSecurity',
49 'DoNotCheckSignature', 49 'DoNotCheckSignature',
50 'NotEnumerable', 50 'NotEnumerable',
51 'Unforgeable', 51 'Unforgeable',
52 ]) 52 ])
53 53
54 54
55 def argument_needs_try_catch(argument, return_promise):
56 idl_type = argument.idl_type
57 base_type = idl_type.base_type
58
59 return not (
60 # These cases are handled by separate code paths in the
61 # generate_argument() macro in Source/bindings/templates/methods.cpp.
62 idl_type.is_callback_interface or
63 base_type == 'SerializedScriptValue' or
64 (argument.is_variadic and idl_type.is_wrapper_type) or
65 # String and enumeration arguments converted using one of the
66 # TOSTRING_* macros except for _PROMISE variants in
67 # Source/bindings/core/v8/V8BindingMacros.h don't use a v8::TryCatch.
68 (base_type == 'DOMString' and not argument.is_variadic and
69 not return_promise))
70
71
72 def use_local_result(method): 55 def use_local_result(method):
73 extended_attributes = method.extended_attributes 56 extended_attributes = method.extended_attributes
74 idl_type = method.idl_type 57 idl_type = method.idl_type
75 return (has_extended_attribute_value(method, 'CallWith', 'ScriptState') or 58 return (has_extended_attribute_value(method, 'CallWith', 'ScriptState') or
76 'ImplementedInPrivateScript' in extended_attributes or 59 'ImplementedInPrivateScript' in extended_attributes or
77 'RaisesException' in extended_attributes or 60 'RaisesException' in extended_attributes or
78 idl_type.is_union_type or 61 idl_type.is_union_type or
79 idl_type.is_explicit_nullable) 62 idl_type.is_explicit_nullable)
80 63
81 64
82 def method_context(interface, method): 65 def method_context(interface, method):
83 arguments = method.arguments 66 arguments = method.arguments
84 extended_attributes = method.extended_attributes 67 extended_attributes = method.extended_attributes
85 idl_type = method.idl_type 68 idl_type = method.idl_type
86 is_static = method.is_static 69 is_static = method.is_static
87 name = method.name 70 name = method.name
88 return_promise = idl_type.name == 'Promise'
89 71
90 idl_type.add_includes_for_type() 72 idl_type.add_includes_for_type()
91 this_cpp_value = cpp_value(interface, method, len(arguments)) 73 this_cpp_value = cpp_value(interface, method, len(arguments))
92 74
93 def function_template(): 75 def function_template():
94 if is_static: 76 if is_static:
95 return 'functionTemplate' 77 return 'functionTemplate'
96 if 'Unforgeable' in extended_attributes: 78 if 'Unforgeable' in extended_attributes:
97 return 'instanceTemplate' 79 return 'instanceTemplate'
98 return 'prototypeTemplate' 80 return 'prototypeTemplate'
(...skipping 12 matching lines...) Expand all
111 includes.update(['bindings/core/v8/ScriptCallStackFactory.h', 93 includes.update(['bindings/core/v8/ScriptCallStackFactory.h',
112 'core/inspector/ScriptArguments.h']) 94 'core/inspector/ScriptArguments.h'])
113 is_call_with_script_state = has_extended_attribute_value(method, 'CallWith', 'ScriptState') 95 is_call_with_script_state = has_extended_attribute_value(method, 'CallWith', 'ScriptState')
114 if is_call_with_script_state: 96 if is_call_with_script_state:
115 includes.add('bindings/core/v8/V8ScriptState.h') 97 includes.add('bindings/core/v8/V8ScriptState.h')
116 is_check_security_for_node = 'CheckSecurity' in extended_attributes 98 is_check_security_for_node = 'CheckSecurity' in extended_attributes
117 if is_check_security_for_node: 99 if is_check_security_for_node:
118 includes.add('bindings/common/BindingSecurity.h') 100 includes.add('bindings/common/BindingSecurity.h')
119 is_custom_element_callbacks = 'CustomElementCallbacks' in extended_attribute s 101 is_custom_element_callbacks = 'CustomElementCallbacks' in extended_attribute s
120 if is_custom_element_callbacks: 102 if is_custom_element_callbacks:
121 includes.add('core/dom/custom/CustomElementCallbackDispatcher.h') 103 includes.add('core/dom/custom/CustomElementProcessingStack.h')
104
105 is_do_not_check_security = 'DoNotCheckSecurity' in extended_attributes
122 106
123 is_check_security_for_frame = ( 107 is_check_security_for_frame = (
124 'CheckSecurity' in interface.extended_attributes and 108 has_extended_attribute_value(interface, 'CheckSecurity', 'Frame') and
125 'DoNotCheckSecurity' not in extended_attributes) 109 not is_do_not_check_security)
110
111 is_check_security_for_window = (
112 has_extended_attribute_value(interface, 'CheckSecurity', 'Window') and
113 not is_do_not_check_security)
114
126 is_raises_exception = 'RaisesException' in extended_attributes 115 is_raises_exception = 'RaisesException' in extended_attributes
127 116
128 arguments_need_try_catch = (
129 any(argument_needs_try_catch(argument, return_promise)
130 for argument in arguments))
131
132 return { 117 return {
133 'activity_logging_world_list': v8_utilities.activity_logging_world_list( method), # [ActivityLogging] 118 'activity_logging_world_list': v8_utilities.activity_logging_world_list( method), # [ActivityLogging]
134 'arguments': [argument_context(interface, method, argument, index) 119 'arguments': [argument_context(interface, method, argument, index)
135 for index, argument in enumerate(arguments)], 120 for index, argument in enumerate(arguments)],
136 'argument_declarations_for_private_script': 121 'argument_declarations_for_private_script':
137 argument_declarations_for_private_script(interface, method), 122 argument_declarations_for_private_script(interface, method),
138 'arguments_need_try_catch': arguments_need_try_catch,
139 'conditional_string': v8_utilities.conditional_string(method), 123 'conditional_string': v8_utilities.conditional_string(method),
140 'cpp_type': (v8_types.cpp_template_type('Nullable', idl_type.cpp_type) 124 'cpp_type': (v8_types.cpp_template_type('Nullable', idl_type.cpp_type)
141 if idl_type.is_explicit_nullable else idl_type.cpp_type), 125 if idl_type.is_explicit_nullable else idl_type.cpp_type),
142 'cpp_value': this_cpp_value, 126 'cpp_value': this_cpp_value,
143 'cpp_type_initializer': idl_type.cpp_type_initializer, 127 'cpp_type_initializer': idl_type.cpp_type_initializer,
144 'custom_registration_extended_attributes': 128 'custom_registration_extended_attributes':
145 CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES.intersection( 129 CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES.intersection(
146 extended_attributes.iterkeys()), 130 extended_attributes.iterkeys()),
147 'deprecate_as': v8_utilities.deprecate_as(method), # [DeprecateAs] 131 'deprecate_as': v8_utilities.deprecate_as(method), # [DeprecateAs]
148 'exposed_test': v8_utilities.exposed(method, interface), # [Exposed] 132 'exposed_test': v8_utilities.exposed(method, interface), # [Exposed]
149 'function_template': function_template(), 133 'function_template': function_template(),
150 'has_custom_registration': is_static or 134 'has_custom_registration': is_static or
151 v8_utilities.has_extended_attribute( 135 v8_utilities.has_extended_attribute(
152 method, CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES), 136 method, CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES),
153 'has_exception_state': 137 'has_exception_state':
154 is_raises_exception or 138 is_raises_exception or
155 is_check_security_for_frame or 139 is_check_security_for_frame or
156 interface.name == 'EventTarget' or # FIXME: merge with is_check_sec urity_for_frame http://crbug.com/383699 140 is_check_security_for_window or
157 any(argument for argument in arguments 141 any(argument for argument in arguments
158 if argument.idl_type.name == 'SerializedScriptValue' or 142 if (argument.idl_type.name == 'SerializedScriptValue' or
159 argument.idl_type.may_raise_exception_on_conversion), 143 argument_conversion_needs_exception_state(method, argument)) ),
160 'idl_type': idl_type.base_type, 144 'idl_type': idl_type.base_type,
161 'is_call_with_execution_context': has_extended_attribute_value(method, ' CallWith', 'ExecutionContext'), 145 'is_call_with_execution_context': has_extended_attribute_value(method, ' CallWith', 'ExecutionContext'),
162 'is_call_with_script_arguments': is_call_with_script_arguments, 146 'is_call_with_script_arguments': is_call_with_script_arguments,
163 'is_call_with_script_state': is_call_with_script_state, 147 'is_call_with_script_state': is_call_with_script_state,
164 'is_check_security_for_frame': is_check_security_for_frame, 148 'is_check_security_for_frame': is_check_security_for_frame,
165 'is_check_security_for_node': is_check_security_for_node, 149 'is_check_security_for_node': is_check_security_for_node,
150 'is_check_security_for_window': is_check_security_for_window,
166 'is_custom': 'Custom' in extended_attributes, 151 'is_custom': 'Custom' in extended_attributes,
167 'is_custom_element_callbacks': is_custom_element_callbacks, 152 'is_custom_element_callbacks': is_custom_element_callbacks,
168 'is_do_not_check_security': 'DoNotCheckSecurity' in extended_attributes, 153 'is_do_not_check_security': is_do_not_check_security,
169 'is_do_not_check_signature': 'DoNotCheckSignature' in extended_attribute s, 154 'is_do_not_check_signature': 'DoNotCheckSignature' in extended_attribute s,
170 'is_explicit_nullable': idl_type.is_explicit_nullable, 155 'is_explicit_nullable': idl_type.is_explicit_nullable,
171 'is_implemented_in_private_script': is_implemented_in_private_script, 156 'is_implemented_in_private_script': is_implemented_in_private_script,
172 'is_partial_interface_member': 157 'is_partial_interface_member':
173 'PartialInterfaceImplementedAs' in extended_attributes, 158 'PartialInterfaceImplementedAs' in extended_attributes,
174 'is_per_world_bindings': 'PerWorldBindings' in extended_attributes, 159 'is_per_world_bindings': 'PerWorldBindings' in extended_attributes,
175 'is_raises_exception': is_raises_exception, 160 'is_raises_exception': is_raises_exception,
176 'is_read_only': 'Unforgeable' in extended_attributes, 161 'is_read_only': 'Unforgeable' in extended_attributes,
177 'is_static': is_static, 162 'is_static': is_static,
178 'is_variadic': arguments and arguments[-1].is_variadic, 163 'is_variadic': arguments and arguments[-1].is_variadic,
(...skipping 20 matching lines...) Expand all
199 'v8_set_return_value_for_main_world': v8_set_return_value(interface.name , method, this_cpp_value, for_main_world=True), 184 'v8_set_return_value_for_main_world': v8_set_return_value(interface.name , method, this_cpp_value, for_main_world=True),
200 'world_suffixes': ['', 'ForMainWorld'] if 'PerWorldBindings' in extended _attributes else [''], # [PerWorldBindings], 185 'world_suffixes': ['', 'ForMainWorld'] if 'PerWorldBindings' in extended _attributes else [''], # [PerWorldBindings],
201 } 186 }
202 187
203 188
204 def argument_context(interface, method, argument, index): 189 def argument_context(interface, method, argument, index):
205 extended_attributes = argument.extended_attributes 190 extended_attributes = argument.extended_attributes
206 idl_type = argument.idl_type 191 idl_type = argument.idl_type
207 this_cpp_value = cpp_value(interface, method, index) 192 this_cpp_value = cpp_value(interface, method, index)
208 is_variadic_wrapper_type = argument.is_variadic and idl_type.is_wrapper_type 193 is_variadic_wrapper_type = argument.is_variadic and idl_type.is_wrapper_type
209 return_promise = (method.idl_type.name == 'Promise' if method.idl_type
210 else False)
211 194
212 if ('ImplementedInPrivateScript' in extended_attributes and 195 if ('ImplementedInPrivateScript' in extended_attributes and
213 not idl_type.is_wrapper_type and 196 not idl_type.is_wrapper_type and
214 not idl_type.is_basic_type): 197 not idl_type.is_basic_type):
215 raise Exception('Private scripts supports only primitive types and DOM w rappers.') 198 raise Exception('Private scripts supports only primitive types and DOM w rappers.')
216 199
200 default_cpp_value = argument.default_cpp_value
217 return { 201 return {
218 'cpp_type': idl_type.cpp_type_args(extended_attributes=extended_attribut es, 202 'cpp_type': idl_type.cpp_type_args(extended_attributes=extended_attribut es,
219 raw_type=True, 203 raw_type=True,
220 used_as_variadic_argument=argument.is _variadic), 204 used_as_variadic_argument=argument.is _variadic),
221 'cpp_type_initializer': idl_type.cpp_type_initializer,
222 'cpp_value': this_cpp_value, 205 'cpp_value': this_cpp_value,
223 # FIXME: check that the default value's type is compatible with the argu ment's 206 # FIXME: check that the default value's type is compatible with the argu ment's
224 'default_value': argument.default_cpp_value, 207 'default_value': default_cpp_value,
225 'enum_validation_expression': idl_type.enum_validation_expression, 208 'enum_validation_expression': idl_type.enum_validation_expression,
226 'handle': '%sHandle' % argument.name, 209 'handle': '%sHandle' % argument.name,
227 # FIXME: remove once [Default] removed and just use argument.default_val ue 210 # FIXME: remove once [Default] removed and just use argument.default_val ue
228 'has_default': 'Default' in extended_attributes or argument.default_valu e, 211 'has_default': 'Default' in extended_attributes or default_cpp_value,
229 'has_type_checking_interface': 212 'has_type_checking_interface':
230 (has_extended_attribute_value(interface, 'TypeChecking', 'Interface' ) or 213 (has_extended_attribute_value(interface, 'TypeChecking', 'Interface' ) or
231 has_extended_attribute_value(method, 'TypeChecking', 'Interface')) and 214 has_extended_attribute_value(method, 'TypeChecking', 'Interface')) and
232 idl_type.is_wrapper_type, 215 idl_type.is_wrapper_type,
233 'has_type_checking_unrestricted': 216 'has_type_checking_unrestricted':
234 (has_extended_attribute_value(interface, 'TypeChecking', 'Unrestrict ed') or 217 (has_extended_attribute_value(interface, 'TypeChecking', 'Unrestrict ed') or
235 has_extended_attribute_value(method, 'TypeChecking', 'Unrestricted' )) and 218 has_extended_attribute_value(method, 'TypeChecking', 'Unrestricted' )) and
236 idl_type.name in ('Float', 'Double'), 219 idl_type.name in ('Float', 'Double'),
237 # Dictionary is special-cased, but arrays and sequences shouldn't be 220 # Dictionary is special-cased, but arrays and sequences shouldn't be
238 'idl_type': idl_type.base_type, 221 'idl_type': idl_type.base_type,
239 'idl_type_object': idl_type, 222 'idl_type_object': idl_type,
240 'index': index, 223 'index': index,
241 'is_clamp': 'Clamp' in extended_attributes,
242 'is_callback_interface': idl_type.is_callback_interface, 224 'is_callback_interface': idl_type.is_callback_interface,
225 # FIXME: Remove generic 'Dictionary' special-casing
226 'is_dictionary': idl_type.is_dictionary or idl_type.base_type == 'Dictio nary',
243 'is_nullable': idl_type.is_nullable, 227 'is_nullable': idl_type.is_nullable,
244 'is_optional': argument.is_optional, 228 'is_optional': argument.is_optional,
245 'is_variadic_wrapper_type': is_variadic_wrapper_type, 229 'is_variadic_wrapper_type': is_variadic_wrapper_type,
246 'is_wrapper_type': idl_type.is_wrapper_type, 230 'is_wrapper_type': idl_type.is_wrapper_type,
247 'name': argument.name, 231 'name': argument.name,
248 'private_script_cpp_value_to_v8_value': idl_type.cpp_value_to_v8_value( 232 'private_script_cpp_value_to_v8_value': idl_type.cpp_value_to_v8_value(
249 argument.name, isolate='scriptState->isolate()', 233 argument.name, isolate='scriptState->isolate()',
250 creation_context='scriptState->context()->Global()'), 234 creation_context='scriptState->context()->Global()'),
251 'v8_set_return_value': v8_set_return_value(interface.name, method, this_ cpp_value), 235 'v8_set_return_value': v8_set_return_value(interface.name, method, this_ cpp_value),
252 'v8_set_return_value_for_main_world': v8_set_return_value(interface.name , method, this_cpp_value, for_main_world=True), 236 'v8_set_return_value_for_main_world': v8_set_return_value(interface.name , method, this_cpp_value, for_main_world=True),
253 'v8_value_to_local_cpp_value': v8_value_to_local_cpp_value(argument, ind ex, return_promise=return_promise), 237 'v8_value_to_local_cpp_value': v8_value_to_local_cpp_value(argument, ind ex, return_promise=method.returns_promise),
254 'vector_type': v8_types.cpp_ptr_type('Vector', 'HeapVector', idl_type.gc _type), 238 'vector_type': v8_types.cpp_ptr_type('Vector', 'HeapVector', idl_type.gc _type),
255 } 239 }
256 240
257 241
258 def argument_declarations_for_private_script(interface, method): 242 def argument_declarations_for_private_script(interface, method):
259 argument_declarations = ['LocalFrame* frame'] 243 argument_declarations = ['LocalFrame* frame']
260 argument_declarations.append('%s* holderImpl' % interface.name) 244 argument_declarations.append('%s* holderImpl' % interface.name)
261 argument_declarations.extend(['%s %s' % (argument.idl_type.cpp_type_args( 245 argument_declarations.extend(['%s %s' % (argument.idl_type.cpp_type_args(
262 used_as_rvalue_type=True), argument.name) for argument in method.argumen ts]) 246 used_as_rvalue_type=True), argument.name) for argument in method.argumen ts])
263 if method.idl_type.name != 'void': 247 if method.idl_type.name != 'void':
264 argument_declarations.append('%s* %s' % (method.idl_type.cpp_type, 'resu lt')) 248 argument_declarations.append('%s* %s' % (method.idl_type.cpp_type, 'resu lt'))
265 return argument_declarations 249 return argument_declarations
266 250
267 251
268 ################################################################################ 252 ################################################################################
269 # Value handling 253 # Value handling
270 ################################################################################ 254 ################################################################################
271 255
272 def cpp_value(interface, method, number_of_arguments): 256 def cpp_value(interface, method, number_of_arguments):
273 def cpp_argument(argument): 257 def cpp_argument(argument):
274 idl_type = argument.idl_type 258 idl_type = argument.idl_type
275 if idl_type.name == 'EventListener': 259 if idl_type.name == 'EventListener':
276 return argument.name 260 return argument.name
277 if (idl_type.is_callback_interface or 261 if idl_type.is_dictionary:
278 idl_type.name in ['NodeFilter', 'NodeFilterOrNull', 262 return '*%s' % argument.name
263 if (idl_type.name in ['NodeFilter', 'NodeFilterOrNull',
279 'XPathNSResolver', 'XPathNSResolverOrNull']): 264 'XPathNSResolver', 'XPathNSResolverOrNull']):
280 # FIXME: remove this special case 265 # FIXME: remove this special case
281 return '%s.release()' % argument.name 266 return '%s.release()' % argument.name
282 return argument.name 267 return argument.name
283 268
284 # Truncate omitted optional arguments 269 # Truncate omitted optional arguments
285 arguments = method.arguments[:number_of_arguments] 270 arguments = method.arguments[:number_of_arguments]
286 cpp_arguments = [] 271 cpp_arguments = []
287 if 'ImplementedInPrivateScript' in method.extended_attributes: 272 if 'ImplementedInPrivateScript' in method.extended_attributes:
288 cpp_arguments.append('toFrameIfNotDetached(info.GetIsolate()->GetCurrent Context())') 273 cpp_arguments.append('toFrameIfNotDetached(info.GetIsolate()->GetCurrent Context())')
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 script_wrappable = 'impl' if inherits_interface(interface_name, 'Node') else '' 339 script_wrappable = 'impl' if inherits_interface(interface_name, 'Node') else ''
355 return idl_type.v8_set_return_value(cpp_value, extended_attributes, script_w rappable=script_wrappable, release=release, for_main_world=for_main_world) 340 return idl_type.v8_set_return_value(cpp_value, extended_attributes, script_w rappable=script_wrappable, release=release, for_main_world=for_main_world)
356 341
357 342
358 def v8_value_to_local_cpp_variadic_value(argument, index, return_promise): 343 def v8_value_to_local_cpp_variadic_value(argument, index, return_promise):
359 assert argument.is_variadic 344 assert argument.is_variadic
360 idl_type = argument.idl_type 345 idl_type = argument.idl_type
361 346
362 suffix = '' 347 suffix = ''
363 348
364 macro = 'TONATIVE_VOID' 349 macro = 'TONATIVE_VOID_EXCEPTIONSTATE'
365 macro_args = [ 350 macro_args = [
366 argument.name, 351 argument.name,
367 'toNativeArguments<%s>(info, %s)' % (idl_type.cpp_type, index), 352 'toImplArguments<%s>(info, %s, exceptionState)' % (idl_type.cpp_type, in dex),
353 'exceptionState',
368 ] 354 ]
369 355
370 if return_promise: 356 if return_promise:
371 suffix += '_PROMISE' 357 suffix += '_PROMISE'
372 macro_args.append('info') 358 macro_args.extend(['info', 'V8ScriptState::current(info.GetIsolate())'])
373 359
374 suffix += '_INTERNAL' 360 suffix += '_INTERNAL'
375 361
376 return '%s%s(%s)' % (macro, suffix, ', '.join(macro_args)) 362 return '%s%s(%s)' % (macro, suffix, ', '.join(macro_args))
377 363
378 364
379 def v8_value_to_local_cpp_value(argument, index, return_promise=False): 365 def v8_value_to_local_cpp_value(argument, index, return_promise=False):
380 extended_attributes = argument.extended_attributes 366 extended_attributes = argument.extended_attributes
381 idl_type = argument.idl_type 367 idl_type = argument.idl_type
382 name = argument.name 368 name = argument.name
(...skipping 17 matching lines...) Expand all
400 property_attributes_list.append('v8::ReadOnly') 386 property_attributes_list.append('v8::ReadOnly')
401 if property_attributes_list: 387 if property_attributes_list:
402 property_attributes_list.insert(0, 'v8::DontDelete') 388 property_attributes_list.insert(0, 'v8::DontDelete')
403 return property_attributes_list 389 return property_attributes_list
404 390
405 391
406 def union_member_argument_context(idl_type, index): 392 def union_member_argument_context(idl_type, index):
407 """Returns a context of union member for argument.""" 393 """Returns a context of union member for argument."""
408 this_cpp_value = 'result%d' % index 394 this_cpp_value = 'result%d' % index
409 this_cpp_type = idl_type.cpp_type 395 this_cpp_type = idl_type.cpp_type
396 this_cpp_type_initializer = idl_type.cpp_type_initializer
410 cpp_return_value = this_cpp_value 397 cpp_return_value = this_cpp_value
411 398
412 if not idl_type.cpp_type_has_null_value: 399 if not idl_type.cpp_type_has_null_value:
413 this_cpp_type = v8_types.cpp_template_type('Nullable', this_cpp_type) 400 this_cpp_type = v8_types.cpp_template_type('Nullable', this_cpp_type)
401 this_cpp_type_initializer = ''
414 cpp_return_value = '%s.get()' % this_cpp_value 402 cpp_return_value = '%s.get()' % this_cpp_value
415 403
416 if idl_type.is_string_type: 404 if idl_type.is_string_type:
417 null_check_value = '!%s.isNull()' % this_cpp_value 405 null_check_value = '!%s.isNull()' % this_cpp_value
418 else: 406 else:
419 null_check_value = this_cpp_value 407 null_check_value = this_cpp_value
420 408
421 return { 409 return {
422 'cpp_type': this_cpp_type, 410 'cpp_type': this_cpp_type,
411 'cpp_type_initializer': this_cpp_type_initializer,
423 'cpp_value': this_cpp_value, 412 'cpp_value': this_cpp_value,
424 'null_check_value': null_check_value, 413 'null_check_value': null_check_value,
425 'v8_set_return_value': idl_type.v8_set_return_value( 414 'v8_set_return_value': idl_type.v8_set_return_value(
426 cpp_value=cpp_return_value, 415 cpp_value=cpp_return_value,
427 release=idl_type.release), 416 release=idl_type.release),
428 } 417 }
429 418
430 419
431 def union_arguments(idl_type): 420 def union_arguments(idl_type):
432 return [union_member_argument_context(member_idl_type, index) 421 return [union_member_argument_context(member_idl_type, index)
433 for index, member_idl_type 422 for index, member_idl_type
434 in enumerate(idl_type.member_types)] 423 in enumerate(idl_type.member_types)]
435 424
436 425
437 def argument_default_cpp_value(argument): 426 def argument_default_cpp_value(argument):
427 if argument.idl_type.is_dictionary:
428 # We always create impl objects for IDL dictionaries.
429 return '%s::create()' % argument.idl_type.base_type
438 if not argument.default_value: 430 if not argument.default_value:
439 return None 431 return None
440 return argument.idl_type.literal_cpp_value(argument.default_value) 432 return argument.idl_type.literal_cpp_value(argument.default_value)
441 433
442 IdlTypeBase.union_arguments = None 434 IdlTypeBase.union_arguments = None
443 IdlUnionType.union_arguments = property(union_arguments) 435 IdlUnionType.union_arguments = property(union_arguments)
444 IdlArgument.default_cpp_value = property(argument_default_cpp_value) 436 IdlArgument.default_cpp_value = property(argument_default_cpp_value)
437
438
439 def method_returns_promise(method):
440 return method.idl_type and method.idl_type.name == 'Promise'
441
442 IdlOperation.returns_promise = property(method_returns_promise)
443
444
445 def argument_conversion_needs_exception_state(method, argument):
446 idl_type = argument.idl_type
447 return (idl_type.v8_conversion_needs_exception_state or
448 argument.is_variadic or
449 (method.returns_promise and (idl_type.is_string_type or
450 idl_type.is_enum)))
OLDNEW
« no previous file with comments | « bindings/scripts/v8_interface.py ('k') | bindings/scripts/v8_types.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698