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:
William S Fulton 2022-10-13 19:46:51 +01:00
commit 46f7501d94
31 changed files with 68 additions and 76 deletions

View file

@ -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);