test directors with classes passed by value, ref and pointer

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7436 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2005-09-13 21:02:21 +00:00
parent cc61850448
commit 5b2e9e54ca
2 changed files with 23 additions and 8 deletions

View File

@ -22,7 +22,9 @@ class Bar
public:
virtual ~Bar();
virtual Foo_int *meth();
virtual void foo_meth(Foo_int &, int);
virtual void foo_meth_ref(Foo_int &, int);
virtual void foo_meth_ptr(Foo_int *, int);
virtual void foo_meth_val(Foo_int, int);
};
Bar::~Bar()
@ -34,10 +36,9 @@ Bar::meth()
return new Foo_int();
}
void
Bar::foo_meth(Foo_int &arg, int param)
{
}
void Bar::foo_meth_ref(Foo_int &arg, int param) { }
void Bar::foo_meth_ptr(Foo_int *arg, int param) { }
void Bar::foo_meth_val(Foo_int arg, int param) { }
%}
%template(Foo_integers) Foo<int>;

View File

@ -39,7 +39,9 @@ public class director_wombat_runme
b.delete();
b = new director_wombat_Bar_derived_1();
b.foo_meth(a, 0);
b.foo_meth_ref(a, 0);
b.foo_meth_ptr(a, 1);
b.foo_meth_val(a, 2);
}
}
@ -71,10 +73,22 @@ class director_wombat_Bar_derived_1 extends Bar
super();
}
public void foo_meth(Foo_integers foo_obj, int param)
public void foo_meth_ref(Foo_integers foo_obj, int param)
{
if (!(foo_obj instanceof director_wombat_Foo_integers_derived_2)) {
throw new RuntimeException ("Test failed: foo_obj is not director_wombat_Foo_integers_derived_2, got " + foo_obj);
throw new RuntimeException ("Test failed: foo_obj in foo_meth_ref is not director_wombat_Foo_integers_derived_2, got " + foo_obj);
}
}
public void foo_meth_ptr(Foo_integers foo_obj, int param)
{
if (!(foo_obj instanceof director_wombat_Foo_integers_derived_2)) {
throw new RuntimeException ("Test failed: foo_obj in foo_meth_ptr is not director_wombat_Foo_integers_derived_2, got " + foo_obj);
}
}
public void foo_meth_val(Foo_integers foo_obj, int param)
{
if (!(foo_obj instanceof director_wombat_Foo_integers_derived_2)) {
throw new RuntimeException ("Test failed: foo_obj in foo_meth_val is not director_wombat_Foo_integers_derived_2, got " + foo_obj);
}
}
}