From: "Chris King" <colanderman@gmail.com>
To: "Erik de Castro Lopo" <mle+ocaml@mega-nerd.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Creating wrappers for C libraries
Date: Fri, 8 Dec 2006 01:36:44 -0500 [thread overview]
Message-ID: <875c7e070612072236s4b5e42c9qed9002c14959c409@mail.gmail.com> (raw)
In-Reply-To: <20061208155437.7ed85c4f.mle+ocaml@mega-nerd.com>
On 12/7/06, Erik de Castro Lopo <mle+ocaml@mega-nerd.com> wrote:
> I was wondering if there was any semi-automated too for creating
> Ocaml bindings for C libraries.
I recently discovered that SWIG (http://www.swig.org/) supports O'Caml
(though I haven't yet used it myself). If you're looking for speed
though it may not be the best choice since all C types are mapped to
one variant type in O'Caml. You can find O'Caml-specific docs here:
http://www.swig.org/Doc1.3/Ocaml.html
I presume you're looking to wrap libsndfile... I've wrapped a few
similar libraries manually with very few problems. The libsndfile API
looks to me like it should be fairly straightforward to wrap thanks to
O'Caml's Bigarrays (plus you'll have lots of cut & paste).
Start by writing a few simple integer, string, or array functions for
O'Caml in C to get a feel for the API without having to worry about
custom blocks and such. The curses wrapper in chapter 18 of the
O'Caml manual is also a very good starting point. The custom block
from that example can be used nearly verbatim for many C structures
(such as SNDFILE *). I can provide you with the source of a couple
other small wrappers if you like.
Hope this helps,
Chris
next prev parent reply other threads:[~2006-12-08 6:36 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-12-08 4:54 Erik de Castro Lopo
2006-12-08 6:36 ` Chris King [this message]
2006-12-08 6:45 ` Sébastien Hinderer
2006-12-08 7:08 ` [Caml-list] " Jon Harrop
2006-12-08 10:18 ` David Baelde
2006-12-08 11:08 ` Sébastien Hinderer
2006-12-08 11:41 ` [Caml-list] " Richard Jones
2006-12-08 12:00 ` Daniel Bünzli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=875c7e070612072236s4b5e42c9qed9002c14959c409@mail.gmail.com \
--to=colanderman@gmail.com \
--cc=caml-list@inria.fr \
--cc=mle+ocaml@mega-nerd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox