Author: zoltan
Date: 2005-06-28 01:13:00 -0400 (Tue, 28 Jun 2005)
New Revision: 46620

Removed:
   trunk/mono/mono/tests/pinvoke18.cs
Modified:
   trunk/mono/mono/tests/Makefile.am
   trunk/mono/mono/tests/pinvoke2.cs
Log:
2005-06-27  Zoltan Varga  <[EMAIL PROTECTED]>

        * Makefile.am pinvoke18.cs pinvoke2.cs: Merge pinvoke18 into pinvoke2.


Modified: trunk/mono/mono/tests/Makefile.am
===================================================================
--- trunk/mono/mono/tests/Makefile.am   2005-06-28 04:42:01 UTC (rev 46619)
+++ trunk/mono/mono/tests/Makefile.am   2005-06-28 05:13:00 UTC (rev 46620)
@@ -74,7 +74,6 @@
        pinvoke11.cs            \
        pinvoke13.cs            \
        pinvoke17.cs            \
-       pinvoke18.cs            \
        invoke.cs               \
        invoke2.cs              \
        runtime-invoke.cs               \

Deleted: trunk/mono/mono/tests/pinvoke18.cs
===================================================================
--- trunk/mono/mono/tests/pinvoke18.cs  2005-06-28 04:42:01 UTC (rev 46619)
+++ trunk/mono/mono/tests/pinvoke18.cs  2005-06-28 05:13:00 UTC (rev 46620)
@@ -1,65 +0,0 @@
-using System;
-using System.Runtime.InteropServices;
-
-class Test
-{
-       [DllImport("libtest")]
-       extern static int marshal_test_ref_bool
-       (
-               int i, 
-               [MarshalAs(UnmanagedType.I1)] ref bool b1, 
-               [MarshalAs(UnmanagedType.VariantBool)] ref bool b2, 
-               ref bool b3
-       );
-
-       struct BoolStruct
-       {
-               public int i;
-               [MarshalAs(UnmanagedType.I1)] public bool b1;
-               [MarshalAs(UnmanagedType.VariantBool)] public bool b2;
-               public bool b3;
-       }
-
-       [DllImport("libtest")]
-       extern static int marshal_test_bool_struct(ref BoolStruct s);
-
-       public static int Main()
-       {
-               for (int i = 0; i < 8; i++)
-               {
-                       bool b1 = (i & 4) != 0;
-                       bool b2 = (i & 2) != 0;
-                       bool b3 = (i & 1) != 0;
-                       bool orig_b1 = b1, orig_b2 = b2, orig_b3 = b3;
-                       if (marshal_test_ref_bool(i, ref b1, ref b2, ref b3) != 
0)
-                               return 4 * i + 1;
-                       if (b1 != !orig_b1)
-                               return 4 * i + 2;
-                       if (b2 != !orig_b2)
-                               return 4 * i + 3;
-                       if (b3 != !orig_b3)
-                               return 4 * i + 4;
-               }
-
-               for (int i = 0; i < 8; i++)
-               {
-                       BoolStruct s = new BoolStruct();
-                       s.i = i;
-                       s.b1 = (i & 4) != 0;
-                       s.b2 = (i & 2) != 0;
-                       s.b3 = (i & 1) != 0;
-                       BoolStruct orig = s;
-                       if (marshal_test_bool_struct(ref s) != 0)
-                               return 4 * i + 33;
-                       if (s.b1 != !orig.b1)
-                               return 4 * i + 34;
-                       if (s.b2 != !orig.b2)
-                               return 4 * i + 35;
-                       if (s.b3 != !orig.b3)
-                               return 4 * i + 36;
-               }
-
-               Console.WriteLine("Success");
-               return 0;
-       }
-}

Modified: trunk/mono/mono/tests/pinvoke2.cs
===================================================================
--- trunk/mono/mono/tests/pinvoke2.cs   2005-06-28 04:42:01 UTC (rev 46619)
+++ trunk/mono/mono/tests/pinvoke2.cs   2005-06-28 05:13:00 UTC (rev 46620)
@@ -872,5 +872,76 @@
                
                return 0;               
        }
+
+       /*
+        * Byref bool marshalling
+        */
+
+       [DllImport("libtest")]
+       extern static int marshal_test_ref_bool
+       (
+               int i, 
+               [MarshalAs(UnmanagedType.I1)] ref bool b1, 
+               [MarshalAs(UnmanagedType.VariantBool)] ref bool b2, 
+               ref bool b3
+       );
+
+       public static int test_0_pass_byref_bool () {
+               for (int i = 0; i < 8; i++)
+               {
+                       bool b1 = (i & 4) != 0;
+                       bool b2 = (i & 2) != 0;
+                       bool b3 = (i & 1) != 0;
+                       bool orig_b1 = b1, orig_b2 = b2, orig_b3 = b3;
+                       if (marshal_test_ref_bool(i, ref b1, ref b2, ref b3) != 
0)
+                               return 4 * i + 1;
+                       if (b1 != !orig_b1)
+                               return 4 * i + 2;
+                       if (b2 != !orig_b2)
+                               return 4 * i + 3;
+                       if (b3 != !orig_b3)
+                               return 4 * i + 4;
+               }
+
+               return 0;
+       }
+
+       /*
+        * Bool struct field marshalling
+        */
+
+       struct BoolStruct
+       {
+               public int i;
+               [MarshalAs(UnmanagedType.I1)] public bool b1;
+               [MarshalAs(UnmanagedType.VariantBool)] public bool b2;
+               public bool b3;
+       }
+
+       [DllImport("libtest")]
+       extern static int marshal_test_bool_struct(ref BoolStruct s);
+
+       public static int test_0_pass_bool_in_struct () {
+               for (int i = 0; i < 8; i++)
+               {
+                       BoolStruct s = new BoolStruct();
+                       s.i = i;
+                       s.b1 = (i & 4) != 0;
+                       s.b2 = (i & 2) != 0;
+                       s.b3 = (i & 1) != 0;
+                       BoolStruct orig = s;
+                       if (marshal_test_bool_struct(ref s) != 0)
+                               return 4 * i + 33;
+                       if (s.b1 != !orig.b1)
+                               return 4 * i + 34;
+                       if (s.b2 != !orig.b2)
+                               return 4 * i + 35;
+                       if (s.b3 != !orig.b3)
+                               return 4 * i + 36;
+               }
+
+               return 0;
+       }
+
 }
 

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to