Subject: Re: [ruby-ffi] DataConverter for callback type |
From: Matijs van Zuijlen |
Date: 9/22/13 2:37 PM |
To: ruby-ffi@googlegroups.com |
I've been digging a little further, and it seems that the rbffi_Function_ForProc function defined in Function.c does exactly what I want, since I have a FFI::FunctionType (i.e., self::Callback), and a Proc (the value argument of #to_native), and I would like to turn this into a FFI::Function. Would it be possible to expose this function to Ruby? On 22/09/13 13:05, Matijs van Zuijlen wrote:
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