Browse thread
wrapping external classes
-
Alexy Khrabrov
-
Mauricio Fernandez
-
Alain Frisch
- Florent Monnier
-
Alain Frisch
-
Mauricio Fernandez
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Florent Monnier <fmonnier@l...> |
| Subject: | Re: [Caml-list] wrapping external classes |
> > (* use a destroy method explicitly if you need to make sure the > > destructor * is called --- Gc.finalise doesn't guarantee this (e.g. the > > program might * terminate before the finalisation function is executed) you can use at_exit to garanty a call before termination > If the handle is really an OCaml integer, it is not possible to attach a > finalizer to it. The finalizer could be attached to the object that > wraps the handle; but the best solution is to use custom blocks and C > finalizers in the C binding. if you are not so fluent in C/C++ there is this work-around that does work: http://www.linux-nantes.org/~fmonnier/OCaml/ocaml-wrapping-c.php#ref_finalise but indeed the classic way is to use the custom_operations struct: http://www.linux-nantes.org/~fmonnier/OCaml/ocaml-wrapping-c.php#ref_custom