| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 ToV8ForCore_h | 5 #ifndef ToV8ForCore_h |
| 6 #define ToV8ForCore_h | 6 #define ToV8ForCore_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 |
| 11 #include "bindings/core/v8/ScriptWrappable.h" | |
| 12 #include "bindings/core/v8/ToV8.h" | 11 #include "bindings/core/v8/ToV8.h" |
| 13 #include "core/CoreExport.h" | |
| 14 #include "core/dom/NotShared.h" | 12 #include "core/dom/NotShared.h" |
| 15 #include "v8/include/v8.h" | 13 #include "v8/include/v8.h" |
| 16 | 14 |
| 17 namespace blink { | 15 namespace blink { |
| 18 | 16 |
| 19 class DOMWindow; | |
| 20 class Dictionary; | 17 class Dictionary; |
| 21 class EventTarget; | |
| 22 class Node; | |
| 23 | |
| 24 inline v8::Local<v8::Value> ToV8(Node* impl, | |
| 25 v8::Local<v8::Object> creation_context, | |
| 26 v8::Isolate* isolate) { | |
| 27 return ToV8(ScriptWrappable::FromNode(impl), creation_context, isolate); | |
| 28 } | |
| 29 | |
| 30 // Special versions for DOMWindow and EventTarget | |
| 31 | |
| 32 CORE_EXPORT v8::Local<v8::Value> ToV8(DOMWindow*, | |
| 33 v8::Local<v8::Object> creation_context, | |
| 34 v8::Isolate*); | |
| 35 CORE_EXPORT v8::Local<v8::Value> ToV8(EventTarget*, | |
| 36 v8::Local<v8::Object> creation_context, | |
| 37 v8::Isolate*); | |
| 38 | |
| 39 // Dictionary | |
| 40 | 18 |
| 41 inline v8::Local<v8::Value> ToV8(const Dictionary& value, | 19 inline v8::Local<v8::Value> ToV8(const Dictionary& value, |
| 42 v8::Local<v8::Object> creation_context, | 20 v8::Local<v8::Object> creation_context, |
| 43 v8::Isolate* isolate) { | 21 v8::Isolate* isolate) { |
| 44 NOTREACHED(); | 22 NOTREACHED(); |
| 45 return v8::Undefined(isolate); | 23 return v8::Undefined(isolate); |
| 46 } | 24 } |
| 47 | 25 |
| 48 template <typename T> | 26 template <typename T> |
| 49 inline v8::Local<v8::Value> ToV8(NotShared<T> value, | 27 inline v8::Local<v8::Value> ToV8(NotShared<T> value, |
| 50 v8::Local<v8::Object> creation_context, | 28 v8::Local<v8::Object> creation_context, |
| 51 v8::Isolate* isolate) { | 29 v8::Isolate* isolate) { |
| 52 return ToV8(value.View(), creation_context, isolate); | 30 return ToV8(value.View(), creation_context, isolate); |
| 53 } | 31 } |
| 54 | 32 |
| 55 } // namespace blink | 33 } // namespace blink |
| 56 | 34 |
| 57 #endif // ToV8ForCore_h | 35 #endif // ToV8ForCore_h |
| OLD | NEW |