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

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

Issue 158663002: IDL compiler: sync Python to r166688 (and clean up special operations+union code) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Typo Created 6 years, 10 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/templates/interface.cpp ('k') | Source/bindings/tests/results/V8TestEventTarget.cpp » ('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 40858988567158839b865bd3a03767f0a1eb14db..69070ae2ad9e58abd60b386e03e160c563e2be2f 100644
--- a/Source/bindings/templates/methods.cpp
+++ b/Source/bindings/templates/methods.cpp
@@ -201,9 +201,32 @@ if (state.hadException()) {
return;
}
{% endif %}
-{% if v8_set_return_value %}{{v8_set_return_value}};{% endif %}{# None for void #}
+{% if method.union_arguments %}
+{{union_type_method_call(method)}}
+{% elif v8_set_return_value %}{{v8_set_return_value}};{% endif %}{# None for void #}
{% endmacro %}
+{######################################}
+{% macro union_type_method_call(method) %}
+{% for cpp_type in method.cpp_type %}
+bool result{{loop.index0}}Enabled = false;
+{{cpp_type}} result{{loop.index0}};
+{% 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}};
+ return;
+}
+{% endfor %}
+{# Fall back to null if none of the union members results are returned #}
+v8SetReturnValueNull(info);
+{%- endmacro %}
+
{######################################}
{% macro throw_type_error(method, error_message) %}
« no previous file with comments | « Source/bindings/templates/interface.cpp ('k') | Source/bindings/tests/results/V8TestEventTarget.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698