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

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

Issue 385603002: IDL: Support using nullable on any method return type (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: use_result_local => use_local_result Created 6 years, 5 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_attributes.py ('k') | Source/bindings/scripts/v8_types.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/scripts/v8_methods.py
diff --git a/Source/bindings/scripts/v8_methods.py b/Source/bindings/scripts/v8_methods.py
index d70230aa4b9f888013b218f83d16b23241fcfcf9..92e4fbc6eacefa672eb0d93773fef20730f0681b 100644
--- a/Source/bindings/scripts/v8_methods.py
+++ b/Source/bindings/scripts/v8_methods.py
@@ -67,6 +67,16 @@ def argument_needs_try_catch(argument):
(base_type == 'DOMString' and not argument.is_variadic))
+def use_local_result(method):
+ extended_attributes = method.extended_attributes
+ idl_type = method.idl_type
+ return (has_extended_attribute_value(method, 'CallWith', 'ScriptState') or
+ 'ImplementedInPrivateScript' in extended_attributes or
+ 'RaisesException' in extended_attributes or
+ idl_type.is_union_type or
+ (idl_type.is_nullable and not idl_type.is_nullable_simple))
+
+
def method_context(interface, method):
arguments = method.arguments
extended_attributes = method.extended_attributes
@@ -110,6 +120,8 @@ def method_context(interface, method):
arguments_need_try_catch = any(argument_needs_try_catch(argument)
for argument in arguments)
+ is_nullable = idl_type.is_nullable and not idl_type.is_nullable_simple
+
return {
'activity_logging_world_list': v8_utilities.activity_logging_world_list(method), # [ActivityLogging]
'arguments': [argument_context(interface, method, argument, index)
@@ -118,7 +130,8 @@ def method_context(interface, method):
argument_declarations_for_private_script(interface, method),
'arguments_need_try_catch': arguments_need_try_catch,
'conditional_string': v8_utilities.conditional_string(method),
- 'cpp_type': idl_type.cpp_type,
+ 'cpp_type': (v8_types.cpp_template_type('Nullable', idl_type.cpp_type)
+ if is_nullable else idl_type.cpp_type),
'cpp_value': this_cpp_value,
'custom_registration_extended_attributes':
CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES.intersection(
@@ -146,12 +159,14 @@ def method_context(interface, method):
'is_do_not_check_security': 'DoNotCheckSecurity' in extended_attributes,
'is_do_not_check_signature': 'DoNotCheckSignature' in extended_attributes,
'is_implemented_in_private_script': is_implemented_in_private_script,
+ 'is_nullable': is_nullable,
'is_partial_interface_member':
'PartialInterfaceImplementedAs' in extended_attributes,
'is_per_world_bindings': 'PerWorldBindings' in extended_attributes,
'is_raises_exception': is_raises_exception,
'is_read_only': 'Unforgeable' in extended_attributes,
'is_static': is_static,
+ 'use_local_result': use_local_result(method),
'is_variadic': arguments and arguments[-1].is_variadic,
'measure_as': v8_utilities.measure_as(method), # [MeasureAs]
'name': name,
@@ -317,11 +332,12 @@ def v8_set_return_value(interface_name, method, cpp_value, for_main_world=False)
release = False
# [CallWith=ScriptState], [RaisesException]
- if (has_extended_attribute_value(method, 'CallWith', 'ScriptState') or
- 'ImplementedInPrivateScript' in extended_attributes or
- 'RaisesException' in extended_attributes or
- idl_type.is_union_type):
- cpp_value = 'result' # use local variable for value
+ if use_local_result(method):
+ if idl_type.is_nullable and not idl_type.is_nullable_simple:
+ # result is of type Nullable<T>
+ cpp_value = 'result.get()'
+ else:
+ cpp_value = 'result'
release = idl_type.release
script_wrappable = 'impl' if inherits_interface(interface_name, 'Node') else ''
« no previous file with comments | « Source/bindings/scripts/v8_attributes.py ('k') | Source/bindings/scripts/v8_types.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698