expose_get_builtin_module_function.patch 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
  2. From: Thiago de Arruda <[email protected]>
  3. Date: Mon, 6 Mar 2017 10:42:34 -0300
  4. Subject: Expose `get_linked_module` function
  5. This is a requirement for electron/electron#8815, which exposes some linked
  6. modules to sandboxed renderers.
  7. TODO(codebytere): remove and replace with a public facing API.
  8. diff --git a/src/node_binding.cc b/src/node_binding.cc
  9. index c2ef9b36d5b2967c798c123b6cbbd099b15c2791..b5c0a93d83ab4d4f6792d0eb648e7198de874bcf 100644
  10. --- a/src/node_binding.cc
  11. +++ b/src/node_binding.cc
  12. @@ -653,6 +653,10 @@ void GetInternalBinding(const FunctionCallbackInfo<Value>& args) {
  13. args.GetReturnValue().Set(exports);
  14. }
  15. +node_module* get_linked_module(const char* name) {
  16. + return FindModule(modlist_linked, name, NM_F_LINKED);
  17. +}
  18. +
  19. void GetLinkedBinding(const FunctionCallbackInfo<Value>& args) {
  20. Environment* env = Environment::GetCurrent(args);
  21. diff --git a/src/node_binding.h b/src/node_binding.h
  22. index eb1364cb01a2bea52bce768056e73b0f3a86ae35..d421a2773403e7b22fcca2fcf8275ef2d9654c55 100644
  23. --- a/src/node_binding.h
  24. +++ b/src/node_binding.h
  25. @@ -146,6 +146,8 @@ void GetInternalBinding(const v8::FunctionCallbackInfo<v8::Value>& args);
  26. void GetLinkedBinding(const v8::FunctionCallbackInfo<v8::Value>& args);
  27. void DLOpen(const v8::FunctionCallbackInfo<v8::Value>& args);
  28. +NODE_EXTERN node_module* get_linked_module(const char *name);
  29. +
  30. } // namespace binding
  31. } // namespace node