Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move CompileAndCall to a helper (#20675)
- Loading branch information
1 parent
5abce7e
commit db4d01c
Showing
8 changed files
with
86 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 0 additions & 55 deletions
55
patches/node/chore_re-add_compileandcall_this_should_be_added_as_a_helper_in.patch
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright (c) 2019 GitHub, Inc. | ||
// Use of this source code is governed by the MIT license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "shell/common/node_util.h" | ||
#include "shell/common/node_includes.h" | ||
#include "third_party/electron_node/src/node_native_module_env.h" | ||
|
||
namespace electron { | ||
|
||
namespace util { | ||
|
||
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, | ||
node::Environment* optional_env) { | ||
v8::Isolate* isolate = context->GetIsolate(); | ||
v8::MaybeLocal<v8::Function> compiled = | ||
node::native_module::NativeModuleEnv::LookupAndCompile( | ||
context, id, parameters, optional_env); | ||
if (compiled.IsEmpty()) { | ||
return v8::MaybeLocal<v8::Value>(); | ||
} | ||
v8::Local<v8::Function> fn = compiled.ToLocalChecked().As<v8::Function>(); | ||
return fn->Call(context, v8::Null(isolate), arguments->size(), | ||
arguments->data()); | ||
} | ||
|
||
} // namespace util | ||
|
||
} // namespace electron |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// 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 SHELL_COMMON_NODE_UTIL_H_ | ||
#define SHELL_COMMON_NODE_UTIL_H_ | ||
|
||
#include <vector> | ||
|
||
#include "v8/include/v8.h" | ||
|
||
namespace node { | ||
class Environment; | ||
} // namespace node | ||
|
||
namespace electron { | ||
|
||
namespace util { | ||
|
||
// 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, | ||
node::Environment* optional_env); | ||
|
||
} // namespace util | ||
|
||
} // namespace electron | ||
|
||
#endif // SHELL_COMMON_NODE_UTIL_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters