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 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 // because of "unresolved external symbol". | 309 // because of "unresolved external symbol". |
310 // Without toV8(void*, ...), call to toV8 with T* will match with | 310 // Without toV8(void*, ...), call to toV8 with T* will match with |
311 // toV8(bool, ...) if T is not a subclass of ScriptWrappable or if T is | 311 // toV8(bool, ...) if T is not a subclass of ScriptWrappable or if T is |
312 // declared but not defined (so it's not clear that T is a subclass of | 312 // declared but not defined (so it's not clear that T is a subclass of |
313 // ScriptWrappable). | 313 // ScriptWrappable). |
314 // This hack helps detect such unwanted implicit conversions from T* to bool. | 314 // This hack helps detect such unwanted implicit conversions from T* to bool. |
315 v8::Local<v8::Value> toV8(void* value, | 315 v8::Local<v8::Value> toV8(void* value, |
316 v8::Local<v8::Object> creationContext, | 316 v8::Local<v8::Object> creationContext, |
317 v8::Isolate*) = delete; | 317 v8::Isolate*) = delete; |
318 | 318 |
319 // Cannot define in ScriptValue because of the circular dependency between toV8
and ScriptValue | 319 // Cannot define in ScriptValue because of the circular dependency between toV8 |
| 320 // and ScriptValue |
320 template <typename T> | 321 template <typename T> |
321 inline ScriptValue ScriptValue::from(ScriptState* scriptState, T&& value) { | 322 inline ScriptValue ScriptValue::from(ScriptState* scriptState, T&& value) { |
322 return ScriptValue(scriptState, toV8(std::forward<T>(value), scriptState)); | 323 return ScriptValue(scriptState, toV8(std::forward<T>(value), scriptState)); |
323 } | 324 } |
324 | 325 |
325 } // namespace blink | 326 } // namespace blink |
326 | 327 |
327 #endif // ToV8_h | 328 #endif // ToV8_h |
OLD | NEW |