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

Unified Diff: Source/bindings/scripts/v8_types.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, 8 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_types.py
diff --git a/Source/bindings/scripts/v8_types.py b/Source/bindings/scripts/v8_types.py
index e5d9a09e402a80733d8bd6e2c522caad4a8ec9ba..cbd964ce593135c0c1bfce32e4475c3909909d0f 100644
--- a/Source/bindings/scripts/v8_types.py
+++ b/Source/bindings/scripts/v8_types.py
@@ -414,7 +414,28 @@ 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, index)
return format_string.format(cpp_type=this_cpp_type, cpp_value=cpp_value, variable_name=variable_name)
+
+def v8_value_to_local_cpp_value_async(idl_type, extended_attributes, v8_value, variable_name, index=None):
Nils Barth (inactive) 2014/04/10 07:48:03 You're just adding 'info' here, right? If so, coul
Nils Barth (inactive) 2014/04/10 07:59:47 Oh, and you're tacking on _PROMISE. Anyway, I've p
yhirano 2014/04/11 10:19:04 Thanks, done
+ """Returns an expression that converts a V8 value to a C++ value and stores it as a local value.
+ The generated code returns a rejected Promise when it sees an error rather than throwing an exception.
+ """
+ this_cpp_type = idl_type.cpp_type_args(extended_attributes=extended_attributes, used_as_argument=True)
+
+ idl_type = idl_type.preprocessed_type
+
+ if idl_type.base_type == 'DOMString' and not idl_type.array_or_sequence_type:
+ format_string = 'V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID_PROMISE({cpp_type}, {variable_name}, {cpp_value}, info)'
+ elif idl_type.is_integer_type:
+ format_string = 'V8TRYCATCH_EXCEPTION_VOID_PROMISE({cpp_type}, {variable_name}, {cpp_value}, info, exceptionState)'
+ else:
+ format_string = 'V8TRYCATCH_VOID_PROMISE({cpp_type}, {variable_name}, {cpp_value}, info)'
+
+ cpp_value = v8_value_to_cpp_value(idl_type, extended_attributes, v8_value, index)
+ return format_string.format(cpp_type=this_cpp_type, cpp_value=cpp_value, variable_name=variable_name)
+
+
IdlType.v8_value_to_local_cpp_value = v8_value_to_local_cpp_value
+IdlType.v8_value_to_local_cpp_value_async = v8_value_to_local_cpp_value_async
IdlUnionType.v8_value_to_local_cpp_value = v8_value_to_local_cpp_value

Powered by Google App Engine
This is Rietveld 408576698