From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 67C6EBBAF for ; Tue, 21 Dec 2010 20:59:07 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Au0AAJeVEE3RVaEtkGdsb2JhbACVcY4RCBYBAQEJCQwHEQQgpyWJdIIYhVIuiFcBAQMFhUQEiwKEAYIM X-IronPort-AV: E=Sophos;i="4.60,209,1291590000"; d="scan'208";a="84534667" Received: from mail-fx0-f45.google.com ([209.85.161.45]) by mail2-smtp-roc.national.inria.fr with ESMTP; 21 Dec 2010 20:59:07 +0100 Received: by fxm12 with SMTP id 12so4595869fxm.4 for ; Tue, 21 Dec 2010 11:59:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:subject :message-id:in-reply-to:references:x-mailer:mime-version :content-type:content-transfer-encoding; bh=JbnNRNxYWjJ0ScoLQQwcQtxZ4CnkzYzmYz4BhjP+LP4=; b=GAGU7xoLDcVJZXeGPxugs6CifhiggzXlijZ9XI8zVOeRiietB4932AZbzL2usoOYSP bBkljRRE2CAkzF0P8XhXsIQ/3dg2mZSZeOHIeYTD9GAgF8cHm0i1AljKFRPQE+/hvK2E P0h7SzVANlEcNTGSAXpuBdXZotbUo6I1/1t+U= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:subject:message-id:in-reply-to:references:x-mailer :mime-version:content-type:content-transfer-encoding; b=uzHHvrZpNJLcoe00DhGgbbhlcNpm/she0MlXvBn7J3RYIvSX1lA4zG5+zoFWiAxlzy kGr2qUgAQ5QJNMbKFEvM4VPsw6NdDgiqxLvUxFEesnwHovuAlqwi/aM3wN3LuIVuIvhL 6w/0MJL7T9irf3uYWUEbosQOg1JVUw7LGReX4= Received: by 10.223.72.9 with SMTP id k9mr370462faj.93.1292961545999; Tue, 21 Dec 2010 11:59:05 -0800 (PST) Received: from lemon.local.tld (176-192-132-95.pool.ukrtel.net [95.132.192.176]) by mx.google.com with ESMTPS id n2sm1461929fam.28.2010.12.21.11.59.04 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 21 Dec 2010 11:59:05 -0800 (PST) Date: Tue, 21 Dec 2010 21:59:13 +0200 From: ygrek To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] wrapping c++ Message-Id: <20101221215913.6c4a946f.ygrekheretix@gmail.com> In-Reply-To: <1F699DA2-07EB-4702-85B5-DE1716551633@gmail.com> References: <1F699DA2-07EB-4702-85B5-DE1716551633@gmail.com> X-Mailer: Sylpheed 3.0.2 (GTK+ 2.20.1; i486-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; callbacks:01 bindings:01 ocaml:01 bindings:01 non-trivial:01 lib:01 wrote:01 typing:01 caml-list:01 objects:02 blocking:04 dec:05 manual:06 probably:07 translation:07 On Mon, 20 Dec 2010 22:16:44 +0000 Joel Reymont wrote: > Are there any recipes for wrapping a large C++ class that uses callbacks? All the same as C bindings. But using C++ features one can reduce the amount of boilerplate needed. E.g. see http://ygrek.org.ua/p/code/cxx_wrapped/cxx_wrapped.h for a simple template class to wrap C++ objects as ocaml custom values (bindings to non-trivial C++ lib will probably need wrapping smart_ptr's as well). Also simple tricks like RAII for blocking_section save some typing. But all in all it is the same manual translation. -- ygrek http://ygrek.org.ua