On this page
End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
Fiddle
A libffi wrapper for Ruby.
Description
Fiddle is an extension to translate a foreign function interface (FFI) with ruby.
It wraps libffi, a popular C library which provides a portable interface that allows code written in one language to call code written in another language.
Example
Here we will use Fiddle::Function to wrap floor(3) from libm
require 'fiddle' libm = Fiddle.dlopen('/lib/libm.so.6') floor = Fiddle::Function.new( libm['floor'], [Fiddle::TYPE_DOUBLE], Fiddle::TYPE_DOUBLE ) puts floor.call(3.14159) #=> 3.0
Class methods 12
Instance methods 1
The alignment size of a char
The alignment size of a double
The alignment size of a float
The alignment size of a int16_t
The alignment size of a int32_t
The alignment size of a int64_t
The alignment size of a int8_t
The alignment size of a intptr_t
The alignment size of a long
The alignment size of a long long
The alignment size of a ptrdiff_t
The alignment size of a short
The alignment size of a size_t
The alignment size of a ssize_t
The alignment size of a uintptr_t
The alignment size of a void*
Add constants for backwards compat
size of a char
size of a const char*
size of a double
size of a float
size of an int
size of a int16_t
size of a int32_t
size of a int64_t
size of a int8_t
size of a intptr_t
size of a long
size of a long long
size of a ptrdiff_t
size of a short
size of a size_t
size of a ssize_t
size of a uintptr_t
size of a void*
C type - const char* (‘\0’ terminated const char*)
C type - double
C type - float
C type - int16_t
C type - int32_t
C type - int64_t
C type - int8_t
C type - intptr_t
C type - long long
C type - ptrdiff_t
C type - short
C type - size_t
C type - ssize_t
C type - uintptr_t
C type - …
C type - void*
Returns a boolean regarding whether the host is WIN32