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

Side by Side Diff: Source/bindings/tests/results/core/TestEnumOrDouble.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 "TestEnumOrDouble.h"
9
10
11 namespace blink {
12
13 TestEnumOrDouble::TestEnumOrDouble()
14 : m_type(SpecificTypeNone)
15 {
16 }
17
18 String TestEnumOrDouble::getAsTestEnum() const
19 {
20 ASSERT(isTestEnum());
21 return m_testEnum;
22 }
23
24 void TestEnumOrDouble::setTestEnum(String value)
25 {
26 ASSERT(isNull());
27 String string = value;
28 if (!(string == "" || string == "EnumValue1" || string == "EnumValue2" || st ring == "EnumValue3")) {
29 ASSERT_NOT_REACHED();
30 return;
31 }
32 m_testEnum = value;
33 m_type = SpecificTypeTestEnum;
34 }
35
36 TestEnumOrDouble TestEnumOrDouble::fromTestEnum(String value)
37 {
38 TestEnumOrDouble container;
39 container.setTestEnum(value);
40 return container;
41 }
42
43 double TestEnumOrDouble::getAsDouble() const
44 {
45 ASSERT(isDouble());
46 return m_double;
47 }
48
49 void TestEnumOrDouble::setDouble(double value)
50 {
51 ASSERT(isNull());
52 m_double = value;
53 m_type = SpecificTypeDouble;
54 }
55
56 TestEnumOrDouble TestEnumOrDouble::fromDouble(double value)
57 {
58 TestEnumOrDouble container;
59 container.setDouble(value);
60 return container;
61 }
62
63 void V8TestEnumOrDouble::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Val ue, TestEnumOrDouble& impl, ExceptionState& exceptionState)
64 {
65 if (v8Value.IsEmpty())
66 return;
67
68 if (v8Value->IsNumber()) {
69 TONATIVE_VOID_EXCEPTIONSTATE(double, cppValue, toRestrictedDouble(v8Valu e, exceptionState), exceptionState);
70 impl.setDouble(cppValue);
71 return;
72 }
73
74 {
75 TOSTRING_VOID_EXCEPTIONSTATE(V8StringResource<>, cppValue, v8Value, exce ptionState);
76 String string = cppValue;
77 if (!(string == "" || string == "EnumValue1" || string == "EnumValue2" | | string == "EnumValue3")) {
78 exceptionState.throwTypeError("'" + string + "' is not a valid enum value.");
79 return;
80 }
81 impl.setTestEnum(cppValue);
82 return;
83 }
84
85 }
86
87 v8::Local<v8::Value> toV8(const TestEnumOrDouble& impl, v8::Local<v8::Object> cr eationContext, v8::Isolate* isolate)
88 {
89 switch (impl.m_type) {
90 case TestEnumOrDouble::SpecificTypeNone:
91 return v8::Null(isolate);
92 case TestEnumOrDouble::SpecificTypeTestEnum:
93 return v8String(isolate, impl.getAsTestEnum());
94 case TestEnumOrDouble::SpecificTypeDouble:
95 return v8::Number::New(isolate, impl.getAsDouble());
96 default:
97 ASSERT_NOT_REACHED();
98 }
99 return v8::Local<v8::Value>();
100 }
101
102 TestEnumOrDouble NativeValueTraits<TestEnumOrDouble>::nativeValue(const v8::Loca l<v8::Value>& value, v8::Isolate* isolate, ExceptionState& exceptionState)
103 {
104 TestEnumOrDouble impl;
105 V8TestEnumOrDouble::toImpl(isolate, value, impl, exceptionState);
106 return impl;
107 }
108
109 } // namespace blink
OLDNEW
« no previous file with comments | « Source/bindings/tests/results/core/TestEnumOrDouble.h ('k') | Source/bindings/tests/results/core/TestInterface2OrUint8Array.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698