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 // toV8() provides C++ -> V8 conversion. Note that toV8() can return an empty | 8 // toV8() provides C++ -> V8 conversion. Note that toV8() can return an empty |
9 // handle. Call sites must check IsEmpty() before using return value. | 9 // handle. Call sites must check IsEmpty() before using return value. |
10 | 10 |
(...skipping 30 matching lines...) Expand all Loading... |
41 { | 41 { |
42 if (UNLIKELY(!impl)) | 42 if (UNLIKELY(!impl)) |
43 return v8::Null(isolate); | 43 return v8::Null(isolate); |
44 v8::Handle<v8::Value> wrapper = DOMDataStore::getWrapper(impl, isolate); | 44 v8::Handle<v8::Value> wrapper = DOMDataStore::getWrapper(impl, isolate); |
45 if (!wrapper.IsEmpty()) | 45 if (!wrapper.IsEmpty()) |
46 return wrapper; | 46 return wrapper; |
47 | 47 |
48 return ScriptWrappable::fromNode(impl)->wrap(creationContext, isolate); | 48 return ScriptWrappable::fromNode(impl)->wrap(creationContext, isolate); |
49 } | 49 } |
50 | 50 |
51 // [Custom=ToV8] | 51 // Special versions for DOMWindow, WorkerGlobalScope and EventTarget |
52 | 52 |
53 CORE_EXPORT v8::Handle<v8::Value> toV8(DOMWindow*, v8::Handle<v8::Object> creati
onContext, v8::Isolate*); | 53 CORE_EXPORT v8::Handle<v8::Value> toV8(DOMWindow*, v8::Handle<v8::Object> creati
onContext, v8::Isolate*); |
54 CORE_EXPORT v8::Handle<v8::Value> toV8(EventTarget*, v8::Handle<v8::Object> crea
tionContext, v8::Isolate*); | 54 CORE_EXPORT v8::Handle<v8::Value> toV8(EventTarget*, v8::Handle<v8::Object> crea
tionContext, v8::Isolate*); |
55 v8::Handle<v8::Value> toV8(WorkerGlobalScope*, v8::Handle<v8::Object> creationCo
ntext, v8::Isolate*); | 55 v8::Handle<v8::Value> toV8(WorkerGlobalScope*, v8::Handle<v8::Object> creationCo
ntext, v8::Isolate*); |
56 | 56 |
57 // PassRefPtr, RawPtr and RefPtr | 57 // PassRefPtr, RawPtr and RefPtr |
58 | 58 |
59 template<typename T> | 59 template<typename T> |
60 inline v8::Handle<v8::Value> toV8(PassRefPtr<T> impl, v8::Handle<v8::Object> cre
ationContext, v8::Isolate* isolate) | 60 inline v8::Handle<v8::Value> toV8(PassRefPtr<T> impl, v8::Handle<v8::Object> cre
ationContext, v8::Isolate* isolate) |
61 { | 61 { |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 | 184 |
185 inline v8::Handle<v8::Value> toV8(const ScriptValue& value, v8::Handle<v8::Objec
t> creationContext, v8::Isolate*) | 185 inline v8::Handle<v8::Value> toV8(const ScriptValue& value, v8::Handle<v8::Objec
t> creationContext, v8::Isolate*) |
186 { | 186 { |
187 return value.v8Value(); | 187 return value.v8Value(); |
188 } | 188 } |
189 | 189 |
190 // Dictionary | 190 // Dictionary |
191 | 191 |
192 inline v8::Handle<v8::Value> toV8(const Dictionary& value, v8::Handle<v8::Object
> creationContext, v8::Isolate*) | 192 inline v8::Handle<v8::Value> toV8(const Dictionary& value, v8::Handle<v8::Object
> creationContext, v8::Isolate*) |
193 { | 193 { |
194 ASSERT_NOT_REACHED(); | 194 RELEASE_ASSERT_NOT_REACHED(); |
195 return v8::Handle<v8::Value>(); | 195 return v8::Handle<v8::Value>(); |
196 } | 196 } |
197 | 197 |
198 // Array | 198 // Array |
199 | 199 |
200 template<typename Sequence> | 200 template<typename Sequence> |
201 inline v8::Handle<v8::Value> toV8SequenceInternal(const Sequence& sequence, v8::
Handle<v8::Object> creationContext, v8::Isolate* isolate) | 201 inline v8::Handle<v8::Value> toV8SequenceInternal(const Sequence& sequence, v8::
Handle<v8::Object> creationContext, v8::Isolate* isolate) |
202 { | 202 { |
203 v8::Local<v8::Array> array = v8::Array::New(isolate, sequence.size()); | 203 v8::Local<v8::Array> array = v8::Array::New(isolate, sequence.size()); |
204 uint32_t index = 0; | 204 uint32_t index = 0; |
(...skipping 28 matching lines...) Expand all Loading... |
233 if (v8Value.IsEmpty()) | 233 if (v8Value.IsEmpty()) |
234 v8Value = v8::Undefined(isolate); | 234 v8Value = v8::Undefined(isolate); |
235 object->Set(v8String(isolate, value[i].first), v8Value); | 235 object->Set(v8String(isolate, value[i].first), v8Value); |
236 } | 236 } |
237 return object; | 237 return object; |
238 } | 238 } |
239 | 239 |
240 } // namespace blink | 240 } // namespace blink |
241 | 241 |
242 #endif // ToV8_h | 242 #endif // ToV8_h |
OLD | NEW |