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

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

Issue 2750003003: bindings: Correctly expand all class/header dependencies in unions. (Closed)
Patch Set: 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/LongOrBoolean.cpp
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/LongOrBoolean.cpp b/third_party/WebKit/Source/bindings/tests/results/core/LongOrBoolean.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..efcfd087ed7124a15da6f9dd9a2c8647ffe4d5ca
--- /dev/null
+++ b/third_party/WebKit/Source/bindings/tests/results/core/LongOrBoolean.cpp
@@ -0,0 +1,112 @@
+// 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 "LongOrBoolean.h"
+
+#include "bindings/core/v8/IDLTypes.h"
+#include "bindings/core/v8/NativeValueTraitsImpl.h"
+#include "bindings/core/v8/ToV8.h"
+
+namespace blink {
+
+LongOrBoolean::LongOrBoolean() : m_type(SpecificTypeNone) {}
+
+bool LongOrBoolean::getAsBoolean() const {
+ DCHECK(isBoolean());
+ return m_boolean;
+}
+
+void LongOrBoolean::setBoolean(bool value) {
+ DCHECK(isNull());
+ m_boolean = value;
+ m_type = SpecificTypeBoolean;
+}
+
+LongOrBoolean LongOrBoolean::fromBoolean(bool value) {
+ LongOrBoolean container;
+ container.setBoolean(value);
+ return container;
+}
+
+int32_t LongOrBoolean::getAsLong() const {
+ DCHECK(isLong());
+ return m_long;
+}
+
+void LongOrBoolean::setLong(int32_t value) {
+ DCHECK(isNull());
+ m_long = value;
+ m_type = SpecificTypeLong;
+}
+
+LongOrBoolean LongOrBoolean::fromLong(int32_t value) {
+ LongOrBoolean container;
+ container.setLong(value);
+ return container;
+}
+
+LongOrBoolean::LongOrBoolean(const LongOrBoolean&) = default;
+LongOrBoolean::~LongOrBoolean() = default;
+LongOrBoolean& LongOrBoolean::operator=(const LongOrBoolean&) = default;
+
+DEFINE_TRACE(LongOrBoolean) {
+}
+
+void V8LongOrBoolean::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, LongOrBoolean& impl, UnionTypeConversionMode conversionMode, ExceptionState& exceptionState) {
+ if (v8Value.IsEmpty())
+ return;
+
+ if (conversionMode == UnionTypeConversionMode::Nullable && isUndefinedOrNull(v8Value))
+ return;
+
+ if (v8Value->IsBoolean()) {
+ impl.setBoolean(v8Value.As<v8::Boolean>()->Value());
+ return;
+ }
+
+ if (v8Value->IsNumber()) {
+ int32_t cppValue = NativeValueTraits<IDLLong>::nativeValue(isolate, v8Value, exceptionState, NormalConversion);
+ if (exceptionState.hadException())
+ return;
+ impl.setLong(cppValue);
+ return;
+ }
+
+ {
+ int32_t cppValue = NativeValueTraits<IDLLong>::nativeValue(isolate, v8Value, exceptionState, NormalConversion);
+ if (exceptionState.hadException())
+ return;
+ impl.setLong(cppValue);
+ return;
+ }
+}
+
+v8::Local<v8::Value> ToV8(const LongOrBoolean& impl, v8::Local<v8::Object> creationContext, v8::Isolate* isolate) {
+ switch (impl.m_type) {
+ case LongOrBoolean::SpecificTypeNone:
+ return v8::Null(isolate);
+ case LongOrBoolean::SpecificTypeBoolean:
+ return v8Boolean(impl.getAsBoolean(), isolate);
+ case LongOrBoolean::SpecificTypeLong:
+ return v8::Integer::New(isolate, impl.getAsLong());
+ default:
+ NOTREACHED();
+ }
+ return v8::Local<v8::Value>();
+}
+
+LongOrBoolean NativeValueTraits<LongOrBoolean>::nativeValue(v8::Isolate* isolate, v8::Local<v8::Value> value, ExceptionState& exceptionState) {
+ LongOrBoolean impl;
+ V8LongOrBoolean::toImpl(isolate, value, impl, UnionTypeConversionMode::NotNullable, exceptionState);
+ return impl;
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698