Subject: [ruby-ffi] DataConverter for callback type |
From: Matijs van Zuijlen |
Date: 9/22/13 6:05 AM |
To: Ruby-FFI Google Group |
Hello, I'm trying to create a DataConverter that represents a callback function. The code basically boils down to this: module Lib include FFI::Library ffi_lib 'some-library' end class Foo < Proc extend FFI::DataConverter Callback = Lib.callback ... # usual call to FFI::Library.callback def self.native_type self::Callback end end [The reason I'm doing this is that I want to wrap procs passed from ruby in some argument conversion code using a method defined on, in this case, Foo] Now, I'm unable to figure out what the definition of Foo.to_native should be. Foo::Callback is of type FFI::FunctionType, which doesn't have a to_native method. Any ideas? Thanks and regards,-- Matijs