Merge branch 'director-shared_ptr'
* director-shared_ptr: director_smartptr runtime tests enhancement Fix Java shared_ptr and directors for derived classes java compilation error.
This commit is contained in:
commit
63a7f3c6b3
6 changed files with 116 additions and 1 deletions
|
|
@ -7,6 +7,14 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
|
|||
Version 4.0.0 (in progress)
|
||||
===========================
|
||||
|
||||
2017-05-23: wsfulton
|
||||
[Java] #230 #759 Fix Java shared_ptr and directors for derived classes java compilation
|
||||
error.
|
||||
|
||||
For shared_ptr proxy proxy classes, add a protected method swigSetCMemOwn for modifying
|
||||
the swigCMemOwn and swigCMemOwnDerived member variables which are used by various other
|
||||
methods for controlling memory ownership.
|
||||
|
||||
2017-05-21: Sghirate
|
||||
[Java, C#, D] #449 Remove unnecessary use of dynamic_cast in directors to enable
|
||||
non-RTTI compilation.
|
||||
|
|
|
|||
|
|
@ -26,6 +26,29 @@ public class runme
|
|||
}
|
||||
}
|
||||
|
||||
private class director_smartptr_MyBarFooDerived : FooDerived
|
||||
{
|
||||
public override string ping()
|
||||
{
|
||||
return "director_smartptr_MyBarFooDerived.ping()";
|
||||
}
|
||||
|
||||
public override string pong()
|
||||
{
|
||||
return "director_smartptr_MyBarFooDerived.pong();" + ping();
|
||||
}
|
||||
|
||||
public override string upcall(FooBar fooBarPtr)
|
||||
{
|
||||
return "overrideDerived;" + fooBarPtr.FooBarDo();
|
||||
}
|
||||
|
||||
public override Foo makeFoo()
|
||||
{
|
||||
return new Foo();
|
||||
}
|
||||
}
|
||||
|
||||
private static void check(string got, string expected)
|
||||
{
|
||||
if (got != expected)
|
||||
|
|
@ -49,5 +72,11 @@ public class runme
|
|||
Foo myFoo2 = new Foo().makeFoo();
|
||||
check(myFoo2.pong(), "Foo::pong();Foo::ping()");
|
||||
check(Foo.callPong(myFoo2), "Foo::pong();Foo::ping()");
|
||||
|
||||
FooDerived myBarFooDerived = new director_smartptr_MyBarFooDerived();
|
||||
check(myBarFooDerived.ping(), "director_smartptr_MyBarFooDerived.ping()");
|
||||
check(FooDerived.callPong(myBarFooDerived), "director_smartptr_MyBarFooDerived.pong();director_smartptr_MyBarFooDerived.ping()");
|
||||
check(FooDerived.callUpcall(myBarFooDerived, fooBar), "overrideDerived;Bar::Foo2::Foo2Bar()");
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,6 @@ public:
|
|||
%include <boost_shared_ptr.i>
|
||||
|
||||
%shared_ptr(Foo)
|
||||
|
||||
%feature("director") Foo;
|
||||
|
||||
class FooBar {
|
||||
|
|
@ -72,5 +71,12 @@ public:
|
|||
static Foo* get_self(Foo *self_);
|
||||
};
|
||||
|
||||
%shared_ptr(FooDerived)
|
||||
%feature("director") FooDerived;
|
||||
|
||||
%inline %{
|
||||
struct FooDerived : Foo {
|
||||
};
|
||||
%}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,12 @@ public class director_smartptr_runme {
|
|||
director_smartptr.Foo myFoo2 = new director_smartptr.Foo().makeFoo();
|
||||
check(myFoo2.pong(), "Foo::pong();Foo::ping()");
|
||||
check(director_smartptr.Foo.callPong(myFoo2), "Foo::pong();Foo::ping()");
|
||||
|
||||
director_smartptr.FooDerived myBarFooDerived = new director_smartptr_MyBarFooDerived();
|
||||
check(myBarFooDerived.ping(), "director_smartptr_MyBarFooDerived.ping()");
|
||||
check(director_smartptr.FooDerived.callPong(myBarFooDerived), "director_smartptr_MyBarFooDerived.pong();director_smartptr_MyBarFooDerived.ping()");
|
||||
check(director_smartptr.FooDerived.callUpcall(myBarFooDerived, fooBar), "overrideDerived;Bar::Foo2::Foo2Bar()");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -58,3 +64,26 @@ class director_smartptr_MyBarFoo extends director_smartptr.Foo {
|
|||
return new director_smartptr.Foo();
|
||||
}
|
||||
}
|
||||
|
||||
class director_smartptr_MyBarFooDerived extends director_smartptr.FooDerived {
|
||||
|
||||
@Override
|
||||
public String ping() {
|
||||
return "director_smartptr_MyBarFooDerived.ping()";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String pong() {
|
||||
return "director_smartptr_MyBarFooDerived.pong();" + ping();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String upcall(director_smartptr.FooBar fooBarPtr) {
|
||||
return "overrideDerived;" + fooBarPtr.FooBarDo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public director_smartptr.Foo makeFoo() {
|
||||
return new director_smartptr.Foo();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,20 @@ class director_smartptr_MyBarFoo(Foo):
|
|||
def makeFoo(self):
|
||||
return Foo()
|
||||
|
||||
class director_smartptr_MyBarFooDerived(FooDerived):
|
||||
|
||||
def ping(self):
|
||||
return "director_smartptr_MyBarFooDerived.ping()"
|
||||
|
||||
def pong(self):
|
||||
return "director_smartptr_MyBarFooDerived.pong();" + self.ping()
|
||||
|
||||
def upcall(self, fooBarPtr):
|
||||
return "overrideDerived;" + fooBarPtr.FooBarDo()
|
||||
|
||||
def makeFoo(self):
|
||||
return Foo()
|
||||
|
||||
def check(got, expected):
|
||||
if (got != expected):
|
||||
raise RuntimeError, "Failed, got: " + got + " expected: " + expected
|
||||
|
|
@ -35,3 +49,8 @@ myFoo2 = Foo().makeFoo()
|
|||
check(myFoo2.pong(), "Foo::pong();Foo::ping()")
|
||||
check(Foo.callPong(myFoo2), "Foo::pong();Foo::ping()")
|
||||
check(myFoo2.upcall(FooBar()), "Bar::Foo2::Foo2Bar()")
|
||||
|
||||
myBarFooDerived = director_smartptr_MyBarFooDerived()
|
||||
check(myBarFooDerived.ping(), "director_smartptr_MyBarFooDerived.ping()")
|
||||
check(FooDerived.callPong(myBarFooDerived), "director_smartptr_MyBarFooDerived.pong();director_smartptr_MyBarFooDerived.ping()")
|
||||
check(FooDerived.callUpcall(myBarFooDerived, fooBar), "overrideDerived;Bar::Foo2::Foo2Bar()")
|
||||
|
|
|
|||
|
|
@ -30,6 +30,25 @@ class Director_smartptr_MyBarFoo < Foo
|
|||
end
|
||||
end
|
||||
|
||||
class Director_smartptr_MyBarFooDerived < FooDerived
|
||||
|
||||
def ping()
|
||||
return "director_smartptr_MyBarFooDerived.ping()"
|
||||
end
|
||||
|
||||
def pong()
|
||||
return "director_smartptr_MyBarFooDerived.pong();" + ping()
|
||||
end
|
||||
|
||||
def upcall(fooBarPtr)
|
||||
return "overrideDerived;" + fooBarPtr.FooBarDo()
|
||||
end
|
||||
|
||||
def makeFoo()
|
||||
return Foo.new()
|
||||
end
|
||||
end
|
||||
|
||||
def check(got, expected)
|
||||
if (got != expected)
|
||||
raise RuntimeError, "Failed, got: #{got} expected: #{expected}"
|
||||
|
|
@ -52,3 +71,8 @@ myFoo2 = Foo.new().makeFoo()
|
|||
check(myFoo2.pong(), "Foo::pong();Foo::ping()")
|
||||
check(Foo.callPong(myFoo2), "Foo::pong();Foo::ping()")
|
||||
check(myFoo2.upcall(FooBar.new()), "Bar::Foo2::Foo2Bar()")
|
||||
|
||||
myBarFooDerived = Director_smartptr_MyBarFooDerived.new()
|
||||
check(myBarFooDerived.ping(), "director_smartptr_MyBarFooDerived.ping()")
|
||||
check(FooDerived.callPong(myBarFooDerived), "director_smartptr_MyBarFooDerived.pong();director_smartptr_MyBarFooDerived.ping()")
|
||||
check(FooDerived.callUpcall(myBarFooDerived, fooBar), "overrideDerived;Bar::Foo2::Foo2Bar()")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue