| Index: Source/bindings/templates/union_container.cpp
|
| diff --git a/Source/bindings/templates/union.cpp b/Source/bindings/templates/union_container.cpp
|
| similarity index 54%
|
| copy from Source/bindings/templates/union.cpp
|
| copy to Source/bindings/templates/union_container.cpp
|
| index 3b7a1ce6a57c618195673d6894a8173852ef9c9e..c62f36649aada709af33b8d4fdf9592bfa175c2f 100644
|
| --- a/Source/bindings/templates/union.cpp
|
| +++ b/Source/bindings/templates/union_container.cpp
|
| @@ -1,11 +1,11 @@
|
| -// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| // This file has been auto-generated by {{code_generator}}. DO NOT MODIFY!
|
|
|
| #include "config.h"
|
| -#include "{{header_filename}}"
|
| +#include "{{cpp_class}}.h"
|
|
|
| {% macro assign_and_return_if_hasinstance(member) %}
|
| if (V8{{member.type_name}}::hasInstance(v8Value, isolate)) {
|
| @@ -14,26 +14,22 @@ if (V8{{member.type_name}}::hasInstance(v8Value, isolate)) {
|
| return;
|
| }
|
| {% endmacro %}
|
| -{% for filename in cpp_includes %}
|
| -#include "{{filename}}"
|
| -{% endfor %}
|
|
|
| namespace blink {
|
|
|
| -{% for container in containers %}
|
| -{{container.cpp_class}}::{{container.cpp_class}}()
|
| +{{cpp_class}}::{{cpp_class}}()
|
| : m_type(SpecificTypeNone)
|
| {
|
| }
|
|
|
| -{% for member in container.members %}
|
| -{{member.rvalue_cpp_type}} {{container.cpp_class}}::getAs{{member.type_name}}() const
|
| +{% for member in members %}
|
| +{{member.rvalue_cpp_type}} {{cpp_class}}::getAs{{member.type_name}}() const
|
| {
|
| ASSERT(is{{member.type_name}}());
|
| return m_{{member.cpp_name}};
|
| }
|
|
|
| -void {{container.cpp_class}}::set{{member.type_name}}({{member.rvalue_cpp_type}} value)
|
| +void {{cpp_class}}::set{{member.type_name}}({{member.rvalue_cpp_type}} value)
|
| {
|
| ASSERT(isNull());
|
| {% if member.enum_validation_expression %}
|
| @@ -47,24 +43,24 @@ void {{container.cpp_class}}::set{{member.type_name}}({{member.rvalue_cpp_type}}
|
| m_type = {{member.specific_type_enum}};
|
| }
|
|
|
| -{{container.cpp_class}} {{container.cpp_class}}::from{{member.type_name}}({{member.rvalue_cpp_type}} value)
|
| +{{cpp_class}} {{cpp_class}}::from{{member.type_name}}({{member.rvalue_cpp_type}} value)
|
| {
|
| - {{container.cpp_class}} container;
|
| + {{cpp_class}} container;
|
| container.set{{member.type_name}}(value);
|
| return container;
|
| }
|
|
|
| {% endfor %}
|
| -{% if container.needs_trace %}
|
| -DEFINE_TRACE({{container.cpp_class}})
|
| +{% if needs_trace %}
|
| +DEFINE_TRACE({{cpp_class}})
|
| {
|
| - {% for member in container.members if member.is_traceable %}
|
| + {% for member in members if member.is_traceable %}
|
| visitor->trace(m_{{member.cpp_name}});
|
| {% endfor %}
|
| }
|
|
|
| {% endif %}
|
| -void V8{{container.cpp_class}}::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, {{container.cpp_class}}& impl, ExceptionState& exceptionState)
|
| +void {{v8_class}}::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, {{cpp_class}}& impl, ExceptionState& exceptionState)
|
| {
|
| if (v8Value.IsEmpty())
|
| return;
|
| @@ -74,50 +70,50 @@ void V8{{container.cpp_class}}::toImpl(v8::Isolate* isolate, v8::Local<v8::Value
|
| NOTE: Step 1 (null or undefined) is handled in *OrNull::toImpl()
|
| FIXME: Implement all necessary steps #}
|
| {# 3. Platform objects (interfaces) #}
|
| - {% for interface in container.interface_types %}
|
| + {% for interface in interface_types %}
|
| {{assign_and_return_if_hasinstance(interface) | indent}}
|
|
|
| {% endfor %}
|
| {# 8. ArrayBuffer #}
|
| - {% if container.array_buffer_type %}
|
| - {{assign_and_return_if_hasinstance(container.array_buffer_type) | indent}}
|
| + {% if array_buffer_type %}
|
| + {{assign_and_return_if_hasinstance(array_buffer_type) | indent}}
|
|
|
| {% endif %}
|
| {# 9., 10. ArrayBufferView #}
|
| {# FIXME: Individual typed arrays (e.g. Uint8Array) aren't supported yet. #}
|
| - {% if container.array_buffer_view_type %}
|
| - {{assign_and_return_if_hasinstance(container.array_buffer_view_type) | indent}}
|
| + {% if array_buffer_view_type %}
|
| + {{assign_and_return_if_hasinstance(array_buffer_view_type) | indent}}
|
|
|
| {% endif %}
|
| - {% if container.dictionary_type %}
|
| + {% if dictionary_type %}
|
| {# 12. Dictionaries #}
|
| {# FIXME: This should also check "object but not Date or RegExp". Add checks
|
| when we implement conversions for Date and RegExp. #}
|
| if (isUndefinedOrNull(v8Value) || v8Value->IsObject()) {
|
| - {% if container.dictionary_type.type_name != 'Dictionary' %}
|
| - {{container.dictionary_type.cpp_local_type}} cppValue;
|
| + {% if dictionary_type.type_name != 'Dictionary' %}
|
| + {{dictionary_type.cpp_local_type}} cppValue;
|
| {% endif %}
|
| - {{container.dictionary_type.v8_value_to_local_cpp_value}};
|
| - impl.set{{container.dictionary_type.type_name}}(cppValue);
|
| + {{dictionary_type.v8_value_to_local_cpp_value}};
|
| + impl.set{{dictionary_type.type_name}}(cppValue);
|
| return;
|
| }
|
|
|
| {% endif %}
|
| - {% if container.array_or_sequence_type %}
|
| + {% if array_or_sequence_type %}
|
| {# 13. Arrays/Sequences #}
|
| {# FIXME: This should also check "object but not Date or RegExp". Add checks
|
| 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}};
|
| - impl.set{{container.array_or_sequence_type.type_name}}(cppValue);
|
| + {{array_or_sequence_type.v8_value_to_local_cpp_value}};
|
| + impl.set{{array_or_sequence_type.type_name}}(cppValue);
|
| return;
|
| }
|
|
|
| {% endif %}
|
| {# FIXME: In some cases, we can omit boolean and numeric type checks because
|
| we have fallback conversions. (step 17 and 18) #}
|
| - {% if container.boolean_type %}
|
| + {% if boolean_type %}
|
| {# 14. Boolean #}
|
| if (v8Value->IsBoolean()) {
|
| impl.setBoolean(v8Value->ToBoolean()->Value());
|
| @@ -125,40 +121,40 @@ void V8{{container.cpp_class}}::toImpl(v8::Isolate* isolate, v8::Local<v8::Value
|
| }
|
|
|
| {% endif %}
|
| - {% if container.numeric_type %}
|
| + {% if numeric_type %}
|
| {# 15. Number #}
|
| if (v8Value->IsNumber()) {
|
| - {{container.numeric_type.v8_value_to_local_cpp_value}};
|
| - impl.set{{container.numeric_type.type_name}}(cppValue);
|
| + {{numeric_type.v8_value_to_local_cpp_value}};
|
| + impl.set{{numeric_type.type_name}}(cppValue);
|
| return;
|
| }
|
|
|
| {% endif %}
|
| - {% if container.string_type %}
|
| + {% if string_type %}
|
| {# 16. String #}
|
| {
|
| - {{container.string_type.v8_value_to_local_cpp_value}};
|
| - {% if container.string_type.enum_validation_expression %}
|
| + {{string_type.v8_value_to_local_cpp_value}};
|
| + {% if string_type.enum_validation_expression %}
|
| String string = cppValue;
|
| - if (!({{container.string_type.enum_validation_expression}})) {
|
| + if (!({{string_type.enum_validation_expression}})) {
|
| exceptionState.throwTypeError("'" + string + "' is not a valid enum value.");
|
| return;
|
| }
|
| {% endif %}
|
| - impl.set{{container.string_type.type_name}}(cppValue);
|
| + impl.set{{string_type.type_name}}(cppValue);
|
| return;
|
| }
|
|
|
| {# 17. Number (fallback) #}
|
| - {% elif container.numeric_type %}
|
| + {% elif numeric_type %}
|
| {
|
| - {{container.numeric_type.v8_value_to_local_cpp_value}};
|
| - impl.set{{container.numeric_type.type_name}}(cppValue);
|
| + {{numeric_type.v8_value_to_local_cpp_value}};
|
| + impl.set{{numeric_type.type_name}}(cppValue);
|
| return;
|
| }
|
|
|
| {# 18. Boolean (fallback) #}
|
| - {% elif container.boolean_type %}
|
| + {% elif boolean_type %}
|
| {
|
| impl.setBoolean(v8Value->ToBoolean()->Value());
|
| return;
|
| @@ -166,18 +162,18 @@ void V8{{container.cpp_class}}::toImpl(v8::Isolate* isolate, v8::Local<v8::Value
|
|
|
| {% else %}
|
| {# 19. TypeError #}
|
| - exceptionState.throwTypeError("The provided value is not of type '{{container.type_string}}'");
|
| + exceptionState.throwTypeError("The provided value is not of type '{{type_string}}'");
|
| {% endif %}
|
| }
|
|
|
| -v8::Local<v8::Value> toV8(const {{container.cpp_class}}& impl, v8::Local<v8::Object> creationContext, v8::Isolate* isolate)
|
| +v8::Local<v8::Value> toV8(const {{cpp_class}}& impl, v8::Local<v8::Object> creationContext, v8::Isolate* isolate)
|
| {
|
| switch (impl.m_type) {
|
| - case {{container.cpp_class}}::SpecificTypeNone:
|
| + case {{cpp_class}}::SpecificTypeNone:
|
| {# FIXME: We might want to return undefined in some cases #}
|
| return v8::Null(isolate);
|
| - {% for member in container.members %}
|
| - case {{container.cpp_class}}::{{member.specific_type_enum}}:
|
| + {% for member in members %}
|
| + case {{cpp_class}}::{{member.specific_type_enum}}:
|
| return {{member.cpp_value_to_v8_value}};
|
| {% endfor %}
|
| default:
|
| @@ -186,12 +182,11 @@ v8::Local<v8::Value> toV8(const {{container.cpp_class}}& impl, v8::Local<v8::Obj
|
| return v8::Local<v8::Value>();
|
| }
|
|
|
| -{{container.cpp_class}} NativeValueTraits<{{container.cpp_class}}>::nativeValue(const v8::Local<v8::Value>& value, v8::Isolate* isolate, ExceptionState& exceptionState)
|
| +{{cpp_class}} NativeValueTraits<{{cpp_class}}>::nativeValue(const v8::Local<v8::Value>& value, v8::Isolate* isolate, ExceptionState& exceptionState)
|
| {
|
| - {{container.cpp_class}} impl;
|
| - V8{{container.cpp_class}}::toImpl(isolate, value, impl, exceptionState);
|
| + {{cpp_class}} impl;
|
| + {{v8_class}}::toImpl(isolate, value, impl, exceptionState);
|
| return impl;
|
| }
|
|
|
| -{% endfor %}
|
| } // namespace blink
|
|
|