Author: holmes
Date: 2007-10-20 17:00:34 -0400 (Sat, 20 Oct 2007)
New Revision: 87858

Modified:
   trunk/mono/mono/tests/ChangeLog
   trunk/mono/mono/tests/libtest.c
   trunk/mono/mono/tests/pinvoke2.cs
Log:
2007-10-20  William Holmes  <[EMAIL PROTECTED]>

        * pinvoke2.cs, libtest.c Adding test cases for marshaling
          booleans as I1 and U1.  Tests commit r87725.

        Code is contributed under MIT/X11 license.


Modified: trunk/mono/mono/tests/ChangeLog
===================================================================
--- trunk/mono/mono/tests/ChangeLog     2007-10-20 17:25:23 UTC (rev 87857)
+++ trunk/mono/mono/tests/ChangeLog     2007-10-20 21:00:34 UTC (rev 87858)
@@ -1,3 +1,10 @@
+2007-10-20  William Holmes  <[EMAIL PROTECTED]>
+
+       * pinvoke2.cs, libtest.c Adding test cases for marshaling
+         booleans as I1 and U1.  Tests commit r87725.
+
+       Code is contributed under MIT/X11 license.
+
 2007-10-18  Zoltan Varga  <[EMAIL PROTECTED]>
 
        * interlocked.cs: Add a test for CompareExchange and negative values.

Modified: trunk/mono/mono/tests/libtest.c
===================================================================
--- trunk/mono/mono/tests/libtest.c     2007-10-20 17:25:23 UTC (rev 87857)
+++ trunk/mono/mono/tests/libtest.c     2007-10-20 21:00:34 UTC (rev 87858)
@@ -252,6 +252,45 @@
        return res;
 }
 
+STDCALL int
+mono_test_marshal_bool_in_as_I1_U1 (char bTrue, char bFalse)
+{
+       if (!bTrue)
+                return 1;
+       if (bFalse)
+                return 2;
+        return 0;
+}
+
+STDCALL int
+mono_test_marshal_bool_out_as_I1_U1 (char* bTrue, char* bFalse)
+{
+        if (!bTrue || !bFalse)
+               return 3;
+
+       *bTrue = 1;
+       *bFalse = 0;
+
+       return 0;
+}
+
+STDCALL int
+mono_test_marshal_bool_ref_as_I1_U1 (char* bTrue, char* bFalse)
+{
+       if (!bTrue || !bFalse)
+                return 4;
+
+       if (!(*bTrue))
+                return 5;
+        if (*bFalse)
+                return 6;
+
+       *bFalse = 1;
+        *bTrue = 0;
+
+       return 0;
+}
+
 STDCALL int 
 mono_test_marshal_array (int *a1)
 {

Modified: trunk/mono/mono/tests/pinvoke2.cs
===================================================================
--- trunk/mono/mono/tests/pinvoke2.cs   2007-10-20 17:25:23 UTC (rev 87857)
+++ trunk/mono/mono/tests/pinvoke2.cs   2007-10-20 21:00:34 UTC (rev 87858)
@@ -157,6 +157,24 @@
        [DllImport ("libtest", EntryPoint="mono_test_marshal_bool_byref")]
        public static extern int mono_test_marshal_bool_byref (int a, ref bool 
b, int c);
 
+       [DllImport ("libtest", EntryPoint="mono_test_marshal_bool_in_as_I1_U1")]
+       public static extern int mono_test_marshal_bool_in_as_I1 ([MarshalAs 
(UnmanagedType.I1)] bool bTrue, [MarshalAs (UnmanagedType.I1)] bool bFalse);
+
+       [DllImport ("libtest", EntryPoint="mono_test_marshal_bool_in_as_I1_U1")]
+       public static extern int mono_test_marshal_bool_in_as_U1 ([MarshalAs 
(UnmanagedType.U1)] bool bTrue, [MarshalAs (UnmanagedType.U1)] bool bFalse);
+
+       [DllImport ("libtest", 
EntryPoint="mono_test_marshal_bool_out_as_I1_U1")]
+       public static extern int mono_test_marshal_bool_out_as_I1 ([MarshalAs 
(UnmanagedType.I1)] out bool bTrue, [MarshalAs (UnmanagedType.I1)] out bool 
bFalse);
+
+       [DllImport ("libtest", 
EntryPoint="mono_test_marshal_bool_out_as_I1_U1")]
+       public static extern int mono_test_marshal_bool_out_as_U1 ([MarshalAs 
(UnmanagedType.U1)] out bool bTrue, [MarshalAs (UnmanagedType.U1)] out bool 
bFalse);
+
+       [DllImport ("libtest", 
EntryPoint="mono_test_marshal_bool_ref_as_I1_U1")]
+       public static extern int mono_test_marshal_bool_ref_as_I1 ([MarshalAs 
(UnmanagedType.I1)] ref bool bTrue, [MarshalAs (UnmanagedType.I1)] ref bool 
bFalse);
+
+       [DllImport ("libtest", 
EntryPoint="mono_test_marshal_bool_ref_as_I1_U1")]
+       public static extern int mono_test_marshal_bool_ref_as_U1 ([MarshalAs 
(UnmanagedType.U1)] ref bool bTrue, [MarshalAs (UnmanagedType.U1)] ref bool 
bFalse);
+
        [DllImport ("libtest", EntryPoint="mono_test_marshal_array")]
        public static extern int mono_test_marshal_array (int [] a1);
 
@@ -619,6 +637,62 @@
                return 0;
        }
 
+       public static int test_0_marshal_bool_as_I1 () {
+
+               int ret;
+               bool bTrue, bFalse;
+               if ((ret = mono_test_marshal_bool_in_as_I1 (true, false)) != 0)
+                       return ret;
+
+               if ((ret = mono_test_marshal_bool_out_as_I1 (out bTrue, out 
bFalse)) != 0)
+                       return ret;
+
+               if(!bTrue)
+                       return 10;
+
+               if(bFalse)
+                       return 11;
+
+               if ((ret = mono_test_marshal_bool_ref_as_I1 (ref bTrue, ref 
bFalse)) != 0)
+                       return ret;
+
+               if(bTrue)
+                       return 12;
+
+               if(!bFalse)
+                       return 13;
+
+               return 0;
+       }
+
+       public static int test_0_marshal_bool_as_U1 () {
+
+               int ret;
+               bool bTrue, bFalse;
+               if ((ret = mono_test_marshal_bool_in_as_U1 (true, false)) != 0)
+                       return ret;
+
+               if ((ret = mono_test_marshal_bool_out_as_U1 (out bTrue, out 
bFalse)) != 0)
+                       return ret;
+
+               if(!bTrue)
+                       return 10;
+
+               if(bFalse)
+                       return 11;
+
+               if ((ret = mono_test_marshal_bool_ref_as_U1 (ref bTrue, ref 
bFalse)) != 0)
+                       return ret;
+
+               if(bTrue)
+                       return 12;
+
+               if(!bFalse)
+                       return 13;
+
+               return 0;
+       }
+
        public static int test_0_return_vtype () {
                SimpleStruct ss = mono_test_return_vtype (new IntPtr (5));
 

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

Reply via email to