Skip to content

Instantly share code, notes, and snippets.

@ghaiklor
Last active August 29, 2015 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ghaiklor/f83961d73e1bca8515e3 to your computer and use it in GitHub Desktop.
Save ghaiklor/f83961d73e1bca8515e3 to your computer and use it in GitHub Desktop.
NodeJS method that registers native module
void node_module_register(void* m) {
struct node_module* mp = reinterpret_cast<struct node_module*>(m);
if (mp->nm_flags & NM_F_BUILTIN) {
mp->nm_link = modlist_builtin;
modlist_builtin = mp;
} else if (!node_is_initialized) {
// "Linked" modules are included as part of the node project.
// Like builtins they are registered *before* node::Init runs.
mp->nm_flags = NM_F_LINKED;
mp->nm_link = modlist_linked;
modlist_linked = mp;
} else {
modpending = mp;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment