Re: [GUI] Example: Binding C++ to Haskell using the ffi

Seth Kurtzberg <[email protected]>
Newsgroups gmane.comp.lang.haskell.ffi,gmane.comp.lang.haskell.gui
Organization M. I. S.
Message-ID <[email protected]>
The C++ compilers are all supposed to use the same name mangling scheme, which 
is part of the standard.

On Saturday 01 March 2003 03:11 pm, Daan Leijen wrote:
> On Sat, 1 Mar 2003 13:40:42 -0800 (PST), David Sankel <[email protected]> 
wrote:
> > Has any though gone into cplusplus?  If so, how would
> > it interface?  Would stubs on the c++ side be
> > generated or would it use the code directly.
>
> I think that it is in general infeasable to call c++ member
> function directly as different c++ compilers use wildly different
> calling conventions and name-mangling schemes. It makes more sense
> to call C++ via extern "C" wrappers and use foreign import ccall on
> the Haskell side.
>
> In my opinion, the 'ideal' way of interfacing to C++, or C, would
> be an adoption of H/Direct to read C or C++ header files directly
> and translating it to a default IDL specification -- one should
> than be able to augment this specification with IDL attributes,
> much like the current 'asf' files of H/Direct but probably more friendly.
> H/Direct could than generate both exern "C" wrappers and Haskell
> marshalling code at the same time.
>
> On the other hand, even though the above approach would solve all
> the interface problems once and for all, it certainly involves a
> significant amount of work to extend H/Direct with a C++ front-end and
> better asf support.
>
> All the best,
> 	Daan.
>
>
> ps. I have been experimenting with interfacing to the wxWindows
> library, a large C++ framework. I have used an existing Eiffel library
> that wrapped the C++ classes in C functions together with a small
> hand-written tool to translate their (simple) header files to Haskell
> marshalling code -- a poor-mans solution until H/Direct gets an update :-)
> It works rather well and imports 400 classes with 2500 methods with
> very reasonable type signatures. You may want to look at it to get some
> inspiration for interfacing to C++: http://wxhaskell.sourceforge.net
> It also shows how you can use polymorphism to mimic inheritance
> relationships (as described in "Calling hell from heaven and heaven
> from hell")
> pps. This is just a preview, don't expect a wxHaskell too soon, I have
> a thesis to finish in the next weeks :-)
>
> > Later,
> >
> > David J. Sankel
> > _______________________________________________
> > GUI mailing list
> > [email protected]
> > http://www.haskell.org/mailman/listinfo/gui
>
> _______________________________________________
> GUI mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/gui

-- 
Seth Kurtzberg
M. I. S. Corp.
480-661-1849
[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.