Code Monkey home page Code Monkey logo

ffi_gen's Introduction

A generator for Ruby FFI bindings

Author: Richard Musiol Contributors: Jeremy Voorhis (thanks for the initial idea) License: MIT (see LICENSE)

Features

  • Generation of FFI methods, structures, unions, enumerations and callbacks
  • Generation of YARD documentation comments
  • Tested with headers of the following libraries:
    • Cairo
    • CEF (Chromium Embedded Framework)
    • Clang
    • LibSSH2
    • LLVM
    • OpenGL
    • SQLite3

Requirements

  • Ruby 1.9
  • Clang 3.5 or later (Download the binaries or build from source configured with --enable-shared)

These requirements are only for running the generator. The generated files are Ruby 1.8 compatible and do not need Clang.

Example

Use the following interface in a script or Rake task:

require "ffi_gen"

FFIGen.generate(
  module_name: "Clang",
  ffi_lib:     "clang",
  headers:     ["clang-c/Index.h"],
  cflags:      `llvm-config --cflags`.split(" "),
  prefixes:    ["clang_", "CX"],
  output:      "clang-c/index.rb"
)

Output: clang-c/index.rb

Other generated files can be found in the test/output directory.

Hints

You may need to set additional include directories:

export CPATH=/usr/lib/gcc/x86_64-linux-gnu/4.6.1/include

Your GCC include paths can be seen with:

`gcc -print-prog-name=cc1` -v

Projects using ffi_gen

Roadmap

  • Support for more libraries:
    • (Write me if you have a whish)
  • Automatic generation of object oriented wrappers
  • Polish YARD documentation comments some more

Feedback

Please use GitHub's issue tracker for problems or suggestions. Pull requests are welcome, too.

ffi_gen's People

Contributors

jvoorhis avatar neelance avatar novogrammer avatar postmodern avatar sheerun avatar whitequark avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

14mrh4x0r

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.