Subject:
[ruby-ffi] cannot define function pointers that take function pointer arguments in jruby struct layout
From:
Aman Gupta
Date:
9/14/09 4:28 AM
To:
ruby-ffi


I'm using ffi-swig-generator on:

typedef void (*MyCallback) (void *data);
typedef struct {
  void (*member) (MyCallback cb);
} MyStruct;

which generates:

  callback(:MyCallback, [ :pointer ], :void)
  class MyStruct < FFI::Struct
    layout(
      :member, callback([ :MyCallback ], :void)
    )
  end

This works fine on with ruby-ffi, but on jruby I get:

/custom/jruby/lib/ruby/1.8/ffi/types.rb:17:in `find_type': Unable to
resolve type 'MyCallback' (FFI::TypeError)
	from /custom/jruby/lib/ruby/1.8/ffi/library.rb:213:in `find_type'
	from /custom/jruby/lib/ruby/1.8/ffi/struct.rb:149:in `find_type'
	from /custom/jruby/lib/ruby/1.8/ffi/library.rb:148:in `callback'
	from /custom/jruby/lib/ruby/1.8/ffi/library.rb:148:in `each'
	from /custom/jruby/lib/ruby/1.8/ffi/library.rb:148:in `map'
	from /custom/jruby/lib/ruby/1.8/ffi/library.rb:148:in `callback'