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 "TestInterfaceOrLong.h" |
| 9 |
| 10 |
| 11 namespace blink { |
| 12 |
| 13 TestInterfaceOrLong::TestInterfaceOrLong() |
| 14 : m_type(SpecificTypeNone) |
| 15 { |
| 16 } |
| 17 |
| 18 PassRefPtr<TestInterfaceImplementation> TestInterfaceOrLong::getAsTestInterface(
) const |
| 19 { |
| 20 ASSERT(isTestInterface()); |
| 21 return m_testInterface; |
| 22 } |
| 23 |
| 24 void TestInterfaceOrLong::setTestInterface(PassRefPtr<TestInterfaceImplementatio
n> value) |
| 25 { |
| 26 ASSERT(isNull()); |
| 27 m_testInterface = value; |
| 28 m_type = SpecificTypeTestInterface; |
| 29 } |
| 30 |
| 31 TestInterfaceOrLong TestInterfaceOrLong::fromTestInterface(PassRefPtr<TestInterf
aceImplementation> value) |
| 32 { |
| 33 TestInterfaceOrLong container; |
| 34 container.setTestInterface(value); |
| 35 return container; |
| 36 } |
| 37 |
| 38 int TestInterfaceOrLong::getAsLong() const |
| 39 { |
| 40 ASSERT(isLong()); |
| 41 return m_long; |
| 42 } |
| 43 |
| 44 void TestInterfaceOrLong::setLong(int value) |
| 45 { |
| 46 ASSERT(isNull()); |
| 47 m_long = value; |
| 48 m_type = SpecificTypeLong; |
| 49 } |
| 50 |
| 51 TestInterfaceOrLong TestInterfaceOrLong::fromLong(int value) |
| 52 { |
| 53 TestInterfaceOrLong container; |
| 54 container.setLong(value); |
| 55 return container; |
| 56 } |
| 57 |
| 58 void V8TestInterfaceOrLong::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8
Value, TestInterfaceOrLong& impl, ExceptionState& exceptionState) |
| 59 { |
| 60 if (v8Value.IsEmpty()) |
| 61 return; |
| 62 |
| 63 if (V8TestInterface::hasInstance(v8Value, isolate)) { |
| 64 RefPtr<TestInterfaceImplementation> cppValue = V8TestInterface::toImpl(v
8::Local<v8::Object>::Cast(v8Value)); |
| 65 impl.setTestInterface(cppValue); |
| 66 return; |
| 67 } |
| 68 |
| 69 if (v8Value->IsNumber()) { |
| 70 TONATIVE_VOID_EXCEPTIONSTATE(int, cppValue, toInt32(v8Value, exceptionSt
ate), exceptionState); |
| 71 impl.setLong(cppValue); |
| 72 return; |
| 73 } |
| 74 |
| 75 { |
| 76 TONATIVE_VOID_EXCEPTIONSTATE(int, cppValue, toInt32(v8Value, exceptionSt
ate), exceptionState); |
| 77 impl.setLong(cppValue); |
| 78 return; |
| 79 } |
| 80 |
| 81 } |
| 82 |
| 83 v8::Local<v8::Value> toV8(const TestInterfaceOrLong& impl, v8::Local<v8::Object>
creationContext, v8::Isolate* isolate) |
| 84 { |
| 85 switch (impl.m_type) { |
| 86 case TestInterfaceOrLong::SpecificTypeNone: |
| 87 return v8::Null(isolate); |
| 88 case TestInterfaceOrLong::SpecificTypeTestInterface: |
| 89 return toV8(impl.getAsTestInterface(), creationContext, isolate); |
| 90 case TestInterfaceOrLong::SpecificTypeLong: |
| 91 return v8::Integer::New(isolate, impl.getAsLong()); |
| 92 default: |
| 93 ASSERT_NOT_REACHED(); |
| 94 } |
| 95 return v8::Local<v8::Value>(); |
| 96 } |
| 97 |
| 98 TestInterfaceOrLong NativeValueTraits<TestInterfaceOrLong>::nativeValue(const v8
::Local<v8::Value>& value, v8::Isolate* isolate, ExceptionState& exceptionState) |
| 99 { |
| 100 TestInterfaceOrLong impl; |
| 101 V8TestInterfaceOrLong::toImpl(isolate, value, impl, exceptionState); |
| 102 return impl; |
| 103 } |
| 104 |
| 105 } // namespace blink |
OLD | NEW |