05dfd14913
* refactor: add EmitWarning(Isolate*, ...) warning * chore: remove EmitWarning(node::Environment*, ...) * chore: add code comments * fixup! refactor: add EmitWarning(Isolate*, ...) warning * chore: remove unused node #includes
41 lines
1.3 KiB
C++
41 lines
1.3 KiB
C++
// Copyright (c) 2019 GitHub, Inc.
|
|
// Use of this source code is governed by the MIT license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#ifndef ELECTRON_SHELL_COMMON_NODE_UTIL_H_
|
|
#define ELECTRON_SHELL_COMMON_NODE_UTIL_H_
|
|
|
|
#include <string_view>
|
|
#include <vector>
|
|
|
|
#include "v8/include/v8-forward.h"
|
|
|
|
namespace node {
|
|
class Environment;
|
|
}
|
|
|
|
namespace electron::util {
|
|
|
|
// Emit a warning via node's process.emitWarning()
|
|
void EmitWarning(v8::Isolate* isolate,
|
|
std::string_view warning_msg,
|
|
std::string_view warning_type);
|
|
|
|
// Emit a warning via node's process.emitWarning(),
|
|
// using JavscriptEnvironment's isolate
|
|
void EmitWarning(std::string_view warning_msg, std::string_view warning_type);
|
|
|
|
// Run a script with JS source bundled inside the binary as if it's wrapped
|
|
// in a function called with a null receiver and arguments specified in C++.
|
|
// The returned value is empty if an exception is encountered.
|
|
// JS code run with this method can assume that their top-level
|
|
// declarations won't affect the global scope.
|
|
v8::MaybeLocal<v8::Value> CompileAndCall(
|
|
v8::Local<v8::Context> context,
|
|
const char* id,
|
|
std::vector<v8::Local<v8::String>>* parameters,
|
|
std::vector<v8::Local<v8::Value>>* arguments);
|
|
|
|
} // namespace electron::util
|
|
|
|
#endif // ELECTRON_SHELL_COMMON_NODE_UTIL_H_
|