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

Unified Diff: Source/bindings/templates/methods.cpp

Issue 466323002: IDL: Use Nullable for union type return value (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 4 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_types.py ('k') | Source/bindings/tests/idls/TestTypedefs.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/templates/methods.cpp
diff --git a/Source/bindings/templates/methods.cpp b/Source/bindings/templates/methods.cpp
index cf307e68859e6f8a5be32b7564636cd4045ddcad..1a34416d767768c500c54fe61b0e7a209b161ab3 100644
--- a/Source/bindings/templates/methods.cpp
+++ b/Source/bindings/templates/methods.cpp
@@ -296,23 +296,26 @@ if (info.Length() >= 2 && listener && !impl->toNode())
{######################################}
{% macro union_type_method_call_and_set_return_value(method) %}
-{% for cpp_type in method.cpp_type %}
-bool result{{loop.index0}}Enabled = false;
-{{cpp_type}} result{{loop.index0}};
+{% for argument in method.union_arguments %}
+{{argument.cpp_type}} {{argument.cpp_value}};
{% endfor %}
{{method.cpp_value}};
{% if method.is_null_expression %}{# used by getters #}
if ({{method.is_null_expression}})
return;
{% endif %}
-{% for v8_set_return_value in method.v8_set_return_value %}
-if (result{{loop.index0}}Enabled) {
- {{v8_set_return_value}};
+{% for argument in method.union_arguments %}
+if ({{argument.null_check_value}}) {
+ {{argument.v8_set_return_value}};
return;
}
{% endfor %}
{# Fall back to null if none of the union members results are returned #}
+{% if method.is_null_expression %}
+ASSERT_NOT_REACHED();
+{% else %}
v8SetReturnValueNull(info);
+{% endif %}
{% endmacro %}
« no previous file with comments | « Source/bindings/scripts/v8_types.py ('k') | Source/bindings/tests/idls/TestTypedefs.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698