Subject:
[ruby-ffi] Re: cannot define function pointers that take function pointer arguments in jruby struct layout
From:
Andrea Fazzi
Date:
9/14/09 1:35 PM
To:
ruby-ffi


Excerpts from Aman Gupta's message of lun set 14 11:28:58 +0200 2009:
> 
> 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'

Ruby-FFI support for callback parameters in callbacks was added in rev 

8d6045c2305f32929f4da5a28d28397523df0170

Maybe that JRuby still doesn't implement it?

-- Andrea Fazzi @ alca.le.it Follow me on http://twitter.com/remogatto