Make method wrappers suffix optional and disabled by default

Unfortunately the changes of 26bf86322 (Use SWIG-specific for
non-overloaded synthesized functions too, 2021-11-09) did break some
existing code bases using SWIG as they hardcoded the old wrapper
function names.

So turn this off by default and add a global variable allowing to enable
this, which can be done for a specific language only. This is ugly but,
unfortunately, there is no way to use the Language object from the C
function Swig_MethodToFunction(), so the only alternative would be to
add another parameter to it, but it already has 6 of them, so it
wouldn't really be that much better.

See #2366, #2368, #2370.
This commit is contained in:
Vadim Zeitlin 2022-09-17 14:27:51 +02:00 committed by Olly Betts
commit b9fa8c23bb
3 changed files with 12 additions and 4 deletions

View file

@ -77,6 +77,9 @@ static Hash *classhash;
extern int GenerateDefault;
extern int ForceExtern;
extern int AddExtern;
extern "C" {
extern int UseWrapperSuffix;
}
/* import modes */
@ -1324,7 +1327,7 @@ int Language::staticmemberfunctionHandler(Node *n) {
// See Swig_MethodToFunction() for the explanation of this code.
if (Getattr(n, "sym:overloaded")) {
Append(cname, Getattr(defaultargs ? defaultargs : n, "sym:overname"));
} else {
} else if (UseWrapperSuffix) {
Append(cname, "__SWIG");
}