Index: Source/bindings/tests/results/core/UnionTypesCore.cpp |
diff --git a/Source/bindings/tests/results/core/UnionTypesCore.cpp b/Source/bindings/tests/results/core/UnionTypesCore.cpp |
index d3523387f89a93d6f1a4de2575ba5b8a8293128b..a65ce648a51f5224940e71a4fbe67890eccfe436 100644 |
--- a/Source/bindings/tests/results/core/UnionTypesCore.cpp |
+++ b/Source/bindings/tests/results/core/UnionTypesCore.cpp |
@@ -2,4 +2,439 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-// FIXME: Implement |
+// This file has been auto-generated by code_generator_v8.py. DO NOT MODIFY! |
+ |
+#include "config.h" |
+#include "bindings/core/v8/UnionTypesCore.h" |
+ |
+#include "bindings/core/v8/V8Node.h" |
+#include "bindings/core/v8/V8NodeList.h" |
+#include "bindings/core/v8/V8TestDictionary.h" |
+#include "bindings/core/v8/V8TestInterface.h" |
+#include "bindings/core/v8/V8TestInterfaceEmpty.h" |
+#include "bindings/core/v8/V8TestInterfaceGarbageCollected.h" |
+#include "bindings/core/v8/V8TestInterfaceWillBeGarbageCollected.h" |
+#include "bindings/tests/idls/core/TestImplements2.h" |
+#include "bindings/tests/idls/core/TestImplements3Implementation.h" |
+#include "bindings/tests/idls/core/TestPartialInterface.h" |
+#include "bindings/tests/idls/core/TestPartialInterfaceImplementation.h" |
+#include "core/dom/NameNodeList.h" |
+#include "core/dom/NodeList.h" |
+#include "core/dom/StaticNodeList.h" |
+#include "core/html/LabelsNodeList.h" |
+ |
+namespace blink { |
+ |
+LongSequenceOrStringArrayOrUnrestrictedDouble::LongSequenceOrStringArrayOrUnrestrictedDouble() |
+ : m_type(SpecificTypeNone) |
+{ |
+} |
+ |
+const Vector<int>& LongSequenceOrStringArrayOrUnrestrictedDouble::getAsLongSequence() |
+{ |
+ ASSERT(isLongSequence()); |
+ return m_longSequence; |
+} |
+ |
+void LongSequenceOrStringArrayOrUnrestrictedDouble::setLongSequence(const Vector<int>& value) |
+{ |
+ ASSERT(isNull()); |
+ m_longSequence = value; |
+ m_type = SpecificTypeLongSequence; |
+} |
+ |
+const Vector<String>& LongSequenceOrStringArrayOrUnrestrictedDouble::getAsStringArray() |
+{ |
+ ASSERT(isStringArray()); |
+ return m_stringArray; |
+} |
+ |
+void LongSequenceOrStringArrayOrUnrestrictedDouble::setStringArray(const Vector<String>& value) |
+{ |
+ ASSERT(isNull()); |
+ m_stringArray = value; |
+ m_type = SpecificTypeStringArray; |
+} |
+ |
+double LongSequenceOrStringArrayOrUnrestrictedDouble::getAsUnrestrictedDouble() |
+{ |
+ ASSERT(isUnrestrictedDouble()); |
+ return m_unrestrictedDouble; |
+} |
+ |
+void LongSequenceOrStringArrayOrUnrestrictedDouble::setUnrestrictedDouble(double value) |
+{ |
+ ASSERT(isNull()); |
+ m_unrestrictedDouble = value; |
+ m_type = SpecificTypeUnrestrictedDouble; |
+} |
+ |
+void V8LongSequenceOrStringArrayOrUnrestrictedDouble::toImpl(v8::Isolate* isolate, v8::Handle<v8::Value> v8Value, LongSequenceOrStringArrayOrUnrestrictedDouble& impl, ExceptionState& exceptionState) |
+{ |
+ if (v8Value.IsEmpty() || isUndefinedOrNull(v8Value)) |
+ return; |
+ |
+ if (v8Value->IsNumber()) { |
+ TONATIVE_VOID_EXCEPTIONSTATE(double, cppValue, toDouble(v8Value, exceptionState), exceptionState); |
+ impl.setUnrestrictedDouble(cppValue); |
+ return; |
+ } |
+ |
+ { |
+ TONATIVE_VOID_EXCEPTIONSTATE(double, cppValue, toDouble(v8Value, exceptionState), exceptionState); |
haraken
2014/10/30 08:39:26
This conversion looks wrong. "LongSequence" and "S
bashi
2014/10/30 12:20:48
Yes, this is wrong as I didn't implement sequences
|
+ return; |
+ } |
+ |
+ exceptionState.throwTypeError("Not a valid union member."); |
+} |
+ |
+v8::Handle<v8::Value> toV8(LongSequenceOrStringArrayOrUnrestrictedDouble& impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) |
+{ |
+ if (impl.isNull()) |
+ return v8::Null(isolate); |
+ |
+ if (impl.isLongSequence()) |
+ return v8Array(impl.getAsLongSequence(), creationContext, isolate); |
+ |
+ if (impl.isStringArray()) |
+ return v8Array(impl.getAsStringArray(), creationContext, isolate); |
+ |
+ if (impl.isUnrestrictedDouble()) |
+ return v8::Number::New(isolate, impl.getAsUnrestrictedDouble()); |
+ |
+ ASSERT_NOT_REACHED(); |
+ return v8::Handle<v8::Value>(); |
+} |
+ |
+NodeOrNodeList::NodeOrNodeList() |
+ : m_type(SpecificTypeNone) |
+{ |
+} |
+ |
+PassRefPtrWillBeRawPtr<Node> NodeOrNodeList::getAsNode() |
+{ |
+ ASSERT(isNode()); |
+ return m_node; |
+} |
+ |
+void NodeOrNodeList::setNode(PassRefPtrWillBeRawPtr<Node> value) |
+{ |
+ ASSERT(isNull()); |
+ m_node = value; |
+ m_type = SpecificTypeNode; |
+} |
+ |
+PassRefPtrWillBeRawPtr<NodeList> NodeOrNodeList::getAsNodeList() |
+{ |
+ ASSERT(isNodeList()); |
+ return m_nodeList; |
+} |
+ |
+void NodeOrNodeList::setNodeList(PassRefPtrWillBeRawPtr<NodeList> value) |
+{ |
+ ASSERT(isNull()); |
+ m_nodeList = value; |
+ m_type = SpecificTypeNodeList; |
+} |
+ |
+void V8NodeOrNodeList::toImpl(v8::Isolate* isolate, v8::Handle<v8::Value> v8Value, NodeOrNodeList& impl, ExceptionState& exceptionState) |
+{ |
+ if (v8Value.IsEmpty() || isUndefinedOrNull(v8Value)) |
+ return; |
+ |
+ if (V8Node::hasInstance(v8Value, isolate)) { |
+ RefPtrWillBeRawPtr<Node> cppValue = V8Node::toImpl(v8::Handle<v8::Object>::Cast(v8Value)); |
+ impl.setNode(cppValue); |
+ return; |
+ } |
+ |
+ if (V8NodeList::hasInstance(v8Value, isolate)) { |
+ RefPtrWillBeRawPtr<NodeList> cppValue = V8NodeList::toImpl(v8::Handle<v8::Object>::Cast(v8Value)); |
+ impl.setNodeList(cppValue); |
+ return; |
+ } |
+ |
+ exceptionState.throwTypeError("Not a valid union member."); |
+} |
+ |
+v8::Handle<v8::Value> toV8(NodeOrNodeList& impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) |
+{ |
+ if (impl.isNull()) |
+ return v8::Null(isolate); |
+ |
+ if (impl.isNode()) |
+ return toV8(impl.getAsNode(), creationContext, isolate); |
+ |
+ if (impl.isNodeList()) |
+ return toV8(impl.getAsNodeList(), creationContext, isolate); |
+ |
+ ASSERT_NOT_REACHED(); |
+ return v8::Handle<v8::Value>(); |
+} |
+ |
+StringOrDouble::StringOrDouble() |
+ : m_type(SpecificTypeNone) |
+{ |
+} |
+ |
+String StringOrDouble::getAsString() |
+{ |
+ ASSERT(isString()); |
+ return m_string; |
+} |
+ |
+void StringOrDouble::setString(String value) |
+{ |
+ ASSERT(isNull()); |
+ m_string = value; |
+ m_type = SpecificTypeString; |
+} |
+ |
+double StringOrDouble::getAsDouble() |
+{ |
+ ASSERT(isDouble()); |
+ return m_double; |
+} |
+ |
+void StringOrDouble::setDouble(double value) |
+{ |
+ ASSERT(isNull()); |
+ m_double = value; |
+ m_type = SpecificTypeDouble; |
+} |
+ |
+void V8StringOrDouble::toImpl(v8::Isolate* isolate, v8::Handle<v8::Value> v8Value, StringOrDouble& impl, ExceptionState& exceptionState) |
+{ |
+ if (v8Value.IsEmpty() || isUndefinedOrNull(v8Value)) |
+ return; |
+ |
+ if (v8Value->IsNumber()) { |
haraken
2014/10/30 08:39:26
I'm getting a bit confused how toImpl works.
When
Jens Widell
2014/10/30 08:49:14
See: http://heycam.github.io/webidl/#es-union (pri
bashi
2014/10/30 12:20:48
Thank you Jens for the explanation!
|
+ TONATIVE_VOID_EXCEPTIONSTATE(double, cppValue, toDouble(v8Value, exceptionState), exceptionState); |
+ impl.setDouble(cppValue); |
+ return; |
+ } |
+ |
+ { |
+ TOSTRING_VOID(V8StringResource<>, cppValue, v8Value); |
haraken
2014/10/30 08:39:26
Just to confirm: It is OK to not pass exceptionSta
Jens Widell
2014/10/30 08:49:14
Ah, good catch. No, I'd say it's not OK here, sinc
bashi
2014/10/30 12:20:48
Yeah, good catch. Done. (though v8_value_to_local_
|
+ impl.setString(cppValue); |
+ return; |
+ } |
+ |
+ exceptionState.throwTypeError("Not a valid union member."); |
+} |
+ |
+v8::Handle<v8::Value> toV8(StringOrDouble& impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) |
+{ |
+ if (impl.isNull()) |
+ return v8::Null(isolate); |
+ |
+ if (impl.isString()) |
+ return v8String(isolate, impl.getAsString()); |
+ |
+ if (impl.isDouble()) |
+ return v8::Number::New(isolate, impl.getAsDouble()); |
+ |
+ ASSERT_NOT_REACHED(); |
+ return v8::Handle<v8::Value>(); |
+} |
+ |
+TestInterfaceGarbageCollectedOrString::TestInterfaceGarbageCollectedOrString() |
+ : m_type(SpecificTypeNone) |
+{ |
+} |
+ |
+RawPtr<TestInterfaceGarbageCollected> TestInterfaceGarbageCollectedOrString::getAsTestInterfaceGarbageCollected() |
+{ |
+ ASSERT(isTestInterfaceGarbageCollected()); |
+ return m_testInterfaceGarbageCollected; |
+} |
+ |
+void TestInterfaceGarbageCollectedOrString::setTestInterfaceGarbageCollected(RawPtr<TestInterfaceGarbageCollected> value) |
+{ |
+ ASSERT(isNull()); |
+ m_testInterfaceGarbageCollected = value; |
+ m_type = SpecificTypeTestInterfaceGarbageCollected; |
+} |
+ |
+String TestInterfaceGarbageCollectedOrString::getAsString() |
+{ |
+ ASSERT(isString()); |
+ return m_string; |
+} |
+ |
+void TestInterfaceGarbageCollectedOrString::setString(String value) |
+{ |
+ ASSERT(isNull()); |
+ m_string = value; |
+ m_type = SpecificTypeString; |
+} |
+ |
+void V8TestInterfaceGarbageCollectedOrString::toImpl(v8::Isolate* isolate, v8::Handle<v8::Value> v8Value, TestInterfaceGarbageCollectedOrString& impl, ExceptionState& exceptionState) |
+{ |
+ if (v8Value.IsEmpty() || isUndefinedOrNull(v8Value)) |
+ return; |
+ |
+ if (V8TestInterfaceGarbageCollected::hasInstance(v8Value, isolate)) { |
+ RawPtr<TestInterfaceGarbageCollected> cppValue = V8TestInterfaceGarbageCollected::toImpl(v8::Handle<v8::Object>::Cast(v8Value)); |
+ impl.setTestInterfaceGarbageCollected(cppValue); |
+ return; |
+ } |
+ |
+ { |
+ TOSTRING_VOID(V8StringResource<>, cppValue, v8Value); |
+ impl.setString(cppValue); |
+ return; |
+ } |
+ |
+ exceptionState.throwTypeError("Not a valid union member."); |
+} |
+ |
+v8::Handle<v8::Value> toV8(TestInterfaceGarbageCollectedOrString& impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) |
+{ |
+ if (impl.isNull()) |
+ return v8::Null(isolate); |
+ |
+ if (impl.isTestInterfaceGarbageCollected()) |
+ return toV8(impl.getAsTestInterfaceGarbageCollected(), creationContext, isolate); |
+ |
+ if (impl.isString()) |
+ return v8String(isolate, impl.getAsString()); |
+ |
+ ASSERT_NOT_REACHED(); |
+ return v8::Handle<v8::Value>(); |
+} |
+ |
+TestInterfaceOrTestInterfaceEmpty::TestInterfaceOrTestInterfaceEmpty() |
+ : m_type(SpecificTypeNone) |
+{ |
+} |
+ |
+PassRefPtr<TestInterfaceImplementation> TestInterfaceOrTestInterfaceEmpty::getAsTestInterface() |
+{ |
+ ASSERT(isTestInterface()); |
+ return m_testInterface; |
+} |
+ |
+void TestInterfaceOrTestInterfaceEmpty::setTestInterface(PassRefPtr<TestInterfaceImplementation> value) |
+{ |
+ ASSERT(isNull()); |
+ m_testInterface = value; |
+ m_type = SpecificTypeTestInterface; |
+} |
+ |
+PassRefPtr<TestInterfaceEmpty> TestInterfaceOrTestInterfaceEmpty::getAsTestInterfaceEmpty() |
+{ |
+ ASSERT(isTestInterfaceEmpty()); |
+ return m_testInterfaceEmpty; |
+} |
+ |
+void TestInterfaceOrTestInterfaceEmpty::setTestInterfaceEmpty(PassRefPtr<TestInterfaceEmpty> value) |
+{ |
+ ASSERT(isNull()); |
+ m_testInterfaceEmpty = value; |
+ m_type = SpecificTypeTestInterfaceEmpty; |
+} |
+ |
+void V8TestInterfaceOrTestInterfaceEmpty::toImpl(v8::Isolate* isolate, v8::Handle<v8::Value> v8Value, TestInterfaceOrTestInterfaceEmpty& impl, ExceptionState& exceptionState) |
+{ |
+ if (v8Value.IsEmpty() || isUndefinedOrNull(v8Value)) |
+ return; |
+ |
+ if (V8TestInterface::hasInstance(v8Value, isolate)) { |
+ RefPtr<TestInterfaceImplementation> cppValue = V8TestInterface::toImpl(v8::Handle<v8::Object>::Cast(v8Value)); |
+ impl.setTestInterface(cppValue); |
+ return; |
+ } |
+ |
+ if (V8TestInterfaceEmpty::hasInstance(v8Value, isolate)) { |
+ RefPtr<TestInterfaceEmpty> cppValue = V8TestInterfaceEmpty::toImpl(v8::Handle<v8::Object>::Cast(v8Value)); |
+ impl.setTestInterfaceEmpty(cppValue); |
+ return; |
+ } |
+ |
+ exceptionState.throwTypeError("Not a valid union member."); |
+} |
+ |
+v8::Handle<v8::Value> toV8(TestInterfaceOrTestInterfaceEmpty& impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) |
+{ |
+ if (impl.isNull()) |
+ return v8::Null(isolate); |
+ |
+ if (impl.isTestInterface()) |
+ return toV8(impl.getAsTestInterface(), creationContext, isolate); |
+ |
+ if (impl.isTestInterfaceEmpty()) |
+ return toV8(impl.getAsTestInterfaceEmpty(), creationContext, isolate); |
+ |
+ ASSERT_NOT_REACHED(); |
+ return v8::Handle<v8::Value>(); |
+} |
+ |
+TestInterfaceWillBeGarbageCollectedOrTestDictionary::TestInterfaceWillBeGarbageCollectedOrTestDictionary() |
+ : m_type(SpecificTypeNone) |
+{ |
+} |
+ |
+PassRefPtrWillBeRawPtr<TestInterfaceWillBeGarbageCollected> TestInterfaceWillBeGarbageCollectedOrTestDictionary::getAsTestInterfaceWillBeGarbageCollected() |
+{ |
+ ASSERT(isTestInterfaceWillBeGarbageCollected()); |
+ return m_testInterfaceWillBeGarbageCollected; |
+} |
+ |
+void TestInterfaceWillBeGarbageCollectedOrTestDictionary::setTestInterfaceWillBeGarbageCollected(PassRefPtrWillBeRawPtr<TestInterfaceWillBeGarbageCollected> value) |
+{ |
+ ASSERT(isNull()); |
+ m_testInterfaceWillBeGarbageCollected = value; |
+ m_type = SpecificTypeTestInterfaceWillBeGarbageCollected; |
+} |
+ |
+TestDictionary TestInterfaceWillBeGarbageCollectedOrTestDictionary::getAsTestDictionary() |
+{ |
+ ASSERT(isTestDictionary()); |
+ return m_testDictionary; |
+} |
+ |
+void TestInterfaceWillBeGarbageCollectedOrTestDictionary::setTestDictionary(TestDictionary value) |
+{ |
+ ASSERT(isNull()); |
+ m_testDictionary = value; |
+ m_type = SpecificTypeTestDictionary; |
+} |
+ |
+void V8TestInterfaceWillBeGarbageCollectedOrTestDictionary::toImpl(v8::Isolate* isolate, v8::Handle<v8::Value> v8Value, TestInterfaceWillBeGarbageCollectedOrTestDictionary& impl, ExceptionState& exceptionState) |
+{ |
+ if (v8Value.IsEmpty() || isUndefinedOrNull(v8Value)) |
+ return; |
+ |
+ if (V8TestInterfaceWillBeGarbageCollected::hasInstance(v8Value, isolate)) { |
+ RefPtrWillBeRawPtr<TestInterfaceWillBeGarbageCollected> cppValue = V8TestInterfaceWillBeGarbageCollected::toImpl(v8::Handle<v8::Object>::Cast(v8Value)); |
+ impl.setTestInterfaceWillBeGarbageCollected(cppValue); |
+ return; |
+ } |
+ |
+ if (v8Value->IsObject()) { |
+ TestDictionary cppValue = V8TestDictionary::toImpl(isolate, v8Value, exceptionState); |
+ if (!exceptionState.hadException()) |
+ impl.setTestDictionary(cppValue); |
+ return; |
+ } |
+ |
+ exceptionState.throwTypeError("Not a valid union member."); |
+} |
+ |
+v8::Handle<v8::Value> toV8(TestInterfaceWillBeGarbageCollectedOrTestDictionary& impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) |
+{ |
+ if (impl.isNull()) |
+ return v8::Null(isolate); |
+ |
+ if (impl.isTestInterfaceWillBeGarbageCollected()) |
+ return toV8(impl.getAsTestInterfaceWillBeGarbageCollected(), creationContext, isolate); |
+ |
+ if (impl.isTestDictionary()) |
+ return toV8(impl.getAsTestDictionary(), creationContext, isolate); |
+ |
+ ASSERT_NOT_REACHED(); |
+ return v8::Handle<v8::Value>(); |
+} |
+ |
+} // namespace blink |