javascript - node ffi struct variable array -


i'm using node-ffi , have structure needs passed. few of variables in structure arrays. how define in javascript wrapper?

c header:

typedef struct {     unsigned char myuchar;     float fmyfloat;     float arrayfloat[array_size]; } smystruct; 

javascript wrapper:

var ffi = require('ffi'); var struct require('ref-struct');  var smystruct = struct({     'myuchar': 'uchar',     'fmyfloat': 'float',     'arrayfloat[array_size]': 'float'  // work?? }); 

is there tutorial indicates of variables can passed node-ffi can point me to? (for example can pass 'uchar'?)

turns out correct way declare array in struct now:

var struct require('ref-struct'); var arraytype require('ref-array');  var smystruct = struct({     'arrayfloat': arraytype('float', 10) // array of floats, length 10 }); 

i still need test bit more thoroughly, , far list of types goes found decent 1 here: https://www.npmjs.com/package/node-ffi


Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -