Browse thread
[Caml-list] interfacing with C++
- Sylvain Kerjean
[
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: | Sylvain Kerjean <skerjean@i...> |
| Subject: | [Caml-list] interfacing with C++ |
let me share my experience :
believe it or not but i am able to create and manipulate windows and
menu bars under BeOS
frome OCaml :)
i modify some files in the compiler (adding some extern "C" stuff in
mlvalues.h etc)
i recompile my ocaml compiler , all is ok.
I compile the following files with the good options, all works well.
When i run my programs all is ok except that i get some seg fault when
my programs create lots of new instances.
Maybe it comes from the register_global_root ?
Any idea ?
i have two files one in C++ , one in ocaml (here are only the
skeletons):
file.ml
------------
type b ;; (* abstract type representing value encapsulating pointer to a
C++ instance*)
external be : unit -> b = "be"
class cl =
object
val interne = be ()
end;;
file.c++
-------------
extern "C" {
value be(value unit);
}
value be(value unit) {
CAMLparam1(unit);
CAMLlocal1(be);
be = alloc(1, Abstract_tag);
register_global_root(&be);
Store_field(be, 0, (value) new CL());
CAMLreturn(be)
}
--
Sylvain Kerjean
IRISA-INRIA, Campus de Beaulieu, 35042 Rennes cedex, France
Tél: +33 (0) 2 99 84 75 99, Fax: +33 (0) 2 99 84 71 71
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr