tjfontaine / node-libclang

nodejs bindings for libclang
MIT License
52 stars 27 forks source link

Reading multiple header files for a single library #5

Open stanleygu opened 11 years ago

stanleygu commented 11 years ago

Is there support for reading multiple header files that belong to a single library? Passing in something like *.h does not seem to work.

tjfontaine commented 11 years ago

At the moment there isn't a way to specify multiple files from the command line, but you could create a header file that merely includes the headers you're interested in. find . -name \*.h -exec echo '#include "{}"' \; > libclangify.h

stanleygu commented 11 years ago

Thanks, this works, however, there is some error in the output.

assert.js:102
  throw new assert.AssertionError({
        ^
AssertionError: the field "buffer" already exists in this Struct type
    at Function.defineProperty (/Users/stanleyg/Dropbox/projects/libsbml/node_modules/ref-struct/lib/struct.js:205:3)

I have created an example gist here.

This is the library I am trying to wrap around.

I also noticed that there seems to be a type uLong that isn't caught by ffi-generate, highlighted here.

tjfontaine commented 11 years ago

in StringBuffer_t can you try renaming buffer to someBuffer and see if that solves the problem for you? I will also investigate the ulong issue.

stanleygu commented 11 years ago

That rename did the trick, now it runs into the uLong issue:

assert.js:102
  throw new assert.AssertionError({
        ^
AssertionError: Could not determine the `ffi_type` instance for type: ulong
    at Type (/Users/stanleyg/Dropbox/projects/libsbml/node_modules/ffi/lib/type.js:121:3)
tjfontaine commented 11 years ago

is there any more to that stacktrace?

stanleygu commented 11 years ago

Yes, here is the entire trace:

stanleyg$ node bindings.js
assert.js:102
  throw new assert.AssertionError({
        ^
AssertionError: Could not determine the `ffi_type` instance for type: ulong
    at Type (/Users/stanleyg/Dropbox/projects/libsbml/node_modules/ffi/lib/type.js:121:3)
    at CIF (/Users/stanleyg/Dropbox/projects/libsbml/node_modules/ffi/lib/cif.js:41:19)
    at ForeignFunction (/Users/stanleyg/Dropbox/projects/libsbml/node_modules/ffi/lib/foreign_function.js:33:13)
    at /Users/stanleyg/Dropbox/projects/libsbml/node_modules/ffi/lib/library.js:68:16
    at Array.forEach (native)
    at new Library (/Users/stanleyg/Dropbox/projects/libsbml/node_modules/ffi/lib/library.js:47:28)
    at Object.<anonymous> (/Users/stanleyg/Dropbox/projects/libsbml/bindings.js:493:19)
    at Module._compile (module.js:449:26)
    at Object.Module._extensions..js (module.js:467:10)
    at Module.load (module.js:356:32)