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

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

Issue 564063002: Generate simple code for "trivial" conversions (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebased Created 6 years, 3 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
« no previous file with comments | « Source/bindings/scripts/v8_methods.py ('k') | Source/bindings/tests/results/core/V8TestInterface.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/scripts/v8_types.py
diff --git a/Source/bindings/scripts/v8_types.py b/Source/bindings/scripts/v8_types.py
index 0462c083b37660bef3de5bc04b59cd2ed85a6954..d4e91efd8e3aaf5d0c875e1b3c556e4535b2477e 100644
--- a/Source/bindings/scripts/v8_types.py
+++ b/Source/bindings/scripts/v8_types.py
@@ -481,6 +481,15 @@ def v8_conversion_needs_exception_state(idl_type):
IdlType.v8_conversion_needs_exception_state = property(v8_conversion_needs_exception_state)
+def v8_conversion_is_trivial(idl_type):
+ # The conversion is a simple expression that returns the converted value and
+ # cannot raise an exception.
+ return (idl_type.base_type == 'boolean' or
+ idl_type.is_wrapper_type)
+
+IdlType.v8_conversion_is_trivial = property(v8_conversion_is_trivial)
+
+
def v8_value_to_cpp_value(idl_type, extended_attributes, v8_value, index, isolate):
if idl_type.name == 'void':
return ''
@@ -557,6 +566,11 @@ def v8_value_to_local_cpp_value(idl_type, extended_attributes, v8_value, variabl
elif idl_type.v8_conversion_needs_exception_state:
macro = 'TONATIVE_DEFAULT_EXCEPTIONSTATE' if used_in_private_script else 'TONATIVE_VOID_EXCEPTIONSTATE'
args.append('exceptionState')
+ elif idl_type.v8_conversion_is_trivial:
+ assignment = '%s = %s' % (variable_name, cpp_value)
+ if declare_variable:
+ return '%s %s' % (this_cpp_type, assignment)
+ return assignment
else:
macro = 'TONATIVE_DEFAULT' if used_in_private_script else 'TONATIVE_VOID'
« no previous file with comments | « Source/bindings/scripts/v8_methods.py ('k') | Source/bindings/tests/results/core/V8TestInterface.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698