# ffi-1.0.11 Documentation

ruby-ffi

    by Wayne Meissner
    http://wiki.github.com/ffi/ffi

## DESCRIPTION:

Ruby-FFI is a ruby extension for programmatically loading dynamic libraries, binding functions within them, and calling those functions from Ruby code. Moreover, a Ruby-FFI extension works without changes on Ruby and JRuby. Discover why should you write your next extension using Ruby-FFI here.

## FEATURES/PROBLEMS:

- It has a very intuitive DSL

- It supports all C native types

- It supports C structs (also nested), enums and global variables

- It supports callbacks

- It has smart methods to handle memory management of pointers and structs

## SYNOPSIS:

    require 'ffi'

    module MyLib
      extend FFI::Library
      ffi_lib 'c'
      attach_function :puts, [ :string ], :int
    end

    MyLib.puts 'Hello boys using libc!'

For less minimalistic and more sane examples you may look at:

- the samples/ folder

- the examples on the wiki

- the projects using FFI listed on this page

## REQUIREMENTS:

- You need a sane building environment in order to compile the extension.

## DOWNLOAD/INSTALL:

From rubyforge:

    [sudo] gem install ffi

or from the git repository on github:

    git clone git://github.com/ffi/ffi.git
    cd ffi
    rake gem:install

## CREDITS:

Special thanks to:

- Yehuda Katz

- Luc Heinrich

- Andrea Fazzi

- Mike Dalessio

- Hongli Lai

- Evan Phoenix

- Aman Gupta

- Beoran

## LICENSE:

See LICENSE file.

## Files

- History.txt
- README.rdoc

## Classes/Modules

- FFI
- FFI::AutoPointer
- FFI::AutoPointer::CallableReleaser
- FFI::AutoPointer::DefaultReleaser
- FFI::AutoPointer::Releaser
- FFI::ConstGenerator
- FFI::ConstGenerator::Constant
- FFI::Enum
- FFI::Enums
- FFI::Generator
- FFI::Generator::Task
- FFI::IO
- FFI::Library
- FFI::ManagedStruct
- FFI::NotFoundError
- FFI::Platform
- FFI::PlatformError
- FFI::Pointer
- FFI::StrPtrConverter
- FFI::Struct
- FFI::Struct::ManagedStructConverter
- FFI::StructGenerator
- FFI::StructGenerator::Field
- FFI::StructLayout
- FFI::StructLayout::Enum
- FFI::StructLayout::InnerStruct
- FFI::StructLayout::Mapped
- FFI::StructLayoutBuilder
- FFI::TypesGenerator
- FFI::Union
- FFI::VariadicInvoker

## Methods

