From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=AWL autolearn=disabled version=3.1.3 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 3EC36BC69 for ; Thu, 20 Dec 2007 17:48:12 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ah4FABwrakfAXQInh2dsb2JhbACCNY1MAgEICimBFJhb X-IronPort-AV: E=Sophos;i="4.24,190,1196636400"; d="scan'208";a="7077813" Received: from concorde.inria.fr ([192.93.2.39]) by mail3-smtp-sop.national.inria.fr with ESMTP; 20 Dec 2007 17:48:12 +0100 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id lBKGm001003420 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Thu, 20 Dec 2007 17:48:11 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ah4FAAorakfUnw6Gg2dsb2JhbACCNY1MAgEIAggiB4EUmGE X-IronPort-AV: E=Sophos;i="4.24,190,1196636400"; d="scan'208";a="5401193" Received: from pih-relay08.plus.net ([212.159.14.134]) by mail2-smtp-roc.national.inria.fr with ESMTP; 20 Dec 2007 17:48:09 +0100 Received: from [80.229.56.224] (helo=beast.local) by pih-relay08.plus.net with esmtp (Exim) id 1J5OZ4-0004iz-Qw for caml-list@inria.fr; Thu, 20 Dec 2007 16:48:07 +0000 From: Jon Harrop Organization: Flying Frog Consultancy Ltd. To: caml-list@inria.fr Subject: Easier FFI Date: Thu, 20 Dec 2007 16:39:15 +0000 User-Agent: KMail/1.9.5 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200712201639.15513.jon@ffconsultancy.com> X-Miltered: at concorde with ID 476A9CC0.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ffi:01 bindings:01 ocaml:01 bindings:01 bigarrays:01 ocaml:01 arrays:01 tweaking:01 ffi:01 stubs:01 nlffi:01 frog:98 strings:01 strings:01 annotated:02 I'm currently revisiting the topic of OpenGL bindings because I'd like to have a play with vertex and fragment shaders. Getting shaders up and running from C++ code is very easy: just a few calls and you pass your shader programs in as strings. However, I have been unable to get this working from OCaml using any of the existing OpenGL bindings (most notably GLCaml). This got me thinking about FFIs. GLCaml currently autogenerates its bindings from a custom annotated C header file. There are some aspects that I'd like to change. For example, GLCaml currently seems to use only bigarrays when strings and ordinary OCaml arrays seem preferable in several circumstances. Rather than invest time and effort into tweaking only GLCaml, I'm wondering what people's thoughts are about autogenerated FFIs for OCaml in general? For example, why can't we have a generic FFI library that allows us to use any external library (unsafely) without leaving OCaml? Then we could write or generate our bindings entirely in OCaml and forget about these C stubs. How does this relate to SML's NLFFI? -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/products/?e