Index: Source/bindings/scripts/v8_methods.py |
diff --git a/Source/bindings/scripts/v8_methods.py b/Source/bindings/scripts/v8_methods.py |
index 8f559f59492ed2af6fa2dc833113c0e12d7207b3..55a8eed977b558bc1efd466a6d9b8dd7802fa608 100644 |
--- a/Source/bindings/scripts/v8_methods.py |
+++ b/Source/bindings/scripts/v8_methods.py |
@@ -51,7 +51,7 @@ CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES = frozenset([ |
]) |
-def argument_needs_try_catch(argument): |
+def argument_needs_try_catch(argument, async): |
idl_type = argument.idl_type |
base_type = not idl_type.native_array_element_type and idl_type.base_type |
@@ -62,9 +62,9 @@ def argument_needs_try_catch(argument): |
base_type == 'SerializedScriptValue' or |
(argument.is_variadic and idl_type.is_wrapper_type) or |
# String and enumeration arguments converted using one of the |
- # TOSTRING_* macros in Source/bindings/core/v8/V8BindingMacros.h don't |
- # use a v8::TryCatch. |
- (base_type == 'DOMString' and not argument.is_variadic)) |
+ # TOSTRING_* macros except for _ASYNC variants in |
+ # Source/bindings/core/v8/V8BindingMacros.h don't use a v8::TryCatch. |
+ (base_type == 'DOMString' and not argument.is_variadic and not async)) |
haraken
2014/07/31 07:54:47
This condition is getting to a mess... but would b
|
def use_local_result(method): |
@@ -83,6 +83,7 @@ def method_context(interface, method): |
idl_type = method.idl_type |
is_static = method.is_static |
name = method.name |
+ async = idl_type.name == 'Promise' |
haraken
2014/07/31 07:54:47
Shall we rename |async| to |return_promise| for cl
yhirano
2014/08/01 02:27:57
Done.
|
idl_type.add_includes_for_type() |
this_cpp_value = cpp_value(interface, method, len(arguments)) |
@@ -122,7 +123,7 @@ def method_context(interface, method): |
'DoNotCheckSecurity' not in extended_attributes) |
is_raises_exception = 'RaisesException' in extended_attributes |
- arguments_need_try_catch = any(argument_needs_try_catch(argument) |
+ arguments_need_try_catch = any(argument_needs_try_catch(argument, async) |
for argument in arguments) |
return { |
@@ -201,6 +202,7 @@ def argument_context(interface, method, argument, index): |
idl_type = argument.idl_type |
this_cpp_value = cpp_value(interface, method, index) |
is_variadic_wrapper_type = argument.is_variadic and idl_type.is_wrapper_type |
+ async = method.idl_type.name == 'Promise' if method.idl_type else False |
if ('ImplementedInPrivateScript' in extended_attributes and |
not idl_type.is_wrapper_type and |
@@ -242,7 +244,7 @@ def argument_context(interface, method, argument, index): |
creation_context='scriptState->context()->Global()'), |
'v8_set_return_value': v8_set_return_value(interface.name, method, this_cpp_value), |
'v8_set_return_value_for_main_world': v8_set_return_value(interface.name, method, this_cpp_value, for_main_world=True), |
- 'v8_value_to_local_cpp_value': v8_value_to_local_cpp_value(argument, index), |
+ 'v8_value_to_local_cpp_value': v8_value_to_local_cpp_value(argument, index, async=async), |
'vector_type': v8_types.cpp_ptr_type('Vector', 'HeapVector', idl_type.gc_type), |
} |
@@ -345,27 +347,35 @@ def v8_set_return_value(interface_name, method, cpp_value, for_main_world=False) |
return idl_type.v8_set_return_value(cpp_value, extended_attributes, script_wrappable=script_wrappable, release=release, for_main_world=for_main_world) |
-def v8_value_to_local_cpp_variadic_value(argument, index): |
+def v8_value_to_local_cpp_variadic_value(argument, index, async): |
assert argument.is_variadic |
idl_type = argument.idl_type |
- macro = 'TONATIVE_VOID_INTERNAL' |
+ suffix = '' |
+ |
+ macro = 'TONATIVE_VOID' |
macro_args = [ |
argument.name, |
'toNativeArguments<%s>(info, %s)' % (idl_type.cpp_type, index), |
] |
- return '%s(%s)' % (macro, ', '.join(macro_args)) |
+ if async: |
+ suffix += '_ASYNC' |
+ macro_args.append('info') |
+ |
+ suffix += '_INTERNAL' |
+ |
+ return '%s%s(%s)' % (macro, suffix, ', '.join(macro_args)) |
-def v8_value_to_local_cpp_value(argument, index): |
+def v8_value_to_local_cpp_value(argument, index, async=False): |
extended_attributes = argument.extended_attributes |
idl_type = argument.idl_type |
name = argument.name |
if argument.is_variadic: |
- return v8_value_to_local_cpp_variadic_value(argument, index) |
+ return v8_value_to_local_cpp_variadic_value(argument, index, async) |
return idl_type.v8_value_to_local_cpp_value(extended_attributes, 'info[%s]' % index, |
- name, index=index, declare_variable=False) |
+ name, index=index, declare_variable=False, async=async) |
################################################################################ |