summaryrefslogtreecommitdiff
path: root/Examples
diff options
context:
space:
mode:
Diffstat (limited to 'Examples')
-rw-r--r--Examples/test-suite/csharp/director_alternating_runme.cs11
-rw-r--r--Examples/test-suite/csharp/director_protected_runme.cs28
-rw-r--r--Examples/test-suite/director_protected.i13
-rw-r--r--Examples/test-suite/director_using.i15
-rw-r--r--Examples/test-suite/java/director_protected_runme.java32
-rw-r--r--Examples/test-suite/php/director_protected_runme.php21
-rw-r--r--Examples/test-suite/python/director_protected_runme.py43
7 files changed, 159 insertions, 4 deletions
diff --git a/Examples/test-suite/csharp/director_alternating_runme.cs b/Examples/test-suite/csharp/director_alternating_runme.cs
new file mode 100644
index 000000000..19365217a
--- /dev/null
+++ b/Examples/test-suite/csharp/director_alternating_runme.cs
@@ -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");
+ }
+}
+
diff --git a/Examples/test-suite/csharp/director_protected_runme.cs b/Examples/test-suite/csharp/director_protected_runme.cs
index ee4697b0e..b44c3b7e9 100644
--- a/Examples/test-suite/csharp/director_protected_runme.cs
+++ b/Examples/test-suite/csharp/director_protected_runme.cs
@@ -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();";
+ }
+}
+
}
diff --git a/Examples/test-suite/director_protected.i b/Examples/test-suite/director_protected.i
index fee45b4a6..0299b238d 100644
--- a/Examples/test-suite/director_protected.i
+++ b/Examples/test-suite/director_protected.i
@@ -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};
diff --git a/Examples/test-suite/director_using.i b/Examples/test-suite/director_using.i
index 9001ffbb9..d86546e86 100644
--- a/Examples/test-suite/director_using.i
+++ b/Examples/test-suite/director_using.i
@@ -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;
+ };
+%}
diff --git a/Examples/test-suite/java/director_protected_runme.java b/Examples/test-suite/java/director_protected_runme.java
index 464b4d4d9..63ac03502 100644
--- a/Examples/test-suite/java/director_protected_runme.java
+++ b/Examples/test-suite/java/director_protected_runme.java
@@ -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();";
+ }
+}
+
diff --git a/Examples/test-suite/php/director_protected_runme.php b/Examples/test-suite/php/director_protected_runme.php
index 73bcba1fd..9d47ef658 100644
--- a/Examples/test-suite/php/director_protected_runme.php
+++ b/Examples/test-suite/php/director_protected_runme.php
@@ -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();
?>
diff --git a/Examples/test-suite/python/director_protected_runme.py b/Examples/test-suite/python/director_protected_runme.py
index 9d565a1b4..fd3c868a1 100644
--- a/Examples/test-suite/python/director_protected_runme.py
+++ b/Examples/test-suite/python/director_protected_runme.py
@@ -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"
+
+