Chromium Code Reviews| Index: Source/bindings/scripts/v8_types.py |
| diff --git a/Source/bindings/scripts/v8_types.py b/Source/bindings/scripts/v8_types.py |
| index 6b76eadd2ed7dc13771662500cd2f0ec0926d251..2fb3d38ddd39e847f34e7aff618407d3881f06c9 100644 |
| --- a/Source/bindings/scripts/v8_types.py |
| +++ b/Source/bindings/scripts/v8_types.py |
| @@ -594,7 +594,7 @@ def v8_value_to_cpp_value_array_or_sequence(native_array_element_type, v8_value, |
| # FIXME: this function should be refactored, as this takes too many flags. |
| -def v8_value_to_local_cpp_value(idl_type, extended_attributes, v8_value, variable_name=None, index=None, declare_variable=True, isolate='info.GetIsolate()', used_in_private_script=False, return_promise=False, needs_exception_state_for_string=False, restricted_float=False): |
| +def v8_value_to_local_cpp_value(idl_type, extended_attributes, v8_value, variable_name, index=None, declare_variable=True, isolate='info.GetIsolate()', bailout_return_value=None, use_exception_state=False, restricted_float=False): |
| """Returns an expression that converts a V8 value to a C++ value and stores it as a local value.""" |
| this_cpp_type = idl_type.cpp_type_args(extended_attributes=extended_attributes, raw_type=True) |
| @@ -605,42 +605,40 @@ def v8_value_to_local_cpp_value(idl_type, extended_attributes, v8_value, variabl |
| cpp_value = v8_value_to_cpp_value(idl_type, extended_attributes, v8_value, variable_name, index, isolate, restricted_float=restricted_float) |
| - if idl_type.is_dictionary or idl_type.is_union_type: |
| - return 'TONATIVE_VOID_EXCEPTIONSTATE_ARGINTERNAL(%s, exceptionState)' % cpp_value |
| - |
| if idl_type.is_string_type or idl_type.v8_conversion_needs_exception_state: |
| # Types that need error handling and use one of a group of (C++) macros |
| # to take care of this. |
| - args = [variable_name, cpp_value] |
| - |
| - if idl_type.v8_conversion_needs_exception_state: |
| - macro = 'TONATIVE_DEFAULT_EXCEPTIONSTATE' if used_in_private_script else 'TONATIVE_VOID_EXCEPTIONSTATE' |
| - elif return_promise or needs_exception_state_for_string: |
| - macro = 'TOSTRING_VOID_EXCEPTIONSTATE' |
| - else: |
| - macro = 'TOSTRING_DEFAULT' if used_in_private_script else 'TOSTRING_VOID' |
| - |
| - if macro.endswith('_EXCEPTIONSTATE'): |
| - args.append('exceptionState') |
| - |
| - if used_in_private_script: |
| - args.append('false') |
| - |
| - suffix = '' |
| - |
| - if return_promise: |
| - suffix += '_PROMISE' |
| - args.append('info') |
| - if macro.endswith('_EXCEPTIONSTATE'): |
| - args.append('ScriptState::current(%s)' % isolate) |
| + arguments = [] |
| if declare_variable: |
| - args.insert(0, this_cpp_type) |
| + macro = 'TONATIVE_DECLARE' |
| + arguments.extend([this_cpp_type, variable_name]) |
| + else: |
| + macro = 'TONATIVE_CONVERT' |
| + |
| + if idl_type.is_dictionary or idl_type.is_union_type: |
| + arguments.append(cpp_value) |
| + if not use_exception_state: |
|
bashi
2015/02/23 23:44:06
When could |use_exception_state| be False for dict
Jens Widell
2015/02/24 07:31:43
(Sorry about the poor documentation.)
Here, 'idl_
|
| + bailout_return_value = 'exceptionState.throwException()' |
| + elif idl_type.v8_conversion_needs_exception_state: |
| + if use_exception_state: |
| + helper = 'convertAndCheck' |
| + else: |
| + helper = 'convertAndThrow' |
| + arguments.append('%s(%s = %s, exceptionState)' % (helper, variable_name, cpp_value)) |
| + else: # idl_type.is_string_type |
| + if use_exception_state: |
| + arguments.append('(%s = %s).prepare(exceptionState)' % (variable_name, v8_value)) |
| + else: |
| + arguments.append('(%s = %s).prepare()' % (variable_name, v8_value)) |
| + |
| + if bailout_return_value: |
| + arguments.append('return ' + bailout_return_value) |
| else: |
| - suffix += '_INTERNAL' |
| + arguments.append('return') |
| - return '%s(%s)' % (macro + suffix, ', '.join(args)) |
| + return '%s(%s)' % (macro, ', '.join(arguments)) |
| # Types that don't need error handling, and simply assign a value to the |
| # local variable. |