cgen generates Haskell bindings to C++ libraries
Installation
Note: you need Haskell cabal for installing cgen.
Install from Hackage:
cabal update && cabal install cgen
Install from source:
$ git clone git://github.com/anttisalonen/cgen
$ cd cgen
$ cabal configure [--user] && cabal build && cabal install
Usage
- Write an interface file for cgen
- cgen -o c/output/dir --interface my-interface-file --include path/to/cpp/headers cpp-header1.h cpp-header2.h ...
- Write an interface file for cgen-hs
- cgen-hs -o hs/output/dir --interface my-cgen-hs-interface-file c/output/dir/*.h
Interface files for cgen
- section @exclude: List of functions to exclude - regular expressions allowed
- section @header: List of the header(s) the generated C library files should include
- section @rename: renamings of types in the generated C library. Format: oldtype|newtype
- section @exclude-class: List of classes to exclude - regular expressions allowed
- lines starting with # are comments
Example:
@exclude
^_.*
.*Listener
# This is a comment.
getErrorDescription
getSetting
@header
OGRE/Ogre.h
@rename
uint|unsigned int
ulong|unsigned long
ushort|unsigned short
# Superclass typedefs.
TransformSpace|Node::TransformSpace
DebugRenderable|Node::DebugRenderable
String|char*
@exclude-class
.*Listener
Interface files for cgen-hs
- section @exclude: List of functions to exclude - regular expressions allowed
- section @default-in: optionally list char* for treating char* as a string parameter
- lines starting with # are comments
Example:
@exclude
Ogre_Vector3_ptr1
Ogre_Vector3_ptr
.*Listener_.*
@default-in
char*
Examples
Hello world, or using cgen with a simple C++ library.
For a complete example, see hogre.
License
BSD
Authors
Antti Salonen (ajsalonen@gmail.com)