[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MirageOS-devel] C++ library to OCaml: OCaml objects



On 20 Jun 2014, at 18:47, Jeremy Yallop <jeremy.yallop@xxxxxxxxxxxx> wrote:

> Hi Steven,
> 
> On 20 June 2014 16:10, Steven Luland <psxsl6@xxxxxxxxxxxxxxxx> wrote:
>> I wanted to set the type to work with the # notation that OCaml uses
> 
> I find it easier to think about this kind of thing if I separate the
> code that binds the C++ from the code that gives it a more idiomatic
> OCaml interface.  You then end up with four "layers" with
> clearly-separated responsibilities:
> 
>  (1) the C++ library itself (object-oriented C++)
>  (2) the 'extern "C"' interface (function-oriented C++)
>  (3) the ctypes bindings (function-oriented OCaml)
>  (4) the OCaml interface (object-oriented OCaml)
> 
> Here's an example to show what I mean.  First, a simple C++ library
> with a thin 'extern "C"' interface that takes "this" arguments and
> forwards calls to member functions:
> 
<snip>
> Hope that helps a bit!

This was an exceptionally useful tutorial into C++ bindings, so I've
created an issue on the Ctypes tracker to copy it in properly to the
documentation:
   https://github.com/ocamllabs/ocaml-ctypes/issues/187

If anyone has used Ctypes and C++ for any libraries that are uploaded
on GitHub, please let us know so that we can link to them as example
code.

cheers,
Anil

_______________________________________________
MirageOS-devel mailing list
MirageOS-devel@xxxxxxxxxxxxxxxxxxxx
http://lists.xenproject.org/cgi-bin/mailman/listinfo/mirageos-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.