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

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

Issue 2749253002: bindings: Expand typedefs before generating union files. (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/FloatOrBoolean.cpp
diff --git a/third_party/WebKit/Source/bindings/tests/results/core/FloatOrBoolean.cpp b/third_party/WebKit/Source/bindings/tests/results/core/FloatOrBoolean.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b42f06f7464d189c17dc07f73aca92a901d7a0f3
--- /dev/null
+++ b/third_party/WebKit/Source/bindings/tests/results/core/FloatOrBoolean.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 "FloatOrBoolean.h"
+
+#include "bindings/core/v8/IDLTypes.h"
+#include "bindings/core/v8/NativeValueTraitsImpl.h"
+#include "bindings/core/v8/ToV8.h"
+
+namespace blink {
+
+FloatOrBoolean::FloatOrBoolean() : m_type(SpecificTypeNone) {}
+
+bool FloatOrBoolean::getAsBoolean() const {
+ DCHECK(isBoolean());
+ return m_boolean;
+}
+
+void FloatOrBoolean::setBoolean(bool value) {
+ DCHECK(isNull());
+ m_boolean = value;
+ m_type = SpecificTypeBoolean;
+}
+
+FloatOrBoolean FloatOrBoolean::fromBoolean(bool value) {
+ FloatOrBoolean container;
+ container.setBoolean(value);
+ return container;
+}
+
+float FloatOrBoolean::getAsFloat() const {
+ DCHECK(isFloat());
+ return m_float;
+}
+
+void FloatOrBoolean::setFloat(float value) {
+ DCHECK(isNull());
+ m_float = value;
+ m_type = SpecificTypeFloat;
+}
+
+FloatOrBoolean FloatOrBoolean::fromFloat(float value) {
+ FloatOrBoolean container;
+ container.setFloat(value);
+ return container;
+}
+
+FloatOrBoolean::FloatOrBoolean(const FloatOrBoolean&) = default;
+FloatOrBoolean::~FloatOrBoolean() = default;
+FloatOrBoolean& FloatOrBoolean::operator=(const FloatOrBoolean&) = default;
+
+DEFINE_TRACE(FloatOrBoolean) {
+}
+
+void V8FloatOrBoolean::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, FloatOrBoolean& 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()) {
+ float cppValue = NativeValueTraits<IDLFloat>::nativeValue(isolate, v8Value, exceptionState);
+ if (exceptionState.hadException())
+ return;
+ impl.setFloat(cppValue);
+ return;
+ }
+
+ {
+ float cppValue = NativeValueTraits<IDLFloat>::nativeValue(isolate, v8Value, exceptionState);
+ if (exceptionState.hadException())
+ return;
+ impl.setFloat(cppValue);
+ return;
+ }
+}
+
+v8::Local<v8::Value> ToV8(const FloatOrBoolean& impl, v8::Local<v8::Object> creationContext, v8::Isolate* isolate) {
+ switch (impl.m_type) {
+ case FloatOrBoolean::SpecificTypeNone:
+ return v8::Null(isolate);
+ case FloatOrBoolean::SpecificTypeBoolean:
+ return v8Boolean(impl.getAsBoolean(), isolate);
+ case FloatOrBoolean::SpecificTypeFloat:
+ return v8::Number::New(isolate, impl.getAsFloat());
+ default:
+ NOTREACHED();
+ }
+ return v8::Local<v8::Value>();
+}
+
+FloatOrBoolean NativeValueTraits<FloatOrBoolean>::nativeValue(v8::Isolate* isolate, v8::Local<v8::Value> value, ExceptionState& exceptionState) {
+ FloatOrBoolean impl;
+ V8FloatOrBoolean::toImpl(isolate, value, impl, UnionTypeConversionMode::NotNullable, exceptionState);
+ return impl;
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698