A DSL that provides the means to dynamically load libraries and build modules around them including calling extern functions within the C library that has been loaded.

Example

require 'fiddle'
require 'fiddle/import'

module LibSum
  extend Fiddle::Importer
  dlload './libsum.so'
  extern 'double sum(double*, int)'
  extern 'double split(double)'
end
Attributes
Read
No documentation available
Instance Methods

Returns the function mapped to name, that was created by either Fiddle::Importer.extern or Fiddle::Importer.bind

Creates a global method from the given C signature using the given opts as bind parameters with the given block.

Returns a new closure wrapper for the name function.

  • ctype is the return type of the function

  • argtype is an Array of arguments, passed to the callback function

  • call_type is the abi of the closure

  • block is passed to the callback

See Fiddle::Closure

Creates a class to wrap the C struct with the value ty

See also Fiddle::Importer.struct

Creates an array of handlers for the given libs, can be an instance of Fiddle::Handle, Fiddle::Importer, or will create a new instance of Fiddle::Handle using Fiddle.dlopen

Raises a DLError if the library cannot be loaded.

See Fiddle.dlopen

Creates a global method from the given C signature.

The Fiddle::CompositeHandler instance

Will raise an error if no handlers are open.

Returns a new Fiddle::Function instance at the memory address of the given name function.

Raises a DLError if the name doesn’t exist.

  • argtype is an Array of arguments, passed to the name function.

  • ctype is the return type of the function

  • call_type is the ABI of the function

See also Fiddle:Function.new

See Fiddle::CompositeHandler.sym and Fiddle::Handler.sym

Returns a new Fiddle::Pointer instance at the memory address of the given name symbol.

Raises a DLError if the name doesn’t exist.

See Fiddle::CompositeHandler.sym and Fiddle::Handle.sym

Returns a new instance of the C struct with the value ty at the addr address.

No documentation available

Returns the sizeof ty, using Fiddle::Importer.parse_ctype to determine the C type and the appropriate Fiddle constant.

Creates a class to wrap the C struct described by signature.

MyStruct = struct ['int i', 'char c']

Sets the type alias for alias_type as orig_type

Creates a class to wrap the C union described by signature.

MyUnion = union ['int i', 'char c']
An alias for create_value