neelance / ffi_gen

A generator for Ruby FFI bindings, directly from header files via LLVM's Clang compiler
MIT License
88 stars 26 forks source link

ncurses won't generate #22

Closed headius closed 4 years ago

headius commented 10 years ago

I'm not sure what I'm doing wrong, but I get an error while ffi-gen is trying to traverse declarations (I think). Here's my gen file:

require 'ffi/gen'

FFI::Gen.generate(
  module_name: "Ncurses",
  ffi_lib: "ncurses",
  headers: ["/usr/include/ncurses.h"],
  cflags: `/usr/local/Cellar/llvm/3.4.2/bin/llvm-config --cflags`.split(" "),
  prefixes: ["_nc_", "NCURSES_", "WA_", "COLOR_", "ACS_"],
  output: "ffi-ncurses.rb")

And here's the error I get running it:

~/projects/ffi-gen $ jruby -Ilib ncurses.rb 
TypeError: wrong argument type NilClass (expected instance of FFI::Struct)
  declarations at /Users/headius/projects/ffi-gen/lib/ffi/gen.rb:327
   generate_rb at /Users/headius/projects/ffi-gen/lib/ffi/gen/ruby_output.rb:10
        indent at /Users/headius/projects/ffi-gen/lib/ffi/gen.rb:150
   generate_rb at /Users/headius/projects/ffi-gen/lib/ffi/gen/ruby_output.rb:5
      generate at /Users/headius/projects/ffi-gen/lib/ffi/gen.rb:280
      generate at /Users/headius/projects/ffi-gen/lib/ffi/gen.rb:742
        (root) at ncurses.rb:3
sheerun commented 9 years ago

@headius I can't confirm. Could you clone current master branch and test it once more?

My setup:

RUBYLIB=$(pwd)/lib CPATH=/usr/include DYLD_LIBRARY_PATH=/Library/Developer/CommandLineTools/usr/lib ruby test.rb

Where test.rb is:

require 'ffi_gen'

FFIGen.generate(
  module_name: "Ncurses",
  ffi_lib: "ncurses",
  headers: ["/usr/include/ncurses.h"],
  cflags: `/usr/local/opt/llvm/bin/llvm-config --cflags`.split(" "),
  prefixes: ["_nc_", "NCURSES_", "WA_", "COLOR_", "ACS_"],
  output: "ffi-ncurses.rb")

I'm testing on Yosemite, all updates.

headius commented 4 years ago

Seems to get past this point fine now and fail elsewhere.