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

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

Issue 265293004: Create fewer local v8::TryCatch objects in generated bindings code (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 7 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 466ab25e05ffe2237fc380efa6eff1c10e11ae9b..0747d4082f2d314f0a9c81a5436c67f35f42f895 100644
--- a/Source/bindings/scripts/v8_types.py
+++ b/Source/bindings/scripts/v8_types.py
@@ -431,13 +431,13 @@ def v8_value_to_cpp_value_array_or_sequence(array_or_sequence_type, v8_value, in
return expression
-def v8_value_to_local_cpp_value(idl_type, extended_attributes, v8_value, variable_name, index=None):
+def v8_value_to_local_cpp_value(idl_type, extended_attributes, v8_value, variable_name, index=None, declare_variable=True):
"""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, used_as_argument=True)
idl_type = idl_type.preprocessed_type
cpp_value = v8_value_to_cpp_value(idl_type, extended_attributes, v8_value, index)
- args = [this_cpp_type, variable_name, cpp_value]
+ args = [variable_name, cpp_value]
if idl_type.base_type == 'DOMString' and not idl_type.array_or_sequence_type:
macro = 'TOSTRING_VOID'
elif idl_type.is_integer_type:
@@ -446,6 +446,12 @@ def v8_value_to_local_cpp_value(idl_type, extended_attributes, v8_value, variabl
else:
macro = 'TONATIVE_VOID'
+ if not declare_variable:
Nils Barth (inactive) 2014/05/07 03:02:19 I prefer to avoid 'not' in if...else, so: if decla
+ # Use a macro that assumes a previously declared local variable.
+ macro += "_NO_DECL"
Nils Barth (inactive) 2014/05/07 03:02:19 ...and single quotes.
+ else:
+ args.insert(0, this_cpp_type)
+
return '%s(%s)' % (macro, ', '.join(args))
IdlType.v8_value_to_local_cpp_value = v8_value_to_local_cpp_value

Powered by Google App Engine
This is Rietveld 408576698