Merged trunk up to revision 12426

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/szager-python-builtin@12427 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Stefan Zager 2011-02-03 19:30:45 +00:00
commit 52a807ce95
16 changed files with 216 additions and 27 deletions

View file

@ -35,11 +35,10 @@ print " Square = (" . $s->x . "," . $s->y . ")\n";
# ----- Call some methods -----
print "\nHere are some properties of the shapes:\n";
print "\nCall some overloaded methods:\n";
foreach (array(1, 2.1, "quick brown fox", $c, $s) as $o) {
print " ".get_class($o)." \$o\n";
print " overloaded = " . overloaded($o) . "\n";
}
print " overloaded = " . overloaded($o) . "\n";
}
# Need to unset($o) or else we hang on to a reference to the Square object.
unset($o);

View file

@ -0,0 +1,11 @@
using System;
using director_alternatingNamespace;
public class director_alternating_runme {
public static void Main() {
if (director_alternating.getBar().id() != director_alternating.idFromGetBar())
throw new Exception("idFromGetBar failed");
}
}

View file

@ -16,6 +16,7 @@ public class runme
Foo f = b.create();
FooBar fb = new FooBar();
FooBar2 fb2 = new FooBar2();
FooBar3 fb3 = new FooBar3();
String s;
s = fb.used();
@ -37,6 +38,21 @@ public class runme
s = fb.pong();
if ( s != ("Bar::pong();Foo::pong();FooBar::ping();"))
throw new Exception("bad FooBar::pong");
// if (fb3.cheer() != "FooBar3::cheer();")
// throw new Exception("bad fb3::cheer");
if (fb2.callping() != "FooBar2::ping();")
throw new Exception("bad fb2.callping");
if (fb2.callcheer() != "FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();")
throw new Exception("bad fb2.callcheer");
if (fb3.callping() != "Bar::ping();")
throw new Exception("bad fb3.callping");
if (fb3.callcheer() != "FooBar3::cheer();")
throw new Exception("bad fb3.callcheer");
}
}
@ -69,4 +85,16 @@ class FooBar2 : Bar
}
}
class FooBar3 : Bar
{
public FooBar3() : base()
{
}
protected override String cheer()
{
return "FooBar3::cheer();";
}
}
}

View file

@ -53,6 +53,10 @@ protected:
virtual std::string used() {
return pang() + pong();
}
virtual std::string cheer() {
return pang() + pong();
}
};
class Bar : public Foo
@ -63,6 +67,14 @@ public:
return new Bar();
}
std::string callping() {
return ping();
}
std::string callcheer() {
return cheer();
}
std::string pong() {
return "Bar::pong();" + Foo::pong();
}
@ -75,6 +87,7 @@ protected:
std::string ping() {
return "Bar::ping();";
};
using Foo::cheer;
enum Hello {hola, chao};

View file

@ -59,9 +59,22 @@
public:
virtual C get_value() const = 0;
using Bar::do_advance;
};
}
%template(FooBar_int) FooBar<int>;
%inline %{
struct SomeBase {
virtual ~SomeBase() {}
virtual void method1() {}
virtual void method2() {}
};
struct PrivateDerived : SomeBase {
private:
virtual void method1() {}
using SomeBase::method2;
};
%}

View file

@ -19,6 +19,7 @@ public class director_protected_runme {
Foo f = b.create();
director_protected_FooBar fb = new director_protected_FooBar();
director_protected_FooBar2 fb2 = new director_protected_FooBar2();
director_protected_FooBar3 fb3 = new director_protected_FooBar3();
{
String s = fb.used();
@ -60,11 +61,34 @@ public class director_protected_runme {
if ( !Modifier.isProtected(method.getModifiers()) )
throw new RuntimeException("Foo::ping should be protected" );
method = b.getClass().getDeclaredMethod("cheer", (java.lang.Class[])null);
if ( !Modifier.isProtected(method.getModifiers()) )
throw new RuntimeException("Bar::cheer should be protected" );
method = f.getClass().getDeclaredMethod("cheer", (java.lang.Class[])null);
if ( !Modifier.isProtected(method.getModifiers()) )
throw new RuntimeException("Foo::cheer should be protected" );
} catch (NoSuchMethodException n) {
throw new RuntimeException("NoSuchmethodException caught. Test failed.");
throw new RuntimeException(n);
} catch (SecurityException s) {
throw new RuntimeException("SecurityException caught. Test failed.");
}
if (!fb3.cheer().equals("director_protected_FooBar3::cheer();"))
throw new RuntimeException("bad fb3::cheer");
if (!fb2.callping().equals("director_protected_FooBar2::ping();"))
throw new RuntimeException("bad fb2.callping");
if (!fb2.callcheer().equals("director_protected_FooBar2::pang();Bar::pong();Foo::pong();director_protected_FooBar2::ping();"))
throw new RuntimeException("bad fb2.callcheer");
if (!fb3.callping().equals("Bar::ping();"))
throw new RuntimeException("bad fb3.callping");
if (!fb3.callcheer().equals("director_protected_FooBar3::cheer();"))
throw new RuntimeException("bad fb3.callcheer");
}
}
@ -83,3 +107,9 @@ class director_protected_FooBar2 extends Bar {
}
}
class director_protected_FooBar3 extends Bar {
public String cheer() {
return "director_protected_FooBar3::cheer();";
}
}

