Subject:
[ruby-ffi] Re: long pointer
From:
Wayne Meissner
Date:
2/20/12 4:46 AM
To:
ruby-ffi@googlegroups.com

Do you mean, a C function with a signature something like:
    void foo(long *l):

In that case, the corresponding ruby-ffi would be:
module MyLib
    extend FFI::LIbrary
    ffi_lib 'mylib'
    attach_function :foo, [ :pointer ], :void
end

and you would invoke it like so:

    ptr = FFI::MemoryPointer.new(:long)
    ptr.write_long(0xdeadbeef)
    MyLib.foo(ptr);

    # now extract the value the C code filled in
    l = ptr.read_long