fix_expose_lookupandcompile_with_parameters.patch 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. Node.js removed custom parameters from the public version of LookupAndCompile,
  6. which we use in Electron. This patch re-exposes a wrapper to allow custom
  7. parameters.
  8. This should be upstreamed.
  9. diff --git a/src/node_builtins.cc b/src/node_builtins.cc
  10. index f3cda64beaa1403cb33f1b0bd8089f3dfcbfc8b9..77386bd234d0b49b122f1de3d27b1a92da5d0ea4 100644
  11. --- a/src/node_builtins.cc
  12. +++ b/src/node_builtins.cc
  13. @@ -482,6 +482,18 @@ MaybeLocal<Value> BuiltinLoader::CompileAndCall(Local<Context> context,
  14. return fn->Call(context, undefined, argc, argv);
  15. }
  16. +MaybeLocal<Function> BuiltinLoader::LookupAndCompile(
  17. + Local<Context> context,
  18. + const char* id,
  19. + std::vector<Local<String>>* parameters,
  20. + Realm* optional_realm) {
  21. + Isolate* isolate = context->GetIsolate();
  22. +
  23. + MaybeLocal<Function> maybe = LookupAndCompileInternal(
  24. + context, id, parameters, optional_realm);
  25. + return maybe;
  26. +}
  27. +
  28. bool BuiltinLoader::CompileAllBuiltins(Local<Context> context) {
  29. std::vector<std::string_view> ids = GetBuiltinIds();
  30. bool all_succeeded = true;
  31. diff --git a/src/node_builtins.h b/src/node_builtins.h
  32. index 11d10f52b7c492bfae4bc58b39c20a693762a72d..b995e15fcd795f310126a38ec652efcd9fd36945 100644
  33. --- a/src/node_builtins.h
  34. +++ b/src/node_builtins.h
  35. @@ -99,6 +99,12 @@ class NODE_EXTERN_PRIVATE BuiltinLoader {
  36. const char* id,
  37. Realm* optional_realm);
  38. + v8::MaybeLocal<v8::Function> LookupAndCompile(
  39. + v8::Local<v8::Context> context,
  40. + const char* id,
  41. + std::vector<v8::Local<v8::String>>* parameters,
  42. + Realm* optional_realm);
  43. +
  44. v8::MaybeLocal<v8::Value> CompileAndCall(v8::Local<v8::Context> context,
  45. const char* id,
  46. int argc,
  47. @@ -109,6 +115,7 @@ class NODE_EXTERN_PRIVATE BuiltinLoader {
  48. const char* id,
  49. Realm* realm);
  50. +
  51. // Returns config.gypi as a JSON string
  52. v8::Local<v8::String> GetConfigString(v8::Isolate* isolate);
  53. bool Exists(const char* id);