Version française
Home     About     Download     Resources     Contact us    
Browse thread
Re: [Caml-list] Calling Ocaml from Python
[ 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] Calling Ocaml from Python
On Thu, 2004-04-29 at 15:07, Max Powers wrote:
> >On Thu, 2004-04-29 at 13:49, skaller wrote:
> >
> >There is an Ocaml module in SWIG which may be useful to you.
> 
> Hmmm, forgive me if I'm totally off base with this, but I thought that SWIG 
> was used to interface a C library to other languages.

Yes.

>  I.e. I can use SWIG to 
> generate an interface to a c library so I can use that from Ocaml, rather 
> than generating an interface to expose Ocaml functions to a C (or other) 
> program. 

You can write a C wrapper for an Ocaml function in C,
and then wrap THAT using SWIG so you can call it from Python.

Writing C that wraps a simple function like

	parse_file: string -> ast

should be easy: string is the filename, and ast is 
a magical pointer to the parse tree. The wrapper would
make it a root of the Caml gc. 

You can probably do that now. Of course you won't
be able to use 'ast' to do anything, but at least
you can check you can invoke the parser on either
side of the interface without a core dump :D

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