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

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

Issue 656073002: IDL: Use ALLOW_ONLY_INLINE_ALLOCATION() in dictionaries (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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 # 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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 if not argument.is_optional]), 172 if not argument.is_optional]),
173 'only_exposed_to_private_script': is_only_exposed_to_private_script, 173 'only_exposed_to_private_script': is_only_exposed_to_private_script,
174 'per_context_enabled_function': v8_utilities.per_context_enabled_functio n_name(method), # [PerContextEnabled] 174 'per_context_enabled_function': v8_utilities.per_context_enabled_functio n_name(method), # [PerContextEnabled]
175 'private_script_v8_value_to_local_cpp_value': idl_type.v8_value_to_local _cpp_value( 175 'private_script_v8_value_to_local_cpp_value': idl_type.v8_value_to_local _cpp_value(
176 extended_attributes, 'v8Value', 'cppValue', isolate='scriptState->is olate()', used_in_private_script=True), 176 extended_attributes, 'v8Value', 'cppValue', isolate='scriptState->is olate()', used_in_private_script=True),
177 'property_attributes': property_attributes(method), 177 'property_attributes': property_attributes(method),
178 'runtime_enabled_function': v8_utilities.runtime_enabled_function_name(m ethod), # [RuntimeEnabled] 178 'runtime_enabled_function': v8_utilities.runtime_enabled_function_name(m ethod), # [RuntimeEnabled]
179 'should_be_exposed_to_script': not (is_implemented_in_private_script and is_only_exposed_to_private_script), 179 'should_be_exposed_to_script': not (is_implemented_in_private_script and is_only_exposed_to_private_script),
180 'signature': 'v8::Local<v8::Signature>()' if is_static or 'DoNotCheckSig nature' in extended_attributes else 'defaultSignature', 180 'signature': 'v8::Local<v8::Signature>()' if is_static or 'DoNotCheckSig nature' in extended_attributes else 'defaultSignature',
181 'union_arguments': idl_type.union_arguments, 181 'union_arguments': idl_type.union_arguments,
182 'use_argument_for_return_value': idl_type.is_dictionary,
haraken 2014/10/15 14:38:28 use_output_parameter_for_result ? 'argument' is a
bashi 2014/10/17 00:50:05 Done.
182 'use_local_result': use_local_result(method), 183 'use_local_result': use_local_result(method),
183 'v8_set_return_value': v8_set_return_value(interface.name, method, this_ cpp_value), 184 'v8_set_return_value': v8_set_return_value(interface.name, method, this_ cpp_value),
184 'v8_set_return_value_for_main_world': v8_set_return_value(interface.name , method, this_cpp_value, for_main_world=True), 185 'v8_set_return_value_for_main_world': v8_set_return_value(interface.name , method, this_cpp_value, for_main_world=True),
185 'world_suffixes': ['', 'ForMainWorld'] if 'PerWorldBindings' in extended _attributes else [''], # [PerWorldBindings], 186 'world_suffixes': ['', 'ForMainWorld'] if 'PerWorldBindings' in extended _attributes else [''], # [PerWorldBindings],
186 } 187 }
187 188
188 189
189 def argument_context(interface, method, argument, index): 190 def argument_context(interface, method, argument, index):
190 extended_attributes = argument.extended_attributes 191 extended_attributes = argument.extended_attributes
191 idl_type = argument.idl_type 192 idl_type = argument.idl_type
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 260
260 ################################################################################ 261 ################################################################################
261 # Value handling 262 # Value handling
262 ################################################################################ 263 ################################################################################
263 264
264 def cpp_value(interface, method, number_of_arguments): 265 def cpp_value(interface, method, number_of_arguments):
265 def cpp_argument(argument): 266 def cpp_argument(argument):
266 idl_type = argument.idl_type 267 idl_type = argument.idl_type
267 if idl_type.name == 'EventListener': 268 if idl_type.name == 'EventListener':
268 return argument.name 269 return argument.name
269 if idl_type.is_dictionary:
270 return '*%s' % argument.name
271 if (idl_type.name in ['NodeFilter', 'NodeFilterOrNull', 270 if (idl_type.name in ['NodeFilter', 'NodeFilterOrNull',
272 'XPathNSResolver', 'XPathNSResolverOrNull']): 271 'XPathNSResolver', 'XPathNSResolverOrNull']):
273 # FIXME: remove this special case 272 # FIXME: remove this special case
274 return '%s.release()' % argument.name 273 return '%s.release()' % argument.name
275 return argument.name 274 return argument.name
276 275
277 # Truncate omitted optional arguments 276 # Truncate omitted optional arguments
278 arguments = method.arguments[:number_of_arguments] 277 arguments = method.arguments[:number_of_arguments]
279 cpp_arguments = [] 278 cpp_arguments = []
280 if 'ImplementedInPrivateScript' in method.extended_attributes: 279 if 'ImplementedInPrivateScript' in method.extended_attributes:
(...skipping 21 matching lines...) Expand all
302 for member_argument in this_union_arguments]) 301 for member_argument in this_union_arguments])
303 302
304 if 'ImplementedInPrivateScript' in method.extended_attributes: 303 if 'ImplementedInPrivateScript' in method.extended_attributes:
305 if method.idl_type.name != 'void': 304 if method.idl_type.name != 'void':
306 cpp_arguments.append('&result') 305 cpp_arguments.append('&result')
307 elif ('RaisesException' in method.extended_attributes or 306 elif ('RaisesException' in method.extended_attributes or
308 (method.is_constructor and 307 (method.is_constructor and
309 has_extended_attribute_value(interface, 'RaisesException', 'Constructor '))): 308 has_extended_attribute_value(interface, 'RaisesException', 'Constructor '))):
310 cpp_arguments.append('exceptionState') 309 cpp_arguments.append('exceptionState')
311 310
311 # If a method returns an IDL dictionary, the return value is passed
312 # as an argument to impl classes.
313 if method.idl_type and method.idl_type.is_dictionary:
haraken 2014/10/15 14:38:28 Do we need the 'method.idl_type and' part?
Jens Widell 2014/10/15 15:39:17 Probably for constructors. Typically when you thin
bashi 2014/10/17 00:50:05 Yes. Similar check exists on L298.
314 cpp_arguments.append('cppValue')
315
312 if method.name == 'Constructor': 316 if method.name == 'Constructor':
313 base_name = 'create' 317 base_name = 'create'
314 elif method.name == 'NamedConstructor': 318 elif method.name == 'NamedConstructor':
315 base_name = 'createForJSConstructor' 319 base_name = 'createForJSConstructor'
316 elif 'ImplementedInPrivateScript' in method.extended_attributes: 320 elif 'ImplementedInPrivateScript' in method.extended_attributes:
317 base_name = '%sMethod' % method.name 321 base_name = '%sMethod' % method.name
318 else: 322 else:
319 base_name = v8_utilities.cpp_name(method) 323 base_name = v8_utilities.cpp_name(method)
320 324
321 cpp_method_name = v8_utilities.scoped_name(interface, method, base_name) 325 cpp_method_name = v8_utilities.scoped_name(interface, method, base_name)
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 430
427 431
428 def union_arguments(idl_type): 432 def union_arguments(idl_type):
429 return [union_member_argument_context(member_idl_type, index) 433 return [union_member_argument_context(member_idl_type, index)
430 for index, member_idl_type 434 for index, member_idl_type
431 in enumerate(idl_type.member_types)] 435 in enumerate(idl_type.member_types)]
432 436
433 437
434 def argument_default_cpp_value(argument): 438 def argument_default_cpp_value(argument):
435 if argument.idl_type.is_dictionary: 439 if argument.idl_type.is_dictionary:
436 # We always create impl objects for IDL dictionaries. 440 return None
437 return '%s::create()' % argument.idl_type.base_type
438 if not argument.default_value: 441 if not argument.default_value:
439 return None 442 return None
440 return argument.idl_type.literal_cpp_value(argument.default_value) 443 return argument.idl_type.literal_cpp_value(argument.default_value)
441 444
442 IdlTypeBase.union_arguments = None 445 IdlTypeBase.union_arguments = None
443 IdlUnionType.union_arguments = property(union_arguments) 446 IdlUnionType.union_arguments = property(union_arguments)
444 IdlArgument.default_cpp_value = property(argument_default_cpp_value) 447 IdlArgument.default_cpp_value = property(argument_default_cpp_value)
445 448
446 449
447 def method_returns_promise(method): 450 def method_returns_promise(method):
448 return method.idl_type and method.idl_type.name == 'Promise' 451 return method.idl_type and method.idl_type.name == 'Promise'
449 452
450 IdlOperation.returns_promise = property(method_returns_promise) 453 IdlOperation.returns_promise = property(method_returns_promise)
451 454
452 455
453 def argument_conversion_needs_exception_state(method, argument): 456 def argument_conversion_needs_exception_state(method, argument):
454 idl_type = argument.idl_type 457 idl_type = argument.idl_type
455 return (idl_type.v8_conversion_needs_exception_state or 458 return (idl_type.v8_conversion_needs_exception_state or
456 argument.is_variadic or 459 argument.is_variadic or
457 (method.returns_promise and (idl_type.is_string_type or 460 (method.returns_promise and (idl_type.is_string_type or
458 idl_type.is_enum))) 461 idl_type.is_enum)))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698