diff options
author | Jeff Greene <hippiehunterenator@gmail.com> | 2017-11-17 05:59:49 +0300 |
---|---|---|
committer | Morgan Brown <morganbr@users.noreply.github.com> | 2017-11-17 05:59:49 +0300 |
commit | 4eada9a5ec5e7e3243a85f7d3399a7e0474ab2f8 (patch) | |
tree | 6903584b4e1be3b628f6644d3124a19b59c9f341 /tests | |
parent | 7384d4ab9969f9bd2edddbd7f80df6612c42b476 (diff) |
Added support for calling methods via virtual slots in WASM (#4931)
* Added support for calling methods via virtual slots
Diffstat (limited to 'tests')
-rw-r--r-- | tests/src/Simple/HelloWasm/Program.cs | 42 |
1 files changed, 35 insertions, 7 deletions
diff --git a/tests/src/Simple/HelloWasm/Program.cs b/tests/src/Simple/HelloWasm/Program.cs index 6d4a5a6e7..4bd9cba4e 100644 --- a/tests/src/Simple/HelloWasm/Program.cs +++ b/tests/src/Simple/HelloWasm/Program.cs @@ -11,17 +11,18 @@ internal static class Program private static unsafe void Main(string[] args) { Add(1, 2); - var tempObj = new TestClass(1337); int tempInt = 0; (*(&tempInt)) = 9; - - tempObj.TestMethod("Hello"); - if(tempInt == 9) { PrintLine("Hello from C#!"); } - + + TestClass tempObj = new TestDerivedClass(1337); + tempObj.TestMethod("Hello"); + tempObj.TestVirtualMethod("Hello"); + tempObj.TestVirtualMethod2("Hello"); + TwoByteStr str = new TwoByteStr() { first = 1, second = 2 }; TwoByteStr str2 = new TwoByteStr() { first = 3, second = 4 }; *(&str) = str2; @@ -107,7 +108,7 @@ internal static class Program } } - private static void PrintLine(string s) + public static void PrintLine(string s) { PrintString(s); PrintString("\n"); @@ -173,7 +174,7 @@ public struct TwoByteStr public class TestClass { public string TestString {get; set;} - + public TestClass(int number) { if(number != 1337) @@ -186,5 +187,32 @@ public class TestClass if(TestString != str) throw new Exception(); } + public virtual void TestVirtualMethod(string str) + { + Program.PrintLine("Virtual Slot Test: Ok If second"); + } + + public virtual void TestVirtualMethod2(string str) + { + Program.PrintLine("Virtual Slot Test 2: Ok"); + } +} + +public class TestDerivedClass : TestClass +{ + public TestDerivedClass(int number) : base(number) + { + + } + public override void TestVirtualMethod(string str) + { + Program.PrintLine("Virtual Slot Test: Ok"); + base.TestVirtualMethod(str); + } + + public override string ToString() + { + throw new Exception(); + } } |