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) %} |