[D] Fixed a bug in the loop breaking code for directors leading to a superclass implementation erroneously being called.
The situation in which this would previously happen is illustrated in the new "director_alternating" test case. Currently broken for C# and Java. Thanks to Jimmy Cao for reporting this. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12380 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
25c8689226
commit
892caec201
6 changed files with 69 additions and 4 deletions
|
|
@ -154,6 +154,7 @@ CPP_TEST_CASES += \
|
|||
derived_nested \
|
||||
destructor_reprotected \
|
||||
director_abstract \
|
||||
director_alternating \
|
||||
director_basic \
|
||||
director_classes \
|
||||
director_classic \
|
||||
|
|
|
|||
7
Examples/test-suite/d/director_alternating_runme.2.d
Normal file
7
Examples/test-suite/d/director_alternating_runme.2.d
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
module director_alternating_runme;
|
||||
|
||||
import director_alternating.director_alternating;
|
||||
|
||||
void main() {
|
||||
assert(getBar().id() == idFromGetBar());
|
||||
}
|
||||
36
Examples/test-suite/director_alternating.i
Normal file
36
Examples/test-suite/director_alternating.i
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
// Checks if calls to a method being defined in the base class, not
|
||||
// overridden in the subclass, but again overridden in a class derived from
|
||||
// the first subclass are dispatched correctly.
|
||||
%module(directors="1") director_alternating;
|
||||
|
||||
%feature("director") Foo;
|
||||
|
||||
%inline %{
|
||||
struct Foo {
|
||||
virtual ~Foo() {}
|
||||
virtual int id() {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
struct Bar : Foo {};
|
||||
|
||||
struct Baz : Bar {
|
||||
virtual int id() {
|
||||
return 2;
|
||||
}
|
||||
};
|
||||
|
||||
// Note that even though the return value is of type Bar*, it really points to
|
||||
// an instance of Baz (in which id() has been overridden).
|
||||
Bar *getBar() {
|
||||
static Baz baz;
|
||||
return &baz;
|
||||
}
|
||||
|
||||
// idFromGetBar() obviously is equivalent to getBar()->id() in C++ – this
|
||||
// should be true from the target language as well.
|
||||
int idFromGetBar() {
|
||||
return getBar()->id();
|
||||
}
|
||||
%}
|
||||
7
Examples/test-suite/director_alternating_runme.1.d
Normal file
7
Examples/test-suite/director_alternating_runme.1.d
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
module director_alternating_runme;
|
||||
|
||||
import director_alternating.director_alternating;
|
||||
|
||||
void main() {
|
||||
assert(getBar().id() == idFromGetBar());
|
||||
}
|
||||
5
Examples/test-suite/python/director_alternating_runme.py
Normal file
5
Examples/test-suite/python/director_alternating_runme.py
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
from director_alternating import *
|
||||
|
||||
id = getBar().id()
|
||||
if id != idFromGetBar():
|
||||
raise RuntimeError, "Got wrong id: " + str(id)
|
||||
Loading…
Add table
Add a link
Reference in a new issue