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 "TestInterfaceOrLong.h" |
| 8 |
| 9 #include "bindings/core/v8/ToV8.h" |
| 10 #include "bindings/core/v8/V8TestInterface.h" |
| 11 #include "bindings/tests/idls/core/TestImplements2.h" |
| 12 #include "bindings/tests/idls/core/TestImplements3Implementation.h" |
| 13 #include "bindings/tests/idls/core/TestPartialInterface.h" |
| 14 #include "bindings/tests/idls/core/TestPartialInterfaceImplementation.h" |
| 15 |
| 16 namespace blink { |
| 17 |
| 18 TestInterfaceOrLong::TestInterfaceOrLong() |
| 19 : m_type(SpecificTypeNone) |
| 20 { |
| 21 } |
| 22 |
| 23 TestInterfaceImplementation* TestInterfaceOrLong::getAsTestInterface() const |
| 24 { |
| 25 ASSERT(isTestInterface()); |
| 26 return m_testInterface; |
| 27 } |
| 28 |
| 29 void TestInterfaceOrLong::setTestInterface(TestInterfaceImplementation* value) |
| 30 { |
| 31 ASSERT(isNull()); |
| 32 m_testInterface = value; |
| 33 m_type = SpecificTypeTestInterface; |
| 34 } |
| 35 |
| 36 TestInterfaceOrLong TestInterfaceOrLong::fromTestInterface(TestInterfaceImplemen
tation* value) |
| 37 { |
| 38 TestInterfaceOrLong container; |
| 39 container.setTestInterface(value); |
| 40 return container; |
| 41 } |
| 42 |
| 43 int TestInterfaceOrLong::getAsLong() const |
| 44 { |
| 45 ASSERT(isLong()); |
| 46 return m_long; |
| 47 } |
| 48 |
| 49 void TestInterfaceOrLong::setLong(int value) |
| 50 { |
| 51 ASSERT(isNull()); |
| 52 m_long = value; |
| 53 m_type = SpecificTypeLong; |
| 54 } |
| 55 |
| 56 TestInterfaceOrLong TestInterfaceOrLong::fromLong(int value) |
| 57 { |
| 58 TestInterfaceOrLong container; |
| 59 container.setLong(value); |
| 60 return container; |
| 61 } |
| 62 |
| 63 TestInterfaceOrLong::TestInterfaceOrLong(const TestInterfaceOrLong&) = default; |
| 64 TestInterfaceOrLong::~TestInterfaceOrLong() = default; |
| 65 TestInterfaceOrLong& TestInterfaceOrLong::operator=(const TestInterfaceOrLong&)
= default; |
| 66 |
| 67 DEFINE_TRACE(TestInterfaceOrLong) |
| 68 { |
| 69 visitor->trace(m_testInterface); |
| 70 } |
| 71 |
| 72 void V8TestInterfaceOrLong::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8
Value, TestInterfaceOrLong& impl, UnionTypeConversionMode conversionMode, Except
ionState& exceptionState) |
| 73 { |
| 74 if (v8Value.IsEmpty()) |
| 75 return; |
| 76 |
| 77 if (conversionMode == UnionTypeConversionMode::Nullable && isUndefinedOrNull
(v8Value)) |
| 78 return; |
| 79 |
| 80 if (V8TestInterface::hasInstance(v8Value, isolate)) { |
| 81 TestInterfaceImplementation* cppValue = V8TestInterface::toImpl(v8::Loca
l<v8::Object>::Cast(v8Value)); |
| 82 impl.setTestInterface(cppValue); |
| 83 return; |
| 84 } |
| 85 |
| 86 if (v8Value->IsNumber()) { |
| 87 int cppValue = toInt32(isolate, v8Value, NormalConversion, exceptionStat
e); |
| 88 if (exceptionState.hadException()) |
| 89 return; |
| 90 impl.setLong(cppValue); |
| 91 return; |
| 92 } |
| 93 |
| 94 { |
| 95 int cppValue = toInt32(isolate, v8Value, NormalConversion, exceptionStat
e); |
| 96 if (exceptionState.hadException()) |
| 97 return; |
| 98 impl.setLong(cppValue); |
| 99 return; |
| 100 } |
| 101 |
| 102 } |
| 103 |
| 104 v8::Local<v8::Value> toV8(const TestInterfaceOrLong& impl, v8::Local<v8::Object>
creationContext, v8::Isolate* isolate) |
| 105 { |
| 106 switch (impl.m_type) { |
| 107 case TestInterfaceOrLong::SpecificTypeNone: |
| 108 return v8::Null(isolate); |
| 109 case TestInterfaceOrLong::SpecificTypeTestInterface: |
| 110 return toV8(impl.getAsTestInterface(), creationContext, isolate); |
| 111 case TestInterfaceOrLong::SpecificTypeLong: |
| 112 return v8::Integer::New(isolate, impl.getAsLong()); |
| 113 default: |
| 114 ASSERT_NOT_REACHED(); |
| 115 } |
| 116 return v8::Local<v8::Value>(); |
| 117 } |
| 118 |
| 119 TestInterfaceOrLong NativeValueTraits<TestInterfaceOrLong>::nativeValue(v8::Isol
ate* isolate, v8::Local<v8::Value> value, ExceptionState& exceptionState) |
| 120 { |
| 121 TestInterfaceOrLong impl; |
| 122 V8TestInterfaceOrLong::toImpl(isolate, value, impl, UnionTypeConversionMode:
:NotNullable, exceptionState); |
| 123 return impl; |
| 124 } |
| 125 |
| 126 } // namespace blink |
OLD | NEW |