From accab383a1e4f3aaa2d0b67a9c4abf37602a5e88 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Tue, 28 Sep 2021 16:02:53 +0800 Subject: [PATCH] src: register external references in os bindings PR-URL: https://github.com/nodejs/node/pull/40239 Refs: https://github.com/nodejs/node/pull/38905 Refs: https://github.com/nodejs/node/issues/37476 Reviewed-By: Anna Henningsen Reviewed-By: Minwoo Jung Reviewed-By: James M Snell --- src/node_crypto.cc | 1 - src/node_external_reference.h | 1 + src/node_os.cc | 17 +++++++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 8563b14036c2af..267705b7cbd4c3 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -32,7 +32,6 @@ namespace node { using v8::Context; using v8::Local; using v8::Object; -using v8::TryCatch; using v8::Value; namespace crypto { diff --git a/src/node_external_reference.h b/src/node_external_reference.h index 7da15290a15e67..445ca19f3fbcf2 100644 --- a/src/node_external_reference.h +++ b/src/node_external_reference.h @@ -62,6 +62,7 @@ class ExternalReferenceRegistry { V(heap_utils) \ V(messaging) \ V(native_module) \ + V(os) \ V(performance) \ V(process_methods) \ V(process_object) \ diff --git a/src/node_os.cc b/src/node_os.cc index 2bbb56aabfcb83..046a6106ccd0e5 100644 --- a/src/node_os.cc +++ b/src/node_os.cc @@ -20,6 +20,7 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. #include "env-inl.h" +#include "node_external_reference.h" #include "string_bytes.h" #ifdef __MINGW32__ @@ -398,7 +399,23 @@ void Initialize(Local target, Boolean::New(env->isolate(), IsBigEndian())).Check(); } +void RegisterExternalReferences(ExternalReferenceRegistry* registry) { + registry->Register(GetHostname); + registry->Register(GetLoadAvg); + registry->Register(GetUptime); + registry->Register(GetTotalMemory); + registry->Register(GetFreeMemory); + registry->Register(GetCPUInfo); + registry->Register(GetInterfaceAddresses); + registry->Register(GetHomeDirectory); + registry->Register(GetUserInfo); + registry->Register(SetPriority); + registry->Register(GetPriority); + registry->Register(GetOSInformation); +} + } // namespace os } // namespace node NODE_MODULE_CONTEXT_AWARE_INTERNAL(os, node::os::Initialize) +NODE_MODULE_EXTERNAL_REFERENCE(os, node::os::RegisterExternalReferences)