var FFI = require('ffi'),
ArrayType = require('ref-array'),
Struct = require('ref-struct'),
ref = require('ref');
var voidPtr = ref.refType(ref.types.void);
exports.CONSTANTS = {
};
var fooStruct_ = exports.fooStruct_ = ArrayType(fooStruct_, 2); // this seems broken to me
var fooStruct_Ptr = exports.fooStruct_Ptr = ref.refType(fooStruct_);
var bazStruct = exports.bazStruct = Struct({
foos: fooStruct_,
});
var bazStructPtr = exports.bazStructPtr = ref.refType(bazStruct);
exports.foo = new FFI.Library('foo', {
someFunc: [ref.types.void, [
bazStructPtr,
]],
});
node foo.js:
assert.js:92
throw new assert.AssertionError({
^
AssertionError: could not determine a proper "type" from: undefined
at Object.coerceType (/home/rye/Downloads/OculusSDK/LibOVR/Src/node_modules/ref/lib/ref.js:389:3)
at Array (/home/rye/Downloads/OculusSDK/LibOVR/Src/node_modules/ref-array/lib/array.js:20:19)
at Object.<anonymous> (/home/rye/Downloads/OculusSDK/LibOVR/Src/foo.js:11:39)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:902:3
Here's a reproducible example:
test.h:
ffi-generate -f test.h -l foo > foo.js
foo.js:
node foo.js: