From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id HAA19359; Thu, 29 Apr 2004 07:33:44 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id HAA19329 for ; Thu, 29 Apr 2004 07:33:43 +0200 (MET DST) Received: from smtp3.adl2.internode.on.net (smtp3.adl2.internode.on.net [203.16.214.203]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i3T5Xejq030318 for ; Thu, 29 Apr 2004 07:33:41 +0200 Received: from [192.168.1.200] (ppp114-169.lns1.syd3.internode.on.net [150.101.114.169]) by smtp3.adl2.internode.on.net (8.12.9/8.12.9) with ESMTP id i3T5XTk2065292; Thu, 29 Apr 2004 15:03:30 +0930 (CST) Subject: Re: [Caml-list] Calling Ocaml from Python From: skaller Reply-To: skaller@users.sourceforge.net To: Max Powers Cc: caml-list In-Reply-To: References: Content-Type: text/plain Message-Id: <1083216808.9537.1289.camel@pelican.wigram> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-4) Date: 29 Apr 2004 15:33:29 +1000 Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce by Joe's j-chkmail ("http://j-chkmail.ensmp.fr")! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 python:01 sourceforge:01 2004:99 2004:99 swig:01 swig:01 python:01 9660:01 glebe:01 invoke:01 ocaml:01 ocaml:01 caml:01 nsw:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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