swig/Lib/ocaml/ocaml.i
Olly Betts 4ac3c87a29 Sort out predefined SWIG-specific macros
Ensure that SWIG_VERSION is defined both at SWIG-time and in the
generated C/C++ wrapper code (it was only defined in the wrapper
for some target languages previously).

SWIGGO and SWIGJAVASCRIPT are now defined in the generated wrappers
to match behaviour for all other target languages.

Stop defining SWIGVERSION in the wrapper.  This only happened as a
side-effect of how SWIG_VERSION was defined but was never documented and
is redundant.

The new testcase also checks that SWIG is defined at SWIG-time but not
in the generated wrapper, and that exactly one of a list of
target-language specific macros is defined.

Fixes #1050
2022-10-05 12:40:15 +13:00

52 lines
1.3 KiB
OpenEdge ABL

/* -----------------------------------------------------------------------------
* ocaml.i
*
* SWIG Configuration File for Ocaml
* ----------------------------------------------------------------------------- */
%include <typemaps/swigversion.swg>
/* Insert common stuff */
%insert(runtime) "swigrun.swg"
/* Include headers */
%insert(runtime) "ocamlrundec.swg"
/* Type registration */
%insert(init) "swiginit.swg"
%insert(init) "typeregister.swg"
%insert(mlitail) %{
val swig_val : c_enum_type -> c_obj -> Swig.c_obj
%}
%insert(mltail) %{
let rec swig_val t v =
match v with
C_enum e -> enum_to_int t v
| C_list l -> Swig.C_list (List.map (swig_val t) l)
| C_array a -> Swig.C_array (Array.map (swig_val t) a)
| _ -> Obj.magic v
%}
/*#ifndef SWIG_NOINCLUDE*/
%insert(runtime) "ocamlrun.swg"
/*#endif*/
%insert(classtemplate) "class.swg"
/* Read in standard typemaps. */
%include <swig.swg>
%include <ocaml.swg>
%include <typecheck.i>
%include <exception.i>
%include <preamble.swg>
/* ocaml keywords */
/* There's no need to use this, because of my rewriting machinery. C++
* words never collide with ocaml keywords */
/* still we include the file, but the warning says that the offending
name will be properly renamed. Just to let the user to know about
it. */
%include <ocamlkw.swg>