3 * This software is covered under the GNU lesser general public license
10 type funcent
= (funcptr
* int * int)
12 type pymodule_func
= { pyml_name
: string ;
13 pyml_func
: (pyobject
-> pyobject
) ;
33 external getfuncarray
: unit -> funcent array
= "pygetfuncarray"
34 let py_funcs = getfuncarray
()
35 external pytype
: pyobject
-> pyobject_type
= "pytype"
37 external pyfuncall1
: (funcptr
* int * int) -> unit -> unit = "pygencall"
38 external pyfuncall2
: (funcptr
* int * int) -> int -> unit = "pygencall"
39 external pyfuncall3
: (funcptr
* int * int) -> string -> unit = "pygencall"
40 external pyfuncall4
: (funcptr
* int * int) -> unit -> int = "pygencall"
41 external pyfuncall5
: (funcptr
* int * int) -> string -> int = "pygencall"
42 external pyfuncall6
: (funcptr
* int * int) -> (int * string) -> int = "pygencall"
43 external pyfuncall7
: (funcptr
* int * int) -> (int * string * int) -> int =
45 external pyfuncall8
: (funcptr
* int * int) -> unit -> string = "pygencall"
46 external pyfuncall9
: (funcptr
* int * int) -> (string * int * pyobject
* pyobject
) -> pyobject
= "pygencall"
47 external pyfuncall10
: (funcptr
* int * int) ->
48 (int * string * int * pyobject
* pyobject
) -> pyobject
= "pygencall"
49 external pyfuncall11
: (funcptr
* int * int) ->
50 (int * string * int * pyobject
* pyobject
* int) -> pyobject
= "pygencall"
51 external pyfuncall12
: (funcptr
* int * int) ->
52 (string * string * int) -> pyobject
= "pygencall"
53 external pyfuncall13
: (funcptr
* int * int) ->
54 (pyobject
* int * int) -> int = "pygencall"
55 external pyfuncall14
: (funcptr
* int * int) -> pyobject
-> pyobject
= "pygencall"
56 external pyfuncall15
: (funcptr
* int * int) -> (pyobject
* pyobject
* int) -> pyobject
= "pygencall"
57 external pyfuncall16
: (funcptr
* int * int) -> (pyobject
* string) -> pyobject
= "pygencall"
58 external pyfuncall17
: (funcptr
* int * int) -> (pyobject
* pyobject
) -> pyobject
= "pygencall"
59 external pyfuncall18
: (funcptr
* int * int) -> pyobject
-> int = "pygencall"
60 external pyfuncall19
: (funcptr
* int * int) -> (pyobject
* pyobject
) -> int = "pygencall"
61 external pyfuncall20
: (funcptr
* int * int) -> (pyobject
* pyobject
* int) -> int = "pygencall"
62 external pyfuncall21
: (funcptr
* int * int) -> (pyobject
* string * pyobject
) -> int = "pygencall"
63 external pyfuncall22
: (funcptr
* int * int) -> (pyobject
* string) -> int = "pygencall"
64 external pyfuncall23
: (funcptr
* int * int) -> (pyobject
* pyobject
) -> (pyobject
* pyobject
) option = "pygencall"
65 external pyfuncall24
: (funcptr
* int * int) -> (pyobject
* pyobject
* pyobject
) -> int = "pygencall"
66 external pyfuncall25
: (funcptr
* int * int) -> pyobject
-> int64
= "pygencall"
67 external pyfuncall26
: (funcptr
* int * int) -> pyobject
-> string = "pygencall"
68 external pyfuncall27
: (funcptr
* int * int) -> (pyobject
* pyobject
) -> pyobject
= "pygencall"
69 external pyfuncall28
: (funcptr
* int * int) -> string -> pyobject
= "pygencall"
70 external pyfuncall29
: (funcptr
* int * int) -> unit -> pyobject
= "pygencall"
71 external pyfuncall30
: (funcptr
* int * int) -> pyobject
-> unit = "pygencall"
72 external pyfuncall31
: (funcptr
* int * int) -> (pyobject
* int) ->
73 (pyobject
* pyobject
* int) option = "pygencall"
74 external pyfuncall34
: (funcptr
* int * int) -> int64
-> pyobject
= "pygencall"
75 external pyfuncall35
: (funcptr
* int * int) -> unit -> int64
= "pygencall"
76 external pyfuncall36
: (funcptr
* int * int) -> float -> pyobject
= "pygencall"
77 external pyfuncall37
: (funcptr
* int * int) -> pyobject
-> float = "pygencall"
78 external pyfuncall39
: (funcptr
* int * int) -> int -> pyobject
= "pygencall"
79 external pyfuncall40
: (funcptr
* int * int) -> (pyobject
* int) ->
80 pyobject
= "pygencall"
81 external pyfuncall41
: (funcptr
* int * int) -> (pyobject
* int * pyobject
) ->
83 external pyfuncall42
: (funcptr
* int * int) -> (pyobject
* pyobject
* pyobject
) ->
84 pyobject
= "pygencall"
85 external pyfuncall43
: (funcptr
* int * int) -> (pyobject
* int) ->
86 (int * int * int) option = "pygencall"
87 external pyfuncall44
: (funcptr
* int * int) -> (int * int * int * int) ->
88 pyobject
= "pygencall"
89 external pyfuncall45
: (funcptr
* int * int) -> (pyobject
* pyobject
) -> unit =
91 external pyfuncall46
: (funcptr
* int * int) -> (pyobject
* string) -> unit =
93 external pyfuncall47
: (funcptr
* int * int) -> (pyobject
* pyobject
* pyobject
) ->
94 (pyobject
* pyobject
* pyobject
) = "pygencall"
95 external pyfuncall48
: (funcptr
* int * int) -> (pyobject
* pyobject
* pyobject
) ->
97 external pyfuncall49
: (funcptr
* int * int) -> (pyobject
* string) -> pyobject
=
99 external pyfuncall50
: (funcptr
* int * int) -> (string * pyobject
* string) ->
100 pyobject
= "pygencall"
101 external pyfuncall51
: (funcptr
* int * int) ->
102 (string * pyobject
* pyobject
* pyobject
) -> pyobject
= "pygencall"
103 external pyfuncall52
: (funcptr
* int * int) -> pyobject
-> string = "pygencall"
104 external pyfuncall53
: (funcptr
* int * int) -> (pyobject
* int * int * pyobject
) -> int = "pygencall"
105 external pyfuncall54
: (funcptr
* int * int) -> (pyobject
* int * int) -> int =
108 let fmt1call func
= pyfuncall1 func
109 let fmt2call func
= pyfuncall2 func
110 let fmt3call func
= pyfuncall3 func
111 let fmt4call func
= pyfuncall4 func
112 let fmt5call func
= pyfuncall5 func
113 let fmt6call func
= pyfuncall6 func
114 let fmt7call func
= pyfuncall7 func
115 let fmt8call func
= pyfuncall8 func
116 let fmt9call func
= pyfuncall9 func
117 let fmt10call func
= pyfuncall10 func
118 let fmt11call func
= pyfuncall11 func
119 let fmt12call func
= pyfuncall12 func
120 let fmt13call func
= pyfuncall13 func
121 let fmt14call func
= pyfuncall14 func
122 let fmt15call func
= pyfuncall15 func
123 let fmt16call func
= pyfuncall16 func
124 let fmt17call func
= pyfuncall17 func
125 let fmt18call func
= pyfuncall18 func
126 let fmt19call func
= pyfuncall19 func
127 let fmt20call func
= pyfuncall20 func
128 let fmt21call func
= pyfuncall21 func
129 let fmt22call func
= pyfuncall22 func
130 let fmt23call func
= pyfuncall23 func
131 let fmt24call func
= pyfuncall24 func
132 let fmt25call func
= pyfuncall25 func
133 let fmt26call func
= pyfuncall26 func
134 let fmt27call func
= pyfuncall27 func
135 let fmt28call func
= pyfuncall28 func
136 let fmt29call func
= pyfuncall29 func
137 let fmt30call func
= pyfuncall30 func
138 let fmt31call func
= pyfuncall31 func
141 let fmt34call func
= pyfuncall34 func
142 let fmt35call func
= pyfuncall35 func
143 let fmt36call func
= pyfuncall36 func
144 let fmt37call func
= pyfuncall37 func
146 let fmt39call func
= pyfuncall39 func
147 let fmt40call func
= pyfuncall40 func
148 let fmt41call func
= pyfuncall41 func
149 let fmt42call func
= pyfuncall42 func
150 let fmt43call func
= pyfuncall43 func
151 let fmt44call func
= pyfuncall44 func
152 let fmt45call func
= pyfuncall45 func
153 let fmt46call func
= pyfuncall46 func
154 let fmt47call func
= pyfuncall47 func
155 let fmt48call func
= pyfuncall48 func
156 let fmt49call func
= pyfuncall49 func
157 let fmt50call func
= pyfuncall50 func
158 let fmt51call func
= pyfuncall51 func
159 let fmt52call func
= pyfuncall52 func
160 let fmt53call func
= pyfuncall53 func
161 let fmt54call func
= pyfuncall54 func
163 let py_cur_func_num = ref 0
164 let pnf () = let this_func = py_funcs.(!py_cur_func_num) in
165 py_cur_func_num := !py_cur_func_num + 1 ; this_func
168 let py_initialize = fmt1call (pnf ())
169 let py_finalize = fmt1call (pnf ())
170 let pyerr_print = fmt1call (pnf ())
172 let py_exit = fmt2call (pnf ())
173 let pyerr_printex = fmt2call (pnf ())
175 let py_setprogramname = fmt3call (pnf ())
176 let py_setpythonhome = fmt3call (pnf ())
178 let py_isinitialized = fmt4call (pnf ())
180 let pyrun_simplestring = fmt5call (pnf ())
182 let pyrun_anyfile = fmt6call (pnf ())
183 let pyrun_simplefile = fmt6call (pnf ())
184 let pyrun_interactiveone = fmt6call (pnf ())
185 let pyrun_interactiveloop = fmt6call (pnf ())
186 let py_fdisinteractive = fmt6call (pnf ())
188 let pyrun_anyfileex = fmt7call (pnf ())
189 let pyrun_simplefileex = fmt7call (pnf ())
191 let py_getprogramname = fmt8call (pnf ())
192 let py_getpythonhome = fmt8call (pnf ())
193 let py_getprogramfullpath = fmt8call (pnf ())
194 let py_getprefix = fmt8call (pnf ())
195 let py_getexecprefix = fmt8call (pnf ())
196 let py_getpath = fmt8call (pnf ())
197 let py_getversion = fmt8call (pnf ())
198 let py_getplatform = fmt8call (pnf ())
199 let py_getcopyright = fmt8call (pnf ())
200 let py_getcompiler = fmt8call (pnf ())
201 let py_getbuildinfo = fmt8call (pnf ())
203 let pyrun_string = fmt9call (pnf ())
205 let pyrun_file = fmt10call (pnf ())
207 let pyrun_fileex = fmt11call (pnf ())
209 let py_compilestring = fmt12call (pnf ())
211 let pyobject_print = fmt13call (pnf ())
213 let pyobject_repr = fmt14call (pnf ())
214 let pyobject_str = fmt14call (pnf ())
215 let pyobject_unicode = fmt14call (pnf ())
217 let pyobject_richcompare = fmt15call (pnf ())
219 let pyobject_getattrstring = fmt16call (pnf ())
221 let pyobject_getattr = fmt17call (pnf ())
222 let pyobject_callobject = fmt17call (pnf ())
224 let pyobject_istrue = fmt18call (pnf ())
225 let pyobject_not = fmt18call (pnf ())
226 let pycallable_check = fmt18call (pnf ())
228 let pyobject_compare = fmt19call (pnf ())
229 let pyobject_hasattr = fmt19call (pnf ())
231 let pyobject_richcomparebool = fmt20call (pnf ())
233 let pyobject_setattrstring = fmt21call (pnf ())
235 let pyobject_hasattrstring = fmt22call (pnf ())
237 let pynumber_coerce = fmt23call (pnf ())
238 let pynumber_coerceex = fmt23call (pnf ())
240 let pyobject_setattr = fmt24call (pnf ())
242 let pyobject_hash = fmt25call (pnf ())
245 let pystring_size = fmt18call (pnf ())
247 let pystring_asstring = fmt26call (pnf ())
249 let pystring_concat = fmt27call (pnf ())
250 let pystring_concatanddel = fmt27call (pnf ())
252 let pystring_fromstring = fmt28call (pnf ())
254 let pystring_format = fmt17call (pnf ())
258 let pydict_new = fmt29call (pnf ())
260 let pydict_getitem = fmt17call (pnf ())
262 let pydict_setitem = fmt24call (pnf ())
264 let pydict_delitem = fmt19call (pnf ())
266 let pydict_clear = fmt30call (pnf ())
268 let pydict_next = fmt31call (pnf ())
270 let pydict_keys = fmt14call (pnf ())
271 let pydict_values = fmt14call (pnf ())
272 let pydict_items = fmt14call (pnf ())
273 let pydict_copy = fmt14call (pnf ())
275 let pydict_size = fmt18call (pnf ())
277 let pydict_getitemstring = fmt16call (pnf ())
279 let pydict_delitemstring = fmt22call (pnf ())
281 let pydict_setitemstring = fmt21call (pnf ())
285 let pyint_fromlong = fmt34call (pnf ())
287 let pyint_aslong = fmt25call (pnf ())
289 let pyint_getmax = fmt35call (pnf ())
293 let pyfloat_fromdouble = fmt36call (pnf ())
295 let pyfloat_asdouble = fmt37call (pnf ())
299 let pymodule_new = fmt28call (pnf ())
301 let pymodule_getdict = fmt14call (pnf ())
303 let pymodule_getname = fmt26call (pnf ())
304 let pymodule_getfilename = fmt26call (pnf ())
307 let pytuple_new = fmt39call (pnf ())
309 let pytuple_size = fmt18call (pnf ())
310 let pytuple_check = fmt18call (pnf ())
312 let pytuple_getitem = fmt40call (pnf ())
314 let pytuple_setitem = fmt41call (pnf ())
316 let pytuple_getslice = fmt13call (pnf ())
319 let pyslice_new = fmt42call (pnf ())
321 let pyslice_getindices = fmt43call (pnf ())
323 let pyrange_new = fmt44call (pnf ())
325 (* Error handling definitions *)
328 let pyerr_setnone = fmt30call (pnf ())
330 let pyerr_setobject = fmt45call (pnf ())
332 let pyerr_setstring = fmt46call (pnf ())
334 let pyerr_occurred = fmt29call (pnf ())
336 let pyerr_clear = fmt1call (pnf ())
338 let pyerr_fetch = fmt47call (pnf ())
340 let pyerr_restore = fmt48call (pnf ())
342 (* Error testing and normalization *)
344 let pyerr_givenexceptionmatches = fmt19call (pnf ())
346 let pyerr_exceptionmatches = fmt18call (pnf ())
348 let pyerr_normalizeexception = fmt47call (pnf ())
352 let pyclass_new = fmt42call (pnf ())
354 let pyinstance_new = fmt42call (pnf ())
357 let pyinstance_newraw = fmt17call (pnf ())
359 let pymethod_new = fmt42call (pnf ())
361 let pymethod_function = fmt14call (pnf ())
362 let pymethod_self = fmt14call (pnf ())
363 let pymethod_class = fmt14call (pnf ())
367 let pymodule_new = fmt28call (pnf ())
369 let pymodule_getdict = fmt14call (pnf ())
371 let pymodule_getname = fmt26call (pnf ())
372 let pymodule_getfilename = fmt26call (pnf ())
374 let pyimport_getmagicnumber = fmt35call (pnf ())
376 let pyimport_execcodemodule = fmt49call (pnf ())
378 let pyimport_execcodemoduleex = fmt50call (pnf ())
380 let pyimport_getmoduledict = fmt29call (pnf ())
382 let pyimport_addmodule = fmt28call (pnf ())
383 let pyimport_importmodule = fmt28call (pnf ())
384 (* - disabled, see comment in pycaml_ml.c. - RWMJ
386 let pyimport_importmoduleex = fmt51call (pnf ())
389 let pyimport_import = fmt28call (pnf ())
391 let pyimport_reloadmodule = fmt14call (pnf ())
393 let pyimport_cleanup = fmt1call (pnf ())
395 let pyimport_importfrozenmodule = fmt5call (pnf ())
397 (* Interface to random parts in ceval.c *)
399 let pyeval_callobjectwithkeywords = fmt42call (pnf ())
401 (* dropped in Python 2.7
402 let pyeval_callobject = fmt17call (pnf ()) *)
405 let pyeval_getbuiltins = fmt29call (pnf ())
406 let pyeval_getglobals = fmt29call (pnf ())
407 let pyeval_getlocals = fmt29call (pnf ())
408 let pyeval_getframe = fmt29call (pnf ())
410 let pyeval_getrestricted = fmt4call (pnf ())
414 let pyobject_type = fmt14call (pnf ())
416 let pyobject_size = fmt18call (pnf ())
418 let pyobject_getitem = fmt17call (pnf ())
420 let pyobject_setitem = fmt24call (pnf ())
422 let pyobject_delitem = fmt17call (pnf ())
424 let pyobject_ascharbuffer = fmt52call (pnf ())
425 let pyobject_asreadbuffer = fmt52call (pnf ())
426 let pyobject_aswritebuffer = fmt52call (pnf ())
428 let pynumber_check = fmt18call (pnf ())
430 let pynumber_add = fmt17call (pnf ())
431 let pynumber_subtract = fmt17call (pnf ())
432 let pynumber_multiply = fmt17call (pnf ())
433 let pynumber_divide = fmt17call (pnf ())
434 let pynumber_remainder = fmt17call (pnf ())
435 let pynumber_divmod = fmt17call (pnf ())
437 let pynumber_power = fmt42call (pnf ())
439 let pynumber_negative = fmt14call (pnf ())
440 let pynumber_positive = fmt14call (pnf ())
441 let pynumber_absolute = fmt14call (pnf ())
442 let pynumber_invert = fmt14call (pnf ())
444 let pynumber_lshift = fmt17call (pnf ())
445 let pynumber_rshift = fmt17call (pnf ())
446 let pynumber_and = fmt17call (pnf ())
447 let pynumber_xor = fmt17call (pnf ())
448 let pynumber_or = fmt17call (pnf ())
450 let pynumber_int = fmt14call (pnf ())
451 let pynumber_long = fmt14call (pnf ())
452 let pynumber_float = fmt14call (pnf ())
454 let pynumber_inplaceadd = fmt17call (pnf ())
455 let pynumber_inplacesubtract = fmt17call (pnf ())
456 let pynumber_inplacemultiply = fmt17call (pnf ())
457 let pynumber_inplacedivide = fmt17call (pnf ())
458 let pynumber_inplaceremainder = fmt17call (pnf ())
459 let pynumber_inplacelshift = fmt17call (pnf ())
460 let pynumber_inplacershift = fmt17call (pnf ())
461 let pynumber_inplaceand = fmt17call (pnf ())
462 let pynumber_inplacexor = fmt17call (pnf ())
463 let pynumber_inplaceor = fmt17call (pnf ())
465 let pynumber_inplacepower = fmt42call (pnf ())
467 let pysequence_check = fmt18call (pnf ())
468 let pysequence_size = fmt18call (pnf ())
469 let pysequence_length = fmt18call (pnf ())
471 let pysequence_concat = fmt17call (pnf ())
473 let pysequence_repeat = fmt40call (pnf ())
474 let pysequence_getitem = fmt40call (pnf ())
476 let pysequence_getslice = fmt13call (pnf ())
478 let pysequence_setitem = fmt41call (pnf ())
480 let pysequence_delitem = fmt20call (pnf ())
482 let pysequence_setslice = fmt53call (pnf ())
484 let pysequence_delslice = fmt54call (pnf ())
486 let pysequence_tuple = fmt14call (pnf ())
487 let pysequence_list = fmt14call (pnf ())
489 let pysequence_fast = fmt16call (pnf ())
491 let pysequence_count = fmt19call (pnf ())
492 let pysequence_contains = fmt19call (pnf ())
493 let pysequence_in = fmt19call (pnf ())
494 let pysequence_index = fmt19call (pnf ())
496 let pysequence_inplaceconcat = fmt17call (pnf ())
498 let pysequence_inplacerepeat = fmt22call (pnf ())
500 let pymapping_check = fmt18call (pnf ())
501 let pymapping_size = fmt18call (pnf ())
502 let pymapping_length = fmt18call (pnf ())
504 let pymapping_haskeystring = fmt16call (pnf ())
506 let pymapping_haskey = fmt19call (pnf ())
508 let pymapping_getitemstring = fmt16call (pnf ())
510 let pymapping_setitemstring = fmt41call (pnf ())
512 external pynull
: unit -> pyobject
= "pynull"
514 external pynone
: unit -> pyobject
= "pynone"
515 external pytrue
: unit -> pyobject
= "pytrue"
516 external pyfalse
: unit -> pyobject
= "pyfalse"
518 external pytuple_fromarray
: pyobject array
-> pyobject
= "pytuple_fromarray"
519 let pytuple_fromsingle elt
= pytuple_fromarray
[| elt
|]
520 let pytuple_empty = pytuple_fromarray
[| |]
521 external pytuple2
: (pyobject
* pyobject
) -> pyobject
=
523 external pytuple3
: (pyobject
* pyobject
* pyobject
) -> pyobject
=
525 external pytuple4
: (pyobject
* pyobject
* pyobject
* pyobject
) ->
526 pyobject
= "pytuple_fromarray"
527 external pytuple5
: (pyobject
* pyobject
* pyobject
* pyobject
* pyobject
) ->
528 pyobject
= "pytuple_fromarray"
529 external pytuple6
: (pyobject
* pyobject
* pyobject
* pyobject
* pyobject
* pyobject
) ->
530 pyobject
= "pytuple_fromarray"
532 let pyint_fromint i
= pyint_fromlong (Int64.of_int i
)
533 let pyint_asint obj
= Int64.to_int
(pyint_aslong obj
)
535 external pytuple_toarray
: pyobject
-> pyobject array
= "pytuple_toarray"
537 external pywrap_closure
: (pyobject
-> pyobject
) -> pyobject
= "pywrap_closure"
538 external pycaml_setargs
: string -> unit = "pycaml_setargs"
540 external pymodule_initmodule
: string -> pymodule_func array
= "pymodule_initmodule"
542 external pywrap_value
: 'a
-> pyobject
= "pywrapvalue" ;;
544 external pyunwrap_value
: pyobject
-> 'a
= "pyunwrapvalue" ;;
546 let _ = py_initialize () ;;