With ffi-inliner you can run C code within your ruby script:
* Mix C snippets in your Ruby code and gulp it on the fly!
* It's based on Ruby-FFI so the C code you inject is portable across
  Ruby implementations!
* Yep, it means that you can run it on JRuby too!
* Fast compilation through tcc
* But it can use the system's compiler (e.g. gcc) on those platforms
  that don't support tcc (e.g. OSX) or that don't have it installed

It depends on ruby-ffi (included in tarball):

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.

* 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

Which regress depends on ruby-rake-compiler (also included):

rake-compiler aims to help Gem developers deal with Ruby extensions,
simplifying code and reducing duplication.

It follows convention over configuration and sets a standardized
structure to build and package both C and Java extensions in your gems.

This is the result of experiences dealing with several Gems that
required native extensions across platforms and different user
configurations where details like portability and clarity of code were
lacking.


The ruby-ffi regress tests don't currently work because the gem doesn't
include all necessary files, so we could drop the ruby-rake-compiler
dependency, but there's an important bugfix in the patches for
ruby-rake-compiler, and it's generally useful, so it's not a bad idea to
add it anyway.

Tested on amd64.  Looking for OKs.

Jeremy

Attachment: ruby-ffi-inliner.tar.gz
Description: application/tar-gz

Reply via email to