|
| 1 | +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Shelley Vohr < [email protected]> |
| 3 | +Date: Thu, 13 Oct 2022 17:10:01 +0200 |
| 4 | +Subject: fix: expose LookupAndCompile with parameters |
| 5 | + |
| 6 | +Node.js removed custom parameters from the public version of LookupAndCompile, |
| 7 | +which we use in Electron. This patch re-exposes a wrapper to allow custom |
| 8 | +parameters. |
| 9 | + |
| 10 | +This should be upstreamed. |
| 11 | + |
| 12 | +diff --git a/src/node_builtins.cc b/src/node_builtins.cc |
| 13 | +index 3bc9d113b6b818dcda332966f09f17248b421263..549339b5b677fa242a7b60ae716789c2a11ab18d 100644 |
| 14 | +--- a/src/node_builtins.cc |
| 15 | ++++ b/src/node_builtins.cc |
| 16 | +@@ -397,6 +397,22 @@ MaybeLocal<Function> BuiltinLoader::LookupAndCompile( |
| 17 | + return maybe; |
| 18 | + } |
| 19 | + |
| 20 | ++MaybeLocal<Function> BuiltinLoader::LookupAndCompile( |
| 21 | ++ Local<Context> context, |
| 22 | ++ const char* id, |
| 23 | ++ std::vector<Local<String>>* parameters, |
| 24 | ++ Environment* optional_env) { |
| 25 | ++ Result result; |
| 26 | ++ Isolate* isolate = context->GetIsolate(); |
| 27 | ++ |
| 28 | ++ MaybeLocal<Function> maybe = GetInstance()->LookupAndCompileInternal( |
| 29 | ++ context, id, parameters, &result); |
| 30 | ++ if (optional_env != nullptr) { |
| 31 | ++ RecordResult(id, result, optional_env); |
| 32 | ++ } |
| 33 | ++ return maybe; |
| 34 | ++} |
| 35 | ++ |
| 36 | + bool BuiltinLoader::CompileAllBuiltins(Local<Context> context) { |
| 37 | + BuiltinLoader* loader = GetInstance(); |
| 38 | + std::vector<std::string> ids = loader->GetBuiltinIds(); |
| 39 | +diff --git a/src/node_builtins.h b/src/node_builtins.h |
| 40 | +index 7f0a25af306ffefbc51ac43689ed208d4cd94f0b..a32a7a990082ea3dad73511f91a9c70c72f6fe31 100644 |
| 41 | +--- a/src/node_builtins.h |
| 42 | ++++ b/src/node_builtins.h |
| 43 | +@@ -49,6 +49,11 @@ class NODE_EXTERN_PRIVATE BuiltinLoader { |
| 44 | + v8::Local<v8::Context> context, |
| 45 | + const char* id, |
| 46 | + Environment* optional_env); |
| 47 | ++ static v8::MaybeLocal<v8::Function> LookupAndCompile( |
| 48 | ++ v8::Local<v8::Context> context, |
| 49 | ++ const char* id, |
| 50 | ++ std::vector<v8::Local<v8::String>>* parameters, |
| 51 | ++ Environment* optional_env); |
| 52 | + |
| 53 | + static v8::Local<v8::Object> GetSourceObject(v8::Local<v8::Context> context); |
| 54 | + // Returns config.gypi as a JSON string |
0 commit comments