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

Unified Diff: Source/bindings/scripts/v8_methods.py

Issue 232563003: API functions returning Promises should not throw exceptions. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: Source/bindings/scripts/v8_methods.py
diff --git a/Source/bindings/scripts/v8_methods.py b/Source/bindings/scripts/v8_methods.py
index 9e92e0ed43d273adc1b054f1be904578a42c0037..c23b9ecf30da4241a5e044fe51080ef6b3310ff1 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
@@ -64,7 +64,7 @@ def argument_needs_try_catch(argument):
# String and enumeration arguments converted using one of the
# TOSTRING_* macros in Source/bindings/core/v8/V8BindingMacros.h don't
# use a v8::TryCatch.
bashi 2014/07/31 02:02:24 Could you update the comment to describe why we ne
yhirano 2014/07/31 03:38:03 Done.
- (base_type == 'DOMString' and not argument.is_variadic))
+ (base_type == 'DOMString' and not argument.is_variadic and not async))
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'
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 {
@@ -243,6 +244,7 @@ def argument_context(interface, method, argument, index):
'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_async': v8_value_to_local_cpp_value(argument, index, async=True),
'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)
################################################################################

Powered by Google App Engine
This is Rietveld 408576698