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 "NodeOrNodeList.h" |
| 8 |
| 9 #include "bindings/core/v8/ToV8.h" |
| 10 #include "bindings/core/v8/V8Node.h" |
| 11 #include "bindings/core/v8/V8NodeList.h" |
| 12 #include "core/dom/NameNodeList.h" |
| 13 #include "core/dom/NodeList.h" |
| 14 #include "core/dom/StaticNodeList.h" |
| 15 #include "core/html/LabelsNodeList.h" |
| 16 |
| 17 namespace blink { |
| 18 |
| 19 NodeOrNodeList::NodeOrNodeList() |
| 20 : m_type(SpecificTypeNone) |
| 21 { |
| 22 } |
| 23 |
| 24 Node* NodeOrNodeList::getAsNode() const |
| 25 { |
| 26 ASSERT(isNode()); |
| 27 return m_node; |
| 28 } |
| 29 |
| 30 void NodeOrNodeList::setNode(Node* value) |
| 31 { |
| 32 ASSERT(isNull()); |
| 33 m_node = value; |
| 34 m_type = SpecificTypeNode; |
| 35 } |
| 36 |
| 37 NodeOrNodeList NodeOrNodeList::fromNode(Node* value) |
| 38 { |
| 39 NodeOrNodeList container; |
| 40 container.setNode(value); |
| 41 return container; |
| 42 } |
| 43 |
| 44 NodeList* NodeOrNodeList::getAsNodeList() const |
| 45 { |
| 46 ASSERT(isNodeList()); |
| 47 return m_nodeList; |
| 48 } |
| 49 |
| 50 void NodeOrNodeList::setNodeList(NodeList* value) |
| 51 { |
| 52 ASSERT(isNull()); |
| 53 m_nodeList = value; |
| 54 m_type = SpecificTypeNodeList; |
| 55 } |
| 56 |
| 57 NodeOrNodeList NodeOrNodeList::fromNodeList(NodeList* value) |
| 58 { |
| 59 NodeOrNodeList container; |
| 60 container.setNodeList(value); |
| 61 return container; |
| 62 } |
| 63 |
| 64 NodeOrNodeList::NodeOrNodeList(const NodeOrNodeList&) = default; |
| 65 NodeOrNodeList::~NodeOrNodeList() = default; |
| 66 NodeOrNodeList& NodeOrNodeList::operator=(const NodeOrNodeList&) = default; |
| 67 |
| 68 DEFINE_TRACE(NodeOrNodeList) |
| 69 { |
| 70 visitor->trace(m_node); |
| 71 visitor->trace(m_nodeList); |
| 72 } |
| 73 |
| 74 void V8NodeOrNodeList::toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value
, NodeOrNodeList& impl, UnionTypeConversionMode conversionMode, ExceptionState&
exceptionState) |
| 75 { |
| 76 if (v8Value.IsEmpty()) |
| 77 return; |
| 78 |
| 79 if (conversionMode == UnionTypeConversionMode::Nullable && isUndefinedOrNull
(v8Value)) |
| 80 return; |
| 81 |
| 82 if (V8Node::hasInstance(v8Value, isolate)) { |
| 83 Node* cppValue = V8Node::toImpl(v8::Local<v8::Object>::Cast(v8Value)); |
| 84 impl.setNode(cppValue); |
| 85 return; |
| 86 } |
| 87 |
| 88 if (V8NodeList::hasInstance(v8Value, isolate)) { |
| 89 NodeList* cppValue = V8NodeList::toImpl(v8::Local<v8::Object>::Cast(v8Va
lue)); |
| 90 impl.setNodeList(cppValue); |
| 91 return; |
| 92 } |
| 93 |
| 94 exceptionState.throwTypeError("The provided value is not of type '(Node or N
odeList)'"); |
| 95 } |
| 96 |
| 97 v8::Local<v8::Value> toV8(const NodeOrNodeList& impl, v8::Local<v8::Object> crea
tionContext, v8::Isolate* isolate) |
| 98 { |
| 99 switch (impl.m_type) { |
| 100 case NodeOrNodeList::SpecificTypeNone: |
| 101 return v8::Null(isolate); |
| 102 case NodeOrNodeList::SpecificTypeNode: |
| 103 return toV8(impl.getAsNode(), creationContext, isolate); |
| 104 case NodeOrNodeList::SpecificTypeNodeList: |
| 105 return toV8(impl.getAsNodeList(), creationContext, isolate); |
| 106 default: |
| 107 ASSERT_NOT_REACHED(); |
| 108 } |
| 109 return v8::Local<v8::Value>(); |
| 110 } |
| 111 |
| 112 NodeOrNodeList NativeValueTraits<NodeOrNodeList>::nativeValue(v8::Isolate* isola
te, v8::Local<v8::Value> value, ExceptionState& exceptionState) |
| 113 { |
| 114 NodeOrNodeList impl; |
| 115 V8NodeOrNodeList::toImpl(isolate, value, impl, UnionTypeConversionMode::NotN
ullable, exceptionState); |
| 116 return impl; |
| 117 } |
| 118 |
| 119 } // namespace blink |
OLD | NEW |