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:
parent
abc1c59c4e
commit
4ac3c87a29
18 changed files with 128 additions and 9 deletions
|
|
@ -4,6 +4,8 @@
|
|||
* C# typemaps
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%include <typemaps/swigversion.swg>
|
||||
|
||||
%include <csharphead.swg>
|
||||
|
||||
/* The ctype, imtype and cstype typemaps work together and so there should be one of each.
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
* Go configuration module.
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
%include <typemaps/swigversion.swg>
|
||||
|
||||
%include <gostring.swg>
|
||||
|
||||
/* Code insertion directives */
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
* SWIG Configuration File for Guile.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%include <typemaps/swigversion.swg>
|
||||
|
||||
/* Macro for inserting Scheme code into the stub */
|
||||
#define %scheme %insert("scheme")
|
||||
#define %goops %insert("goops")
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
* Java typemaps
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%include <typemaps/swigversion.swg>
|
||||
|
||||
%include <javahead.swg>
|
||||
|
||||
/* The jni, jtype and jstype typemaps work together and so there should be one of each.
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@
|
|||
* This file is parsed by SWIG before reading any other interface file.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%include <typemaps/swigversion.swg>
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* includes
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@
|
|||
* This file is parsed by SWIG before reading any other interface file.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%include <typemaps/swigversion.swg>
|
||||
|
||||
/* Include headers */
|
||||
%runtime "swigrun.swg" // Common C API type-checking code
|
||||
%runtime "swigerrors.swg" // SWIG errors
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
* SWIG Configuration File for Ocaml
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%include <typemaps/swigversion.swg>
|
||||
|
||||
/* Insert common stuff */
|
||||
%insert(runtime) "swigrun.swg"
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
* PHP configuration file
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%include <typemaps/swigversion.swg>
|
||||
|
||||
// Default to generating PHP type declarations (for PHP >= 8) except for
|
||||
// cases which are liable to cause compatibility issues with existing
|
||||
// bindings.
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ std_strings.swg Common macros to implemented the std::string/std::wstring typem
|
|||
strings.swg Common macros and typemaps for string and wstring (char *, wchar_t *)
|
||||
|
||||
swigmacros.swg Basic macros
|
||||
swigversion.swg Define SWIG_VERSION
|
||||
fragments.swg Macros for fragment manipulations
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -109,15 +109,7 @@ nocppval
|
|||
#endif
|
||||
%enddef
|
||||
|
||||
/* insert the SWIGVERSION in the interface and the wrapper code */
|
||||
#if SWIG_VERSION
|
||||
%insert("header") {
|
||||
%define_as(SWIGVERSION, SWIG_VERSION)
|
||||
%#define SWIG_VERSION SWIGVERSION
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
%include <typemaps/swigversion.swg>
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Casting operators
|
||||
|
|
|
|||
17
Lib/typemaps/swigversion.swg
Normal file
17
Lib/typemaps/swigversion.swg
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* Define SWIG_VERSION
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* Define SWIG_VERSION in the interface and the wrapper code.
|
||||
*
|
||||
* Best practice is to use SWIG-time checks for SWIG_VERSION, but SWIG_VERSION
|
||||
* was unintentionally defined like this for many years, and while it was never
|
||||
* documented there are likely user interface files which rely on it.
|
||||
*/
|
||||
%define %define_swig_version_()%#define SWIG_VERSION_ SWIG_VERSION %enddef
|
||||
%insert("header") {
|
||||
%define_swig_version_()
|
||||
%#define SWIG_VERSION SWIG_VERSION_
|
||||
%#undef SWIG_VERSION_
|
||||
}
|
||||
#undef %define_swig_version_
|
||||
Loading…
Add table
Add a link
Reference in a new issue