Type:
Module
Constants:
TYPE_VOID : Document-const

TYPE_VOID

C type - void

TYPE_VOIDP : Document-const

TYPE_VOIDP

C type - void*

TYPE_CHAR : Document-const

TYPE_CHAR

C type - char

TYPE_SHORT : Document-const

TYPE_SHORT

C type - short

TYPE_INT : Document-const

TYPE_INT

C type - int

TYPE_LONG : Document-const

TYPE_LONG

C type - long

TYPE_LONG_LONG : Document-const

TYPE_LONG_LONG

C type - long long

TYPE_FLOAT : Document-const

TYPE_FLOAT

C type - float

TYPE_DOUBLE : Document-const

TYPE_DOUBLE

C type - double

TYPE_SIZE_T : Document-const

TYPE_SIZE_T

C type - size_t

TYPE_SSIZE_T : Document-const

TYPE_SSIZE_T

C type - ssize_t

TYPE_PTRDIFF_T : Document-const

TYPE_PTRDIFF_T

C type - ptrdiff_t

TYPE_INTPTR_T : Document-const

TYPE_INTPTR_T

C type - intptr_t

TYPE_UINTPTR_T : Document-const

TYPE_UINTPTR_T

C type - uintptr_t

ALIGN_VOIDP : Document-const

ALIGN_VOIDP

The alignment size of a void*

ALIGN_CHAR : Document-const

ALIGN_CHAR

The alignment size of a char

ALIGN_SHORT : Document-const

ALIGN_SHORT

The alignment size of a short

ALIGN_INT : Document-const

ALIGN_INT

The alignment size of an int

ALIGN_LONG : Document-const

ALIGN_LONG

The alignment size of a long

ALIGN_LONG_LONG : Document-const

ALIGN_LONG_LONG

The alignment size of a long long

ALIGN_FLOAT : Document-const

ALIGN_FLOAT

The alignment size of a float

ALIGN_DOUBLE : Document-const

ALIGN_DOUBLE

The alignment size of a double

ALIGN_SIZE_T : Document-const

ALIGN_SIZE_T

The alignment size of a size_t

ALIGN_SSIZE_T : Document-const

ALIGN_SSIZE_T

The alignment size of a ssize_t

ALIGN_PTRDIFF_T : Document-const

ALIGN_PTRDIFF_T

The alignment size of a ptrdiff_t

ALIGN_INTPTR_T : Document-const

ALIGN_INTPTR_T

The alignment size of a intptr_t

ALIGN_UINTPTR_T : Document-const

ALIGN_UINTPTR_T

The alignment size of a uintptr_t

WINDOWS : Qtrue

Returns a boolean regarding whether the host is WIN32

SIZEOF_VOIDP : Document-const

SIZEOF_VOIDP

size of a void*

SIZEOF_CHAR : Document-const

SIZEOF_CHAR

size of a char

SIZEOF_SHORT : Document-const

SIZEOF_SHORT

size of a short

SIZEOF_INT : Document-const

SIZEOF_INT

size of an int

SIZEOF_LONG : Document-const

SIZEOF_LONG

size of a long

SIZEOF_LONG_LONG : Document-const

SIZEOF_LONG_LONG

size of a long long

SIZEOF_FLOAT : Document-const

SIZEOF_FLOAT

size of a float

SIZEOF_DOUBLE : Document-const

SIZEOF_DOUBLE

size of a double

SIZEOF_SIZE_T : Document-const

SIZEOF_SIZE_T

size of a size_t

SIZEOF_SSIZE_T : Document-const

SIZEOF_SSIZE_T

size of a ssize_t

SIZEOF_PTRDIFF_T : Document-const

SIZEOF_PTRDIFF_T

size of a ptrdiff_t

SIZEOF_INTPTR_T : Document-const

SIZEOF_INTPTR_T

size of a intptr_t

SIZEOF_UINTPTR_T : Document-const

SIZEOF_UINTPTR_T

size of a uintptr_t

RUBY_FREE : Document-const

RUBY_FREE

Address of the ruby_xfree() function

BUILD_RUBY_PLATFORM : Document-const

BUILD_RUBY_PLATFORM

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

See also RUBY_PLATFORM

RTLD_GLOBAL : Handle::RTLD_GLOBAL # :nodoc:

Add constants for backwards compat

RTLD_LAZY : Handle::RTLD_LAZY
RTLD_NOW : Handle::RTLD_NOW

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 clal 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
call
  • References/Ruby on Rails/Ruby/Classes/Fiddle/Fiddle::Function

call(*args) Instance Public methods Calls the constructed

2025-01-10 15:47:30
struct
  • References/Ruby on Rails/Ruby/Classes/Fiddle/Fiddle::Importer

struct(signature) Instance Public methods Creates a class to wrap the

2025-01-10 15:47:30
malloc
  • References/Ruby on Rails/Ruby/Classes/Fiddle/Fiddle::Pointer

Fiddle::Pointer.malloc(size, freefunc = nil) => fiddle pointer instance Class Public methods

2025-01-10 15:47:30
new
  • References/Ruby on Rails/Ruby/Classes/Fiddle/Fiddle::Handle

new(lib = nil, flags = Fiddle::RTLD_LAZY | Fiddle::RTLD_GLOBAL) Class Public methods Create

2025-01-10 15:47:30
[]=
  • References/Ruby on Rails/Ruby/Classes/Fiddle/Fiddle::Pointer

ptr[index] = int â intptr[start, length] = string or cptr or addr â string or dl_cptr or addr

2025-01-10 15:47:30
new
  • References/Ruby on Rails/Ruby/Classes/Fiddle/Fiddle::CStructEntity

new(addr, types, func = nil) Class Public methods Wraps the

2025-01-10 15:47:30
parse_struct_signature
  • References/Ruby on Rails/Ruby/Classes/Fiddle/Fiddle::CParser

parse_struct_signature(signature, tymap=nil) Instance Public methods Parses

2025-01-10 15:47:30
to_i
  • References/Ruby on Rails/Ruby/Classes/Fiddle/Fiddle::Closure

to_i() Instance Public methods Returns the memory address for this closure

2025-01-10 15:47:30
to_int
  • References/Ruby on Rails/Ruby/Classes/Fiddle/Fiddle::Pointer

to_i Instance Public methods Returns the integer memory location of this pointer

2025-01-10 15:47:30
call
  • References/Ruby on Rails/Ruby/Classes/Fiddle/Fiddle::Closure/Fiddle::Closure::BlockCaller

call(*args) Instance Public methods Calls the constructed

2025-01-10 15:47:30