2004-02-02 Zoltan Varga <vargaz@freemail.hu>
[mono.git] / mono / tests / pinvoke14.cs
1 using System;
2 using System.Runtime.InteropServices;
3
4 [StructLayout (LayoutKind.Sequential)]
5 class SimpleObj
6 {
7         public string str;
8         public int i;
9 }
10
11 class Test {
12         
13         [DllImport ("libtest")]
14         static extern int class_marshal_test0 (SimpleObj obj);
15
16         [DllImport ("libtest")]
17         static extern void class_marshal_test1 (out SimpleObj obj);
18         
19         [DllImport ("libtest")]
20         static extern int class_marshal_test2 (ref SimpleObj obj);
21
22         [DllImport ("libtest")]
23         static extern int class_marshal_test4 (SimpleObj obj);
24
25         static int Main ()
26         {
27                 SimpleObj obj0 = new SimpleObj ();
28                 obj0.str = "T1";
29                 obj0.i = 4;
30                 
31                 if (class_marshal_test0 (obj0) != 0)
32                         return 1;
33
34                 if (class_marshal_test4 (null) != 0)
35                         return 2;
36
37                 SimpleObj obj1;
38
39                 class_marshal_test1 (out obj1);
40
41                 if (obj1.str != "ABC")
42                         return 3;
43
44                 if (obj1.i != 5)
45                         return 4;
46
47                 if (class_marshal_test2 (ref obj1) != 0)
48                         return 5;
49                 
50                 return 0;
51         }
52 }