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