Skip to content

Instantly share code, notes, and snippets.

@wware
Last active August 29, 2015 14:08
Show Gist options
  • Save wware/8a0d0fcd98dbbc921898 to your computer and use it in GitHub Desktop.
Save wware/8a0d0fcd98dbbc921898 to your computer and use it in GitHub Desktop.
{
"targets": [
{
"target_name": "foo",
"sources": [ "foo.cxx", "foo_wrap.cxx" ]
}
]
}
int sum(int x, int y)
{
return x + y;
}
int sum(int x, int y);
%module foo
%{
#include "foo.h"
%}
%include "foo.h"
#!/bin/sh
if [ ! -f ./build/Release/foo.node ]
then
swig -c++ -javascript -node foo.i
node-gyp clean || exit 1
node-gyp configure || exit 1
node-gyp build || exit 1
fi
node tryit.js
var foo = require('./build/Release/foo');
console.log(foo.sum(3, 4));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment