OLD | NEW |
(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 "BooleanOrStringOrUnrestrictedDouble.h" |
| 9 |
| 10 |
| 11 namespace blink { |
| 12 |
| 13 BooleanOrStringOrUnrestrictedDouble::BooleanOrStringOrUnrestrictedDouble() |
| 14 : m_type(SpecificTypeNone) |
| 15 { |
| 16 } |
| 17 |
| 18 bool BooleanOrStringOrUnrestrictedDouble::getAsBoolean() const |
| 19 { |
| 20 ASSERT(isBoolean()); |
| 21 return m_boolean; |
| 22 } |
| 23 |
| 24 void BooleanOrStringOrUnrestrictedDouble::setBoolean(bool value) |
| 25 { |
| 26 ASSERT(isNull()); |
| 27 m_boolean = value; |
| 28 m_type = SpecificTypeBoolean; |
| 29 } |
| 30 |
| 31 BooleanOrStringOrUnrestrictedDouble BooleanOrStringOrUnrestrictedDouble::fromBoo
lean(bool value) |
| 32 { |
| 33 BooleanOrStringOrUnrestrictedDouble container; |
| 34 container.setBoolean(value); |
| 35 return container; |
| 36 } |
| 37 |
| 38 String BooleanOrStringOrUnrestrictedDouble::getAsString() const |
| 39 { |
| 40 ASSERT(isString()); |
| 41 return m_string; |
| 42 } |
| 43 |
| 44 void BooleanOrStringOrUnrestrictedDouble::setString(String value) |
| 45 { |
| 46 ASSERT(isNull()); |
| 47 m_string = value; |
| 48 m_type = SpecificTypeString; |
| 49 } |
| 50 |
| 51 BooleanOrStringOrUnrestrictedDouble BooleanOrStringOrUnrestrictedDouble::fromStr
ing(String value) |
| 52 { |
| 53 BooleanOrStringOrUnrestrictedDouble container; |
| 54 container.setString(value); |
| 55 return container; |
| 56 } |
| 57 |
| 58 double BooleanOrStringOrUnrestrictedDouble::getAsUnrestrictedDouble() const |
| 59 { |
| 60 ASSERT(isUnrestrictedDouble()); |
| 61 return m_unrestrictedDouble; |
| 62 } |
| 63 |
| 64 void BooleanOrStringOrUnrestrictedDouble::setUnrestrictedDouble(double value) |
| 65 { |
| 66 ASSERT(isNull()); |
| 67 m_unrestrictedDouble = value; |
| 68 m_type = SpecificTypeUnrestrictedDouble; |
| 69 } |
| 70 |
| 71 BooleanOrStringOrUnrestrictedDouble BooleanOrStringOrUnrestrictedDouble::fromUnr
estrictedDouble(double value) |
| 72 { |
| 73 BooleanOrStringOrUnrestrictedDouble container; |
| 74 container.setUnrestrictedDouble(value); |
| 75 return container; |
| 76 } |
| 77 |
| 78 void V8BooleanOrStringOrUnrestrictedDouble::toImpl(v8::Isolate* isolate, v8::Loc
al<v8::Value> v8Value, BooleanOrStringOrUnrestrictedDouble& impl, ExceptionState
& exceptionState) |
| 79 { |
| 80 if (v8Value.IsEmpty()) |
| 81 return; |
| 82 |
| 83 if (v8Value->IsBoolean()) { |
| 84 impl.setBoolean(v8Value->ToBoolean()->Value()); |
| 85 return; |
| 86 } |
| 87 |
| 88 if (v8Value->IsNumber()) { |
| 89 TONATIVE_VOID_EXCEPTIONSTATE(double, cppValue, toDouble(v8Value, excepti
onState), exceptionState); |
| 90 impl.setUnrestrictedDouble(cppValue); |
| 91 return; |
| 92 } |
| 93 |
| 94 { |
| 95 TOSTRING_VOID_EXCEPTIONSTATE(V8StringResource<>, cppValue, v8Value, exce
ptionState); |
| 96 impl.setString(cppValue); |
| 97 return; |
| 98 } |
| 99 |
| 100 } |
| 101 |
| 102 v8::Local<v8::Value> toV8(const BooleanOrStringOrUnrestrictedDouble& impl, v8::L
ocal<v8::Object> creationContext, v8::Isolate* isolate) |
| 103 { |
| 104 switch (impl.m_type) { |
| 105 case BooleanOrStringOrUnrestrictedDouble::SpecificTypeNone: |
| 106 return v8::Null(isolate); |
| 107 case BooleanOrStringOrUnrestrictedDouble::SpecificTypeBoolean: |
| 108 return v8Boolean(impl.getAsBoolean(), isolate); |
| 109 case BooleanOrStringOrUnrestrictedDouble::SpecificTypeString: |
| 110 return v8String(isolate, impl.getAsString()); |
| 111 case BooleanOrStringOrUnrestrictedDouble::SpecificTypeUnrestrictedDouble: |
| 112 return v8::Number::New(isolate, impl.getAsUnrestrictedDouble()); |
| 113 default: |
| 114 ASSERT_NOT_REACHED(); |
| 115 } |
| 116 return v8::Local<v8::Value>(); |
| 117 } |
| 118 |
| 119 BooleanOrStringOrUnrestrictedDouble NativeValueTraits<BooleanOrStringOrUnrestric
tedDouble>::nativeValue(const v8::Local<v8::Value>& value, v8::Isolate* isolate,
ExceptionState& exceptionState) |
| 120 { |
| 121 BooleanOrStringOrUnrestrictedDouble impl; |
| 122 V8BooleanOrStringOrUnrestrictedDouble::toImpl(isolate, value, impl, exceptio
nState); |
| 123 return impl; |
| 124 } |
| 125 |
| 126 } // namespace blink |
OLD | NEW |