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

Side by Side Diff: third_party/WebKit/Source/bindings/tests/results/core/UnrestrictedDoubleOrString.cpp

Issue 1961883002: Generate separate files for union type containers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // This file has been auto-generated by code_generator_v8.py. DO NOT MODIFY!
6
7 #include "UnrestrictedDoubleOrString.h"
8
9 #include "bindings/core/v8/ToV8.h"
10
11 namespace blink {
12
13 UnrestrictedDoubleOrString::UnrestrictedDoubleOrString()
14 : m_type(SpecificTypeNone)
15 {
16 }
17
18 double UnrestrictedDoubleOrString::getAsUnrestrictedDouble() const
19 {
20 ASSERT(isUnrestrictedDouble());
21 return m_unrestrictedDouble;
22 }
23
24 void UnrestrictedDoubleOrString::setUnrestrictedDouble(double value)
25 {
26 ASSERT(isNull());
27 m_unrestrictedDouble = value;
28 m_type = SpecificTypeUnrestrictedDouble;
29 }
30
31 UnrestrictedDoubleOrString UnrestrictedDoubleOrString::fromUnrestrictedDouble(do uble value)
32 {
33 UnrestrictedDoubleOrString container;
34 container.setUnrestrictedDouble(value);
35 return container;
36 }
37
38 String UnrestrictedDoubleOrString::getAsString() const
39 {
40 ASSERT(isString());
41 return m_string;
42 }
43
44 void UnrestrictedDoubleOrString::setString(String value)
45 {
46 ASSERT(isNull());
47 m_string = value;
48 m_type = SpecificTypeString;
49 }
50
51 UnrestrictedDoubleOrString UnrestrictedDoubleOrString::fromString(String value)
52 {
53 UnrestrictedDoubleOrString container;
54 container.setString(value);
55 return container;
56 }
57
58 UnrestrictedDoubleOrString::UnrestrictedDoubleOrString(const UnrestrictedDoubleO rString&) = default;
59 UnrestrictedDoubleOrString::~UnrestrictedDoubleOrString() = default;
60 UnrestrictedDoubleOrString& UnrestrictedDoubleOrString::operator=(const Unrestri ctedDoubleOrString&) = default;
61
62 DEFINE_TRACE(UnrestrictedDoubleOrString)
63 {
64 }
65
66 void V8UnrestrictedDoubleOrString::toImpl(v8::Isolate* isolate, v8::Local<v8::Va lue> v8Value, UnrestrictedDoubleOrString& impl, UnionTypeConversionMode conversi onMode, ExceptionState& exceptionState)
67 {
68 if (v8Value.IsEmpty())
69 return;
70
71 if (conversionMode == UnionTypeConversionMode::Nullable && isUndefinedOrNull (v8Value))
72 return;
73
74 if (v8Value->IsNumber()) {
75 double cppValue = toDouble(isolate, v8Value, exceptionState);
76 if (exceptionState.hadException())
77 return;
78 impl.setUnrestrictedDouble(cppValue);
79 return;
80 }
81
82 {
83 V8StringResource<> cppValue = v8Value;
84 if (!cppValue.prepare(exceptionState))
85 return;
86 impl.setString(cppValue);
87 return;
88 }
89
90 }
91
92 v8::Local<v8::Value> toV8(const UnrestrictedDoubleOrString& impl, v8::Local<v8:: Object> creationContext, v8::Isolate* isolate)
93 {
94 switch (impl.m_type) {
95 case UnrestrictedDoubleOrString::SpecificTypeNone:
96 return v8::Null(isolate);
97 case UnrestrictedDoubleOrString::SpecificTypeUnrestrictedDouble:
98 return v8::Number::New(isolate, impl.getAsUnrestrictedDouble());
99 case UnrestrictedDoubleOrString::SpecificTypeString:
100 return v8String(isolate, impl.getAsString());
101 default:
102 ASSERT_NOT_REACHED();
103 }
104 return v8::Local<v8::Value>();
105 }
106
107 UnrestrictedDoubleOrString NativeValueTraits<UnrestrictedDoubleOrString>::native Value(v8::Isolate* isolate, v8::Local<v8::Value> value, ExceptionState& exceptio nState)
108 {
109 UnrestrictedDoubleOrString impl;
110 V8UnrestrictedDoubleOrString::toImpl(isolate, value, impl, UnionTypeConversi onMode::NotNullable, exceptionState);
111 return impl;
112 }
113
114 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698