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 #ifndef ToV8_h | 5 #ifndef ToV8_h |
6 #define ToV8_h | 6 #define ToV8_h |
7 | 7 |
8 #include "bindings/core/v8/DOMDataStore.h" | 8 #include "bindings/core/v8/DOMDataStore.h" |
9 #include "bindings/core/v8/ScriptValue.h" | 9 #include "bindings/core/v8/ScriptValue.h" |
10 #include "bindings/core/v8/ScriptWrappable.h" | 10 #include "bindings/core/v8/ScriptWrappable.h" |
11 #include "bindings/core/v8/V8Binding.h" | 11 #include "bindings/core/v8/V8Binding.h" |
12 #include "platform/heap/Handle.h" | 12 #include "platform/heap/Handle.h" |
13 #include "wtf/Forward.h" | 13 #include "wtf/Forward.h" |
14 #include <v8.h> | 14 #include <v8.h> |
15 | 15 |
16 namespace blink { | 16 namespace blink { |
17 | 17 |
18 class DOMWindow; | 18 class DOMWindow; |
19 class Dictionary; | |
19 class EventTarget; | 20 class EventTarget; |
20 class WorkerGlobalScope; | 21 class WorkerGlobalScope; |
21 | 22 |
22 // ScriptWrappable | 23 // ScriptWrappable |
23 | 24 |
24 inline v8::Handle<v8::Value> toV8(ScriptWrappable* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) | 25 inline v8::Handle<v8::Value> toV8(ScriptWrappable* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) |
25 { | 26 { |
26 if (UNLIKELY(!impl)) | 27 if (UNLIKELY(!impl)) |
27 return v8::Null(isolate); | 28 return v8::Null(isolate); |
28 v8::Handle<v8::Value> wrapper = DOMDataStore::getWrapper(impl, isolate); | 29 v8::Handle<v8::Value> wrapper = DOMDataStore::getWrapper(impl, isolate); |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
175 return v8::Undefined(isolate); | 176 return v8::Undefined(isolate); |
176 } | 177 } |
177 | 178 |
178 // ScriptValue | 179 // ScriptValue |
179 | 180 |
180 inline v8::Handle<v8::Value> toV8(const ScriptValue& value, v8::Handle<v8::Objec t> creationContext, v8::Isolate*) | 181 inline v8::Handle<v8::Value> toV8(const ScriptValue& value, v8::Handle<v8::Objec t> creationContext, v8::Isolate*) |
181 { | 182 { |
182 return value.v8Value(); | 183 return value.v8Value(); |
183 } | 184 } |
184 | 185 |
186 // Dictionary | |
187 | |
188 inline v8::Handle<v8::Value> toV8(const Dictionary& value, v8::Handle<v8::Object > creationContext, v8::Isolate*) | |
189 { | |
190 ASSERT_NOT_REACHED(); | |
Jens Widell
2015/02/23 12:07:00
Adding this was necessary due to the use of sequen
haraken
2015/02/23 13:41:17
I'm fine in this CL, but it would be great if we c
| |
191 return v8::Handle<v8::Value>(); | |
192 } | |
193 | |
185 // Array | 194 // Array |
186 | 195 |
187 template<typename Sequence> | 196 template<typename Sequence> |
188 inline v8::Handle<v8::Value> toV8SequenceInternal(const Sequence& sequence, v8:: Handle<v8::Object> creationContext, v8::Isolate* isolate) | 197 inline v8::Handle<v8::Value> toV8SequenceInternal(const Sequence& sequence, v8:: Handle<v8::Object> creationContext, v8::Isolate* isolate) |
189 { | 198 { |
190 v8::Local<v8::Array> array = v8::Array::New(isolate, sequence.size()); | 199 v8::Local<v8::Array> array = v8::Array::New(isolate, sequence.size()); |
191 uint32_t index = 0; | 200 uint32_t index = 0; |
192 typename Sequence::const_iterator end = sequence.end(); | 201 typename Sequence::const_iterator end = sequence.end(); |
193 for (typename Sequence::const_iterator iter = sequence.begin(); iter != end; ++iter) | 202 for (typename Sequence::const_iterator iter = sequence.begin(); iter != end; ++iter) |
194 array->Set(v8::Integer::New(isolate, index++), toV8(*iter, creationConte xt, isolate)); | 203 array->Set(v8::Integer::New(isolate, index++), toV8(*iter, creationConte xt, isolate)); |
195 return array; | 204 return array; |
196 } | 205 } |
197 | 206 |
198 template<typename T, size_t inlineCapacity> | 207 template<typename T, size_t inlineCapacity> |
199 inline v8::Handle<v8::Value> toV8(const Vector<T, inlineCapacity>& value, v8::Ha ndle<v8::Object> creationContext, v8::Isolate* isolate) | 208 inline v8::Handle<v8::Value> toV8(const Vector<T, inlineCapacity>& value, v8::Ha ndle<v8::Object> creationContext, v8::Isolate* isolate) |
200 { | 209 { |
201 return toV8SequenceInternal(value, creationContext, isolate); | 210 return toV8SequenceInternal(value, creationContext, isolate); |
202 } | 211 } |
203 | 212 |
204 template<typename T, size_t inlineCapacity> | 213 template<typename T, size_t inlineCapacity> |
205 inline v8::Handle<v8::Value> toV8(const HeapVector<T, inlineCapacity>& value, v8 ::Handle<v8::Object> creationContext, v8::Isolate* isolate) | 214 inline v8::Handle<v8::Value> toV8(const HeapVector<T, inlineCapacity>& value, v8 ::Handle<v8::Object> creationContext, v8::Isolate* isolate) |
206 { | 215 { |
207 return toV8SequenceInternal(value, creationContext, isolate); | 216 return toV8SequenceInternal(value, creationContext, isolate); |
208 } | 217 } |
209 | 218 |
210 } // namespace blink | 219 } // namespace blink |
211 | 220 |
212 #endif // ToV8_h | 221 #endif // ToV8_h |
OLD | NEW |