| 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) | 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 Loading... |
| 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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 script_wrappable = 'impl' if inherits_interface(interface_name, 'Node') else
'' | 373 script_wrappable = 'impl' if inherits_interface(interface_name, 'Node') else
'' |
| 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) | 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) |
| 373 | 375 |
| 374 | 376 |
| 375 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): |
| 376 assert argument.is_variadic | 378 assert argument.is_variadic |
| 377 idl_type = argument.idl_type | 379 idl_type = argument.idl_type |
| 378 | 380 |
| 379 suffix = '' | 381 suffix = '' |
| 380 | 382 |
| 381 macro = 'TONATIVE_VOID' | 383 macro = 'TONATIVE_VOID_EXCEPTIONSTATE' |
| 382 macro_args = [ | 384 macro_args = [ |
| 383 argument.name, | 385 argument.name, |
| 384 'toImplArguments<%s>(info, %s)' % (idl_type.cpp_type, index), | 386 'toImplArguments<%s>(info, %s, exceptionState)' % (idl_type.cpp_type, in
dex), |
| 387 'exceptionState', |
| 385 ] | 388 ] |
| 386 | 389 |
| 387 if return_promise: | 390 if return_promise: |
| 388 suffix += '_PROMISE' | 391 suffix += '_PROMISE' |
| 389 macro_args.append('info') | 392 macro_args.extend(['info', 'ScriptState::current(info.GetIsolate())']) |
| 390 | 393 |
| 391 suffix += '_INTERNAL' | 394 suffix += '_INTERNAL' |
| 392 | 395 |
| 393 return '%s%s(%s)' % (macro, suffix, ', '.join(macro_args)) | 396 return '%s%s(%s)' % (macro, suffix, ', '.join(macro_args)) |
| 394 | 397 |
| 395 | 398 |
| 396 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): |
| 397 extended_attributes = argument.extended_attributes | 400 extended_attributes = argument.extended_attributes |
| 398 idl_type = argument.idl_type | 401 idl_type = argument.idl_type |
| 399 name = argument.name | 402 name = argument.name |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 if argument.idl_type.is_dictionary: | 461 if argument.idl_type.is_dictionary: |
| 459 # We always create impl objects for IDL dictionaries. | 462 # We always create impl objects for IDL dictionaries. |
| 460 return '%s::create()' % argument.idl_type.base_type | 463 return '%s::create()' % argument.idl_type.base_type |
| 461 if not argument.default_value: | 464 if not argument.default_value: |
| 462 return None | 465 return None |
| 463 return argument.idl_type.literal_cpp_value(argument.default_value) | 466 return argument.idl_type.literal_cpp_value(argument.default_value) |
| 464 | 467 |
| 465 IdlTypeBase.union_arguments = None | 468 IdlTypeBase.union_arguments = None |
| 466 IdlUnionType.union_arguments = property(union_arguments) | 469 IdlUnionType.union_arguments = property(union_arguments) |
| 467 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) |
| OLD | NEW |