Cleanup SWIG_VERSION definition
Add Swig_obligatory_macros which must be called by each target language to define SWIG_VERSION correctly in the generated code, as well as the language specific macro SWIGXXX where XXX is the target language name. Drop the #ifdef SWIGXXX that was previously generated - I can't see the point of this and if users are defining this macro somehow, then users will need to change this Closes #1050
This commit is contained in:
parent
e123c2afe8
commit
46f7501d94
31 changed files with 68 additions and 76 deletions
|
|
@ -4,8 +4,6 @@
|
|||
* 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,8 +4,6 @@
|
|||
* Go configuration module.
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
%include <typemaps/swigversion.swg>
|
||||
|
||||
%include <gostring.swg>
|
||||
|
||||
/* Code insertion directives */
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@
|
|||
* 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,8 +4,6 @@
|
|||
* 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,8 +5,6 @@
|
|||
* This file is parsed by SWIG before reading any other interface file.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%include <typemaps/swigversion.swg>
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* includes
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
|
|
|||
|
|
@ -5,8 +5,6 @@
|
|||
* 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,8 +4,6 @@
|
|||
* SWIG Configuration File for Ocaml
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%include <typemaps/swigversion.swg>
|
||||
|
||||
/* Insert common stuff */
|
||||
%insert(runtime) "swigrun.swg"
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@
|
|||
* 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,7 +48,6 @@ 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,8 +109,6 @@ nocppval
|
|||
#endif
|
||||
%enddef
|
||||
|
||||
%include <typemaps/swigversion.swg>
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Casting operators
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
|
|
|||
|
|
@ -1,16 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* 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 %define_swig_version_
|
||||
|
|
@ -399,7 +399,7 @@ public:
|
|||
|
||||
Swig_banner(f_begin);
|
||||
|
||||
Printf(f_runtime, "\n\n#ifndef SWIGCSHARP\n#define SWIGCSHARP\n#endif\n\n");
|
||||
Swig_obligatory_macros(f_runtime, "CSHARP");
|
||||
|
||||
if (directorsEnabled()) {
|
||||
Printf(f_runtime, "#define SWIG_DIRECTORS\n");
|
||||
|
|
|
|||
|
|
@ -472,7 +472,7 @@ public:
|
|||
|
||||
Swig_banner(f_begin);
|
||||
|
||||
Printf(f_runtime, "\n\n#ifndef SWIGD\n#define SWIGD\n#endif\n\n");
|
||||
Swig_obligatory_macros(f_runtime, "D");
|
||||
|
||||
if (directorsEnabled()) {
|
||||
Printf(f_runtime, "#define SWIG_DIRECTORS\n");
|
||||
|
|
|
|||
|
|
@ -512,6 +512,9 @@ private:
|
|||
Swig_register_filebyname("cgo_comment_typedefs", f_cgo_comment_typedefs);
|
||||
|
||||
Swig_banner(f_c_begin);
|
||||
|
||||
Swig_obligatory_macros(f_c_runtime, "GO");
|
||||
|
||||
if (CPlusPlus) {
|
||||
Printf(f_c_begin, "\n// source: %s\n\n", swig_filename);
|
||||
} else {
|
||||
|
|
@ -519,7 +522,6 @@ private:
|
|||
}
|
||||
|
||||
Printf(f_c_runtime, "#define SWIGMODULE %s\n", module);
|
||||
Printf(f_c_runtime, "#ifndef SWIGGO\n#define SWIGGO\n#endif\n\n");
|
||||
|
||||
if (gccgo_flag) {
|
||||
Printf(f_c_runtime, "#define SWIGGO_PREFIX %s\n", go_prefix);
|
||||
|
|
|
|||
|
|
@ -321,7 +321,7 @@ public:
|
|||
|
||||
Swig_banner(f_begin);
|
||||
|
||||
Printf(f_runtime, "\n\n#ifndef SWIGGUILE\n#define SWIGGUILE\n#endif\n\n");
|
||||
Swig_obligatory_macros(f_runtime, "GUILE");
|
||||
|
||||
/* Write out directives and declarations */
|
||||
|
||||
|
|
|
|||
|
|
@ -456,7 +456,7 @@ public:
|
|||
|
||||
Swig_banner(f_begin);
|
||||
|
||||
Printf(f_runtime, "\n\n#ifndef SWIGJAVA\n#define SWIGJAVA\n#endif\n\n");
|
||||
Swig_obligatory_macros(f_runtime, "JAVA");
|
||||
|
||||
if (directorsEnabled()) {
|
||||
Printf(f_runtime, "#define SWIG_DIRECTORS\n");
|
||||
|
|
|
|||
|
|
@ -1615,7 +1615,7 @@ int JSCEmitter::initialize(Node *n) {
|
|||
|
||||
Swig_banner(f_wrap_cpp);
|
||||
|
||||
Printf(f_runtime, "#ifndef SWIGJAVASCRIPT\n#define SWIGJAVASCRIPT\n#endif\n\n");
|
||||
Swig_obligatory_macros(f_runtime, "JAVASCRIPT");
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
@ -1947,7 +1947,7 @@ int V8Emitter::initialize(Node *n) {
|
|||
|
||||
Swig_banner(f_wrap_cpp);
|
||||
|
||||
Printf(f_runtime, "#ifndef SWIGJAVASCRIPT\n#define SWIGJAVASCRIPT\n#endif\n\n");
|
||||
Swig_obligatory_macros(f_runtime, "JAVASCRIPT");
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -329,7 +329,7 @@ public:
|
|||
/* Standard stuff for the SWIG runtime section */
|
||||
Swig_banner(f_begin);
|
||||
|
||||
Printf(f_runtime, "\n\n#ifndef SWIGLUA\n#define SWIGLUA\n#endif\n\n");
|
||||
Swig_obligatory_macros(f_runtime, "LUA");
|
||||
|
||||
emitLuaFlavor(f_runtime);
|
||||
|
||||
|
|
|
|||
|
|
@ -911,25 +911,11 @@ int SWIG_main(int argc, char *argv[], const TargetLanguageModule *tlm) {
|
|||
Preprocessor_define((DOH *) "SWIG 1", 0);
|
||||
Preprocessor_define((DOH *) "__STDC__", 0);
|
||||
|
||||
// Set the SWIG version value in format 0xAABBCC from package version expected to be in format A.B.C
|
||||
String *package_version = NewString(PACKAGE_VERSION); /* Note that the fakeversion has not been set at this point */
|
||||
char *token = strtok(Char(package_version), ".");
|
||||
String *vers = NewString("SWIG_VERSION 0x");
|
||||
int count = 0;
|
||||
while (token) {
|
||||
int len = (int)strlen(token);
|
||||
assert(len == 1 || len == 2);
|
||||
Printf(vers, "%s%s", (len == 1) ? "0" : "", token);
|
||||
token = strtok(NULL, ".");
|
||||
count++;
|
||||
}
|
||||
Delete(package_version);
|
||||
assert(count == 3); // Check version format is correct
|
||||
|
||||
/* Turn on contracts */
|
||||
String *vers = Swig_package_version_hex();
|
||||
Preprocessor_define(vers, 0);
|
||||
Delete(vers);
|
||||
|
||||
Swig_contract_mode_set(1);
|
||||
Preprocessor_define(vers, 0);
|
||||
|
||||
/* Turn off directors mode */
|
||||
Wrapper_director_mode_set(0);
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ public:
|
|||
|
||||
Swig_banner(f_begin);
|
||||
|
||||
Printf(f_runtime, "\n\n#ifndef SWIGMZSCHEME\n#define SWIGMZSCHEME\n#endif\n\n");
|
||||
Swig_obligatory_macros(f_runtime, "MZSCHEME");
|
||||
|
||||
module = Getattr(n, "name");
|
||||
|
||||
|
|
|
|||
|
|
@ -276,7 +276,7 @@ public:
|
|||
|
||||
Swig_banner(f_begin);
|
||||
|
||||
Printf(f_runtime, "\n\n#ifndef SWIGOCAML\n#define SWIGOCAML\n#endif\n\n");
|
||||
Swig_obligatory_macros(f_runtime, "OCAML");
|
||||
|
||||
Printf(f_runtime, "#define SWIG_MODULE \"%s\"\n", module);
|
||||
/* Module name */
|
||||
|
|
|
|||
|
|
@ -190,7 +190,7 @@ public:
|
|||
|
||||
Swig_banner(f_begin);
|
||||
|
||||
Printf(f_runtime, "\n\n#ifndef SWIGOCTAVE\n#define SWIGOCTAVE\n#endif\n\n");
|
||||
Swig_obligatory_macros(f_runtime, "OCTAVE");
|
||||
|
||||
Printf(f_runtime, "#define SWIG_name_d \"%s\"\n", module);
|
||||
Printf(f_runtime, "#define SWIG_name %s\n", module);
|
||||
|
|
|
|||
|
|
@ -319,7 +319,7 @@ public:
|
|||
|
||||
Swig_banner(f_begin);
|
||||
|
||||
Printf(f_runtime, "\n\n#ifndef SWIGPERL\n#define SWIGPERL\n#endif\n\n");
|
||||
Swig_obligatory_macros(f_runtime, "PERL");
|
||||
|
||||
if (directorsEnabled()) {
|
||||
Printf(f_runtime, "#define SWIG_DIRECTORS\n");
|
||||
|
|
|
|||
|
|
@ -609,6 +609,12 @@ public:
|
|||
|
||||
Swig_banner(f_begin);
|
||||
|
||||
Swig_obligatory_macros(f_runtime, "PHP");
|
||||
|
||||
if (directorsEnabled()) {
|
||||
Printf(f_runtime, "#define SWIG_DIRECTORS\n");
|
||||
}
|
||||
|
||||
// We need to include php.h before string.h gets included, at least with
|
||||
// PHP 8.2. Otherwise string.h is included without _GNU_SOURCE being
|
||||
// included and memrchr() doesn't get declared, and then inline code in
|
||||
|
|
@ -636,12 +642,6 @@ public:
|
|||
"# endif\n"
|
||||
"#endif\n\n");
|
||||
|
||||
Printf(f_runtime, "#ifndef SWIGPHP\n#define SWIGPHP\n#endif\n\n");
|
||||
|
||||
if (directorsEnabled()) {
|
||||
Printf(f_runtime, "#define SWIG_DIRECTORS\n");
|
||||
}
|
||||
|
||||
/* Set the module name */
|
||||
module = Copy(Getattr(n, "name"));
|
||||
cap_module = NewStringf("%(upper)s", module);
|
||||
|
|
|
|||
|
|
@ -587,7 +587,7 @@ public:
|
|||
|
||||
Swig_banner(f_begin);
|
||||
|
||||
Printf(f_runtime, "\n\n#ifndef SWIGPYTHON\n#define SWIGPYTHON\n#endif\n\n");
|
||||
Swig_obligatory_macros(f_runtime, "PYTHON");
|
||||
|
||||
if (directorsEnabled()) {
|
||||
Printf(f_runtime, "#define SWIG_DIRECTORS\n");
|
||||
|
|
|
|||
|
|
@ -740,8 +740,7 @@ int R::top(Node *n) {
|
|||
|
||||
Swig_banner(f_begin);
|
||||
|
||||
Printf(f_runtime, "\n\n#ifndef SWIGR\n#define SWIGR\n#endif\n\n");
|
||||
|
||||
Swig_obligatory_macros(f_runtime, "R");
|
||||
|
||||
Swig_banner_target_lang(s_init, "#");
|
||||
outputCommandLineArguments(s_init);
|
||||
|
|
|
|||
|
|
@ -1087,7 +1087,7 @@ public:
|
|||
|
||||
Swig_banner(f_begin);
|
||||
|
||||
Printf(f_runtime, "\n\n#ifndef SWIGRUBY\n#define SWIGRUBY\n#endif\n\n");
|
||||
Swig_obligatory_macros(f_runtime, "RUBY");
|
||||
|
||||
if (directorsEnabled()) {
|
||||
Printf(f_runtime, "#define SWIG_DIRECTORS\n");
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ public:
|
|||
/* Output module initialization code */
|
||||
Swig_banner(beginSection);
|
||||
|
||||
Printf(runtimeSection, "\n\n#ifndef SWIGSCILAB\n#define SWIGSCILAB\n#endif\n\n");
|
||||
Swig_obligatory_macros(runtimeSection, "SCILAB");
|
||||
|
||||
// Gateway header source merged with wrapper source in nobuilder mode
|
||||
if (!generateBuilder)
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ public:
|
|||
|
||||
Swig_banner(f_begin);
|
||||
|
||||
Printf(f_runtime, "\n\n#ifndef SWIGTCL\n#define SWIGTCL\n#endif\n\n");
|
||||
Swig_obligatory_macros(f_runtime, "TCL");
|
||||
|
||||
/* Set the module name, namespace, and prefix */
|
||||
|
||||
|
|
|
|||
|
|
@ -62,6 +62,44 @@ const char *Swig_package_version(void) {
|
|||
return fake_version ? fake_version : PACKAGE_VERSION;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_package_version_hex()
|
||||
*
|
||||
* Return the package version in hex format "0xAABBCC" such as "0x040200" for 4.2.0
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *Swig_package_version_hex(void) {
|
||||
String *package_version = NewString(Swig_package_version());
|
||||
char *token = strtok(Char(package_version), ".");
|
||||
String *vers = NewString("SWIG_VERSION 0x");
|
||||
int count = 0;
|
||||
while (token) {
|
||||
int len = (int)strlen(token);
|
||||
assert(len == 1 || len == 2);
|
||||
Printf(vers, "%s%s", (len == 1) ? "0" : "", token);
|
||||
token = strtok(NULL, ".");
|
||||
count++;
|
||||
}
|
||||
Delete(package_version);
|
||||
assert(count == 3); // Check version format is correct
|
||||
return vers;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_obligatory_macros()
|
||||
*
|
||||
* Generates the SWIG_VERSION and SWIGXXX macros where XXX is the target language
|
||||
* name (must be provided uppercase).
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Swig_obligatory_macros(String *f_runtime, const char *language) {
|
||||
String *version_hex = Swig_package_version_hex();
|
||||
Printf(f_runtime, "\n\n");
|
||||
Printf(f_runtime, "#define %s\n", version_hex);
|
||||
Printf(f_runtime, "#define SWIG%s\n", language);
|
||||
Delete(version_hex);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_banner()
|
||||
*
|
||||
|
|
|
|||
|
|
@ -308,6 +308,8 @@ extern int ParmList_is_compactdefargs(ParmList *p);
|
|||
extern char *Swig_copy_string(const char *c);
|
||||
extern void Swig_set_fakeversion(const char *version);
|
||||
extern const char *Swig_package_version(void);
|
||||
extern String *Swig_package_version_hex(void);
|
||||
extern void Swig_obligatory_macros(String *f_runtime, const char *language);
|
||||
extern void Swig_banner(File *f);
|
||||
extern void Swig_banner_target_lang(File *f, const_String_or_char_ptr commentchar);
|
||||
extern String *Swig_strip_c_comments(const String *s);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue