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 "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 |
OLD | NEW |