OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // This file has been auto-generated by code_generator_v8.py. DO NOT MODIFY! | 5 // This file has been auto-generated by code_generator_v8.py. DO NOT MODIFY! |
6 | 6 |
7 #include "config.h" | 7 #include "bindings/modules/v8/BooleanOrString.cpp" |
8 #include "bindings/modules/v8/UnionTypesModules.h" | |
9 | |
10 | |
11 namespace blink { | |
12 | |
13 BooleanOrString::BooleanOrString() | |
14 : m_type(SpecificTypeNone) | |
15 { | |
16 } | |
17 | |
18 bool BooleanOrString::getAsBoolean() const | |
19 { | |
20 ASSERT(isBoolean()); | |
21 return m_boolean; | |
22 } | |
23 | |
24 void BooleanOrString::setBoolean(bool value) | |
25 { | |
26 ASSERT(isNull()); | |
27 m_boolean = value; | |
28 m_type = SpecificTypeBoolean; | |
29 } | |
30 | |
31 BooleanOrString BooleanOrString::fromBoolean(bool value) | |
32 { | |
33 BooleanOrString container; | |
34 container.setBoolean(value); | |
35 return container; | |
36 } | |
37 | |
38 String BooleanOrString::getAsString() const | |
39 { | |
40 ASSERT(isString()); | |
41 return m_string; | |
42 } | |
43 | |
44 void BooleanOrString::setString(String value) | |
45 { | |
46 ASSERT(isNull()); | |
47 m_string = value; | |
48 m_type = SpecificTypeString; | |
49 } | |
50 | |
51 BooleanOrString BooleanOrString::fromString(String value) | |
52 { | |
53 BooleanOrString container; | |
54 container.setString(value); | |
55 return container; | |
56 } | |
57 | |
58 void V8BooleanOrString::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Valu
e, BooleanOrString& impl, ExceptionState& exceptionState) | |
59 { | |
60 if (v8Value.IsEmpty()) | |
61 return; | |
62 | |
63 if (v8Value->IsBoolean()) { | |
64 impl.setBoolean(v8Value->ToBoolean()->Value()); | |
65 return; | |
66 } | |
67 | |
68 { | |
69 TOSTRING_VOID_EXCEPTIONSTATE(V8StringResource<>, cppValue, v8Value, exce
ptionState); | |
70 impl.setString(cppValue); | |
71 return; | |
72 } | |
73 | |
74 } | |
75 | |
76 v8::Local<v8::Value> toV8(const BooleanOrString& impl, v8::Local<v8::Object> cre
ationContext, v8::Isolate* isolate) | |
77 { | |
78 switch (impl.m_type) { | |
79 case BooleanOrString::SpecificTypeNone: | |
80 return v8::Null(isolate); | |
81 case BooleanOrString::SpecificTypeBoolean: | |
82 return v8Boolean(impl.getAsBoolean(), isolate); | |
83 case BooleanOrString::SpecificTypeString: | |
84 return v8String(isolate, impl.getAsString()); | |
85 default: | |
86 ASSERT_NOT_REACHED(); | |
87 } | |
88 return v8::Local<v8::Value>(); | |
89 } | |
90 | |
91 BooleanOrString NativeValueTraits<BooleanOrString>::nativeValue(const v8::Local<
v8::Value>& value, v8::Isolate* isolate, ExceptionState& exceptionState) | |
92 { | |
93 BooleanOrString impl; | |
94 V8BooleanOrString::toImpl(isolate, value, impl, exceptionState); | |
95 return impl; | |
96 } | |
97 | |
98 } // namespace blink | |
OLD | NEW |