-
Notifications
You must be signed in to change notification settings - Fork 15k
/
fix_expose_lookupandcompile_with_parameters.patch
55 lines (50 loc) · 2.07 KB
/
fix_expose_lookupandcompile_with_parameters.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shelley Vohr <shelley.vohr@gmail.com>
Date: Thu, 13 Oct 2022 17:10:01 +0200
Subject: fix: expose LookupAndCompile with parameters
Node.js removed custom parameters from the public version of LookupAndCompile,
which we use in Electron. This patch re-exposes a wrapper to allow custom
parameters.
This should be upstreamed.
diff --git a/src/node_builtins.cc b/src/node_builtins.cc
index 7e4a43a6f13845c8a81bae96ec073ccdfc655999..26ebc322afa36994b4f1b93f992ac8b726263191 100644
--- a/src/node_builtins.cc
+++ b/src/node_builtins.cc
@@ -482,6 +482,22 @@ MaybeLocal<Value> BuiltinLoader::CompileAndCall(Local<Context> context,
return fn->Call(context, undefined, argc, argv);
}
+MaybeLocal<Function> BuiltinLoader::LookupAndCompile(
+ Local<Context> context,
+ const char* id,
+ std::vector<Local<String>>* parameters,
+ Environment* optional_env) {
+ Result result;
+ Isolate* isolate = context->GetIsolate();
+
+ MaybeLocal<Function> maybe = GetInstance()->LookupAndCompileInternal(
+ context, id, parameters, &result);
+ if (optional_env != nullptr) {
+ RecordResult(id, result, optional_env);
+ }
+ return maybe;
+}
+
bool BuiltinLoader::CompileAllBuiltins(Local<Context> context) {
std::vector<std::string_view> ids = GetBuiltinIds();
bool all_succeeded = true;
diff --git a/src/node_builtins.h b/src/node_builtins.h
index ba0c926a7968ec6a4cf07a469f1fd9314287a937..03ecd853b26a581f57b3311915fb7f46e713b00d 100644
--- a/src/node_builtins.h
+++ b/src/node_builtins.h
@@ -107,6 +107,12 @@ class NODE_EXTERN_PRIVATE BuiltinLoader {
const char* id,
Realm* realm);
+ static v8::MaybeLocal<v8::Function> LookupAndCompile(
+ v8::Local<v8::Context> context,
+ const char* id,
+ std::vector<v8::Local<v8::String>>* parameters,
+ Environment* optional_env);
+
// Returns config.gypi as a JSON string
v8::Local<v8::String> GetConfigString(v8::Isolate* isolate);
bool Exists(const char* id);