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

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: simplify 'cpp_type' generation 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..c21af08b176e4d34c92957bb020168b5124b2c85 100644
--- a/Source/bindings/scripts/v8_types.py
+++ b/Source/bindings/scripts/v8_types.py
@@ -118,7 +118,7 @@ CPP_SPECIAL_CONVERSION_RULES = {
}
-def cpp_type(idl_type, extended_attributes=None, used_as_argument=False, used_in_cpp_sequence=False):
+def cpp_type(idl_type, extended_attributes=None, used_as_argument=False, used_as_variadic_argument=False, used_in_cpp_sequence=False):
"""Returns C++ type corresponding to IDL type.
|idl_type| argument is of type IdlType, while return value is a string
@@ -144,7 +144,10 @@ def cpp_type(idl_type, extended_attributes=None, used_as_argument=False, used_in
idl_type = idl_type.preprocessed_type
# Composite types
- array_or_sequence_type = idl_type.array_or_sequence_type
+ if used_as_variadic_argument:
+ array_or_sequence_type = idl_type
+ else:
+ array_or_sequence_type = idl_type.array_or_sequence_type
if array_or_sequence_type:
vector_type = cpp_ptr_type('Vector', 'HeapVector', array_or_sequence_type.gc_type)
return cpp_template_type(vector_type, array_or_sequence_type.cpp_type_args(used_in_cpp_sequence=True))
@@ -431,13 +434,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 +449,12 @@ def v8_value_to_local_cpp_value(idl_type, extended_attributes, v8_value, variabl
else:
macro = 'TONATIVE_VOID'
+ if declare_variable:
+ args.insert(0, this_cpp_type)
+ else:
+ # Use a macro that assumes a previously declared local variable.
+ macro += '_INTERNAL'
+
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