From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 9DF637F8E8 for ; Thu, 22 May 2014 10:25:08 +0200 (CEST) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of yallop@gmail.com) identity=pra; client-ip=209.85.216.171; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="yallop@gmail.com"; x-sender="yallop@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of yallop@gmail.com designates 209.85.216.171 as permitted sender) identity=mailfrom; client-ip=209.85.216.171; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="yallop@gmail.com"; x-sender="yallop@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-qc0-f171.google.com) identity=helo; client-ip=209.85.216.171; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="yallop@gmail.com"; x-sender="postmaster@mail-qc0-f171.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AuABADS0fVPRVdirlGdsb2JhbABZg1tYgmnCOAgWDgEBAQEHCwsJEiqCTwQZARseAxIQDwImAiQBEQEFASIBiD4BAxENpHOMEYFygw2ZOgoZJw1khUgRAQEEDIEekCCBSwSZcJE0GCmEaTww X-IPAS-Result: AuABADS0fVPRVdirlGdsb2JhbABZg1tYgmnCOAgWDgEBAQEHCwsJEiqCTwQZARseAxIQDwImAiQBEQEFASIBiD4BAxENpHOMEYFygw2ZOgoZJw1khUgRAQEEDIEekCCBSwSZcJE0GCmEaTww X-IronPort-AV: E=Sophos;i="4.98,885,1392159600"; d="scan'208";a="63123858" Received: from mail-qc0-f171.google.com ([209.85.216.171]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 22 May 2014 10:24:40 +0200 Received: by mail-qc0-f171.google.com with SMTP id x13so5116148qcv.2 for ; Thu, 22 May 2014 01:24:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=ILaMYH0EiPPioFmOGmGIC6OOW919I0ctYGfJo2b9vX0=; b=cevMEwICDsqCCEOuXxeORSkg+hWaIggbGVgpMcpaPJlWUYUXSgDp0G1mTbbOT8VV4f x774esvj1rIAuDaclk/h/cM5WpSYQpglHttHn0UEchy0CfjXdZDxB7HPBd+ZEYD5oPTV wo0rB3o+w6DRebCVfQ4Lnz/t8jHc9/FetxO8U2T0ITcnmYxCjqlysEXPYHmrCC5py3S4 ZoaZQNzHmUuXcyin0UDBjMxr4tB3PYFsaGpEiGz748QGYRtukcACL24jKTreQifYyeID 2kqz4sDeU/8cempuEP15k6pmU74i1b2Z8aVM5bnmKWQ6XWDeEDabDOKPDPkpGgCv37or ipbA== MIME-Version: 1.0 X-Received: by 10.229.125.130 with SMTP id y2mr11230245qcr.22.1400747079035; Thu, 22 May 2014 01:24:39 -0700 (PDT) Received: by 10.96.189.225 with HTTP; Thu, 22 May 2014 01:24:38 -0700 (PDT) Date: Thu, 22 May 2014 09:24:38 +0100 Message-ID: From: Jeremy Yallop To: Caml List , ctypes@lists.ocaml.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Caml-list] ANN: ocaml-ctypes 0.3 I'm pleased to announce the release of ocaml-ctypes 0.3, which is now available on OPAM and for download from GitHub: https://github.com/ocamllabs/ocaml-ctypes/releases/ The ocaml-ctypes library makes it possible to call C functions directly from OCaml without writing any C code. For example, you can bind C's "puts" function by supplying its name and type: # let puts =3D foreign "puts" (string @-> returning int);; val puts : string -> int =3D You can then call the function immediately: # puts "Hello, world!";; Hello, world! - : int =3D 14 This is a simple example, but you can use the library to describe most standard C types -- scalars, functions, structs, unions, arrays, and pointers to values and functions -- making it possible to bind and call almost any C function without leaving OCaml. The ocaml-ctypes 0.1 release was announced on caml-list last summer: https://sympa.inria.fr/sympa/arc/caml-list/2013-06/msg00046.html Since then the library has acquired a number of new features, including * Stub generation for functions. In addition to the dynamic binding mode illustrated with "puts" above, ocaml-ctypes now supports generating stub code which can be statically linked into your program. The interface for stub generation is close to the existing interface for dynamic binding, so it should be easy to adapt existing code that uses ctypes to use stub generation. The pull request that introduced stub generation describes the interface: https://github.com/ocamllabs/ocaml-ctypes/pull/129 The release notes link to a number of examples: https://github.com/ocamllabs/ocaml-ctypes/releases/tag/ocaml-ctypes-0.3 * Support for inverse stub generation. Stub generation can also operate in reverse, turning OCaml code into a shared library that can be used from C. There is an example available which exposes a simple subset of Xmlm's XML-parsing API to C (all without actually writing any C, of course): https://github.com/yallop/ocaml-ctypes-inverted-stubs-example/ * Support for bigarrays. * Support for passing OCaml strings directly to C. (Patch by Peter Zotov.) * Top-level printing for C types and values: you can now build a representation of a C type or a value and see its C printed form: # void @-> returning (ptr (array 10 (funptr (void @-> returning char)))= );; - : (unit -> (unit -> char) carray ptr) fn =3D char(*(*(void))[10])(voi= d) # struct_value ;; - : (s, [ `Struct ]) structured =3D { i =3D 10, d =3D 3.5 } The release notes for this release and for ocaml-ctypes 0.2 list a number of other newly-available features. There is also one backwards-incompatible change: what was previously the Ctypes.Array module is now called Ctypes.CArray. I'm grateful to the following people for contributions to the 0.2 and 0.3 releases: Daniel B=C3=BCnzli Ivan Gotovchits Rob Hoes Anil Madhavapeddy Mike McClurg Greg Perkins David Sheets Peter Zotov Jeremy.