summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVadim Zeitlin <vz-swig@zeitlins.org>2021-11-09 23:33:31 +0100
committerVadim Zeitlin <vz-swig@zeitlins.org>2021-11-09 23:35:30 +0100
commit26bf86322b18040e2f2156c34a47b44c927d1399 (patch)
tree13d027f1b7472e056f31a4a122f7a8f846e71336
parent119222be770546ee7fdc19c1b603d66a23c1c302 (diff)
downloadswig-26bf86322b18040e2f2156c34a47b44c927d1399.tar.gz
Use SWIG-specific for non-overloaded synthesized functions too
This avoids conflicts between such functions, which are generated when using %extend to add static methods to an existing class, and the actual wrapper functions generated by the backend. This shouldn't result in any user-visible changes.
-rw-r--r--Source/Modules/lang.cxx3
-rw-r--r--Source/Swig/cwrap.c15
2 files changed, 15 insertions, 3 deletions
diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx
index 3064d22f9..196ff47a9 100644
--- a/Source/Modules/lang.cxx
+++ b/Source/Modules/lang.cxx
@@ -1321,8 +1321,11 @@ int Language::staticmemberfunctionHandler(Node *n) {
mrename = mangled;
if (code) {
+ // See Swig_MethodToFunction() for the explanation of this code.
if (Getattr(n, "sym:overloaded")) {
Append(cname, Getattr(defaultargs ? defaultargs : n, "sym:overname"));
+ } else {
+ Append(cname, "__SWIG");
}
if (!defaultargs) {
diff --git a/Source/Swig/cwrap.c b/Source/Swig/cwrap.c
index d6e5e0cdc..0d8008ef0 100644
--- a/Source/Swig/cwrap.c
+++ b/Source/Swig/cwrap.c
@@ -1076,9 +1076,18 @@ int Swig_MethodToFunction(Node *n, const_String_or_char_ptr nspace, String *clas
/* Check if the method is overloaded. If so, and it has code attached, we append an extra suffix
to avoid a name-clash in the generated wrappers. This allows overloaded methods to be defined
- in C. */
- if (Getattr(n, "sym:overloaded") && code) {
- Append(mangled, Getattr(defaultargs ? defaultargs : n, "sym:overname"));
+ in C.
+
+ But when not using the suffix used for overloaded functions, we still need to ensure that the
+ wrapper name doesn't conflict with any wrapper functions, so make it sufficiently unique by
+ appending a suffix similar to the one used for overloaded functions to it.
+ */
+ if (code) {
+ if (Getattr(n, "sym:overloaded")) {
+ Append(mangled, Getattr(defaultargs ? defaultargs : n, "sym:overname"));
+ } else {
+ Append(mangled, "__SWIG");
+ }
}
/* See if there is any code that we need to emit */