From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p06NWihX025335 for ; Fri, 7 Jan 2011 00:32:45 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Aj0FAAvfJU2uedqy/2dsb2JhbACWEI8CvTOCFoM2BIRnjDU X-IronPort-AV: E=Sophos;i="4.60,285,1291590000"; d="scan'208";a="86218430" Received: from b2.da.79ae.static.theplanet.com (HELO pse.psellos.com) ([174.121.218.178]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 07 Jan 2011 00:32:39 +0100 Received: from pse.psellos.com (localhost.localdomain [127.0.0.1]) by pse.psellos.com (8.13.8/8.13.8) with ESMTP id p06NWZjN016342 for ; Thu, 6 Jan 2011 17:32:35 -0600 Received: (from jeffsco@localhost) by pse.psellos.com (8.13.8/8.13.8/Submit) id p06NWZCF016330; Thu, 6 Jan 2011 17:32:35 -0600 To: caml-list@inria.fr References: <201101041938.p04JcS2Q003466@pse.psellos.com> <10E36BD7-F233-4D47-8B40-E145474E6132@gmail.com> From: Jeffrey Scofield Date: 06 Jan 2011 17:32:35 -0600 Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: [Caml-list] Re: Native OCaml iPhone app now in iTunes Store Joel Reymont writes: > > All the code is in OCaml; there's no ObjC except in the (thin) > > wrappers around the native iOS libraries. We wanted to write as > > much in OCaml as possible. > > How did you wrap the native libraries then? We went through a few iterations of plans for generating wrappers automatically. But we determined that automatically generated wrappers that follow Objective C idioms are too cumbersome to use from OCaml. An automatic tool is going to require a lot of human input on data structure choices, at the very least. What we did in the end was to design a basic framework with an OCaml class for each ObjC class. The method APIs use idiomatic OCaml types for values and collections. The support code uses Cocoa foundation classes to do dynamic method invocation, so the amount of ObjC code in each wrapper is kept to a minimum (typically there is none). The framework lets us build individual wrappers quickly and keeps things coherent and consistent. We code up wrappers by hand as we need them. > I've been meaning to write a Cocoa bridge for OCaml but haven't > gotten to it yet. It would be a big project. > Are your wrappers available? We'll be happy to release source to our Cocoa wrapper layer once we recoup some of our investment in it. In the meantime we can offer advice on things that worked and didn't work for us. Regards, Jeffrey