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

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

Powered by Google App Engine
This is Rietveld 408576698