English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
wrapping external classes
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2008-12-11 (02:20)
From: Alexy Khrabrov <deliverable@g...>
Subject: wrapping external classes
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...