Added 3 new files
[mono.git] / mono / tests / pinvoke8.cs
1 using System;
2 using System.Runtime.InteropServices;
3
4 public class Test {
5
6         [StructLayout (LayoutKind.Sequential)]
7         public struct SimpleStruct {
8                 public bool a;
9                 public bool b;
10                 public bool c;
11                 public string d;
12         }
13
14         [DllImport ("libtest.so", EntryPoint="mono_test_return_vtype2")]
15         public static extern SimpleStruct mono_test_return_vtype2 (ReturnVTypeDelegate d);
16
17         public static SimpleStruct managed_return_vtype (SimpleStruct ss) {
18                 SimpleStruct res;
19
20                 Console.WriteLine ("delegate called");
21                 Console.WriteLine ("A: " + ss.a);
22                 Console.WriteLine ("B: " + ss.b);
23                 Console.WriteLine ("C: " + ss.c);
24                 Console.WriteLine ("D: " + ss.d);
25
26                 res.a = !ss.a;
27                 res.b = !ss.b;
28                 res.c = !ss.c;
29                 res.d = "TEST5";
30
31                 return res;
32         }
33
34         public delegate SimpleStruct ReturnVTypeDelegate (SimpleStruct ss);
35
36         public static int Main () {
37                 ReturnVTypeDelegate d = new ReturnVTypeDelegate (managed_return_vtype);
38                 SimpleStruct ss = mono_test_return_vtype2 (d);
39
40                 Console.WriteLine ("A: " + ss.a);
41                 Console.WriteLine ("B: " + ss.b);
42                 Console.WriteLine ("C: " + ss.c);
43                 Console.WriteLine ("D: " + ss.d);
44
45                 if (!ss.a && ss.b && !ss.c && ss.d == "TEST5")
46                         return 0;
47                 
48                 return 1;
49         }
50 }