Add testcase for using declaration and extend for flattening class

Closes #1581
This commit is contained in:
William S Fulton 2024-08-24 17:32:07 +01:00
parent 30030583da
commit 3b01f3fd91
3 changed files with 56 additions and 0 deletions

View File

@ -586,6 +586,7 @@ CPP_TEST_CASES += \
using_directive_and_declaration \
using_directive_and_declaration_forward \
using_extend \
using_extend_flatten \
using_inherit \
using_member \
using_member_multiple_inherit \

View File

@ -0,0 +1,21 @@
import using_extend_flatten.*;
public class using_extend_flatten_runme {
static {
try {
System.loadLibrary("using_extend_flatten");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
System.exit(1);
}
}
public static void main(String argv[]) {
ExtendDerived ed = new ExtendDerived();
ed.one();
ed.two();
ed.three();
}
}

View File

@ -0,0 +1,34 @@
%module using_extend_flatten
// Issue #1581 - how to flatten all the methods in a base class into a derived class.
// Just ExtendDerived is exposed including the methods from the base class, exposed via a using declaration.
%extend ExtendDerived {
using ExtendBase::one;
}
%ignore ExtendBase;
%inline %{
class ExtendBase
{
public:
void one();
virtual void two();
virtual void three();
};
class ExtendDerived : public ExtendBase
{
public:
void two() override;
void three() override;
};
%}
%{
void ExtendBase::one() {}
void ExtendBase::two() {}
void ExtendBase::three() {}
void ExtendDerived::two() {}
void ExtendDerived::three() {}
%}