summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam S Fulton <wsf@fultondesigns.co.uk>2016-03-07 21:39:53 +0000
committerWilliam S Fulton <wsf@fultondesigns.co.uk>2016-03-07 21:42:27 +0000
commit5117c77d4a4e2c6555fe2446252af7ff40dcac7e (patch)
treeed64bab96d1abf4a2ae8c56e4003c2deb5286a2c
parent2dec8c55148f78128115abe234b6f211fd0f6007 (diff)
downloadswig-5117c77d4a4e2c6555fe2446252af7ff40dcac7e.tar.gz
Interface feature fix for typedef types
-rw-r--r--Examples/test-suite/multiple_inheritance_interfaces.i15
-rw-r--r--Source/Modules/interface.cxx18
2 files changed, 25 insertions, 8 deletions
diff --git a/Examples/test-suite/multiple_inheritance_interfaces.i b/Examples/test-suite/multiple_inheritance_interfaces.i
index 9444f9dbf..2972922fb 100644
--- a/Examples/test-suite/multiple_inheritance_interfaces.i
+++ b/Examples/test-suite/multiple_inheritance_interfaces.i
@@ -49,3 +49,18 @@ struct U : R {};
struct V : S {};
struct W : T {};
%}
+
+#if defined(SWIGJAVA) || defined(SWIGCSHARP)
+%interface_impl(BaseOverloaded);
+#endif
+%inline %{
+struct BaseOverloaded {
+ typedef P PTypedef;
+ virtual ~BaseOverloaded() {}
+ virtual void identical_overload(int i, const PTypedef &pp = PTypedef()) {}
+};
+
+struct DerivedOverloaded : public BaseOverloaded {
+ virtual void identical_overload(int i, const PTypedef &p = PTypedef()) {}
+};
+%}
diff --git a/Source/Modules/interface.cxx b/Source/Modules/interface.cxx
index 03d15a615..f6d4c955b 100644
--- a/Source/Modules/interface.cxx
+++ b/Source/Modules/interface.cxx
@@ -144,27 +144,29 @@ void Swig_interface_propagate_methods(Node *n) {
if (!is_interface && GetFlag(mi.item, "abstract"))
continue;
String *this_decl = Getattr(mi.item, "decl");
- String *resolved_decl = SwigType_typedef_resolve_all(this_decl);
- bool overloaded = false;
- if (SwigType_isfunction(resolved_decl)) {
+ String *this_decl_resolved = SwigType_typedef_resolve_all(this_decl);
+ bool identically_overloaded_method = false; // true when a base class' method is implemented in n
+ if (SwigType_isfunction(this_decl_resolved)) {
String *name = Getattr(mi.item, "name");
for (Node *child = firstChild(n); child; child = nextSibling(child)) {
if (Getattr(child, "interface:owner"))
break; // at the end of the list are newly appended methods
if (checkAttribute(child, "name", name)) {
String *decl = SwigType_typedef_resolve_all(Getattr(child, "decl"));
- overloaded = Strcmp(decl, this_decl) == 0;
+ identically_overloaded_method = Strcmp(decl, this_decl_resolved) == 0;
Delete(decl);
- if (overloaded)
+ if (identically_overloaded_method)
break;
}
}
}
- Delete(resolved_decl);
- if (!overloaded)
+ Delete(this_decl_resolved);
+ if (!identically_overloaded_method) {
+ // TODO: Fix if the method is overloaded with different arguments / has default args
appendChild(n, mi.item);
- else
+ } else {
Delete(mi.item);
+ }
}
Delete(methods);
}