From 77a9907dd99785d8bfd7da3b8fe0911fcc8f5be2 Mon Sep 17 00:00:00 2001 From: Guerin Date: Tue, 31 Jan 2017 22:46:17 +0100 Subject: [PATCH] Update ocaml documentation (#885) Update ocaml simple example documentation Replaced python references by ocaml ones. --- Examples/ocaml/simple/index.html | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Examples/ocaml/simple/index.html b/Examples/ocaml/simple/index.html index dace471a3..9ae997be5 100644 --- a/Examples/ocaml/simple/index.html +++ b/Examples/ocaml/simple/index.html @@ -1,18 +1,18 @@ -SWIG:Examples:python:simple +SWIG:Examples:ocaml:simple -SWIG/Examples/python/simple/ +SWIG/Examples/ocaml/simple/
-

Simple Python Example

+

Simple Ocaml Example

-This example illustrates how you can hook Python to a very simple C program containing +This example illustrates how you can hook Ocaml to a very simple C program containing a function and a global variable.

The C Code

@@ -57,7 +57,7 @@ extern double Foo;

Compilation

    -
  1. swig -python example.i +
  2. swig -ocaml example.i

  3. Compile example_wrap.c and example.c to create the extension examplemodule.so. @@ -65,29 +65,29 @@ to create the extension examplemodule.so.

    Using the extension

    -Click here to see a script that calls our C functions from Python. +Click here to see a script that calls our C functions from Ocaml.

    Key points

      -
    • Use the import statement to load your extension module from Python. For example: +
    • Use the open statement to load your extension module from Ocaml. For example:
      -import example
      +open Example
       
      -
    • C functions work just like Python functions. For example: +
    • C functions work just like Ocaml functions. For example:
      -g = example.gcd(42,105)
      +let g = _gcd '(x,y) as int
       
      -
    • C global variables are accessed through a special variable called 'cvar'. For example: +
    • C global variable Foo is wrapped as _Foo in ocaml. For example:
      -a = example.cvar.Foo
      +let _ = Printf.printf "Foo = %f\n" (_Foo '() as float)