Skip to content
On this page

End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

module · Ruby 3.0

Fiddle

1 instance methods 12 class methods

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

Example
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

Constants

ALIGN_CHAR

The alignment size of a char

ALIGN_DOUBLE

The alignment size of a double

ALIGN_FLOAT

The alignment size of a float

ALIGN_INT

The alignment size of an int

ALIGN_INT16_T

The alignment size of a int16_t

ALIGN_INT32_T

The alignment size of a int32_t

ALIGN_INT64_T

The alignment size of a int64_t

ALIGN_INT8_T

The alignment size of a int8_t

ALIGN_INTPTR_T

The alignment size of a intptr_t

ALIGN_LONG

The alignment size of a long

ALIGN_LONG_LONG

The alignment size of a long long

ALIGN_PTRDIFF_T

The alignment size of a ptrdiff_t

ALIGN_SHORT

The alignment size of a short

ALIGN_SIZE_T

The alignment size of a size_t

ALIGN_SSIZE_T

The alignment size of a ssize_t

ALIGN_UINTPTR_T

The alignment size of a uintptr_t

ALIGN_VOIDP

The alignment size of a void*

BUILD_RUBY_PLATFORM

Platform built against (i.e. “x86_64-linux”, etc.)

See also RUBY_PLATFORM

Add constants for backwards compat

No documentation available
No documentation available

RUBY_FREE

Address of the ruby_xfree() function

SIZEOF_CHAR

size of a char

SIZEOF_DOUBLE

size of a double

SIZEOF_FLOAT

size of a float

SIZEOF_INT

size of an int

SIZEOF_INT16_T

size of a int16_t

SIZEOF_INT32_T

size of a int32_t

SIZEOF_INT64_T

size of a int64_t

SIZEOF_INT8_T

size of a int8_t

SIZEOF_INTPTR_T

size of a intptr_t

SIZEOF_LONG

size of a long

SIZEOF_LONG_LONG

size of a long long

SIZEOF_PTRDIFF_T

size of a ptrdiff_t

SIZEOF_SHORT

size of a short

SIZEOF_SIZE_T

size of a size_t

SIZEOF_SSIZE_T

size of a ssize_t

SIZEOF_UINTPTR_T

size of a uintptr_t

SIZEOF_VOIDP

size of a void*

TYPE_CHAR

C type - char

TYPE_CONST_STRING

C type - const char* (‘\0’ terminated const char*)

TYPE_DOUBLE

C type - double

TYPE_FLOAT

C type - float

TYPE_INT

C type - int

TYPE_INT16_T

C type - int16_t

TYPE_INT32_T

C type - int32_t

TYPE_INT64_T

C type - int64_t

TYPE_INT8_T

C type - int8_t

TYPE_INTPTR_T

C type - intptr_t

TYPE_LONG

C type - long

TYPE_LONG_LONG

C type - long long

TYPE_PTRDIFF_T

C type - ptrdiff_t

TYPE_SHORT

C type - short

TYPE_SIZE_T

C type - size_t

TYPE_SSIZE_T

C type - ssize_t

TYPE_UINTPTR_T

C type - uintptr_t

TYPE_VOID

C type - void

TYPE_VOIDP

C type - void*

No documentation available

Returns a boolean regarding whether the host is WIN32