From 49066042a2df12b23a79fc4771f2e4324c3801df Mon Sep 17 00:00:00 2001 From: Paul Querna Date: Tue, 13 Jul 2010 00:22:33 -0700 Subject: [PATCH] Add basic structure and macros for node modules. --- src/node.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/node.h b/src/node.h index 065bf2c1fa..aec0955786 100644 --- a/src/node.h +++ b/src/node.h @@ -82,5 +82,35 @@ v8::Local ErrnoException(int errorno, const char *path = NULL); const char *signo_string(int errorno); + + +struct node_module_struct { + int version; + void *dso_handle; + const char *name; + void (*register_func) (v8::Handle target); +}; + +/** + * When this version number is changed, node.js will refuse + * to load older modules. This should be done whenever + * an API is broken in the C++ side, including in v8 or + * other dependencies + */ +#define NODE_MODULE_VERSION (1) + +#define NODE_STANDARD_MODULE_STUFF \ + NODE_MODULE_VERSION, \ + NULL, \ + __FILE__ + +#define NODE_MODULE(modname, regfunc) \ + node::node_module_struct modname ## _module = \ + { \ + NODE_STANDARD_MODULE_STUFF, \ + regfunc \ + }; + + } // namespace node #endif // SRC_NODE_H_