caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Wrapping C++ in Ocaml?
@ 2007-01-02 10:32 Erik de Castro Lopo
  2007-01-02 13:13 ` [Caml-list] " micha
  2007-01-02 14:57 ` Dmitry Bely
  0 siblings, 2 replies; 3+ messages in thread
From: Erik de Castro Lopo @ 2007-01-02 10:32 UTC (permalink / raw)
  To: caml-list

Hi all,

I have wrapped a C library for use with Ocaml and didn't find 
the task too daunting. I have now found a C++ library that would
be useful, but the Ocaml ORA book makes no mention of wrapping
C++ libraries.

Has anyone got any experience wrapping C++ libraries in Ocaml?
Is it possible? Painful but doable? Too painful to think about?

Any pointers or advice appreciated.

Cheers,
Erik
-- 
+-----------------------------------------------------------+
  Erik de Castro Lopo
+-----------------------------------------------------------+
"I consider C++ the most significant technical hazard to the survival
of your project and do so without apologies." -- Alistair Cockburn


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] Wrapping C++ in Ocaml?
  2007-01-02 10:32 Wrapping C++ in Ocaml? Erik de Castro Lopo
@ 2007-01-02 13:13 ` micha
  2007-01-02 14:57 ` Dmitry Bely
  1 sibling, 0 replies; 3+ messages in thread
From: micha @ 2007-01-02 13:13 UTC (permalink / raw)
  To: Erik de Castro Lopo; +Cc: caml-list

Erik de Castro Lopo schrieb:
> Hi all,
>
> I have wrapped a C library for use with Ocaml and didn't find 
> the task too daunting. I have now found a C++ library that would
> be useful, but the Ocaml ORA book makes no mention of wrapping
> C++ libraries.
>
>   
you can only wrapp via C - functions

> Has anyone got any experience wrapping C++ libraries in Ocaml?
> Is it possible? Painful but doable? Too painful to think about?
>
>   
I have done it a few times, it's much typing :-)
you must write a c function for the methods of the class you want to 
wrap and give them a pointer to the c++ class, so you can call the 
method there. Often you define on the c++ side an adapter class which 
delegates method calls to the ocaml side (f.e. when wrapping events from 
and to c++/ocaml). For big libraries it's a neverending task without 
more tools.
There is the platinum framework (on sourceforge), a c++ class lib with a 
little gui. This lib compiles for win32, Linux, WinCE and qnx, I have 
done some wrapping to the gui part, together with the event handling and 
it works very nice (if you want to read it as an example).

> Any pointers or advice appreciated.
>
>   
Python, Ruby and Perl all have wrappers for QT and they use tools to 
generate the C interface I think. Maybe worth to look at...

cheers,
 Michael


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] Wrapping C++ in Ocaml?
  2007-01-02 10:32 Wrapping C++ in Ocaml? Erik de Castro Lopo
  2007-01-02 13:13 ` [Caml-list] " micha
@ 2007-01-02 14:57 ` Dmitry Bely
  1 sibling, 0 replies; 3+ messages in thread
From: Dmitry Bely @ 2007-01-02 14:57 UTC (permalink / raw)
  To: caml-list

On 1/2/07, Erik de Castro Lopo <mle+ocaml@mega-nerd.com> wrote:

> Has anyone got any experience wrapping C++ libraries in Ocaml?
> Is it possible? Painful but doable? Too painful to think about?
>
> Any pointers or advice appreciated.

Swig?

http://www.swig.org

- Dmitry Bely


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-01-02 14:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-02 10:32 Wrapping C++ in Ocaml? Erik de Castro Lopo
2007-01-02 13:13 ` [Caml-list] " micha
2007-01-02 14:57 ` Dmitry Bely

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).