Version française
Home     About     Download     Resources     Contact us    
Browse thread
libplot for OCaml?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Markus Mottl <mottl@m...>
Subject: Re: libplot for OCaml?
On Mon, 04 Dec 2000, Olivier Andrieu wrote:
> Markus Mottl writes:
>  > has anybody already considered implementing an interface to the
>  > libplot-library?
>  > [ ...]	
>  > I don't have time to do it right now, but if anybody wants to give
>  > it a try, I could imagine helping a bit. It doesn't look terribly
>  > difficult and may be a good exercise to try out camlidl...

> I had never heard of both libplot and camlidl, so your post was a
> revelation for me ! So, I tried to generate stub code for the libplot
> header with camlidl. Seems to work fine, but I have a little problem :
> some functions in libplot take FILE* arguments. Since that's not a
> `basic' type, it is not handled by camlidl. Nevertheless, I guess it
> could be possible to map an in_channel (or out_channel) CAML type to
> a FILE struct. 

Unfortunately, there does not seem to be a basic type for this in camlidl
- yet. Maybe the developers can tell us which would be the best way to
do it with camlidl?

Otherwise, it is always possible to use "c2ml" and"ml2c" for conversions.

I haven't tried it, but the following might work:

Use the conversion macros and functions defined in "byterun/io.{h,c}":

The "Channel"-macro gives you access to the C-representation of
OCaml-channels. Then you can get at the Unix file descriptor with:

  int fd = Channel(some_channel)->fd;

Now you can use "fdopen" (see man page for details):

  FILE *file = fdopen(fd, some_mode);

It doesn't look terribly difficult, but some support for this in camlidl
would be very nice! Or maybe there are already other (better) ways to do it?

Best regards,
Markus Mottl

-- 
Markus Mottl, mottl@miss.wu-wien.ac.at, http://miss.wu-wien.ac.at/~mottl