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

Unified Diff: third_party/WebKit/Source/bindings/tests/results/core/NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord.cpp

Issue 2746713003: bindings: Add support for nested union types (Closed)
Patch Set: Improve documentation Created 3 years, 9 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: third_party/WebKit/Source/bindings/tests/results/core/NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord.cpp
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord.cpp b/third_party/WebKit/Source/bindings/tests/results/core/NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1e8f7eced741aa077866989b1c5ebb10f0886f89
--- /dev/null
+++ b/third_party/WebKit/Source/bindings/tests/results/core/NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord.cpp
@@ -0,0 +1,217 @@
+// Copyright 2014 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_v8.py.
+// DO NOT MODIFY!
+
+// This file has been generated from the Jinja2 template in
+// third_party/WebKit/Source/bindings/templates/union_container.cpp.tmpl
+
+// clang-format off
+#include "NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord.h"
+
+#include "bindings/core/v8/ArrayBufferOrArrayBufferViewOrBlobOrDocumentOrStringOrFormDataOrURLSearchParams.h"
+#include "bindings/core/v8/IDLTypes.h"
+#include "bindings/core/v8/NativeValueTraitsImpl.h"
+#include "bindings/core/v8/ToV8.h"
+#include "bindings/core/v8/V8Event.h"
+#include "bindings/core/v8/V8Node.h"
+#include "bindings/core/v8/V8XMLHttpRequest.h"
+
+namespace blink {
+
+NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord::NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord() : m_type(SpecificTypeNone) {}
+
+Event* NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord::getAsEvent() const {
+ DCHECK(isEvent());
+ return m_event;
+}
+
+void NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord::setEvent(Event* value) {
+ DCHECK(isNull());
+ m_event = value;
+ m_type = SpecificTypeEvent;
+}
+
+NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord::fromEvent(Event* value) {
+ NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord container;
+ container.setEvent(value);
+ return container;
+}
+
+const Vector<int32_t>& NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord::getAsLongSequence() const {
+ DCHECK(isLongSequence());
+ return m_longSequence;
+}
+
+void NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord::setLongSequence(const Vector<int32_t>& value) {
+ DCHECK(isNull());
+ m_longSequence = value;
+ m_type = SpecificTypeLongSequence;
+}
+
+NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord::fromLongSequence(const Vector<int32_t>& value) {
+ NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord container;
+ container.setLongSequence(value);
+ return container;
+}
+
+Node* NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord::getAsNode() const {
+ DCHECK(isNode());
+ return m_node;
+}
+
+void NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord::setNode(Node* value) {
+ DCHECK(isNull());
+ m_node = value;
+ m_type = SpecificTypeNode;
+}
+
+NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord::fromNode(Node* value) {
+ NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord container;
+ container.setNode(value);
+ return container;
+}
+
+String NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord::getAsString() const {
+ DCHECK(isString());
+ return m_string;
+}
+
+void NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord::setString(String value) {
+ DCHECK(isNull());
+ m_string = value;
+ m_type = SpecificTypeString;
+}
+
+NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord::fromString(String value) {
+ NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord container;
+ container.setString(value);
+ return container;
+}
+
+const HeapVector<std::pair<String, ByteStringOrNodeList>>& NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord::getAsStringByteStringOrNodeListRecord() const {
+ DCHECK(isStringByteStringOrNodeListRecord());
+ return m_stringByteStringOrNodeListRecord;
+}
+
+void NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord::setStringByteStringOrNodeListRecord(const HeapVector<std::pair<String, ByteStringOrNodeList>>& value) {
+ DCHECK(isNull());
+ m_stringByteStringOrNodeListRecord = value;
+ m_type = SpecificTypeStringByteStringOrNodeListRecord;
+}
+
+NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord::fromStringByteStringOrNodeListRecord(const HeapVector<std::pair<String, ByteStringOrNodeList>>& value) {
+ NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord container;
+ container.setStringByteStringOrNodeListRecord(value);
+ return container;
+}
+
+XMLHttpRequest* NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord::getAsXMLHttpRequest() const {
+ DCHECK(isXMLHttpRequest());
+ return m_xmlHttpRequest;
+}
+
+void NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord::setXMLHttpRequest(XMLHttpRequest* value) {
+ DCHECK(isNull());
+ m_xmlHttpRequest = value;
+ m_type = SpecificTypeXMLHttpRequest;
+}
+
+NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord::fromXMLHttpRequest(XMLHttpRequest* value) {
+ NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord container;
+ container.setXMLHttpRequest(value);
+ return container;
+}
+
+NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord::NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord(const NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord&) = default;
+NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord::~NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord() = default;
+NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord& NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord::operator=(const NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord&) = default;
+
+DEFINE_TRACE(NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord) {
+ visitor->trace(m_event);
+ visitor->trace(m_node);
+ visitor->trace(m_stringByteStringOrNodeListRecord);
+ visitor->trace(m_xmlHttpRequest);
+}
+
+void V8NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord& impl, UnionTypeConversionMode conversionMode, ExceptionState& exceptionState) {
+ if (v8Value.IsEmpty())
+ return;
+
+ if (conversionMode == UnionTypeConversionMode::Nullable && isUndefinedOrNull(v8Value))
+ return;
+
+ if (V8Event::hasInstance(v8Value, isolate)) {
+ Event* cppValue = V8Event::toImpl(v8::Local<v8::Object>::Cast(v8Value));
+ impl.setEvent(cppValue);
+ return;
+ }
+
+ if (V8Node::hasInstance(v8Value, isolate)) {
+ Node* cppValue = V8Node::toImpl(v8::Local<v8::Object>::Cast(v8Value));
+ impl.setNode(cppValue);
+ return;
+ }
+
+ if (V8XMLHttpRequest::hasInstance(v8Value, isolate)) {
+ XMLHttpRequest* cppValue = V8XMLHttpRequest::toImpl(v8::Local<v8::Object>::Cast(v8Value));
+ impl.setXMLHttpRequest(cppValue);
+ return;
+ }
+
+ if (v8Value->IsArray()) {
+ Vector<int32_t> cppValue = toImplArray<Vector<int32_t>>(v8Value, 0, isolate, exceptionState);
+ if (exceptionState.hadException())
+ return;
+ impl.setLongSequence(cppValue);
+ return;
+ }
+
+ if (v8Value->IsObject()) {
+ HeapVector<std::pair<String, ByteStringOrNodeList>> cppValue = NativeValueTraits<IDLRecord<IDLString, ByteStringOrNodeList>>::nativeValue(isolate, v8Value, exceptionState);
+ if (exceptionState.hadException())
+ return;
+ impl.setStringByteStringOrNodeListRecord(cppValue);
+ return;
+ }
+
+ {
+ V8StringResource<> cppValue = v8Value;
+ if (!cppValue.prepare(exceptionState))
+ return;
+ impl.setString(cppValue);
+ return;
+ }
+}
+
+v8::Local<v8::Value> ToV8(const NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord& impl, v8::Local<v8::Object> creationContext, v8::Isolate* isolate) {
+ switch (impl.m_type) {
+ case NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord::SpecificTypeNone:
+ return v8::Null(isolate);
+ case NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord::SpecificTypeEvent:
+ return ToV8(impl.getAsEvent(), creationContext, isolate);
+ case NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord::SpecificTypeLongSequence:
+ return ToV8(impl.getAsLongSequence(), creationContext, isolate);
+ case NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord::SpecificTypeNode:
+ return ToV8(impl.getAsNode(), creationContext, isolate);
+ case NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord::SpecificTypeString:
+ return v8String(isolate, impl.getAsString());
+ case NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord::SpecificTypeStringByteStringOrNodeListRecord:
+ return ToV8(impl.getAsStringByteStringOrNodeListRecord(), creationContext, isolate);
+ case NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord::SpecificTypeXMLHttpRequest:
+ return ToV8(impl.getAsXMLHttpRequest(), creationContext, isolate);
+ default:
+ NOTREACHED();
+ }
+ return v8::Local<v8::Value>();
+}
+
+NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord NativeValueTraits<NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord>::nativeValue(v8::Isolate* isolate, v8::Local<v8::Value> value, ExceptionState& exceptionState) {
+ NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord impl;
+ V8NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord::toImpl(isolate, value, impl, UnionTypeConversionMode::NotNullable, exceptionState);
+ return impl;
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698