1 %module (docstring="Javascript interface to libmraa") mraa
3 %feature("autodoc", "3");
7 %array_class(uint8_t, uint8Array);
10 #include <node_buffer.h>
13 %typemap(in) (const uint8_t *data, int length) {
14 $1 = (uint8_t*) node::Buffer::Data($input);
15 $2 = node::Buffer::Length($input);
18 %typemap(in) (uint8_t *txBuf, int length) {
19 $1 = (uint8_t*) node::Buffer::Data($input);
20 $2 = node::Buffer::Length($input);
23 %typemap(in) (v8::Handle<v8::Function> func) {
24 $1 = v8::Local<v8::Function>::Cast($input);
29 %typemap(out) uint8_t*
31 %#if SWIG_V8_VERSION > 0x032872
32 $result = node::Buffer::New((char*) $1, arg3);
34 $result = node::Buffer::New((char*) $1, arg3)->handle_;
39 %newobject I2c::read(uint8_t *data, int length);
40 %newobject Spi::write(uint8_t *data, int length);
42 %typemap(in) (uint8_t *data, int length) {
44 int ecode = SWIG_AsVal_int($input, &x);
45 if (!SWIG_IsOK(ecode)) {
46 SWIG_exception_fail(SWIG_ArgError(ecode), "Expected an int");
50 SWIG_exception_fail(SWIG_ERROR, "Positive integer expected");
51 SWIGV8_RETURN(SWIGV8_UNDEFINED());
53 $1 = (uint8_t*) malloc($2 * sizeof(uint8_t));
56 %typemap(argout) (uint8_t *data, int length) {
57 if (result < 0) { /* Check for I/O error */
59 SWIG_exception_fail(SWIG_ERROR, "I2c write failed");
60 SWIGV8_RETURN(SWIGV8_UNDEFINED());
62 %#if SWIG_V8_VERSION > 0x032872
63 $result = node::Buffer::New((char*) $1, result);
65 $result = node::Buffer::New((char*) $1, result)->handle_;
73 //Adding mraa_init() to the module initialisation process