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

Unified Diff: Source/bindings/tests/results/core/UnionTypesCore.cpp

Issue 680193003: IDL: Generate union type containers (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 2 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
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..57c4bf47fce305e00c7ae67a0e81190f91b9333c 100644
--- a/Source/bindings/tests/results/core/UnionTypesCore.cpp
+++ b/Source/bindings/tests/results/core/UnionTypesCore.cpp
@@ -2,4 +2,437 @@
// 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/V8NodeList.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_specificType(SpecificTypeNone)
+{
+}
+
+const Vector<int>& LongSequenceOrStringArrayOrUnrestrictedDouble::getAsLongSequence()
+{
+ ASSERT(isLongSequence());
+ return m_longSequence;
+}
+
+void LongSequenceOrStringArrayOrUnrestrictedDouble::setLongSequence(const Vector<int>& value)
+{
+ ASSERT(isNull());
+ m_longSequence = value;
+ m_specificType = SpecificTypeLongSequence;
+}
+
+const Vector<String>& LongSequenceOrStringArrayOrUnrestrictedDouble::getAsStringArray()
+{
+ ASSERT(isStringArray());
+ return m_stringArray;
+}
+
+void LongSequenceOrStringArrayOrUnrestrictedDouble::setStringArray(const Vector<String>& value)
+{
+ ASSERT(isNull());
+ m_stringArray = value;
+ m_specificType = SpecificTypeStringArray;
+}
+
+double LongSequenceOrStringArrayOrUnrestrictedDouble::getAsUnrestrictedDouble()
+{
+ ASSERT(isUnrestrictedDouble());
+ return m_unrestrictedDouble;
+}
+
+void LongSequenceOrStringArrayOrUnrestrictedDouble::setUnrestrictedDouble(double value)
+{
+ ASSERT(isNull());
+ m_unrestrictedDouble = value;
+ m_specificType = 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);
+ 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);
haraken 2014/10/29 04:59:30 Just to confirm: This is v8::Null(isolate), not v8
bashi 2014/10/29 09:57:37 Yes. The first patch set returned undefined, but t
+
+ 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::Null(isolate);
haraken 2014/10/29 04:59:30 Nit: v8::Null(isolate) => v8::Handle<v8::Value>()
bashi 2014/10/29 09:57:36 Done.
+}
+
+NodeOrNodeList::NodeOrNodeList()
+ : m_specificType(SpecificTypeNone)
+{
+}
+
+PassRefPtr<Node> NodeOrNodeList::getAsNode()
+{
+ ASSERT(isNode());
+ return m_node;
+}
+
+void NodeOrNodeList::setNode(PassRefPtr<Node> value)
+{
+ ASSERT(isNull());
+ m_node = value;
+ m_specificType = SpecificTypeNode;
+}
+
+PassRefPtr<NodeList> NodeOrNodeList::getAsNodeList()
+{
+ ASSERT(isNodeList());
+ return m_nodeList;
+}
+
+void NodeOrNodeList::setNodeList(PassRefPtr<NodeList> value)
+{
+ ASSERT(isNull());
+ m_nodeList = value;
+ m_specificType = 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)) {
+ RefPtr<Node> cppValue = V8Node::toImpl(v8::Handle<v8::Object>::Cast(v8Value));
+ impl.setNode(cppValue);
+ return;
+ }
+
+ if (V8NodeList::hasInstance(v8Value, isolate)) {
+ RefPtr<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::Null(isolate);
+}
+
+StringOrDouble::StringOrDouble()
+ : m_specificType(SpecificTypeNone)
+{
+}
+
+String StringOrDouble::getAsString()
+{
+ ASSERT(isString());
+ return m_string;
+}
+
+void StringOrDouble::setString(String value)
+{
+ ASSERT(isNull());
+ m_string = value;
+ m_specificType = SpecificTypeString;
+}
+
+double StringOrDouble::getAsDouble()
+{
+ ASSERT(isDouble());
+ return m_double;
+}
+
+void StringOrDouble::setDouble(double value)
+{
+ ASSERT(isNull());
+ m_double = value;
+ m_specificType = 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()) {
+ TONATIVE_VOID_EXCEPTIONSTATE(double, cppValue, toDouble(v8Value, exceptionState), exceptionState);
+ impl.setDouble(cppValue);
+ return;
+ }
+
+ {
+ TOSTRING_VOID(V8StringResource<>, cppValue, v8Value);
+ impl.setString(cppValue);
+ return;
+ }
+
+ {
+ TONATIVE_VOID_EXCEPTIONSTATE(double, cppValue, toDouble(v8Value, exceptionState), exceptionState);
+ 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::Null(isolate);
+}
+
+TestInterfaceGarbageCollectedOrString::TestInterfaceGarbageCollectedOrString()
+ : m_specificType(SpecificTypeNone)
+{
+}
+
+PassRefPtr<TestInterfaceGarbageCollected> TestInterfaceGarbageCollectedOrString::getAsTestInterfaceGarbageCollected()
+{
+ ASSERT(isTestInterfaceGarbageCollected());
+ return m_testInterfaceGarbageCollected;
+}
+
+void TestInterfaceGarbageCollectedOrString::setTestInterfaceGarbageCollected(PassRefPtr<TestInterfaceGarbageCollected> value)
+{
+ ASSERT(isNull());
+ m_testInterfaceGarbageCollected = value;
+ m_specificType = SpecificTypeTestInterfaceGarbageCollected;
+}
+
+String TestInterfaceGarbageCollectedOrString::getAsString()
+{
+ ASSERT(isString());
+ return m_string;
+}
+
+void TestInterfaceGarbageCollectedOrString::setString(String value)
+{
+ ASSERT(isNull());
+ m_string = value;
+ m_specificType = 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)) {
+ RefPtr<TestInterfaceGarbageCollected> cppValue = V8TestInterfaceGarbageCollected::toImpl(v8::Handle<v8::Object>::Cast(v8Value));
haraken 2014/10/29 04:59:30 This looks strange and will break compile in oilpa
bashi 2014/10/29 09:57:37 Good catch! Done.
+ 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::Null(isolate);
+}
+
+TestInterfaceOrTestInterfaceEmpty::TestInterfaceOrTestInterfaceEmpty()
+ : m_specificType(SpecificTypeNone)
+{
+}
+
+PassRefPtr<TestInterface> TestInterfaceOrTestInterfaceEmpty::getAsTestInterface()
+{
+ ASSERT(isTestInterface());
+ return m_testInterface;
+}
+
+void TestInterfaceOrTestInterfaceEmpty::setTestInterface(PassRefPtr<TestInterface> value)
+{
+ ASSERT(isNull());
+ m_testInterface = value;
+ m_specificType = SpecificTypeTestInterface;
+}
+
+PassRefPtr<TestInterfaceEmpty> TestInterfaceOrTestInterfaceEmpty::getAsTestInterfaceEmpty()
+{
+ ASSERT(isTestInterfaceEmpty());
+ return m_testInterfaceEmpty;
+}
+
+void TestInterfaceOrTestInterfaceEmpty::setTestInterfaceEmpty(PassRefPtr<TestInterfaceEmpty> value)
+{
+ ASSERT(isNull());
+ m_testInterfaceEmpty = value;
+ m_specificType = 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<TestInterface> 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::Null(isolate);
+}
+
+TestInterfaceWillBeGarbageCollectedOrTestDictionary::TestInterfaceWillBeGarbageCollectedOrTestDictionary()
+ : m_specificType(SpecificTypeNone)
+{
+}
+
+PassRefPtr<TestInterfaceWillBeGarbageCollected> TestInterfaceWillBeGarbageCollectedOrTestDictionary::getAsTestInterfaceWillBeGarbageCollected()
+{
+ ASSERT(isTestInterfaceWillBeGarbageCollected());
+ return m_testInterfaceWillBeGarbageCollected;
+}
+
+void TestInterfaceWillBeGarbageCollectedOrTestDictionary::setTestInterfaceWillBeGarbageCollected(PassRefPtr<TestInterfaceWillBeGarbageCollected> value)
+{
+ ASSERT(isNull());
+ m_testInterfaceWillBeGarbageCollected = value;
+ m_specificType = SpecificTypeTestInterfaceWillBeGarbageCollected;
+}
+
+PassRefPtr<TestDictionary> TestInterfaceWillBeGarbageCollectedOrTestDictionary::getAsTestDictionary()
+{
+ ASSERT(isTestDictionary());
+ return m_testDictionary;
+}
+
+void TestInterfaceWillBeGarbageCollectedOrTestDictionary::setTestDictionary(PassRefPtr<TestDictionary> value)
+{
+ ASSERT(isNull());
+ m_testDictionary = value;
+ m_specificType = 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)) {
+ RefPtr<TestInterfaceWillBeGarbageCollected> cppValue = V8TestInterfaceWillBeGarbageCollected::toImpl(v8::Handle<v8::Object>::Cast(v8Value));
haraken 2014/10/29 04:59:30 RefPtr<TestInterfaceWillBeGarbageCollected> => Ref
bashi 2014/10/29 09:57:37 Done.
+ impl.setTestInterfaceWillBeGarbageCollected(cppValue);
+ return;
+ }
+
+ if (V8TestDictionary::hasInstance(v8Value, isolate)) {
+ RefPtr<TestDictionary> cppValue = V8TestDictionary::toImpl(v8::Handle<v8::Object>::Cast(v8Value));
+ 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::Null(isolate);
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698