mirror of https://github.com/swig/swig
Add testcase for using declaration and extend for flattening class
Closes #1581
This commit is contained in:
parent
30030583da
commit
3b01f3fd91
|
@ -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 \
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -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() {}
|
||||
%}
|
Loading…
Reference in New Issue