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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 | 49 |
50 return ScriptWrappable::fromNode(impl)->wrap(isolate, creationContext); | 50 return ScriptWrappable::fromNode(impl)->wrap(isolate, creationContext); |
51 } | 51 } |
52 | 52 |
53 // Special versions for DOMWindow, WorkerOrWorkletGlobalScope and EventTarget | 53 // Special versions for DOMWindow, WorkerOrWorkletGlobalScope and EventTarget |
54 | 54 |
55 CORE_EXPORT v8::Local<v8::Value> toV8(DOMWindow*, v8::Local<v8::Object> creation
Context, v8::Isolate*); | 55 CORE_EXPORT v8::Local<v8::Value> toV8(DOMWindow*, v8::Local<v8::Object> creation
Context, v8::Isolate*); |
56 CORE_EXPORT v8::Local<v8::Value> toV8(EventTarget*, v8::Local<v8::Object> creati
onContext, v8::Isolate*); | 56 CORE_EXPORT v8::Local<v8::Value> toV8(EventTarget*, v8::Local<v8::Object> creati
onContext, v8::Isolate*); |
57 v8::Local<v8::Value> toV8(WorkerOrWorkletGlobalScope*, v8::Local<v8::Object> cre
ationContext, v8::Isolate*); | 57 v8::Local<v8::Value> toV8(WorkerOrWorkletGlobalScope*, v8::Local<v8::Object> cre
ationContext, v8::Isolate*); |
58 | 58 |
59 // PassRefPtr, RawPtr and RefPtr | 59 // PassRefPtr and RefPtr |
60 | 60 |
61 template<typename T> | 61 template<typename T> |
62 inline v8::Local<v8::Value> toV8(PassRefPtr<T> impl, v8::Local<v8::Object> creat
ionContext, v8::Isolate* isolate) | 62 inline v8::Local<v8::Value> toV8(PassRefPtr<T> impl, v8::Local<v8::Object> creat
ionContext, v8::Isolate* isolate) |
63 { | 63 { |
64 return toV8(impl.get(), creationContext, isolate); | 64 return toV8(impl.get(), creationContext, isolate); |
65 } | 65 } |
66 | 66 |
67 template<typename T> | 67 template<typename T> |
68 inline v8::Local<v8::Value> toV8(RawPtr<T> impl, v8::Local<v8::Object> creationC
ontext, v8::Isolate* isolate) | |
69 { | |
70 return toV8(impl.get(), creationContext, isolate); | |
71 } | |
72 | |
73 template<typename T> | |
74 inline v8::Local<v8::Value> toV8(const RefPtr<T>& impl, v8::Local<v8::Object> cr
eationContext, v8::Isolate* isolate) | 68 inline v8::Local<v8::Value> toV8(const RefPtr<T>& impl, v8::Local<v8::Object> cr
eationContext, v8::Isolate* isolate) |
75 { | 69 { |
76 return toV8(impl.get(), creationContext, isolate); | 70 return toV8(impl.get(), creationContext, isolate); |
77 } | 71 } |
78 | 72 |
79 // Primitives | 73 // Primitives |
80 | 74 |
81 inline v8::Local<v8::Value> toV8(const String& value, v8::Local<v8::Object> crea
tionContext, v8::Isolate* isolate) | 75 inline v8::Local<v8::Value> toV8(const String& value, v8::Local<v8::Object> crea
tionContext, v8::Isolate* isolate) |
82 { | 76 { |
83 return v8String(isolate, value); | 77 return v8String(isolate, value); |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 // Cannot define in ScriptValue because of the circular dependency between toV8
and ScriptValue | 259 // Cannot define in ScriptValue because of the circular dependency between toV8
and ScriptValue |
266 template<typename T> | 260 template<typename T> |
267 inline ScriptValue ScriptValue::from(ScriptState* scriptState, T&& value) | 261 inline ScriptValue ScriptValue::from(ScriptState* scriptState, T&& value) |
268 { | 262 { |
269 return ScriptValue(scriptState, toV8(std::forward<T>(value), scriptState)); | 263 return ScriptValue(scriptState, toV8(std::forward<T>(value), scriptState)); |
270 } | 264 } |
271 | 265 |
272 } // namespace blink | 266 } // namespace blink |
273 | 267 |
274 #endif // ToV8_h | 268 #endif // ToV8_h |
OLD | NEW |