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
This commit is contained in:
Olly Betts 2022-07-20 15:05:21 +12:00
commit 4ac3c87a29
18 changed files with 128 additions and 9 deletions

View file

@ -147,6 +147,14 @@ SWIGTCL Defined when using Tcl
SWIGXML Defined when using XML
</pre></div>
<p>
SWIG also defines <tt>SWIG_VERSION</tt> and a target language macro in
the generated wrapper file (since SWIG 4.2.0 - in older versions these
were defined for some target languages but this wasn't consistent). Best
practice is to use SWIG-time conditional checks because that results in smaller
generated wrapper sources.
</p>
<p>
In addition, SWIG defines the following set of standard C/C++ macros:
</p>