Fixes for the family of %interface macros for overloaded methods

When C++ methods are not able to be overloaded in a derived class,
such as when they differ by just const, or the target language
parameters types are identical even when the C++ parameter types
are different, SWIG will ignore one of the overloaded methods with
a warning. A %ignore is required to explicitly ignore one of the
overloaded methods to avoid the warning message. Methods added
in the derived classes due to one of the %interface macros are now
similarly ignored/not added to the derived class.

The adding of additional methods into the parse tree is now more
robust and complete resulting in support for %feature and %rename
for the added methods.

Closes #1277
This commit is contained in:
William S Fulton 2022-03-12 12:46:59 +00:00
commit b6ece11fc1
12 changed files with 259 additions and 15 deletions

View file

@ -3434,9 +3434,11 @@ Consider the following C++ code:
namespace Space {
struct Base1 {
virtual void Method1();
virtual Base1();
};
struct Base2 {
virtual void Method2();
virtual Base2();
};
struct Derived : Base1, Base2 {
};
@ -3453,7 +3455,7 @@ SWIG generates a warning for the above code:
<div class="shell">
<pre>
example.i:10: Warning 813: Warning for Derived, base Base2 ignored.
example.i:12: Warning 813: Warning for Derived, base Base2 ignored.
Multiple inheritance is not supported in Java.
</pre>
</div>
@ -3506,7 +3508,7 @@ public class Base1SwigImpl implements Base1 {
</div>
<p>
In fact any class deriving from <tt>Base</tt> will now implement the interface instead of
In fact any class using <tt>Base</tt> as an immediate base class will now implement the interface instead of
deriving from it (or ignoring the base in the case of multiple base classes).
Hence the <tt>Derived</tt> proxy class will now implement both bases:
</p>
@ -3535,6 +3537,15 @@ public class Derived implements Base1, Base2 {
</pre>
</div>
<p>
The proxy class has methods added to it, from the implemented bases, so that
the underlying C++ implementation can be called.
In the example above, <tt>Method1</tt> and <tt>Method2</tt> have been added from the implemented bases.
If a method is ignored in the base, such as via <tt>%ignore</tt>, then that method
will be excluded from the interface and there will not be an additional method
added to the proxy class implementing that interface.
</p>
<p>
Wherever a class marked as an interface is used, such as the <tt>UseBases</tt> method in the example,
the interface name is used as the type in the Java layer: