| 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 CORE_EXPORT v8::Local<v8::Value> toV8(DOMWindow*, | 62 CORE_EXPORT v8::Local<v8::Value> toV8(DOMWindow*, |
| 63 v8::Local<v8::Object> creationContext, | 63 v8::Local<v8::Object> creationContext, |
| 64 v8::Isolate*); | 64 v8::Isolate*); |
| 65 CORE_EXPORT v8::Local<v8::Value> toV8(EventTarget*, | 65 CORE_EXPORT v8::Local<v8::Value> toV8(EventTarget*, |
| 66 v8::Local<v8::Object> creationContext, | 66 v8::Local<v8::Object> creationContext, |
| 67 v8::Isolate*); | 67 v8::Isolate*); |
| 68 v8::Local<v8::Value> toV8(WorkerOrWorkletGlobalScope*, | 68 v8::Local<v8::Value> toV8(WorkerOrWorkletGlobalScope*, |
| 69 v8::Local<v8::Object> creationContext, | 69 v8::Local<v8::Object> creationContext, |
| 70 v8::Isolate*); | 70 v8::Isolate*); |
| 71 | 71 |
| 72 // PassRefPtr and RefPtr | |
| 73 | |
| 74 template <typename T> | |
| 75 inline v8::Local<v8::Value> toV8(PassRefPtr<T> impl, | |
| 76 v8::Local<v8::Object> creationContext, | |
| 77 v8::Isolate* isolate) { | |
| 78 return toV8(impl.get(), creationContext, isolate); | |
| 79 } | |
| 80 | |
| 81 template <typename T> | |
| 82 inline v8::Local<v8::Value> toV8(const RefPtr<T>& impl, | |
| 83 v8::Local<v8::Object> creationContext, | |
| 84 v8::Isolate* isolate) { | |
| 85 return toV8(impl.get(), creationContext, isolate); | |
| 86 } | |
| 87 | |
| 88 // Primitives | 72 // Primitives |
| 89 | 73 |
| 90 inline v8::Local<v8::Value> toV8(const String& value, | 74 inline v8::Local<v8::Value> toV8(const String& value, |
| 91 v8::Local<v8::Object> creationContext, | 75 v8::Local<v8::Object> creationContext, |
| 92 v8::Isolate* isolate) { | 76 v8::Isolate* isolate) { |
| 93 return v8String(isolate, value); | 77 return v8String(isolate, value); |
| 94 } | 78 } |
| 95 | 79 |
| 96 inline v8::Local<v8::Value> toV8(const char* value, | 80 inline v8::Local<v8::Value> toV8(const char* value, |
| 97 v8::Local<v8::Object> creationContext, | 81 v8::Local<v8::Object> creationContext, |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 // Cannot define in ScriptValue because of the circular dependency between toV8 | 303 // Cannot define in ScriptValue because of the circular dependency between toV8 |
| 320 // and ScriptValue | 304 // and ScriptValue |
| 321 template <typename T> | 305 template <typename T> |
| 322 inline ScriptValue ScriptValue::from(ScriptState* scriptState, T&& value) { | 306 inline ScriptValue ScriptValue::from(ScriptState* scriptState, T&& value) { |
| 323 return ScriptValue(scriptState, toV8(std::forward<T>(value), scriptState)); | 307 return ScriptValue(scriptState, toV8(std::forward<T>(value), scriptState)); |
| 324 } | 308 } |
| 325 | 309 |
| 326 } // namespace blink | 310 } // namespace blink |
| 327 | 311 |
| 328 #endif // ToV8_h | 312 #endif // ToV8_h |
| OLD | NEW |