Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

External nanomsg fixes #238

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,24 @@
}],
['OS=="linux" and use_system_libnanomsg=="true"', {
'include_dirs+': [
'<!@(pkg-config nanomsg --cflags-only-I | sed s/-I//g)/nanomsg || echo "")',
'<!@(pkg-config libnanomsg --cflags | sed s/-I//g || echo "")',
'<!@(pkg-config nanomsg --cflags-only-I | sed s/-I//g || echo "")'
],
'libraries': [
'<!@(pkg-config nanomsg --libs || echo "")',
'<!@(pkg-config libnanomsg --libs || echo "")',
'<!@(pkg-config nanomsg --libs || echo "")'
],
'defines': [
'SYSTEM_NANOMSG=1',
],
}],
['OS=="mac" and use_system_libnanomsg=="true"', {
'include_dirs+': [
'<!@(pkg-config libnanomsg --cflags | sed s/-I//g || echo "")',
'<!@(pkg-config nanomsg --cflags | sed s/-I//g || echo "")',
'<!@(pkg-config nanomsg --cflags | sed s/-I//g || echo "")'
],
'libraries': [
'<!@(pkg-config libnanomsg --libs || echo "")',
'<!@(pkg-config nanomsg --libs || echo "")',
'<!@(pkg-config nanomsg --libs || echo "")'
],
'defines': [
'SYSTEM_NANOMSG=1',
],
}],
['OS=="mac" and asan=="true"', {
Expand Down
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "nanomsg",
"version": "4.2.1",
"version": "4.2.4",
"description": "Node bindings for nanomsg",
"main": "lib/index.js",
"dependencies": {
"bindings": "^1.5.0",
"nan": "^2.15.0"
"nan": "^2.18.0"
},
"devDependencies": {
"buffer-alloc": "1.2.0",
Expand Down
21 changes: 20 additions & 1 deletion src/node_nanomsg.cc
Original file line number Diff line number Diff line change
@@ -1,16 +1,35 @@
#ifndef SYSTEM_NANOMSG

#include "bus.h"
#include "inproc.h"
#include "ipc.h"
#include "nn.h"
#include "pair.h"
#include "pipeline.h"
#include "poll_ctx.h"
#include "pubsub.h"
#include "reqrep.h"
#include "survey.h"
#include "tcp.h"
#include "ws.h"

#else

#include "nanomsg/bus.h"
#include "nanomsg/inproc.h"
#include "nanomsg/ipc.h"
#include "nanomsg/nn.h"
#include "nanomsg/pair.h"
#include "nanomsg/pipeline.h"
#include "nanomsg/pubsub.h"
#include "nanomsg/reqrep.h"
#include "nanomsg/survey.h"
#include "nanomsg/tcp.h"
#include "nanomsg/ws.h"

#endif

#include "poll_ctx.h"

NAN_METHOD(Socket) {
int domain = Nan::To<int>(info[0]).FromJust();
int protocol = Nan::To<int>(info[1]).FromJust();
Expand Down
14 changes: 11 additions & 3 deletions src/poll_ctx.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#ifndef SYSTEM_NANOMSG
#include "nn.h"
#else
#include "nanomsg/nn.h"
#endif
#include "poll_ctx.h"

void PollCtx::on_readable(uv_poll_t* req, int /* status */, int events) {
Expand Down Expand Up @@ -37,8 +41,12 @@ v8::Local<v8::Value> PollCtx::WrapPointer (void* ptr, size_t length) {
PollCtx* PollCtx::UnwrapPointer (v8::Local<v8::Value> buffer) {
v8::Local<v8::ArrayBufferView> ui = buffer.As<v8::ArrayBufferView>();
v8::Local<v8::ArrayBuffer> abuf = ui->Buffer();
std::shared_ptr<v8::BackingStore> ab_c = abuf->GetBackingStore();
void *data = NULL;
#if (V8_MAJOR_VERSION >= 8)
data = static_cast<char*>(abuf->GetBackingStore()->Data());
abuf->Detach();
return reinterpret_cast<PollCtx*>(node::Buffer::HasInstance(buffer) ?
static_cast<char*>(ab_c->Data()) : NULL);
#else
data = static_cast<char*>(abuf->GetContents().Data());
#endif
return reinterpret_cast<PollCtx*>(node::Buffer::HasInstance(buffer) ? data : NULL);
}