Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Automatic wrapper generator
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: skaller <skaller@u...>
Subject: Re: [Caml-list] Automatic wrapper generator
On Tue, 2004-05-18 at 18:58, Richard Jones wrote:
> John,
> 
> This is of course brilliant news if it can be made to work. 

I think it can be "made" to work. By 'made' I mean: C headers
are relatively unstructured hacks, some important header
files actually contain *syntax* errors for example!

So it is to be expected the client will need to apply some
directives to guide the wrapping, so as to 'undo' the C hackery
if you like.

>  I can
> help you with testing - I've got a few different platforms around
> here.

Great! Note: there is currently no Ocaml back end.

> I'm interested to know, though: how do you deal with ownership of
> objects: eg. The struct returned from gethostbyname(3) is static and
> so shouldn't be managed/freed from OCaml; whereas getnameinfo(3)
> requires you to pass in allocated buffers and their sizes.  This
> information isn't available in the header files ...

Simple. I don't. For a low level C interface, everything
works exactly 'as if in C'. If you need to create a string
you call 'malloc' and 'strcpy', just as in C.

So, if there is a static data structure and you call
a function that returns it, you have to manage
it from Felix or Ocaml exactly as in C: don't free it
or you'll core dump.

Note that this couldn't possibly work in Ocaml except
that the garbage collector is smart and *knows* which
pointers to leave alone. Those pointers you manage
'just as you would do in C'.

-- 
John Skaller, mailto:skaller@users.sf.net
voice: 061-2-9660-0850, 
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language http://felix.sf.net



-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners