Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Support native extension loading on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
piscisaureus committed Oct 28, 2011
1 parent dd93c53 commit 4a1efb2
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 8 deletions.
2 changes: 2 additions & 0 deletions common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@
# ... or that C implementations shouldn't use
# POSIX names
'_CRT_NONSTDC_NO_DEPRECATE',
'BUILDING_V8_SHARED=1',
'BUILDING_UV_SHARED=1',
],
}],
[ 'OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris"', {
Expand Down
41 changes: 33 additions & 8 deletions src/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,23 @@
#ifndef SRC_NODE_H_
#define SRC_NODE_H_

#ifdef _WIN32
# ifndef BUILDING_NODE_EXTENSION
# define NODE_EXTERN __declspec(dllexport)
# else
# define NODE_EXTERN __declspec(dllimport)
# endif
#else
# define NODE_EXTERN /* nothing */
#endif

#ifdef BUILDING_NODE_EXTENSION
# undef BUILDING_V8_SHARED
# undef BUILDING_UV_SHARED
# define USING_V8_SHARED 1
# define USING_UV_SHARED 1
#endif

// This should be defined in make system.
// See issue https://github.com/joyent/node/issues/1236
#if defined(__MINGW32__) || defined(_MSC_VER)
Expand Down Expand Up @@ -196,16 +213,24 @@ node_module_struct* get_builtin_module(const char *name);
NULL, \
__FILE__

#define NODE_MODULE(modname, regfunc) \
node::node_module_struct modname ## _module = \
{ \
NODE_STANDARD_MODULE_STUFF, \
regfunc, \
NODE_STRINGIFY(modname) \
};
#ifdef _WIN32
# define NODE_MODULE_EXPORT __declspec(dllexport)
#else
# define NODE_MODULE_EXPORT /* empty */
#endif

#define NODE_MODULE(modname, regfunc) \
extern "C" { \
NODE_MODULE_EXPORT node::node_module_struct modname ## _module = \
{ \
NODE_STANDARD_MODULE_STUFF, \
regfunc, \
NODE_STRINGIFY(modname) \
}; \
}

#define NODE_MODULE_DECL(modname) \
extern node::node_module_struct modname ## _module;
extern "C" node::node_module_struct modname ## _module;

void SetErrno(uv_err_t err);
void MakeCallback(v8::Handle<v8::Object> object,
Expand Down

0 comments on commit 4a1efb2

Please sign in to comment.