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

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

Issue 555133003: Use ExceptionState to throw exceptions when converting arrays (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: fix MessagePortArray conversion Created 6 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
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 return_promise = method.idl_type and method.idl_type.name == 'Promise' 56 return_promise = method.idl_type and method.idl_type.name == 'Promise'
57 idl_type = argument.idl_type 57 idl_type = argument.idl_type
58 base_type = idl_type.base_type 58 base_type = idl_type.base_type
59 59
60 return not( 60 return not(
61 # These cases are handled by separate code paths in the 61 # These cases are handled by separate code paths in the
62 # generate_argument() macro in Source/bindings/templates/methods.cpp. 62 # generate_argument() macro in Source/bindings/templates/methods.cpp.
63 idl_type.is_callback_interface or 63 idl_type.is_callback_interface or
64 base_type == 'SerializedScriptValue' or 64 base_type == 'SerializedScriptValue' or
65 (argument.is_variadic and idl_type.is_wrapper_type) or 65 (argument.is_variadic and idl_type.is_wrapper_type) or
66 # Variadic arguments use toImplArguments() with throws excentions via
67 # its ExceptionState& argument.
68 argument.is_variadic or
66 # String and enumeration arguments converted using one of the 69 # String and enumeration arguments converted using one of the
67 # TOSTRING_* macros except for _PROMISE variants in 70 # TOSTRING_* macros except for _PROMISE variants in
68 # Source/bindings/core/v8/V8BindingMacros.h don't use a v8::TryCatch. 71 # Source/bindings/core/v8/V8BindingMacros.h don't use a v8::TryCatch.
69 ((base_type == 'DOMString' or idl_type.is_enum) and 72 ((base_type == 'DOMString' or idl_type.is_enum) and
70 not argument.is_variadic and
71 not return_promise) or 73 not return_promise) or
72 # Conversion that take an ExceptionState& argument throw all their 74 # Conversion that take an ExceptionState& argument throw all their
73 # exceptions via it, and doesn't need/use a TryCatch, except if the 75 # exceptions via it, and doesn't need/use a TryCatch, except if the
74 # argument has [Clamp], in which case it uses a separate code path in 76 # argument has [Clamp], in which case it uses a separate code path in
75 # Source/bindings/templates/methods.cpp, which *does* use a TryCatch. 77 # Source/bindings/templates/methods.cpp, which *does* use a TryCatch.
76 idl_type.v8_conversion_needs_exception_state) 78 argument.v8_conversion_needs_exception_state)
77 79
78 80
79 def use_local_result(method): 81 def use_local_result(method):
80 extended_attributes = method.extended_attributes 82 extended_attributes = method.extended_attributes
81 idl_type = method.idl_type 83 idl_type = method.idl_type
82 return (has_extended_attribute_value(method, 'CallWith', 'ScriptState') or 84 return (has_extended_attribute_value(method, 'CallWith', 'ScriptState') or
83 'ImplementedInPrivateScript' in extended_attributes or 85 'ImplementedInPrivateScript' in extended_attributes or
84 'RaisesException' in extended_attributes or 86 'RaisesException' in extended_attributes or
85 idl_type.is_union_type or 87 idl_type.is_union_type or
86 idl_type.is_explicit_nullable) 88 idl_type.is_explicit_nullable)
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 'exposed_test': v8_utilities.exposed(method, interface), # [Exposed] 163 'exposed_test': v8_utilities.exposed(method, interface), # [Exposed]
162 'function_template': function_template(), 164 'function_template': function_template(),
163 'has_custom_registration': is_static or 165 'has_custom_registration': is_static or
164 v8_utilities.has_extended_attribute( 166 v8_utilities.has_extended_attribute(
165 method, CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES), 167 method, CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES),
166 'has_exception_state': 168 'has_exception_state':
167 is_raises_exception or 169 is_raises_exception or
168 is_check_security_for_frame or 170 is_check_security_for_frame or
169 is_check_security_for_window or 171 is_check_security_for_window or
170 any(argument for argument in arguments 172 any(argument for argument in arguments
171 if argument.idl_type.name == 'SerializedScriptValue' or 173 if (argument.idl_type.name == 'SerializedScriptValue' or
172 argument.idl_type.v8_conversion_needs_exception_state), 174 argument.v8_conversion_needs_exception_state)),
173 'idl_type': idl_type.base_type, 175 'idl_type': idl_type.base_type,
174 'is_call_with_execution_context': has_extended_attribute_value(method, ' CallWith', 'ExecutionContext'), 176 'is_call_with_execution_context': has_extended_attribute_value(method, ' CallWith', 'ExecutionContext'),
175 'is_call_with_script_arguments': is_call_with_script_arguments, 177 'is_call_with_script_arguments': is_call_with_script_arguments,
176 'is_call_with_script_state': is_call_with_script_state, 178 'is_call_with_script_state': is_call_with_script_state,
177 'is_check_security_for_frame': is_check_security_for_frame, 179 'is_check_security_for_frame': is_check_security_for_frame,
178 'is_check_security_for_node': is_check_security_for_node, 180 'is_check_security_for_node': is_check_security_for_node,
179 'is_check_security_for_window': is_check_security_for_window, 181 'is_check_security_for_window': is_check_security_for_window,
180 'is_custom': 'Custom' in extended_attributes, 182 'is_custom': 'Custom' in extended_attributes,
181 'is_custom_element_callbacks': is_custom_element_callbacks, 183 'is_custom_element_callbacks': is_custom_element_callbacks,
182 'is_do_not_check_security': is_do_not_check_security, 184 'is_do_not_check_security': is_do_not_check_security,
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 script_wrappable = 'impl' if inherits_interface(interface_name, 'Node') else '' 371 script_wrappable = 'impl' if inherits_interface(interface_name, 'Node') else ''
370 return idl_type.v8_set_return_value(cpp_value, extended_attributes, script_w rappable=script_wrappable, release=release, for_main_world=for_main_world) 372 return idl_type.v8_set_return_value(cpp_value, extended_attributes, script_w rappable=script_wrappable, release=release, for_main_world=for_main_world)
371 373
372 374
373 def v8_value_to_local_cpp_variadic_value(argument, index, return_promise): 375 def v8_value_to_local_cpp_variadic_value(argument, index, return_promise):
374 assert argument.is_variadic 376 assert argument.is_variadic
375 idl_type = argument.idl_type 377 idl_type = argument.idl_type
376 378
377 suffix = '' 379 suffix = ''
378 380
379 macro = 'TONATIVE_VOID' 381 macro = 'TONATIVE_VOID_EXCEPTIONSTATE'
380 macro_args = [ 382 macro_args = [
381 argument.name, 383 argument.name,
382 'toImplArguments<%s>(info, %s)' % (idl_type.cpp_type, index), 384 'toImplArguments<%s>(info, %s, exceptionState)' % (idl_type.cpp_type, in dex),
385 'exceptionState',
383 ] 386 ]
384 387
385 if return_promise: 388 if return_promise:
386 suffix += '_PROMISE' 389 suffix += '_PROMISE'
387 macro_args.append('info') 390 macro_args.extend(['info', 'ScriptState::current(info.GetIsolate())'])
388 391
389 suffix += '_INTERNAL' 392 suffix += '_INTERNAL'
390 393
391 return '%s%s(%s)' % (macro, suffix, ', '.join(macro_args)) 394 return '%s%s(%s)' % (macro, suffix, ', '.join(macro_args))
392 395
393 396
394 def v8_value_to_local_cpp_value(argument, index, return_promise=False): 397 def v8_value_to_local_cpp_value(argument, index, return_promise=False):
395 extended_attributes = argument.extended_attributes 398 extended_attributes = argument.extended_attributes
396 idl_type = argument.idl_type 399 idl_type = argument.idl_type
397 name = argument.name 400 name = argument.name
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 if argument.idl_type.is_dictionary: 459 if argument.idl_type.is_dictionary:
457 # We always create impl objects for IDL dictionaries. 460 # We always create impl objects for IDL dictionaries.
458 return '%s::create()' % argument.idl_type.base_type 461 return '%s::create()' % argument.idl_type.base_type
459 if not argument.default_value: 462 if not argument.default_value:
460 return None 463 return None
461 return argument.idl_type.literal_cpp_value(argument.default_value) 464 return argument.idl_type.literal_cpp_value(argument.default_value)
462 465
463 IdlTypeBase.union_arguments = None 466 IdlTypeBase.union_arguments = None
464 IdlUnionType.union_arguments = property(union_arguments) 467 IdlUnionType.union_arguments = property(union_arguments)
465 IdlArgument.default_cpp_value = property(argument_default_cpp_value) 468 IdlArgument.default_cpp_value = property(argument_default_cpp_value)
469
470
471 def v8_conversion_needs_exception_state(argument):
472 return (argument.idl_type.v8_conversion_needs_exception_state or
473 argument.is_variadic)
474
475 IdlArgument.v8_conversion_needs_exception_state = property(v8_conversion_needs_e xception_state)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698