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

Unified Diff: third_party/WebKit/Source/bindings/tests/results/core/XMLHttpRequestOrString.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
« no previous file with comments | « third_party/WebKit/Source/bindings/tests/results/core/XMLHttpRequestOrString.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/bindings/tests/results/core/XMLHttpRequestOrString.cpp
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/XMLHttpRequestOrString.cpp b/third_party/WebKit/Source/bindings/tests/results/core/XMLHttpRequestOrString.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..cb4aa5f4d0cf512a283f91cbafc812408c80e0f2
--- /dev/null
+++ b/third_party/WebKit/Source/bindings/tests/results/core/XMLHttpRequestOrString.cpp
@@ -0,0 +1,108 @@
+// 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 "XMLHttpRequestOrString.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/V8XMLHttpRequest.h"
+
+namespace blink {
+
+XMLHttpRequestOrString::XMLHttpRequestOrString() : m_type(SpecificTypeNone) {}
+
+String XMLHttpRequestOrString::getAsString() const {
+ DCHECK(isString());
+ return m_string;
+}
+
+void XMLHttpRequestOrString::setString(String value) {
+ DCHECK(isNull());
+ m_string = value;
+ m_type = SpecificTypeString;
+}
+
+XMLHttpRequestOrString XMLHttpRequestOrString::fromString(String value) {
+ XMLHttpRequestOrString container;
+ container.setString(value);
+ return container;
+}
+
+XMLHttpRequest* XMLHttpRequestOrString::getAsXMLHttpRequest() const {
+ DCHECK(isXMLHttpRequest());
+ return m_xmlHttpRequest;
+}
+
+void XMLHttpRequestOrString::setXMLHttpRequest(XMLHttpRequest* value) {
+ DCHECK(isNull());
+ m_xmlHttpRequest = value;
+ m_type = SpecificTypeXMLHttpRequest;
+}
+
+XMLHttpRequestOrString XMLHttpRequestOrString::fromXMLHttpRequest(XMLHttpRequest* value) {
+ XMLHttpRequestOrString container;
+ container.setXMLHttpRequest(value);
+ return container;
+}
+
+XMLHttpRequestOrString::XMLHttpRequestOrString(const XMLHttpRequestOrString&) = default;
+XMLHttpRequestOrString::~XMLHttpRequestOrString() = default;
+XMLHttpRequestOrString& XMLHttpRequestOrString::operator=(const XMLHttpRequestOrString&) = default;
+
+DEFINE_TRACE(XMLHttpRequestOrString) {
+ visitor->trace(m_xmlHttpRequest);
+}
+
+void V8XMLHttpRequestOrString::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, XMLHttpRequestOrString& impl, UnionTypeConversionMode conversionMode, ExceptionState& exceptionState) {
+ if (v8Value.IsEmpty())
+ return;
+
+ if (conversionMode == UnionTypeConversionMode::Nullable && isUndefinedOrNull(v8Value))
+ return;
+
+ if (V8XMLHttpRequest::hasInstance(v8Value, isolate)) {
+ XMLHttpRequest* cppValue = V8XMLHttpRequest::toImpl(v8::Local<v8::Object>::Cast(v8Value));
+ impl.setXMLHttpRequest(cppValue);
+ return;
+ }
+
+ {
+ V8StringResource<> cppValue = v8Value;
+ if (!cppValue.prepare(exceptionState))
+ return;
+ impl.setString(cppValue);
+ return;
+ }
+}
+
+v8::Local<v8::Value> ToV8(const XMLHttpRequestOrString& impl, v8::Local<v8::Object> creationContext, v8::Isolate* isolate) {
+ switch (impl.m_type) {
+ case XMLHttpRequestOrString::SpecificTypeNone:
+ return v8::Null(isolate);
+ case XMLHttpRequestOrString::SpecificTypeString:
+ return v8String(isolate, impl.getAsString());
+ case XMLHttpRequestOrString::SpecificTypeXMLHttpRequest:
+ return ToV8(impl.getAsXMLHttpRequest(), creationContext, isolate);
+ default:
+ NOTREACHED();
+ }
+ return v8::Local<v8::Value>();
+}
+
+XMLHttpRequestOrString NativeValueTraits<XMLHttpRequestOrString>::nativeValue(v8::Isolate* isolate, v8::Local<v8::Value> value, ExceptionState& exceptionState) {
+ XMLHttpRequestOrString impl;
+ V8XMLHttpRequestOrString::toImpl(isolate, value, impl, UnionTypeConversionMode::NotNullable, exceptionState);
+ return impl;
+}
+
+} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/bindings/tests/results/core/XMLHttpRequestOrString.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698