caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Gerd Stolpmann <info@gerd-stolpmann.de>
To: "Ömer Sinan Ağacan" <omeragacan@gmail.com>
Cc: OCaml Mailing List <caml-list@inria.fr>
Subject: Re: [Caml-list] any automated FFI bindings generators?
Date: Thu, 30 Jan 2014 15:13:37 +0100	[thread overview]
Message-ID: <1391091217.3822.28.camel@thinkpad> (raw)
In-Reply-To: <CAMQQO3nfqhpL+tq+tTiHaDirDL+ayP1ucodN4f3amnT5+4u+gA@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1677 bytes --]

Am Donnerstag, den 30.01.2014, 13:01 +0200 schrieb Ömer Sinan Ağacan:
> Hi all,
> 
> I want to be able to use some very big C libraries from OCaml and I
> want to automate process of writing bindings as much as possible. What
> are my options for this? Do we have any tools to generate bindings?

I ran into this question a couple of months ago. The options we have are
not really good (e.g. I tried camlidl before). Because of this I wrote
my own utility that is special-cased for my application (bindings of
gnutls):

https://godirepo.camlcity.org/wwwsvn/branches/onet4/code/tools/stubgen.ml?rev=1935&root=lib-ocamlnet2&view=auto

See here for an example how to use it:

https://godirepo.camlcity.org/wwwsvn/branches/onet4/code/src/nettls-gnutls/?root=lib-ocamlnet2

especially gnutls.descr. Basically, this a little OCaml program, and by
calling a function (called "standard") you generate a binding, e.g. 

standard "gnutls_alert_description_t gnutls_alert_get (gnutls_session_t
session)"

The syntax in the string mimicks C header declarations, and can use
special data types like ztstr (for zero-terminated string).

I haven't found time to make something more systematic out of this idea.
Currently, the strong point of this method is that it is quite easy to
adapt it to your own needs.

Gerd
-- 
------------------------------------------------------------
Gerd Stolpmann, Darmstadt, Germany    gerd@gerd-stolpmann.de
Creator of GODI and camlcity.org.
Contact details:        http://www.camlcity.org/contact.html
Company homepage:       http://www.gerd-stolpmann.de
------------------------------------------------------------

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

  reply	other threads:[~2014-01-30 14:13 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-30 11:01 Ömer Sinan Ağacan
2014-01-30 14:13 ` Gerd Stolpmann [this message]
2014-01-31  1:28 ` Francois Berenger
2014-01-31 15:22   ` Markus Weißmann
2014-01-31 15:31     ` Daniel Bünzli
2014-01-31 16:23       ` Markus Weissmann
2014-01-31  9:08 ` Adrien Nader
2014-01-31  9:12   ` Adrien Nader
2014-02-02 17:04     ` Adrien Nader
2014-01-31 15:41 ` Xavier Leroy

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=1391091217.3822.28.camel@thinkpad \
    --to=info@gerd-stolpmann.de \
    --cc=caml-list@inria.fr \
    --cc=omeragacan@gmail.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;
as well as URLs for NNTP newsgroup(s).