import source from 1.3.40
[external/swig.git] / Lib / ocaml / ocaml.i
1 /* -----------------------------------------------------------------------------
2  * See the LICENSE file for information on copyright, usage and redistribution
3  * of SWIG, and the README file for authors - http://www.swig.org/release.html.
4  *
5  * ocaml.i
6  *
7  * SWIG Configuration File for Ocaml
8  * ----------------------------------------------------------------------------- */
9
10 %runtime %{
11 #define SWIGSTATIC static
12 %}
13
14 /* Insert common stuff */
15 %insert(runtime) "swigrun.swg"
16
17 /* Include headers */
18 %insert(runtime) "ocamldec.swg"
19
20 /* Type registration */
21 %insert(init) "swiginit.swg"
22 %insert(init) "typeregister.swg"
23
24 %insert(mlitail) %{
25   val swig_val : c_enum_type -> c_obj -> Swig.c_obj
26 %}
27
28 %insert(mltail) %{
29   let rec swig_val t v = 
30     match v with
31         C_enum e -> enum_to_int t v
32       | C_list l -> Swig.C_list (List.map (swig_val t) l)
33       | C_array a -> Swig.C_array (Array.map (swig_val t) a)
34       | _ -> Obj.magic v
35 %}
36
37 /*#ifndef SWIG_NOINCLUDE*/
38 %insert(runtime) "ocaml.swg"
39 /*#endif*/
40
41 %insert(classtemplate) "class.swg"
42
43 /* Definitions */
44 #define SWIG_malloc(size) swig_malloc(size, FUNC_NAME)
45 #define SWIG_free(mem) free(mem)
46
47 /* Read in standard typemaps. */
48 %include <swig.swg>
49 %include <typemaps.i>
50 %include <typecheck.i>
51 %include <exception.i>
52 %include <preamble.swg>
53
54 /* ocaml keywords */
55 /* There's no need to use this, because of my rewriting machinery.  C++
56  * words never collide with ocaml keywords */
57
58 /* still we include the file, but the warning says that the offending
59    name will be properly renamed. Just to let the user to know about
60    it. */
61 %include <ocamlkw.swg>