Just starting to play with FFI on my Win32 box…after reading a few of
the blog posts mentioned in Charlie’s
http://blog.headius.com/2008/10/ffi-for-ruby-now-available.html post I’m
seeing that the arg order to attach_method may be different than
documented.
It appears that if you want to have a Ruby module method named
differently than the native function you need to use this format
attach_function(ruby_name, native_name, arg_types_array, return_type)
rather than first specifying the native fcn name and then the ruby name.
Did I misread the source code docs and the blogs wrt arg order? What’s
the real API that will be used by the ‘ffi’ gem as well as JRuby?
Jon
SAMPLE CODE (Win32)
require ‘ffi’
module Win32
extend FFI::Library
ffi_lib :user32
ffi_convention :stdcall
attach_function :message_box, :MessageBoxA, [ :pointer, :string,
:string, :uint ], :int
end
rc = Win32.message_box(nil, ‘Hello World!’, ‘Some Title’, 2)
puts “Return code: #{rc}”
boom…
Win32.MessageBoxA(nil, ‘Hello World Again!’, ‘Another Title’, 2)
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email