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:
Diffstat (limited to 'src/node.cc')
-rw-r--r--src/node.cc24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/node.cc b/src/node.cc
index 05120fbde1f..cced5e7f8f8 100644
--- a/src/node.cc
+++ b/src/node.cc
@@ -124,6 +124,16 @@ typedef int mode_t;
extern char **environ;
#endif
+// This is used to load built-in modules. Instead of using
+// __attribute__((constructor)), we call the _register_<modname>
+// function for each built-in modules explicitly in
+// node::RegisterBuiltinModules(). This is only forward declaration.
+// The definitions are in each module's implementation when calling
+// the NODE_BUILTIN_MODULE_CONTEXT_AWARE.
+#define V(modname) void _register_##modname();
+ NODE_BUILTIN_MODULES(V)
+#undef V
+
namespace node {
using v8::Array;
@@ -4305,6 +4315,9 @@ void Init(int* argc,
// Initialize prog_start_time to get relative uptime.
prog_start_time = static_cast<double>(uv_now(uv_default_loop()));
+ // Register built-in modules
+ node::RegisterBuiltinModules();
+
// Make inherited handles noninheritable.
uv_disable_stdio_inheritance();
@@ -4694,11 +4707,18 @@ int Start(int argc, char** argv) {
return exit_code;
}
+// Call built-in modules' _register_<module name> function to
+// do module registration explicitly.
+void RegisterBuiltinModules() {
+#define V(modname) _register_##modname();
+ NODE_BUILTIN_MODULES(V)
+#undef V
+}
} // namespace node
#if !HAVE_INSPECTOR
-static void InitEmptyBindings() {}
+void InitEmptyBindings() {}
-NODE_MODULE_CONTEXT_AWARE_BUILTIN(inspector, InitEmptyBindings)
+NODE_BUILTIN_MODULE_CONTEXT_AWARE(inspector, InitEmptyBindings)
#endif // !HAVE_INSPECTOR