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

Unified Diff: Source/bindings/scripts/v8_methods.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_methods.py
diff --git a/Source/bindings/scripts/v8_methods.py b/Source/bindings/scripts/v8_methods.py
index dd32e7c7251a2e34b83f721c7d8fec6947755aa8..ee10a9a718726a888d84ee96cd8ae397cb7f8dd8 100644
--- a/Source/bindings/scripts/v8_methods.py
+++ b/Source/bindings/scripts/v8_methods.py
@@ -40,6 +40,12 @@ import v8_utilities
from v8_utilities import has_extended_attribute_value
+def argument_needs_try_catch(argument):
+ return not (argument.get("is_callback_interface") or
Nils Barth (inactive) 2014/05/07 03:02:19 Single quotes. Also, can't these just be usual key
Jens Widell 2014/05/07 10:34:46 Neither 'is_callback_interface' nor 'is_variadic_w
Nils Barth (inactive) 2014/05/08 00:55:13 Got it -- I thought it might be something like tha
+ argument.get("idl_type") == "SerializedScriptValue" or
+ argument.get("is_variadic_wrapper_type"))
+
+
def generate_method(interface, method):
arguments = method.arguments
extended_attributes = method.extended_attributes
@@ -79,10 +85,14 @@ def generate_method(interface, method):
'DoNotCheckSecurity' not in extended_attributes)
is_raises_exception = 'RaisesException' in extended_attributes
+ generated_arguments = [generate_argument(interface, method, argument, index)
+ for index, argument in enumerate(arguments)]
+
return {
'activity_logging_world_list': v8_utilities.activity_logging_world_list(method), # [ActivityLogging]
- 'arguments': [generate_argument(interface, method, argument, index)
- for index, argument in enumerate(arguments)],
+ 'arguments': generated_arguments,
+ 'arguments_need_try_catch': any(
Nils Barth (inactive) 2014/05/07 03:02:19 Fix linebreaks, wrapping as follows: 'argu
+ argument_needs_try_catch(argument) for argument in generated_arguments),
'conditional_string': v8_utilities.conditional_string(method),
'cpp_type': idl_type.cpp_type,
'cpp_value': this_cpp_value,
@@ -143,8 +153,18 @@ def generate_argument(interface, method, argument, index):
this_cpp_value = cpp_value(interface, method, index)
is_variadic_wrapper_type = argument.is_variadic and idl_type.is_wrapper_type
+ if argument.is_variadic and not is_variadic_wrapper_type:
Nils Barth (inactive) 2014/05/07 03:02:19 Slightly more direct: if argument.is_variadic and
+ cpp_type = idl_type.cpp_type_args(extended_attributes=extended_attributes,
Nils Barth (inactive) 2014/05/07 03:02:19 Prefer single assignment: element_cpp_type = ...
+ used_in_cpp_sequence=is_variadic_wrapper_type)
Nils Barth (inactive) 2014/05/07 03:02:19 You can drop used_in_cpp_sequence, as it's always
+ vector_type = v8_types.cpp_ptr_type('Vector', 'HeapVector', idl_type.gc_type)
+ cpp_type = v8_types.cpp_template_type(vector_type, cpp_type)
+ else:
+ cpp_type = idl_type.cpp_type_args(extended_attributes=extended_attributes,
Nils Barth (inactive) 2014/05/07 03:02:19 Do we need to pass extended_attributes here? (It'
Jens Widell 2014/05/07 10:34:46 Not passing it makes run-bindings-test fail with t
Nils Barth (inactive) 2014/05/08 00:55:13 Got it, looks like there is a use in constructors;
+ used_as_argument=not is_variadic_wrapper_type,
+ used_in_cpp_sequence=is_variadic_wrapper_type)
+
return {
- 'cpp_type': idl_type.cpp_type_args(used_in_cpp_sequence=is_variadic_wrapper_type),
+ 'cpp_type': cpp_type,
'cpp_value': this_cpp_value,
'enum_validation_expression': idl_type.enum_validation_expression,
'has_default': 'Default' in extended_attributes,
@@ -250,9 +270,8 @@ def v8_value_to_local_cpp_value(argument, index):
idl_type = argument.idl_type
name = argument.name
if argument.is_variadic:
- vector_type = v8_types.cpp_ptr_type('Vector', 'HeapVector', idl_type.gc_type)
- return 'TONATIVE_VOID({vector_type}<{cpp_type}>, {name}, toNativeArguments<{cpp_type}>(info, {index}))'.format(
- vector_type=vector_type, cpp_type=idl_type.cpp_type, name=name,
+ return 'TONATIVE_VOID_NO_DECL({name}, toNativeArguments<{cpp_type}>(info, {index}))'.format(
+ cpp_type=idl_type.cpp_type, name=name,
index=index)
# [Default=NullString]
if (argument.is_optional and idl_type.name == 'String' and
@@ -261,7 +280,7 @@ def v8_value_to_local_cpp_value(argument, index):
else:
v8_value = 'info[%s]' % index
return idl_type.v8_value_to_local_cpp_value(extended_attributes, v8_value,
- name, index=index)
+ name, index=index, declare_variable=False)
################################################################################

Powered by Google App Engine
This is Rietveld 408576698