node_util.h 944 B

12345678910111213141516171819202122232425262728293031
  1. // Copyright (c) 2019 GitHub, Inc.
  2. // Use of this source code is governed by the MIT license that can be
  3. // found in the LICENSE file.
  4. #ifndef ELECTRON_SHELL_COMMON_NODE_UTIL_H_
  5. #define ELECTRON_SHELL_COMMON_NODE_UTIL_H_
  6. #include <vector>
  7. #include "v8/include/v8.h"
  8. namespace node {
  9. class Environment;
  10. }
  11. namespace electron::util {
  12. // Run a script with JS source bundled inside the binary as if it's wrapped
  13. // in a function called with a null receiver and arguments specified in C++.
  14. // The returned value is empty if an exception is encountered.
  15. // JS code run with this method can assume that their top-level
  16. // declarations won't affect the global scope.
  17. v8::MaybeLocal<v8::Value> CompileAndCall(
  18. v8::Local<v8::Context> context,
  19. const char* id,
  20. std::vector<v8::Local<v8::String>>* parameters,
  21. std::vector<v8::Local<v8::Value>>* arguments);
  22. } // namespace electron::util
  23. #endif // ELECTRON_SHELL_COMMON_NODE_UTIL_H_