From e460e14d57869c37b181f1e4839c70d8fa89ffb3 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Tue, 5 Nov 2019 22:50:24 +0100 Subject: src: allow adding linked bindings to Environment This allows manually adding linked bindings to an `Environment` instance, without having to register modules at program load in a global namespace. PR-URL: https://github.com/nodejs/node/pull/30274 Reviewed-By: Gireesh Punathil Reviewed-By: Ben Noordhuis --- src/node.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/node.h') diff --git a/src/node.h b/src/node.h index 8215552227..7602d14ed7 100644 --- a/src/node.h +++ b/src/node.h @@ -668,6 +668,17 @@ extern "C" NODE_EXTERN void node_module_register(void* mod); v8::Local module, \ v8::Local context) +// Allows embedders to add a binding to the current Environment* that can be +// accessed through process._linkedBinding() in the target Environment and all +// Worker threads that it creates. +// In each variant, the registration function needs to be usable at least for +// the time during which the Environment exists. +NODE_EXTERN void AddLinkedBinding(Environment* env, const node_module& mod); +NODE_EXTERN void AddLinkedBinding(Environment* env, + const char* name, + addon_context_register_func fn, + void* priv); + /* Called after the event loop exits but before the VM is disposed. * Callbacks are run in reverse order of registration, i.e. newest first. * -- cgit v1.2.3