View file

@ -45,6 +45,7 @@
%shared_ptr(Space::KlassDerived)
%shared_ptr(Space::Klass2ndDerived)
%shared_ptr(Space::Klass3rdDerived)
%shared_ptr(IgnoredMultipleInheritBase) // IgnoredMultipleInheritBase not actually used in any wrapped functions, so this isn't entirely necessary and warning 520 could instead have been suppressed.
#endif

View file

@ -18,8 +18,8 @@ public:
double *z;
void move(double dx, double dy);
virtual double area(Shape &ref, int & (FunkSpace::Funktions::*d)(const int &, int));
virtual double abc(Thing<short> ts, Thing< const Space::Shape * > tda[]);
virtual double area(Shape &ref, int & (FunkSpace::Funktions::*d)(const int &, int)) { return 0.0; }
virtual double abc(Thing<short> ts, Thing< const Space::Shape * > tda[]) { return 0.0; }
};
}

View file

@ -26,10 +26,17 @@ class FooBar2 extends Bar {
}
}
class FooBar3 extends Bar {
function cheer() {
return "FooBar3::cheer();";
}
}
$b = new Bar();
$f = $b->create();
$fb = new FooBar();
$fb2 = new FooBar2();
$fb3 = new FooBar3();
check::equal($fb->used(), "Foo::pang();Bar::pong();Foo::pong();FooBar::ping();", "bad FooBar::used");
@ -42,7 +49,7 @@ check::equal($f->pong(), "Bar::pong();Foo::pong();Bar::ping();", "bad Foo::pong"
check::equal($fb->pong(), "Bar::pong();Foo::pong();FooBar::ping();", "bad FooBar::pong");
$method = new ReflectionMethod('Bar', 'ping');
check::equal($method->isProtected(), true, "Boo::ping should be protected");
check::equal($method->isProtected(), true, "Foo::ping should be protected");
$method = new ReflectionMethod('Foo', 'ping');
check::equal($method->isProtected(), true, "Foo::ping should be protected");
@ -50,5 +57,17 @@ check::equal($method->isProtected(), true, "Foo::ping should be protected");
$method = new ReflectionMethod('FooBar', 'pang');
check::equal($method->isProtected(), true, "FooBar::pang should be protected");
$method = new ReflectionMethod('Bar', 'cheer');
check::equal($method->isProtected(), true, "Bar::cheer should be protected");
$method = new ReflectionMethod('Foo', 'cheer');
check::equal($method->isProtected(), true, "Foo::cheer should be protected");
check::equal($fb3->cheer(), "FooBar3::cheer();", "bad fb3::pong");
check::equal($fb2->callping(), "FooBar2::ping();", "bad fb2::callping");
check::equal($fb2->callcheer(), "FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();", "bad fb2::callcheer");
check::equal($fb3->callping(), "Bar::ping();", "bad fb3::callping");
check::equal($fb3->callcheer(), "FooBar3::cheer();", "bad fb3::callcheer");
check::done();
?>

View file

@ -12,11 +12,16 @@ class FooBar2(Bar):
def pang(self):
return "FooBar2::pang();"
class FooBar3(Bar):
def cheer(self):
return "FooBar3::cheer();"
b = Bar()
f = b.create()
fb = FooBar()
fb2 = FooBar2()
fb3 = FooBar3()
try:
@ -66,7 +71,7 @@ try:
except:
pass
if not protected:
raise RuntimeError,"Boo::ping is protected"
raise RuntimeError,"Foo::ping is protected"
protected=1
try:
@ -86,3 +91,39 @@ except:
pass
if not protected:
raise RuntimeError,"FooBar::pang is protected"
protected=1
try:
b.cheer()
protected=0
except:
pass
if not protected:
raise RuntimeError,"Bar::cheer is protected"
protected=1
try:
f.cheer()
protected=0
except:
pass
if not protected:
raise RuntimeError,"Foo::cheer is protected"
if fb3.cheer() != "FooBar3::cheer();":
raise RuntimeError, "bad fb3::cheer"
if fb2.callping() != "FooBar2::ping();":
raise RuntimeError, "bad fb2.callping"
if fb2.callcheer() != "FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();":
raise RuntimeError, "bad fb2.callcheer"
if fb3.callping() != "Bar::ping();":
raise RuntimeError, "bad fb3.callping"
if fb3.callcheer() != "FooBar3::cheer();":
raise RuntimeError, "bad fb3.callcheer"