obuchtala / swig

Branch for the development of SWIG's javascript target (v8 and jsc)
https://github.com/swig/swig
Other
25 stars 14 forks source link

build node.js extensions with an 'init' symbol #8

Closed johncant closed 11 years ago

johncant commented 11 years ago

Hi guys,

thanks to @oliver---- 's gist and his code, I got my header to SWIGify then compile, but only after adding the 'init' function which the node runtime looks for.

I also added two macros, which seem to make sense given equivalent macros for other languages - are they right?

johncant commented 11 years ago

There's no way I would have understood it without your efforts.

obuchtala commented 11 years ago

Find an 'in-production' node module here https://github.com/substance/store

I fixed some stuff lately... and this is really working. (including npm setup)

obuchtala commented 11 years ago
%module redis

%header %{
#define SWIG 1

#include <jsobjects_v8.hpp>
#include <redis_error.hpp>
#include <redis_access.hpp>

using namespace jsobjects;
%}

%include <std_string.i>
%include <node.i>

%include <jsobjects.i>

/* important: declare all methods which create new instances here */
%newobject RedisAccess::Create;
%newobject RedisAccess::asList;
%newobject RedisAccess::asHash;

%include "redis_error.hpp"
%include "redis_access.hpp"

%node(redis)

Notes:

Have a look at this and provide feedback :)

johncant commented 11 years ago

You're right. I built my node module with node-waf, which is deprecated. DUH!