OLD | NEW |
| (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 "BooleanOrString.h" | |
8 | |
9 #include "bindings/core/v8/ToV8.h" | |
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 BooleanOrString::BooleanOrString(const BooleanOrString&) = default; | |
59 BooleanOrString::~BooleanOrString() = default; | |
60 BooleanOrString& BooleanOrString::operator=(const BooleanOrString&) = default; | |
61 | |
62 DEFINE_TRACE(BooleanOrString) | |
63 { | |
64 } | |
65 | |
66 void V8BooleanOrString::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Valu
e, BooleanOrString& impl, UnionTypeConversionMode conversionMode, ExceptionState
& exceptionState) | |
67 { | |
68 if (v8Value.IsEmpty()) | |
69 return; | |
70 | |
71 if (conversionMode == UnionTypeConversionMode::Nullable && isUndefinedOrNull
(v8Value)) | |
72 return; | |
73 | |
74 if (v8Value->IsBoolean()) { | |
75 impl.setBoolean(v8Value.As<v8::Boolean>()->Value()); | |
76 return; | |
77 } | |
78 | |
79 { | |
80 V8StringResource<> cppValue = v8Value; | |
81 if (!cppValue.prepare(exceptionState)) | |
82 return; | |
83 impl.setString(cppValue); | |
84 return; | |
85 } | |
86 | |
87 } | |
88 | |
89 v8::Local<v8::Value> toV8(const BooleanOrString& impl, v8::Local<v8::Object> cre
ationContext, v8::Isolate* isolate) | |
90 { | |
91 switch (impl.m_type) { | |
92 case BooleanOrString::SpecificTypeNone: | |
93 return v8::Null(isolate); | |
94 case BooleanOrString::SpecificTypeBoolean: | |
95 return v8Boolean(impl.getAsBoolean(), isolate); | |
96 case BooleanOrString::SpecificTypeString: | |
97 return v8String(isolate, impl.getAsString()); | |
98 default: | |
99 ASSERT_NOT_REACHED(); | |
100 } | |
101 return v8::Local<v8::Value>(); | |
102 } | |
103 | |
104 BooleanOrString NativeValueTraits<BooleanOrString>::nativeValue(v8::Isolate* iso
late, v8::Local<v8::Value> value, ExceptionState& exceptionState) | |
105 { | |
106 BooleanOrString impl; | |
107 V8BooleanOrString::toImpl(isolate, value, impl, UnionTypeConversionMode::Not
Nullable, exceptionState); | |
108 return impl; | |
109 } | |
110 | |
111 } // namespace blink | |
OLD | NEW |