Greetings Rubyists.
The JRuby team is proud to announce the release of 0.2.0 of FFI for
Ruby. This release is compatible with the FFI implementation released
in JRuby 1.1.6
Get it via ‘gem install ffi’ or download the source and/or gem files
from the project page at http://kenai.com/projects/ruby-ffi
Special thanks to:
Yehuda K.
Luc Heinrich
Andrea F.
Mike D.
Hongli L.
Highlights of changes since 0.1.1:
-
About 25% faster function invocation. This is probably not that
important, since as soon as you start putting significant ruby code
around any native call, the native call overhead becomes a bit of a
wash. Still, the first thing people do is benchmarks, so speeding it
up a bit was probably worth it. -
type definitions for size_t, ssize_t, etc autogenerated when ffi gem
is installed. -
variadic function support (from Luc H. [email protected])
-
nil can be passed as a string argument (from Luc H.
[email protected]) -
FFI libraries can now be mixed in to other modules. (from Luc
Heinrich [email protected]) -
uses system libffi if it is new enough. This really only works
under very recent linux distributions and libffi from macports. -
Better library name mangling. Now when an absolute path is set as
ffi_lib, no name mangling occurs. Also on Linux, if you request ‘c’
or ‘libc.so’ as the library, it is converted into ‘libc.so.6’ -
Multiple libraries can be specified. This is once again, useful on
linux, where you have to specify the exact version of a library, but
you want it to work on other platforms too. e.g. ffi_lib ‘ncurses’,
‘libncurses.so.5’ -
Many, many more specs. Most specs now run against the included
libtest native library. It is still a long way from 100% test
coverage, but its better than 0.1 was. -
Better tainted string handling. All strings originating in native
code - i.e. returned from a function, or obtained from a pointer or
buffer via get_string() are tainted. If a tainted string is passed to
a native function, an error is raised. -
automatic Struct layout. This means you can specify the layout as
an array of name, type pairs and the offset and size will be
automatically calculated. -
Fixed specs and rbxspecs rake targets (Patch from Hongli L.
[email protected]) -
FFI.errno will now return the errno set by the last native function
call -
Memory allocated for Buffer and MemoryPointer is guaranteed to be at
least 8 byte aligned. -
Integer types are all range checked. i.e. if you try and pass a
value > 127 as a :char parameter, it will raise an error. -
Add compat.h header to deal with ancient (i.e. < 1.8.6) versions of
ruby -
Add missing :float and :double Struct member support (Patch from
Andrea F. [email protected]) -
Reworked get_string and put_string to only handle NUL terminated ascii
strings, and create get_bytes/put_bytes for binary data. -
Per-module/library type definitions/aliases.
-
Custom managment of Pointer & Struct lifecycle (from Mike D.)
-
Library handle caching (from Luc H. [email protected])