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=2.4 required=5.0 tests=AWL,DNS_FROM_RFC_POST, SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id D4DEFBB84 for ; Thu, 11 Dec 2008 03:20:48 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AukAAGMHQElKfVwZkGdsb2JhbACTDD4BAQEBCQkMBxEDpVuBBIw3AQMBA4MD X-IronPort-AV: E=Sophos;i="4.33,749,1220220000"; d="scan'208";a="32487540" Received: from qw-out-2122.google.com ([74.125.92.25]) by mail4-smtp-sop.national.inria.fr with ESMTP; 11 Dec 2008 03:20:48 +0100 Received: by qw-out-2122.google.com with SMTP id 9so322764qwb.15 for ; Wed, 10 Dec 2008 18:20:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:from:to :content-type:content-transfer-encoding:mime-version:subject:date :x-mailer; bh=H6RbXy2BzleGtOYDXttUzdyvfGKvpqZVfnsRRRU2/yQ=; b=Pa1oOPEc7/kpTEbEKctyBSjLjzvVzZqD5YP4YBvY4WZc/BdDuAZJo7AWQ7D7ZUoWjE AZg3voTV1ehpFiOOfa0P61Lzt9lGji+BLAW1lY7WrlRz/AOYPHYDEHoRecCO9tlM0hD3 gIOq3Qvb7VUUL0RoAV/V5u8JWo3wr2+OF3IjE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:from:to:content-type:content-transfer-encoding :mime-version:subject:date:x-mailer; b=KzZkvdobTjHdYbxhX4AX2c8joclLU1f/WOeklruRM+CvSaWrJRYvIX7+VedhVPzIfJ wNe+Ta1PxZIBlJvnY6wqz/PN/v41fVFlrwCmiYmt1TPWixJs/uuzP/bOuIImeNjHofct PLPjFjcvdQAAFq4qKPiQhOtIKny8F2YmP4/aY= Received: by 10.214.114.21 with SMTP id m21mr3016771qac.109.1228962047274; Wed, 10 Dec 2008 18:20:47 -0800 (PST) Received: from ?192.168.1.102? ([64.30.3.122]) by mx.google.com with ESMTPS id 5sm669677ywd.41.2008.12.10.18.20.45 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 10 Dec 2008 18:20:46 -0800 (PST) Message-Id: <8119C403-2D50-4DFA-901C-FC3F8409843E@gmail.com> From: Alexy Khrabrov To: caml-list@yquem.inria.fr Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v929.2) Subject: wrapping external classes Date: Wed, 10 Dec 2008 21:20:41 -0500 X-Mailer: Apple Mail (2.929.2) X-Spam: no; 0.00; ocaml:01 bindings:01 ocaml:01 cheers:01 wrote:01 integer:01 integer:01 functions:01 constructor:01 int:01 int:01 parse:02 string:02 string:02 external:03 I'm wrapping a C++ library in ocaml bindings. Originally I wrote an in-C++ object pool handler returning integer handles, and wrapped the constructor, destructor, and the main compute function in my lmclient.ml file as create, destroy, and compute functions, then declared in OCaml as external create : string -> int -> int = "lmclient_create" external destroy : int -> int = "lmclient_destroy" external compute : int -> string -> string = "lmclient_compute" I can call them as Lmclient.create, etc. The create returns an integer handle which is then used by others to compute and destroy the corresponding C++ object inside my pool manager. Now I want to avoid the explicit destroy, and want to add more methods, so I'd like to wrap these three and more into an OCaml object. How do I glue the external definitions to object methods? Apparently method external or external method doesn't parse... Cheers, Alexy