From 3d668262a09ef031003babc14eff9e5d4ac81698 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Thu, 29 Nov 2018 00:46:45 +0800 Subject: src: move C++ binding/addon related code into node_binding{.h, .cc} This patch: - Moves the C++ binding/addon related code out of node_internals.h/node.cc and into dedicated files node_binding.h/node_binding.cc, and only puts the code resued by other files into the header. - Introduce a node::binding namespace so that code exposed to other files can be easily recognized. PR-URL: https://github.com/nodejs/node/pull/24701 Reviewed-By: Ben Noordhuis Reviewed-By: Richard Lau --- src/node_internals.h | 112 ++------------------------------------------------- 1 file changed, 3 insertions(+), 109 deletions(-) (limited to 'src/node_internals.h') diff --git a/src/node_internals.h b/src/node_internals.h index 68c0b1f753..6cb40c9070 100644 --- a/src/node_internals.h +++ b/src/node_internals.h @@ -24,15 +24,15 @@ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS +#include "env-inl.h" #include "node.h" +#include "node_binding.h" #include "node_mutex.h" #include "node_persistent.h" +#include "tracing/trace_event.h" #include "util-inl.h" -#include "env-inl.h" #include "uv.h" #include "v8.h" -#include "tracing/trace_event.h" -#include "node_api.h" #include #include @@ -57,12 +57,6 @@ #define Z_MAX_LEVEL 9 #define Z_DEFAULT_LEVEL Z_DEFAULT_COMPRESSION -enum { - NM_F_BUILTIN = 1 << 0, - NM_F_LINKED = 1 << 1, - NM_F_INTERNAL = 1 << 2, -}; - struct sockaddr; // Variation on NODE_DEFINE_CONSTANT that sets a String value. @@ -83,92 +77,6 @@ struct sockaddr; constant_attributes).FromJust(); \ } while (0) - -#if HAVE_OPENSSL -#define NODE_BUILTIN_OPENSSL_MODULES(V) V(crypto) V(tls_wrap) -#else -#define NODE_BUILTIN_OPENSSL_MODULES(V) -#endif - -#if NODE_HAVE_I18N_SUPPORT -#define NODE_BUILTIN_ICU_MODULES(V) V(icu) -#else -#define NODE_BUILTIN_ICU_MODULES(V) -#endif - -// A list of built-in modules. In order to do module registration -// in node::Init(), need to add built-in modules in the following list. -// Then in node::RegisterBuiltinModules(), it calls modules' registration -// function. This helps the built-in modules are loaded properly when -// node is built as static library. No need to depend on the -// __attribute__((constructor)) like mechanism in GCC. -#define NODE_BUILTIN_STANDARD_MODULES(V) \ - V(async_wrap) \ - V(buffer) \ - V(cares_wrap) \ - V(config) \ - V(contextify) \ - V(domain) \ - V(fs) \ - V(fs_event_wrap) \ - V(heap_utils) \ - V(http2) \ - V(http_parser) \ - V(inspector) \ - V(js_stream) \ - V(messaging) \ - V(module_wrap) \ - V(native_module) \ - V(options) \ - V(os) \ - V(performance) \ - V(pipe_wrap) \ - V(process_wrap) \ - V(serdes) \ - V(signal_wrap) \ - V(spawn_sync) \ - V(stream_pipe) \ - V(stream_wrap) \ - V(string_decoder) \ - V(symbols) \ - V(tcp_wrap) \ - V(timers) \ - V(trace_events) \ - V(tty_wrap) \ - V(types) \ - V(udp_wrap) \ - V(url) \ - V(util) \ - V(uv) \ - V(v8) \ - V(worker) \ - V(zlib) - -#define NODE_BUILTIN_MODULES(V) \ - NODE_BUILTIN_STANDARD_MODULES(V) \ - NODE_BUILTIN_OPENSSL_MODULES(V) \ - NODE_BUILTIN_ICU_MODULES(V) - -#define NODE_MODULE_CONTEXT_AWARE_CPP(modname, regfunc, priv, flags) \ - static node::node_module _module = { \ - NODE_MODULE_VERSION, \ - flags, \ - nullptr, \ - __FILE__, \ - nullptr, \ - (node::addon_context_register_func) (regfunc), \ - NODE_STRINGIFY(modname), \ - priv, \ - nullptr \ - }; \ - void _register_ ## modname() { \ - node_module_register(&_module); \ - } - - -#define NODE_BUILTIN_MODULE_CONTEXT_AWARE(modname, regfunc) \ - NODE_MODULE_CONTEXT_AWARE_CPP(modname, regfunc, nullptr, NM_F_BUILTIN) - namespace node { namespace native_module { @@ -281,12 +189,6 @@ void SetupProcessObject(Environment* env, const std::vector& args, const std::vector& exec_args); -// Call _register functions for all of -// the built-in modules. Because built-in modules don't -// use the __attribute__((constructor)). Need to -// explicitly call the _register* functions. -void RegisterBuiltinModules(); - enum Endianness { kLittleEndian, // _Not_ LITTLE_ENDIAN, clashes with endian.h. kBigEndian @@ -782,9 +684,6 @@ static inline const char* errno_string(int errorno) { } } -#define NODE_MODULE_CONTEXT_AWARE_INTERNAL(modname, regfunc) \ - NODE_MODULE_CONTEXT_AWARE_CPP(modname, regfunc, nullptr, NM_F_INTERNAL) - #define TRACING_CATEGORY_NODE "node" #define TRACING_CATEGORY_NODE1(one) \ TRACING_CATEGORY_NODE "," \ @@ -857,11 +756,6 @@ void DefineZlibConstants(v8::Local target); } // namespace node -void napi_module_register_by_symbol(v8::Local exports, - v8::Local module, - v8::Local context, - napi_addon_register_func init); - #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS #endif // SRC_NODE_INTERNALS_H_ -- cgit v1.2.3