Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2019-04-20 16:35:27 +0300
committerJoyee Cheung <joyeec9h3@gmail.com>2020-07-18 06:02:58 +0300
commitef9964f4c183f062ca25337984a542895590141d (patch)
tree35d1b1b8bc3e4b65aa6572b6e0ab4c0ec022e97d /src/node.cc
parent404302fff5079b5d9faaecbb9a1b2de67f2d86cc (diff)
src: add an ExternalReferenceRegistry class
Add an ExternalReferenceRegistry class for registering static external references. To register the external JS to C++ references created in a binding (e.g. when a FunctionTemplate is created): - Add the binding name (same as the id used for `internalBinding()` and `NODE_MODULE_CONTEXT_AWARE_INTERNAL`) to `EXTERNAL_REFERENCE_BINDING_LIST` in `src/node_external_reference.h`. - In the file where the binding is implemented, create a registration function to register the static C++ references (e.g. the C++ functions in `v8::FunctionCallback` associated with the function templates), like this: ```c++ void RegisterExternalReferences( ExternalReferenceRegistry* registry) { registry->Register(cpp_func_1); } ``` - At the end of the file where `NODE_MODULE_CONTEXT_AWARE_INTERNAL` is also usually called, register the registration function with ``` NODE_MODULE_EXTERNAL_REFERENCE(binding_name, RegisterExternalReferences); ``` PR-URL: https://github.com/nodejs/node/pull/32984 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Diffstat (limited to 'src/node.cc')
-rw-r--r--src/node.cc1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/node.cc b/src/node.cc
index eabee549a68..e27edec0efe 100644
--- a/src/node.cc
+++ b/src/node.cc
@@ -1069,6 +1069,7 @@ int Start(int argc, char** argv) {
if (blob != nullptr) {
// TODO(joyeecheung): collect external references and set it in
// params.external_references.
+ external_references = NodeMainInstance::CollectExternalReferences();
external_references.push_back(reinterpret_cast<intptr_t>(nullptr));
params.external_references = external_references.data();
params.snapshot_blob = blob;