Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] automated binding generation (announce: Forklift)
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2003-08-26 (00:36)
From: Jeff Henrikson <jehenrik@y...>
Subject: [Caml-list] automated binding generation (announce: Forklift)
Hi OCaml users,

Forklift is a program for generating language bindings based on C 
header files.  It is similar in concept to SWIG or CamlIDL.  Below I 
append the features and limitations from the README file.  Forklift 
originally grew out of frustration trying to write an OCaml SWIG 
language module about 18 months ago.  After 2000 lines of C for SWIG, I 
became convinced that I wasn't going to get what I wanted.  So now 
there is a new program that attempts to get what I want.  Features 
include a pleasing stub composition model for higher order type 

This is a pre-alpha release.  Your feedback is solicited.  See the 
"limitations" section for disclaimers.


Jeff Henrikson

FEATURES (aka "What makes Forklift different?")

     ->  Forklift generates foreign function interface stubs based on
         reading C header files intact, without annotation.  IDL and SWIG
         also make stubs from header files, but they do so by requiring
         inline modifications to the source code, making any stub
         preparation irrelevant when version 2.0 of the header files
         are released.  Forklift's annotations are kept as separate input

     ->  Forklift, like SWIG, works with C code stubs rather than an
         exhaustive grammar for describing every possible type.  This
         makes it more flexible and allows it to describe multiple
         representations for the same data.

     ->  Forklift requires enough structure of the C code to provide
         higher order type representations.  For example, given a way
         to convert "int" variables, one can provide an abstract
         way to convert arrays such that an int array conversion
         can be generated.

     ->  Forklift's stub algebra admits full n variables -> k variables
         transformation generality.  For example we can map an (int, 
	pair in consecutive parameters to a HLL int array, where the
	the first is taken to mean the length and the second a pointer.

     ->  Forklift provides for a rich pattern matching vocabulary, not
         simply equality matching on variable names.

     ->  Forklift generates constructors, destructors and accessors
         for data structures automatically.  A flexible set of
         options allow choices between single accessors vs bulk
	accessors, read-only vs read-write accessors, etc.  For
         languages which support finalization, finalization methods
         can be generated.

     ->  Forklift can be (and for the time being must be!) run as
         an interactive session, typically as an emacs inferior
         buffer.  Its utility functions allow the user to query the
         header files instead of reading them.  So one can ask "what
         functions pass a pointer to this structure as a first
         parameter?" and get an exhaustive list of function
         identifiers.  This saves laborious reading, copy-pasting,
         and editing.


     --  The callback module hasn't been written yet.

     --  Forklift currently only implements an Objective Caml
         language module.

     --  Forklift currently free-rides on ocaml syntax, using the
         toplevel as its interaction environment.  In the future it will
         have its own interactive language-agnostic syntax.

     --  A C preprocessor emulator is not yet written, so header files
	must be manually run through cpp.

     --  IDL orthogonality has not yet been analyzed.


         Forklift requires:

         ocaml >= 3.06, pcre, ocaml-pcre, ocaml emacs mode.

LICENSE? (from the README)


     Copyright (c) 2003 Jeff Henrikson

     This is Release 0.5.0 of Forklift, a stub generator for foreign
     function interfaces.

     License is hereby granted to use this software and distribute it
     for educational, research and nonprofit purposes, as long as this
     copyright notice is retained and modifications are clearly marked.


     N.B. A more commercially friendly license will be probably be chosen
     soon.  Maybe LGPL.  But the current distribution is probably already
     violating Freetype's license by including the headers in the way 
     they have been.  More thinking is necessary.

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: