Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with arrays of structs inside other structs #2

Open
wwwtyro opened this issue May 9, 2014 · 1 comment
Open

Issue with arrays of structs inside other structs #2

wwwtyro opened this issue May 9, 2014 · 1 comment

Comments

@wwwtyro
Copy link

wwwtyro commented May 9, 2014

Here's a reproducible example:

test.h:

typedef struct fooStruct_
{
    int bar;
} fooStruct;

typedef struct bazStruct_
{
    fooStruct  foos[2];
} bazStruct;

void someFunc(bazStruct* baz);

ffi-generate -f test.h -l foo > foo.js

foo.js:

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
@coconitro
Copy link

Running into this as well. I know this is an older ticket but OP did you ever find a work around?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants