new director test
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@9213 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
afa9552b5c
commit
7c2c142a68
5 changed files with 359 additions and 0 deletions
116
Examples/test-suite/csharp/director_classic_runme.cs
Executable file
116
Examples/test-suite/csharp/director_classic_runme.cs
Executable file
|
|
@ -0,0 +1,116 @@
|
|||
using System;
|
||||
|
||||
namespace director_classicNamespace {
|
||||
|
||||
public class runme
|
||||
{
|
||||
static void Main()
|
||||
{
|
||||
{
|
||||
Person person = new Person();
|
||||
check(person, "Person");
|
||||
person.Dispose();
|
||||
}
|
||||
{
|
||||
Person person = new Child();
|
||||
check(person, "Child");
|
||||
person.Dispose();
|
||||
}
|
||||
{
|
||||
Person person = new GrandChild();
|
||||
check(person, "GrandChild");
|
||||
person.Dispose();
|
||||
}
|
||||
{
|
||||
Person person = new TargetLangPerson();
|
||||
check(person, "TargetLangPerson");
|
||||
person.Dispose();
|
||||
}
|
||||
{
|
||||
Person person = new TargetLangChild();
|
||||
check(person, "TargetLangChild");
|
||||
person.Dispose();
|
||||
}
|
||||
{
|
||||
Person person = new TargetLangGrandChild();
|
||||
check(person, "TargetLangGrandChild");
|
||||
person.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
static void check(Person person, String expected) {
|
||||
String ret;
|
||||
// Normal target language polymorphic call
|
||||
ret = person.id();
|
||||
if (debug)
|
||||
Console.WriteLine(ret);
|
||||
if (ret != expected)
|
||||
throw new Exception("Failed. Received: " + ret + " Expected: " + expected);
|
||||
|
||||
// Polymorphic call from C++
|
||||
Caller caller = new Caller();
|
||||
caller.setCallback(person);
|
||||
ret = caller.call();
|
||||
if (debug)
|
||||
Console.WriteLine(ret);
|
||||
if (ret != expected)
|
||||
throw new Exception("Failed. Received: " + ret + " Expected: " + expected);
|
||||
|
||||
// Polymorphic call of object created in target language and passed to C++ and back again
|
||||
Person baseclass = caller.baseClass();
|
||||
ret = baseclass.id();
|
||||
if (debug)
|
||||
Console.WriteLine(ret);
|
||||
if (ret != expected)
|
||||
throw new Exception("Failed. Received: " + ret + " Expected: " + expected);
|
||||
|
||||
caller.resetCallback();
|
||||
if (debug)
|
||||
Console.WriteLine("----------------------------------------");
|
||||
}
|
||||
static bool debug = false;
|
||||
}
|
||||
|
||||
public class TargetLangPerson : Person
|
||||
{
|
||||
public TargetLangPerson()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
|
||||
public override String id()
|
||||
{
|
||||
String identifier = "TargetLangPerson";
|
||||
return identifier;
|
||||
}
|
||||
}
|
||||
|
||||
public class TargetLangChild : Child
|
||||
{
|
||||
public TargetLangChild()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
|
||||
public override String id()
|
||||
{
|
||||
String identifier = "TargetLangChild";
|
||||
return identifier;
|
||||
}
|
||||
}
|
||||
|
||||
public class TargetLangGrandChild : GrandChild
|
||||
{
|
||||
public TargetLangGrandChild()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
|
||||
public override String id()
|
||||
{
|
||||
String identifier = "TargetLangGrandChild";
|
||||
return identifier;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue