blob: 077c84a3fb6ab127c64b592eb1baa12701cacd94 [file] [log] [blame]
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ToV8ForCore_h
#define ToV8ForCore_h
// ToV8() provides C++ -> V8 conversion. Note that ToV8() can return an empty
// handle. Call sites must check IsEmpty() before using return value.
#include "bindings/core/v8/ToV8.h"
#include "bindings/core/v8/V8NodeFilterCondition.h"
#include "core/dom/ArrayBufferViewHelpers.h"
#include "core/dom/Node.h"
#include "v8/include/v8.h"
namespace blink {
class Dictionary;
class DOMWindow;
class EventTarget;
CORE_EXPORT v8::Local<v8::Value> ToV8(DOMWindow*,
v8::Local<v8::Object> creation_context,
v8::Isolate*);
CORE_EXPORT v8::Local<v8::Value> ToV8(EventTarget*,
v8::Local<v8::Object> creation_context,
v8::Isolate*);
inline v8::Local<v8::Value> ToV8(Node* node,
v8::Local<v8::Object> creation_context,
v8::Isolate* isolate) {
return ToV8(static_cast<ScriptWrappable*>(node), creation_context, isolate);
}
inline v8::Local<v8::Value> ToV8(const Dictionary& value,
v8::Local<v8::Object> creation_context,
v8::Isolate* isolate) {
NOTREACHED();
return v8::Undefined(isolate);
}
template <typename T>
inline v8::Local<v8::Value> ToV8(NotShared<T> value,
v8::Local<v8::Object> creation_context,
v8::Isolate* isolate) {
return ToV8(value.View(), creation_context, isolate);
}
inline v8::Local<v8::Value> ToV8(const V8NodeFilterCondition* value,
v8::Local<v8::Object> creation_context,
v8::Isolate* isolate) {
return value ? value->Callback(isolate) : v8::Null(isolate).As<v8::Value>();
}
} // namespace blink
#endif // ToV8ForCore_h