1. Yosuke Onoue
  2. otypes

Wiki

Clone wiki

otypes / Home

Example

(* example.ml *)

let x = 5;;

let f x = x * 2;;

let () =
  Callback.register "x" x;
  Callback.register "f" f;;
$ ocamlopt -c example.ml
$ ocamlopt -output-obj -o example.so example.cmx
from otypes.bootstrap import make

make('example.so', 'example_module')

import example_module

x = example_module.caml_named_value('x')
print example_module.int_val(x)
f = example_module.caml_named_value('f')
y = example_module.val_int(10)
z = example_module.caml_callback(f, y)
print example_module.int_val(z)

Updated