# Ffi-swig-generator 0.2.1

**URL:** <https://www.ruby-forum.com/t/ffi-swig-generator-0-2-1/162343>\
**Category:** Ruby\
**Created:** [March 9, 2009, 12:26am UTC](https://www.ruby-forum.com/t/ffi-swig-generator-0-2-1/162343 "2009-03-09T00:26:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![gendag](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/f04885/32.png) [@gendag](https://www.ruby-forum.com/u/gendag)\
**Post date:** [March 9, 2009, 12:26am UTC](https://www.ruby-forum.com/t/ffi-swig-generator-0-2-1/162343/1 "2009-03-09T00:26:09Z")

</div>

ffi-swig-generator version 0.2.1  
by Andrea F.  
[http://kenai.com/projects/ruby-ffi](http://kenai.com/projects/ruby-ffi)

== DESCRIPTION

ffi-swig-generator is a ruby-ffi wrapper code generator based on SWIG  
interface files.

ffi-swig-generator is able to traverse a XML parse tree file generated  
by the +swig+ command and to produce a ruby-ffi interface file from  
it.

ffi-swig-generator is shipped with a command line tool (ffi-gen) and a  
rake  
task that automates the code generation process.

ffi-swig-generator XML capabilities are provided by nokogiri.

== CHANGES

- 1 minor enhancement
  - Removed old lib/ffi-generator.rb file.

== FEATURES

- The program is able to generate:
  - all C native types
  - #define constants
  - typedefs
  - struct, union, array and enum types
  - callbacks (pointers to functions)

- Naive indentation of the generated code

== SYNOPSIS

> From command line:

ffi-gen mylib.xml mylib.rb

> From a Rakefile:

require ‘ffi-swig-generator’  
FFI::Generator::Task.new :input\_fn =\> ‘my\_interface\_dir/\*.i’  
output\_dir =\> ‘my\_output\_dir’

== REQUIREMENTS

- rake \>= 0.8.3
- nokogiri \>= 1.1.1
- swig \>= 1.3

== DOWNLOAD

To download and install from rubygems:

[sudo] gem install ffi-swig-generator

To download the develpment trunk:

hg clone [http://kenai.com/hg/ruby-ffi~swig-generator](http://kenai.com/hg/ruby-ffi~swig-generator)

== EXAMPLES

See the examples in examples/ folder.

libc.i is an interface file containing some excerpt of libc functions.

wiiuse.i is a enough complex example of a C header file interface. It  
reproduces the content of wiiuse.h, the header file of the wiiuse  
library. wiiuse is a C library that handles the connection with  
Nintendo Wiimote devices. The interface file is almost a mere  
copy/paste from the original header file. See  
[GitHub - remogatto/ffi-wiiuse: wiiuse ruby binding using FFI](http://github.com/remogatto/ffi-wiiuse) to get updated revision of  
ffi-wiiuse library.
