Using declarations in inheritance hierarchy improvements.

- Improved documentation for using declarations.
- Issue new warning WARN_LANG_USING_NAME_DIFFERENT when there
  is a conflict in the target language name to be used when
  introducing a method via a using declaration. Previously
  the method was silently ignored. Issue #1840. Issue #655.
This commit is contained in:
William S Fulton 2022-02-26 12:13:11 +00:00
commit 79a1bbee8b
8 changed files with 176 additions and 30 deletions

View file

@ -0,0 +1,7 @@
cpp_using_rename.i:18: Warning 526: Using declaration Base::use_me, with name 'use_me', is not actually using
cpp_using_rename.i:10: Warning 526: the method from Base::use_me(int), with name 'UseMe', as the names are different.
cpp_using_rename.i:19: Warning 526: Using declaration Base::use_me_too, with name 'UseMeToo', is not actually using
cpp_using_rename.i:11: Warning 526: the method from Base::use_me_too(double) const, with name 'use_me_too', as the names are different.
cpp_using_rename.i:19: Warning 526: Using declaration Base::use_me_too, with name 'UseMeToo', is not actually using
cpp_using_rename.i:12: Warning 526: the method from Base::use_me_too(bool) const, with name 'use_me_too', as the names are different.
cpp_using_rename.i:20: Warning 315: Nothing known about 'Base::does_not_exist'.

View file

@ -12,3 +12,13 @@ bb = BB()
swig_assert_equal(bb.greater(int(1)), 0)
swig_assert_equal(bb.greater(float(1)), 1)
swig_assert_equal(bb.great(True), 2)
cc = CC()
swig_assert_equal(cc.greater(int(10)), 0)
swig_assert_equal(cc.greater(float(10)), 1)
swig_assert_equal(cc.greater(True), 20)
dd = DD()
swig_assert_equal(dd.greater(int(10)), 0)
swig_assert_equal(dd.greater(float(10)), 1)
swig_assert_equal(dd.greaterstill(True), 30)

View file

@ -1,7 +1,13 @@
%module using_member
/* using declaration tests, including renaming */
%warnfilter(SWIGWARN_LANG_USING_NAME_DIFFERENT) one::twotwo::threetwo::BB::great;
%rename(greater) one::two::three::interface1::AA::great(int);
%rename(greater) one::two::three::interface1::AA::great(float);
%rename(greater) one::CC::great;
%rename(greater) one::DD::great;
%rename(greaterstill) one::DD::great(bool);
%inline %{
namespace interface1
@ -46,5 +52,19 @@ namespace one {
};
}
}
class CC : public two::three::AA
{
public:
using two::three::AA::great;
int great(bool) {return 20;}
};
class DD : public two::three::AA
{
public:
using two::three::AA::great;
int great(bool) {return 30;}
};
}
%}