src: add multi-context support
[platform/upstream/nodejs.git] / src / node.h
index 527ac25..00f60d3 100644 (file)
@@ -58,6 +58,7 @@
 # define SIGKILL         9
 #endif
 
+#include "v8.h"  // NOLINT(build/include_order)
 #include "node_version.h"  // NODE_MODULE_VERSION
 #include "node_object_wrap.h"
 
@@ -95,9 +96,6 @@ NODE_EXTERN v8::Handle<v8::Value> MakeCallback(
 #include "node_internals.h"
 #endif
 
-#include "uv.h"
-#include "v8.h"
-
 #include <assert.h>
 
 #ifndef NODE_STRINGIFY
@@ -185,9 +183,6 @@ NODE_EXTERN ssize_t DecodeWrite(char *buf,
                                 v8::Handle<v8::Value>,
                                 enum encoding encoding = BINARY);
 
-v8::Local<v8::Object> BuildStatsObject(const uv_stat_t* s);
-
-
 #ifdef _WIN32
 NODE_EXTERN v8::Local<v8::Value> WinapiErrnoException(int errorno,
     const char *syscall = NULL,  const char *msg = "",
@@ -197,14 +192,21 @@ NODE_EXTERN v8::Local<v8::Value> WinapiErrnoException(int errorno,
 const char *signo_string(int errorno);
 
 
-NODE_EXTERN typedef void (* addon_register_func)(
-    v8::Handle<v8::Object> exports, v8::Handle<v8::Value> module);
+NODE_EXTERN typedef void (*addon_register_func)(
+    v8::Handle<v8::Object> exports,
+    v8::Handle<v8::Value> module);
+
+NODE_EXTERN typedef void (*addon_context_register_func)(
+    v8::Handle<v8::Object> exports,
+    v8::Handle<v8::Value> module,
+    v8::Handle<v8::Context> context);
 
 struct node_module_struct {
   int version;
   void *dso_handle;
   const char *filename;
   node::addon_register_func register_func;
+  node::addon_context_register_func register_context_func;
   const char *modname;
 };
 
@@ -226,7 +228,19 @@ node_module_struct* get_builtin_module(const char *name);
     NODE_MODULE_EXPORT node::node_module_struct modname ## _module =  \
     {                                                                 \
       NODE_STANDARD_MODULE_STUFF,                                     \
-      (node::addon_register_func)regfunc,                             \
+      (node::addon_register_func) (regfunc),                          \
+      NULL,                                                           \
+      NODE_STRINGIFY(modname)                                         \
+    };                                                                \
+  }
+
+#define NODE_MODULE_CONTEXT_AWARE(modname, regfunc)                   \
+  extern "C" {                                                        \
+    NODE_MODULE_EXPORT node::node_module_struct modname ## _module =  \
+    {                                                                 \
+      NODE_STANDARD_MODULE_STUFF,                                     \
+      NULL,                                                           \
+      (regfunc),                                                      \
       NODE_STRINGIFY(modname)                                         \
     };                                                                \
   }