Source

opycaml /

Filename Size Date modified Message
examples
js_of_ocaml
js_of_ocaml2
oowrap
python
tests
496 B
240 B
993 B
595 B
159 B
2.6 KB
20.5 KB
741 B
2.7 KB
11.2 KB
8.7 KB
546 B
636 B
715 B
100 B
1.9 KB
552 B
337 B
720 B
6.2 KB
14.6 KB
336 B
11.1 KB
409 B
9.6 KB
3.7 KB
2.5 KB
574 B
2.8 KB
3.9 KB
11.7 KB
15.0 KB
5.8 KB
30.9 KB
9.3 KB
3.2 KB
1.9 KB
1.7 KB
332 B
( ゚∀゚)o彡°O'PyCaml

  If you do not see a For-all sign at the first line, install unicode capable fonts.

What currently you can do:

  You can call some of Python/C API functions from OCaml.

How to install:

  Read INSTALL.txt

How to use:

  test.ml is for an example.

  - api.ml provides the main Python/OCaml interface. 
    Use "open Opycaml.Api" in your OCaml programs. 
    Once opened, Python/ML API functions are available by
    Py.<Class>.<function> names. For example,

       Py.Object.repr    for   PyObject_Repr
       Py.String.check   for   PyStrnig_Check 

    You can omit Py. prefix for the module names which do not collide
    with OCaml standard library name space:

       Object.repr       for   PyObject_Repr
       (String is in OCaml standard library, so no short cut is available.)

  - Do not forget calling Base.initialize for initialization.

  - autoapi.ml is auto-created by CamlIDL. It provides almost of 
    all the available API functions in OPyCaml. Their comments are
    from Python/C API reference, which are useful to understand them.

  - api.ml extends autoapi.ml, providing things not easily done by
    CamlIDL's code generator.

  - A C function Py<Hoo>_<Bar> is mapped into an ML function Hoo.bar, 
    where the first letter of "Bar" is lowercased.

    For example:
      PyObject_Repr =>  Object.repr
      PyString_Check => String.check   
               ( Note that String module is available by Py.String )

    There is one exception: If a C function has all-capital-or-underscore
    postfix name, such as PyTuple_GET_ITEM, its ML function name is not
    first letter lowercased but is prefixed by '_':

      PyTuple_GET_ITEM => Tuple._GET_ITEM

OO Interface

    OO style interface, OOApi.ml is now also provided. This module is automatically generated from api.ml.
    See examples/testoo.ml for how to use.

    - open Opycaml.OOApi at the beginning of your module

    - The Api function calls like [Api.M.func m args] are in OO style in OOApi, [m#func args], if [m]'s an object of [M].

    - If an Api function call [Api.M.func m args] has no trivial OO style translation, i.e. if [m] is not an object of [M], [OOApi.M.func] is available.
    
    - For example,

        open Opycaml.Api

        let _ = Base.initialize ()
        ... Dict.getItemString dict "foobar" ...

      becomes as follows in OO style:

        open Opycaml.OOApi

        let _ = Base.initialize ()           (* It has no trivial OO translation. *)
        ... dict#getItemString "foobar" ...  

Js_of_ocaml Interface

    If you have js_of_ocaml installed, there is a small tool to use the syntax sugar of js_of_ocaml for Python dictionary access in OPyCaml. See js_of_ocaml directory.