summaryrefslogtreecommitdiff
path: root/src/node_internals.h
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2018-11-29 00:46:45 +0800
committerRich Trott <rtrott@gmail.com>2018-11-30 20:14:24 -0800
commit3d668262a09ef031003babc14eff9e5d4ac81698 (patch)
tree90206d42148b96c3a60429315e0cd5f39140446c /src/node_internals.h
parent976065d9cb88a118c0238a8518a2570b28cce817 (diff)
downloadandroid-node-v8-3d668262a09ef031003babc14eff9e5d4ac81698.tar.gz
android-node-v8-3d668262a09ef031003babc14eff9e5d4ac81698.tar.bz2
android-node-v8-3d668262a09ef031003babc14eff9e5d4ac81698.zip
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 <info@bnoordhuis.nl> Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Diffstat (limited to 'src/node_internals.h')
-rw-r--r--src/node_internals.h112
1 files changed, 3 insertions, 109 deletions
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 <stdint.h>
#include <stdlib.h>
@@ -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<std::string>& args,
const std::vector<std::string>& exec_args);
-// Call _register<module_name> 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<v8::Object> target);
} // namespace node
-void napi_module_register_by_symbol(v8::Local<v8::Object> exports,
- v8::Local<v8::Value> module,
- v8::Local<v8::Context> context,
- napi_addon_register_func init);
-
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
#endif // SRC_NODE_INTERNALS_H_