From 5d0b27c7a6c4aae2b14e50bdab63b1b388f7a6cd Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 28 Apr 2005 22:03:50 +0000 Subject: [PATCH] test asymmetric type marshalling - out attribute for ctype, imtype and cstype typemaps. also test fix for garbage collection problem where the proxy class was being collected before an unmanaged function that used the object returned - problem was most visible in multithreaded environment, so the test kicks off a few threads git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7173 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/csharp/Makefile.in | 1 + .../csharp/csharp_typemaps_runme.cs | 108 ++++++++++++++++++ Examples/test-suite/csharp_typemaps.i | 75 ++++++++++++ 3 files changed, 184 insertions(+) create mode 100644 Examples/test-suite/csharp/csharp_typemaps_runme.cs create mode 100644 Examples/test-suite/csharp_typemaps.i diff --git a/Examples/test-suite/csharp/Makefile.in b/Examples/test-suite/csharp/Makefile.in index 010ab0bab..597dbd211 100644 --- a/Examples/test-suite/csharp/Makefile.in +++ b/Examples/test-suite/csharp/Makefile.in @@ -14,6 +14,7 @@ top_builddir = @top_builddir@../ CPP_TEST_CASES = \ csharp_exceptions \ + csharp_typemaps \ enum_thorough_simple \ enum_thorough_typesafe diff --git a/Examples/test-suite/csharp/csharp_typemaps_runme.cs b/Examples/test-suite/csharp/csharp_typemaps_runme.cs new file mode 100644 index 000000000..66afb3692 --- /dev/null +++ b/Examples/test-suite/csharp/csharp_typemaps_runme.cs @@ -0,0 +1,108 @@ +using System; +using System.Threading; +using csharp_typemapsNamespace; + +public class runme +{ + static void Main() + { + // Test the C# types customisation by modifying the default char * typemaps to return a single char + Things things = new Things(); + System.Text.StringBuilder initialLetters = new System.Text.StringBuilder(); + char myChar = things.start("boo"); + initialLetters.Append(myChar); + myChar = Things.stop("hiss"); + initialLetters.Append(myChar); + myChar = csharp_typemaps.partyon("off"); + initialLetters.Append(myChar); + myChar = csharp_typemaps.STRINGCONSTANT; + initialLetters.Append(myChar); + if (initialLetters.ToString() != "bhox") + throw new Exception("initial letters failed"); + if (csharp_typemaps.go != "zzz") + throw new Exception("go variable failed"); + + // Eager garbage collector test + { + const int NUM_THREADS = 8; + Thread[] threads = new Thread[NUM_THREADS]; + TestThread[] testThreads = new TestThread[NUM_THREADS]; + // invoke the threads + for (int i=0; i