| Index: Source/bindings/templates/union.cpp
|
| diff --git a/Source/bindings/templates/union.cpp b/Source/bindings/templates/union.cpp
|
| index cd9c3692ade642b49edda25d197be29a7bb62923..1d7c982e82ccb80dc1add5ac620a3618c670f6b3 100644
|
| --- a/Source/bindings/templates/union.cpp
|
| +++ b/Source/bindings/templates/union.cpp
|
| @@ -7,11 +7,12 @@
|
| #include "config.h"
|
| #include "{{header_filename}}"
|
|
|
| +{% from 'conversions.cpp' import v8_value_to_local_cpp_value %}
|
| {% macro assign_and_return_if_hasinstance(member) %}
|
| if (V8{{member.type_name}}::hasInstance(v8Value, isolate)) {
|
| {{member.cpp_local_type}} cppValue = V8{{member.type_name}}::toImpl(v8::Local<v8::Object>::Cast(v8Value));
|
| impl.set{{member.type_name}}(cppValue);
|
| - return;
|
| + return true;
|
| }
|
| {% endmacro %}
|
| {% for filename in cpp_includes %}
|
| @@ -64,10 +65,10 @@ void {{container.cpp_class}}::trace(Visitor* visitor)
|
| }
|
|
|
| {% endif %}
|
| -void V8{{container.cpp_class}}::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, {{container.cpp_class}}& impl, ExceptionState& exceptionState)
|
| +bool V8{{container.cpp_class}}::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, {{container.cpp_class}}& impl, ExceptionState& exceptionState)
|
| {
|
| if (v8Value.IsEmpty())
|
| - return;
|
| + return true;
|
|
|
| {# The numbers in the following comments refer to the steps described in
|
| http://heycam.github.io/webidl/#es-union
|
| @@ -97,9 +98,9 @@ void V8{{container.cpp_class}}::toImpl(v8::Isolate* isolate, v8::Local<v8::Value
|
| {% if container.dictionary_type.type_name != 'Dictionary' %}
|
| {{container.dictionary_type.cpp_local_type}} cppValue;
|
| {% endif %}
|
| - {{container.dictionary_type.v8_value_to_local_cpp_value}};
|
| + {{v8_value_to_local_cpp_value(container.dictionary_type) | indent(8)}}
|
| impl.set{{container.dictionary_type.type_name}}(cppValue);
|
| - return;
|
| + return true;
|
| }
|
|
|
| {% endif %}
|
| @@ -109,9 +110,9 @@ void V8{{container.cpp_class}}::toImpl(v8::Isolate* isolate, v8::Local<v8::Value
|
| when we implement conversions for Date and RegExp. #}
|
| {# FIXME: Should check for sequences too, not just Array instances. #}
|
| if (v8Value->IsArray()) {
|
| - {{container.array_or_sequence_type.v8_value_to_local_cpp_value}};
|
| + {{v8_value_to_local_cpp_value(container.array_or_sequence_type) | indent(8)}}
|
| impl.set{{container.array_or_sequence_type.type_name}}(cppValue);
|
| - return;
|
| + return true;
|
| }
|
|
|
| {% endif %}
|
| @@ -121,52 +122,53 @@ void V8{{container.cpp_class}}::toImpl(v8::Isolate* isolate, v8::Local<v8::Value
|
| {# 14. Boolean #}
|
| if (v8Value->IsBoolean()) {
|
| impl.setBoolean(v8Value->ToBoolean()->Value());
|
| - return;
|
| + return true;
|
| }
|
|
|
| {% endif %}
|
| {% if container.numeric_type %}
|
| {# 15. Number #}
|
| if (v8Value->IsNumber()) {
|
| - {{container.numeric_type.v8_value_to_local_cpp_value}};
|
| + {{v8_value_to_local_cpp_value(container.numeric_type) | indent(8)}}
|
| impl.set{{container.numeric_type.type_name}}(cppValue);
|
| - return;
|
| + return true;
|
| }
|
|
|
| {% endif %}
|
| {% if container.string_type %}
|
| {# 16. String #}
|
| {
|
| - {{container.string_type.v8_value_to_local_cpp_value}};
|
| + {{v8_value_to_local_cpp_value(container.string_type) | indent(8)}}
|
| {% if container.string_type.enum_validation_expression %}
|
| String string = cppValue;
|
| if (!({{container.string_type.enum_validation_expression}})) {
|
| exceptionState.throwTypeError("'" + string + "' is not a valid enum value.");
|
| - return;
|
| + return false;
|
| }
|
| {% endif %}
|
| impl.set{{container.string_type.type_name}}(cppValue);
|
| - return;
|
| + return true;
|
| }
|
|
|
| {# 17. Number (fallback) #}
|
| {% elif container.numeric_type %}
|
| {
|
| - {{container.numeric_type.v8_value_to_local_cpp_value}};
|
| + {{v8_value_to_local_cpp_value(container.numeric_type) | indent(8)}}
|
| impl.set{{container.numeric_type.type_name}}(cppValue);
|
| - return;
|
| + return true;
|
| }
|
|
|
| {# 18. Boolean (fallback) #}
|
| {% elif container.boolean_type %}
|
| {
|
| - impl.setBoolean(v8Value->ToBoolean()->Value());
|
| - return;
|
| + impl.setBoolean(v8Value->BooleanValue());
|
| + return true;
|
| }
|
|
|
| {% else %}
|
| {# 19. TypeError #}
|
| exceptionState.throwTypeError("The provided value is not of type '{{container.type_string}}'");
|
| + return false;
|
| {% endif %}
|
| }
|
|
|
|
|