Bitbucket is a code hosting site with unlimited public and private repositories. We're also free for small teams!

Close
( ゚∀゚)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.



Recent activity

camlspotter

camlspotter pushed 3 commits to camlspotter/opycaml

509b1bd - cleanup after a long sleep
e51352a - added finance_demo_oo.ml which is not finished
c17957f - recovered finance_demo for python_matplotlib, but table.finance.yahoo.com is not working from 30/Dec/2013. How timely!
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.