OLD | NEW |
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 Loading... |
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 or | 78 argument.v8_conversion_needs_exception_state or |
77 # A trivial conversion cannot throw exceptions at all, so doesn't need a | 79 # A trivial conversion cannot throw exceptions at all, so doesn't need a |
78 # TryCatch to catch them. | 80 # TryCatch to catch them. |
79 idl_type.v8_conversion_is_trivial) | 81 idl_type.v8_conversion_is_trivial) |
80 | 82 |
81 | 83 |
82 def use_local_result(method): | 84 def use_local_result(method): |
83 extended_attributes = method.extended_attributes | 85 extended_attributes = method.extended_attributes |
84 idl_type = method.idl_type | 86 idl_type = method.idl_type |
85 return (has_extended_attribute_value(method, 'CallWith', 'ScriptState') or | 87 return (has_extended_attribute_value(method, 'CallWith', 'ScriptState') or |
86 'ImplementedInPrivateScript' in extended_attributes or | 88 'ImplementedInPrivateScript' in extended_attributes or |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 'exposed_test': v8_utilities.exposed(method, interface), # [Exposed] | 166 'exposed_test': v8_utilities.exposed(method, interface), # [Exposed] |
165 'function_template': function_template(), | 167 'function_template': function_template(), |
166 'has_custom_registration': is_static or | 168 'has_custom_registration': is_static or |
167 v8_utilities.has_extended_attribute( | 169 v8_utilities.has_extended_attribute( |
168 method, CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES), | 170 method, CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES), |
169 'has_exception_state': | 171 'has_exception_state': |
170 is_raises_exception or | 172 is_raises_exception or |
171 is_check_security_for_frame or | 173 is_check_security_for_frame or |
172 is_check_security_for_window or | 174 is_check_security_for_window or |
173 any(argument for argument in arguments | 175 any(argument for argument in arguments |
174 if argument.idl_type.name == 'SerializedScriptValue' or | 176 if (argument.idl_type.name == 'SerializedScriptValue' or |
175 argument.idl_type.v8_conversion_needs_exception_state), | 177 argument.v8_conversion_needs_exception_state)), |
176 'idl_type': idl_type.base_type, | 178 'idl_type': idl_type.base_type, |
177 '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'), |
178 'is_call_with_script_arguments': is_call_with_script_arguments, | 180 'is_call_with_script_arguments': is_call_with_script_arguments, |
179 'is_call_with_script_state': is_call_with_script_state, | 181 'is_call_with_script_state': is_call_with_script_state, |
180 'is_check_security_for_frame': is_check_security_for_frame, | 182 'is_check_security_for_frame': is_check_security_for_frame, |
181 'is_check_security_for_node': is_check_security_for_node, | 183 'is_check_security_for_node': is_check_security_for_node, |
182 'is_check_security_for_window': is_check_security_for_window, | 184 'is_check_security_for_window': is_check_security_for_window, |
183 'is_custom': 'Custom' in extended_attributes, | 185 'is_custom': 'Custom' in extended_attributes, |
184 'is_custom_element_callbacks': is_custom_element_callbacks, | 186 'is_custom_element_callbacks': is_custom_element_callbacks, |
185 'is_do_not_check_security': is_do_not_check_security, | 187 'is_do_not_check_security': is_do_not_check_security, |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 script_wrappable = 'impl' if inherits_interface(interface_name, 'Node') else
'' | 376 script_wrappable = 'impl' if inherits_interface(interface_name, 'Node') else
'' |
375 return idl_type.v8_set_return_value(cpp_value, extended_attributes, script_w
rappable=script_wrappable, release=release, for_main_world=for_main_world) | 377 return idl_type.v8_set_return_value(cpp_value, extended_attributes, script_w
rappable=script_wrappable, release=release, for_main_world=for_main_world) |
376 | 378 |
377 | 379 |
378 def v8_value_to_local_cpp_variadic_value(argument, index, return_promise): | 380 def v8_value_to_local_cpp_variadic_value(argument, index, return_promise): |
379 assert argument.is_variadic | 381 assert argument.is_variadic |
380 idl_type = argument.idl_type | 382 idl_type = argument.idl_type |
381 | 383 |
382 suffix = '' | 384 suffix = '' |
383 | 385 |
384 macro = 'TONATIVE_VOID' | 386 macro = 'TONATIVE_VOID_EXCEPTIONSTATE' |
385 macro_args = [ | 387 macro_args = [ |
386 argument.name, | 388 argument.name, |
387 'toImplArguments<%s>(info, %s)' % (idl_type.cpp_type, index), | 389 'toImplArguments<%s>(info, %s, exceptionState)' % (idl_type.cpp_type, in
dex), |
| 390 'exceptionState', |
388 ] | 391 ] |
389 | 392 |
390 if return_promise: | 393 if return_promise: |
391 suffix += '_PROMISE' | 394 suffix += '_PROMISE' |
392 macro_args.append('info') | 395 macro_args.extend(['info', 'ScriptState::current(info.GetIsolate())']) |
393 | 396 |
394 suffix += '_INTERNAL' | 397 suffix += '_INTERNAL' |
395 | 398 |
396 return '%s%s(%s)' % (macro, suffix, ', '.join(macro_args)) | 399 return '%s%s(%s)' % (macro, suffix, ', '.join(macro_args)) |
397 | 400 |
398 | 401 |
399 def v8_value_to_local_cpp_value(argument, index, return_promise=False): | 402 def v8_value_to_local_cpp_value(argument, index, return_promise=False): |
400 extended_attributes = argument.extended_attributes | 403 extended_attributes = argument.extended_attributes |
401 idl_type = argument.idl_type | 404 idl_type = argument.idl_type |
402 name = argument.name | 405 name = argument.name |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 if argument.idl_type.is_dictionary: | 464 if argument.idl_type.is_dictionary: |
462 # We always create impl objects for IDL dictionaries. | 465 # We always create impl objects for IDL dictionaries. |
463 return '%s::create()' % argument.idl_type.base_type | 466 return '%s::create()' % argument.idl_type.base_type |
464 if not argument.default_value: | 467 if not argument.default_value: |
465 return None | 468 return None |
466 return argument.idl_type.literal_cpp_value(argument.default_value) | 469 return argument.idl_type.literal_cpp_value(argument.default_value) |
467 | 470 |
468 IdlTypeBase.union_arguments = None | 471 IdlTypeBase.union_arguments = None |
469 IdlUnionType.union_arguments = property(union_arguments) | 472 IdlUnionType.union_arguments = property(union_arguments) |
470 IdlArgument.default_cpp_value = property(argument_default_cpp_value) | 473 IdlArgument.default_cpp_value = property(argument_default_cpp_value) |
| 474 |
| 475 |
| 476 def v8_conversion_needs_exception_state(argument): |
| 477 return (argument.idl_type.v8_conversion_needs_exception_state or |
| 478 argument.is_variadic) |
| 479 |
| 480 IdlArgument.v8_conversion_needs_exception_state = property(v8_conversion_needs_e
xception_state) |
OLD | NEW |