Commit | Line | Data |
---|---|---|
34e49164 C |
1 | open Pycaml |
2 | ||
3 | let foo_bar_print = pywrap_closure | |
4 | (fun x -> pytuple_fromarray (pytuple_toarray x)) ;; | |
5 | let sd = pyimport_getmoduledict () ;; | |
6 | let mx = pymodule_new "CamlModule" ;; | |
7 | let cd = pydict_new () ;; | |
8 | let cx = pyclass_new (pynull (), cd, pystring_fromstring "CamlClass") ;; | |
9 | let cmx = pymethod_new (foo_bar_print,(pynull ()),cx) ;; | |
10 | let _ = pydict_setitemstring (cd, "CamlMethod", cmx) ;; | |
11 | let _ = pydict_setitemstring (pymodule_getdict mx, "CamlClass", cx) ;; | |
12 | let _ = pydict_setitemstring (sd, "CamlModule", mx) ;; | |
13 | let _ = pyrun_simplestring | |
14 | ("from CamlModule import CamlClass\n" ^ | |
15 | "x = CamlClass()\n" ^ | |
16 | "for i in range(100000):\n" ^ | |
17 | " x.CamlMethod(1,2,3,4)\n") |