From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Shelley Vohr 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 522670ed5c9951c506dcdf2745585552ad2a081f..12ea7cdabb16a7f4ea350bdf1cd5d073e035fda1 100644 --- a/src/node_builtins.cc +++ b/src/node_builtins.cc @@ -435,6 +435,22 @@ MaybeLocal BuiltinLoader::LookupAndCompile( return maybe; } +MaybeLocal BuiltinLoader::LookupAndCompile( + Local context, + const char* id, + std::vector>* parameters, + Environment* optional_env) { + Result result; + Isolate* isolate = context->GetIsolate(); + + MaybeLocal maybe = GetInstance()->LookupAndCompileInternal( + context, id, parameters, &result); + if (optional_env != nullptr) { + RecordResult(id, result, optional_env); + } + return maybe; +} + bool BuiltinLoader::CompileAllBuiltins(Local context) { BuiltinLoader* loader = GetInstance(); std::vector ids = loader->GetBuiltinIds(); diff --git a/src/node_builtins.h b/src/node_builtins.h index 8d9f7c409659a30747e5feeac6cfec4208791370..34a51c3e5a79154c3633143b352aa9e108497767 100644 --- a/src/node_builtins.h +++ b/src/node_builtins.h @@ -50,6 +50,11 @@ class NODE_EXTERN_PRIVATE BuiltinLoader { v8::Local context, const char* id, Environment* optional_env); + static v8::MaybeLocal LookupAndCompile( + v8::Local context, + const char* id, + std::vector>* parameters, + Environment* optional_env); static v8::Local GetSourceObject(v8::Local context); // Returns config.gypi as a JSON string