Version française
Home     About     Download     Resources     Contact us    
Browse thread
Wrapping var_args, or C ... in ocaml?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Guillaume Yziquel <guillaume.yziquel@c...>
Subject: Re: [Caml-list] Wrapping var_args, or C ... in ocaml?
Richard Jones a écrit :
> On Mon, Feb 15, 2010 at 12:13:17AM +0100, Guillaume Yziquel wrote:
>> Richard Jones a écrit :
>>> On Sun, Feb 14, 2010 at 11:46:10PM +0100, Guillaume Yziquel wrote:
>
> However I'm still confused what you are trying to do here.  If you're
> trying to bind the above, maybe look first at PyCaml?

Well, somehow, PyCaml seems to never have wanted to work with me.

I tried Art Yerkes' version, Thomas Fishbacher's version, Henrik 
Stuart's version, and Yoann Padioleau's merge of these versions. Somehow 
things always seem wrong. I get a segfault with Yoann Padioleau's 
version due to the layout of the Python table function (WTF!? BTW).

So I'm rewriting a Python embedding.

http://yziquel.homelinux.org/gitweb/?p=ocaml-python.git;a=shortlog;h=refs/heads/yziquel
http://yziquel.homelinux.org/debian/pool/main/o/ocaml-python/
http://yziquel.homelinux.org/topos/api/ocaml-python/Python.html

Sample session:

> yziquel@seldon:~$ ocaml
>         Objective Caml version 3.11.1
> 
> # #use "topfind";;
> - : unit = ()
> Findlib has been successfully loaded. Additional directives:
>   #require "package";;      to load a package
>   #list;;                   to list the available packages
>   #camlp4o;;                to load camlp4 (standard syntax)
>   #camlp4r;;                to load camlp4 (revised syntax)
>   #predicates "p,q,...";;   to set these predicates
>   Topfind.reset();;         to force that packages will be reloaded
>   #thread;;                 to enable threads
> 
> - : unit = ()
> # #require "python.interpreter";;
> /usr/lib/ocaml/python: added to search path
> /usr/lib/ocaml/python/python.cma: loaded
> /usr/lib/ocaml/python/oCamlPython.cmo: loaded
> # open Python;;
> # let dolfin = Module.import "dolfin";;
> val dolfin : Python.pymodule Python.t = <abstr>
> # let dictionary = Module.get_dict dolfin;;
> val dictionary : Python.dict Python.t = <abstr>
> # let keys = Dict.keys dictionary;;
> val keys : string list Python.t = <abstr>
> # let key_list = list_from keys;;
> val key_list : string Python.t list =
>   [<abstr>; <abstr>; <abstr>; <abstr>; <abstr>; <abstr>; <abstr>; <abstr>;
>    <abstr>; <abstr>; <abstr>; <abstr>; <abstr>; <abstr>; <abstr>; <abstr>;
>    <abstr>; <abstr>; <abstr>; <abstr>; <abstr>; ...]
> # let string_list = List.map string_from key_list;;
> val string_list : string list =
>   ["restriction"; "gt"; "precedence"; "TrialFunctions"; "ale"; "as_tensor";
>    "cross"; "__path__"; "shape"; "PETScFactory"; "has_mpi"; "down_cast";
>    "differentiation"; "Mesh"; "has_scotch"; "rot"; "has_slepc"; "DOLFIN_PI";
>    "begin"; "le"; "outer"; "VectorElement"; "parameters"; "ln";
>    "uBLASVector"; "uBLASDenseMatrix"; "tr"; "Assembler"; "terminal";
>    "UnitCube"; "lt"; "CRITICAL"; "hermite"; "derivative"; "logger";
>    "uBLASDenseFactory"; "norm"; "MPI"; "info"; "triangle"; "R1"; "R2";
-- 
      Guillaume Yziquel
http://yziquel.homelinux.org/