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

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

Issue 953123003: IDL: Put generated union type containers in separate files (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2015 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 "config.h"
8 #include "UnrestrictedDoubleOrString.h"
9
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 void V8UnrestrictedDoubleOrString::toImpl(v8::Isolate* isolate, v8::Local<v8::Va lue> v8Value, UnrestrictedDoubleOrString& impl, ExceptionState& exceptionState)
59 {
60 if (v8Value.IsEmpty())
61 return;
62
63 if (v8Value->IsNumber()) {
64 TONATIVE_VOID_EXCEPTIONSTATE(double, cppValue, toDouble(v8Value, excepti onState), exceptionState);
65 impl.setUnrestrictedDouble(cppValue);
66 return;
67 }
68
69 {
70 TOSTRING_VOID_EXCEPTIONSTATE(V8StringResource<>, cppValue, v8Value, exce ptionState);
71 impl.setString(cppValue);
72 return;
73 }
74
75 }
76
77 v8::Local<v8::Value> toV8(const UnrestrictedDoubleOrString& impl, v8::Local<v8:: Object> creationContext, v8::Isolate* isolate)
78 {
79 switch (impl.m_type) {
80 case UnrestrictedDoubleOrString::SpecificTypeNone:
81 return v8::Null(isolate);
82 case UnrestrictedDoubleOrString::SpecificTypeUnrestrictedDouble:
83 return v8::Number::New(isolate, impl.getAsUnrestrictedDouble());
84 case UnrestrictedDoubleOrString::SpecificTypeString:
85 return v8String(isolate, impl.getAsString());
86 default:
87 ASSERT_NOT_REACHED();
88 }
89 return v8::Local<v8::Value>();
90 }
91
92 UnrestrictedDoubleOrString NativeValueTraits<UnrestrictedDoubleOrString>::native Value(const v8::Local<v8::Value>& value, v8::Isolate* isolate, ExceptionState& e xceptionState)
93 {
94 UnrestrictedDoubleOrString impl;
95 V8UnrestrictedDoubleOrString::toImpl(isolate, value, impl, exceptionState);
96 return impl;
97 }
98
99 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698