caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Alexy Khrabrov <deliverable@gmail.com>
To: caml-list@yquem.inria.fr
Subject: wrapping external classes
Date: Wed, 10 Dec 2008 21:20:41 -0500	[thread overview]
Message-ID: <8119C403-2D50-4DFA-901C-FC3F8409843E@gmail.com> (raw)

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


             reply	other threads:[~2008-12-11  2:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-11  2:20 Alexy Khrabrov [this message]
2008-12-11 10:37 ` [Caml-list] " Mauricio Fernandez
2008-12-11 15:07   ` Alain Frisch
2008-12-11 16:21     ` Florent Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8119C403-2D50-4DFA-901C-FC3F8409843E@gmail.com \
    --to=deliverable@gmail.com \
    --cc=caml-list@yquem.inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).