| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // This file has been auto-generated by code_generator_v8.py. | 5 // This file has been auto-generated by code_generator_v8.py. |
| 6 // DO NOT MODIFY! | 6 // DO NOT MODIFY! |
| 7 | 7 |
| 8 // This file has been generated from the Jinja2 template in | 8 // This file has been generated from the Jinja2 template in |
| 9 // third_party/WebKit/Source/bindings/templates/union_container.cpp.tmpl | 9 // third_party/WebKit/Source/bindings/templates/union_container.cpp.tmpl |
| 10 | 10 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 m_testInterface2 = value; | 28 m_testInterface2 = value; |
| 29 m_type = SpecificTypeTestInterface2; | 29 m_type = SpecificTypeTestInterface2; |
| 30 } | 30 } |
| 31 | 31 |
| 32 TestInterface2OrUint8Array TestInterface2OrUint8Array::fromTestInterface2(TestIn
terface2* value) { | 32 TestInterface2OrUint8Array TestInterface2OrUint8Array::fromTestInterface2(TestIn
terface2* value) { |
| 33 TestInterface2OrUint8Array container; | 33 TestInterface2OrUint8Array container; |
| 34 container.setTestInterface2(value); | 34 container.setTestInterface2(value); |
| 35 return container; | 35 return container; |
| 36 } | 36 } |
| 37 | 37 |
| 38 DOMUint8Array* TestInterface2OrUint8Array::getAsUint8Array() const { | 38 NotShared<DOMUint8Array> TestInterface2OrUint8Array::getAsUint8Array() const { |
| 39 DCHECK(isUint8Array()); | 39 DCHECK(isUint8Array()); |
| 40 return m_uint8Array; | 40 return m_uint8Array; |
| 41 } | 41 } |
| 42 | 42 |
| 43 void TestInterface2OrUint8Array::setUint8Array(DOMUint8Array* value) { | 43 void TestInterface2OrUint8Array::setUint8Array(NotShared<DOMUint8Array> value) { |
| 44 DCHECK(isNull()); | 44 DCHECK(isNull()); |
| 45 m_uint8Array = value; | 45 m_uint8Array = Member<DOMUint8Array>(value.View()); |
| 46 m_type = SpecificTypeUint8Array; | 46 m_type = SpecificTypeUint8Array; |
| 47 } | 47 } |
| 48 | 48 |
| 49 TestInterface2OrUint8Array TestInterface2OrUint8Array::fromUint8Array(DOMUint8Ar
ray* value) { | 49 TestInterface2OrUint8Array TestInterface2OrUint8Array::fromUint8Array(NotShared<
DOMUint8Array> value) { |
| 50 TestInterface2OrUint8Array container; | 50 TestInterface2OrUint8Array container; |
| 51 container.setUint8Array(value); | 51 container.setUint8Array(value); |
| 52 return container; | 52 return container; |
| 53 } | 53 } |
| 54 | 54 |
| 55 TestInterface2OrUint8Array::TestInterface2OrUint8Array(const TestInterface2OrUin
t8Array&) = default; | 55 TestInterface2OrUint8Array::TestInterface2OrUint8Array(const TestInterface2OrUin
t8Array&) = default; |
| 56 TestInterface2OrUint8Array::~TestInterface2OrUint8Array() = default; | 56 TestInterface2OrUint8Array::~TestInterface2OrUint8Array() = default; |
| 57 TestInterface2OrUint8Array& TestInterface2OrUint8Array::operator=(const TestInte
rface2OrUint8Array&) = default; | 57 TestInterface2OrUint8Array& TestInterface2OrUint8Array::operator=(const TestInte
rface2OrUint8Array&) = default; |
| 58 | 58 |
| 59 DEFINE_TRACE(TestInterface2OrUint8Array) { | 59 DEFINE_TRACE(TestInterface2OrUint8Array) { |
| 60 visitor->Trace(m_testInterface2); | 60 visitor->Trace(m_testInterface2); |
| 61 visitor->Trace(m_uint8Array); | 61 visitor->Trace(m_uint8Array); |
| 62 } | 62 } |
| 63 | 63 |
| 64 void V8TestInterface2OrUint8Array::toImpl(v8::Isolate* isolate, v8::Local<v8::Va
lue> v8Value, TestInterface2OrUint8Array& impl, UnionTypeConversionMode conversi
onMode, ExceptionState& exceptionState) { | 64 void V8TestInterface2OrUint8Array::toImpl(v8::Isolate* isolate, v8::Local<v8::Va
lue> v8Value, TestInterface2OrUint8Array& impl, UnionTypeConversionMode conversi
onMode, ExceptionState& exceptionState) { |
| 65 if (v8Value.IsEmpty()) | 65 if (v8Value.IsEmpty()) |
| 66 return; | 66 return; |
| 67 | 67 |
| 68 if (conversionMode == UnionTypeConversionMode::kNullable && IsUndefinedOrNull(
v8Value)) | 68 if (conversionMode == UnionTypeConversionMode::kNullable && IsUndefinedOrNull(
v8Value)) |
| 69 return; | 69 return; |
| 70 | 70 |
| 71 if (V8TestInterface2::hasInstance(v8Value, isolate)) { | 71 if (V8TestInterface2::hasInstance(v8Value, isolate)) { |
| 72 TestInterface2* cppValue = V8TestInterface2::toImpl(v8::Local<v8::Object>::C
ast(v8Value)); | 72 TestInterface2* cppValue = V8TestInterface2::toImpl(v8::Local<v8::Object>::C
ast(v8Value)); |
| 73 impl.setTestInterface2(cppValue); | 73 impl.setTestInterface2(cppValue); |
| 74 return; | 74 return; |
| 75 } | 75 } |
| 76 | 76 |
| 77 if (v8Value->IsUint8Array()) { | 77 if (v8Value->IsUint8Array()) { |
| 78 DOMUint8Array* cppValue = V8Uint8Array::toImpl(v8::Local<v8::Object>::Cast(v
8Value)); | 78 NotShared<DOMUint8Array> cppValue = ToNotShared<NotShared<DOMUint8Array>>(is
olate, v8Value, exceptionState); |
| 79 if (exceptionState.HadException()) |
| 80 return; |
| 79 impl.setUint8Array(cppValue); | 81 impl.setUint8Array(cppValue); |
| 80 return; | 82 return; |
| 81 } | 83 } |
| 82 | 84 |
| 83 exceptionState.ThrowTypeError("The provided value is not of type '(TestInterfa
ce2 or Uint8Array)'"); | 85 exceptionState.ThrowTypeError("The provided value is not of type '(TestInterfa
ce2 or Uint8Array)'"); |
| 84 } | 86 } |
| 85 | 87 |
| 86 v8::Local<v8::Value> ToV8(const TestInterface2OrUint8Array& impl, v8::Local<v8::
Object> creationContext, v8::Isolate* isolate) { | 88 v8::Local<v8::Value> ToV8(const TestInterface2OrUint8Array& impl, v8::Local<v8::
Object> creationContext, v8::Isolate* isolate) { |
| 87 switch (impl.m_type) { | 89 switch (impl.m_type) { |
| 88 case TestInterface2OrUint8Array::SpecificTypeNone: | 90 case TestInterface2OrUint8Array::SpecificTypeNone: |
| 89 return v8::Null(isolate); | 91 return v8::Null(isolate); |
| 90 case TestInterface2OrUint8Array::SpecificTypeTestInterface2: | 92 case TestInterface2OrUint8Array::SpecificTypeTestInterface2: |
| 91 return ToV8(impl.getAsTestInterface2(), creationContext, isolate); | 93 return ToV8(impl.getAsTestInterface2(), creationContext, isolate); |
| 92 case TestInterface2OrUint8Array::SpecificTypeUint8Array: | 94 case TestInterface2OrUint8Array::SpecificTypeUint8Array: |
| 93 return ToV8(impl.getAsUint8Array(), creationContext, isolate); | 95 return ToV8(impl.getAsUint8Array(), creationContext, isolate); |
| 94 default: | 96 default: |
| 95 NOTREACHED(); | 97 NOTREACHED(); |
| 96 } | 98 } |
| 97 return v8::Local<v8::Value>(); | 99 return v8::Local<v8::Value>(); |
| 98 } | 100 } |
| 99 | 101 |
| 100 TestInterface2OrUint8Array NativeValueTraits<TestInterface2OrUint8Array>::Native
Value(v8::Isolate* isolate, v8::Local<v8::Value> value, ExceptionState& exceptio
nState) { | 102 TestInterface2OrUint8Array NativeValueTraits<TestInterface2OrUint8Array>::Native
Value(v8::Isolate* isolate, v8::Local<v8::Value> value, ExceptionState& exceptio
nState) { |
| 101 TestInterface2OrUint8Array impl; | 103 TestInterface2OrUint8Array impl; |
| 102 V8TestInterface2OrUint8Array::toImpl(isolate, value, impl, UnionTypeConversion
Mode::kNotNullable, exceptionState); | 104 V8TestInterface2OrUint8Array::toImpl(isolate, value, impl, UnionTypeConversion
Mode::kNotNullable, exceptionState); |
| 103 return impl; | 105 return impl; |
| 104 } | 106 } |
| 105 | 107 |
| 106 } // namespace blink | 108 } // namespace blink |
| OLD | NEW |