- ::add_typedef — FFI
- ::align — FFI::Struct
- ::aligned — FFI::Struct
- ::alignment — FFI::Struct
- ::auto_ptr — FFI::Struct
- ::bsd? — FFI::Platform
- ::builder — FFI::Union
- ::by_ref — FFI::Struct
- ::by_value — FFI::Struct
- ::callback — FFI::Struct
- ::enclosing_module — FFI::Struct
- ::errno — FFI
- ::errno= — FFI
- ::extended — FFI::Library
- ::find_field_type — FFI::Struct
- ::find_type — FFI::Struct
- ::find_type — FFI
- ::for_fd — FFI::IO
- ::from_native — FFI::AutoPointer
- ::from_native — FFI::StrPtrConverter
- ::generate — FFI::TypesGenerator
- ::in — FFI::Struct
- ::layout — FFI::Struct
- ::mac? — FFI::Platform
- ::map_library_name — FFI
- ::members — FFI::Struct
- ::native_read — FFI::IO
- ::native_type — FFI::AutoPointer
- ::new — FFI::StructGenerator::Field
- ::new — FFI::ManagedStruct
- ::new — FFI::Generator
- ::new — FFI::ConstGenerator::Constant
- ::new — FFI::NotFoundError
- ::new — FFI::StructGenerator
- ::new — FFI::ConstGenerator
- ::new — FFI::StructLayoutBuilder
- ::new — FFI::Struct::ManagedStructConverter
- ::new — FFI::Enum
- ::new — FFI::Enums
- ::new — FFI::AutoPointer::Releaser
- ::new — FFI::StructLayout::Mapped
- ::new — FFI::AutoPointer
- ::new — FFI::Generator::Task
- ::offset_of — FFI::Struct
- ::offsets — FFI::Struct
- ::options — FFI::ConstGenerator
- ::options — FFI::StructGenerator
- ::options= — FFI::StructGenerator
- ::options= — FFI::ConstGenerator
- ::out — FFI::Struct
- ::pack — FFI::Struct
- ::packed — FFI::Struct
- ::ptr — FFI::Struct
- ::size — FFI::Struct
- ::size — FFI::Pointer
- ::size= — FFI::Struct
- ::type_size — FFI
- ::typedef — FFI
- ::unix? — FFI::Platform
- ::val — FFI::Struct
- ::windows? — FFI::Platform
- #<< — FFI::Enums
- #[] — FFI::Enum
- #[] — FFI::ConstGenerator
- #__map_symbol — FFI::Enums
- #add — FFI::StructLayoutBuilder
- #add_array — FFI::StructLayoutBuilder
- #add_field — FFI::StructLayoutBuilder
- #add_struct — FFI::StructLayoutBuilder
- #align — FFI::Struct
- #alignment — FFI::Struct
- #alignment= — FFI::StructLayoutBuilder
- #attach — FFI::VariadicInvoker
- #attach_function — FFI::Library
- #attach_variable — FFI::Library
- #autorelease= — FFI::AutoPointer
- #autorelease= — FFI::AutoPointer::Releaser
- #build — FFI::StructLayoutBuilder
- #calculate — FFI::StructGenerator
- #calculate — FFI::ConstGenerator
- #call — FFI::VariadicInvoker
- #call — FFI::AutoPointer::Releaser
- #callback — FFI::Library
- #clear — FFI::Struct
- #const — FFI::ConstGenerator
- #constants — FFI::Generator
- #converted_value — FFI::ConstGenerator::Constant
- #dump_config — FFI::StructGenerator
- #dump_constants — FFI::ConstGenerator
- #enum — FFI::Library
- #enum_type — FFI::Library
- #enum_value — FFI::Library
- #ffi_convention — FFI::Library
- #ffi_lib — FFI::Library
- #ffi_lib_flags — FFI::Library
- #ffi_libraries — FFI::Library
- #field — FFI::StructGenerator
- #find — FFI::Enum
- #find — FFI::Enums
- #find_type — FFI::Library
- #found? — FFI::StructGenerator
- #free — FFI::AutoPointer
- #free — FFI::AutoPointer::Releaser
- #from_native — FFI::Enum
- #from_native — FFI::Struct::ManagedStructConverter
- #function_names — FFI::Library
- #generate_layout — FFI::StructGenerator
- #get — FFI::StructLayout::InnerStruct
- #get — FFI::StructLayout::Enum
- #get — FFI::StructLayout::Mapped
- #get_field — FFI::StructGenerator
- #include — FFI::ConstGenerator
- #include — FFI::StructGenerator
- #init — FFI::VariadicInvoker
- #members — FFI::Struct
- #name — FFI::StructGenerator
- #native_type — FFI::Enum
- #offset= — FFI::StructGenerator::Field
- #offset_of — FFI::StructLayout
- #offset_of — FFI::Struct
- #offsets — FFI::Struct
- #offsets — FFI::StructLayout
- #packed= — FFI::StructLayoutBuilder
- #put — FFI::StructLayout::Mapped
- #put — FFI::StructLayout::Enum
- #read_array_of_type — FFI::Pointer
- #read_string — FFI::Pointer
- #read_string_length — FFI::Pointer
- #read_string_to_null — FFI::Pointer
- #release — FFI::AutoPointer::DefaultReleaser
- #release — FFI::AutoPointer::CallableReleaser
- #ruby_name — FFI::ConstGenerator::Constant
- #size — FFI::Struct
- #size= — FFI::StructLayoutBuilder
- #struct — FFI::Generator
- #symbol_map — FFI::Enum
- #symbols — FFI::Enum
- #to_config — FFI::StructGenerator::Field
- #to_h — FFI::Enum
- #to_hash — FFI::Enum
- #to_native — FFI::Enum
- #to_ptr — FFI::Struct
- #to_ruby — FFI::ConstGenerator
- #to_ruby — FFI::ConstGenerator::Constant
- #to_s — FFI::Generator
- #typedef — FFI::Library
- #union= — FFI::StructLayoutBuilder
- #union? — FFI::StructLayoutBuilder
- #values — FFI::Struct
- #write_array_of_type — FFI::Pointer
- #write_string — FFI::Pointer
- #write_string_length — FFI::Pointer

[Validate]

Generated with the Darkfish Rdoc Generator 2.