2 using System.Runtime.InteropServices;
4 public class marshalbool
6 [AttributeUsage (AttributeTargets.Method)]
7 sealed class MonoPInvokeCallbackAttribute : Attribute {
8 public MonoPInvokeCallbackAttribute (Type t) {}
11 [DllImport ("libtest")]
12 static extern int mono_test_marshal_bool_in (int arg, uint expected,
14 [MarshalAs (UnmanagedType.Bool)] bool bBoolCustMarsh,
15 [MarshalAs (UnmanagedType.I1)] bool bI1CustMarsh,
16 [MarshalAs (UnmanagedType.U1)] bool bU1CustMarsh,
17 [MarshalAs (UnmanagedType.VariantBool)] bool bVBCustMarsh);
19 [DllImport ("libtest")]
20 static extern int mono_test_marshal_bool_out (int arg, uint testVal,
21 out bool bDefaultMarsh,
22 [MarshalAs (UnmanagedType.Bool)] out bool bBoolCustMarsh,
23 [MarshalAs (UnmanagedType.I1)] out bool bI1CustMarsh,
24 [MarshalAs (UnmanagedType.U1)] out bool bU1CustMarsh,
25 [MarshalAs (UnmanagedType.VariantBool)] out bool bVBCustMarsh);
27 [DllImport ("libtest")]
28 static extern int mono_test_marshal_bool_ref (int arg, uint expected, uint testVal,
29 ref bool bDefaultMarsh,
30 [MarshalAs (UnmanagedType.Bool)] ref bool bBoolCustMarsh,
31 [MarshalAs (UnmanagedType.I1)] ref bool bI1CustMarsh,
32 [MarshalAs (UnmanagedType.U1)] ref bool bU1CustMarsh,
33 [MarshalAs (UnmanagedType.VariantBool)] ref bool bVBCustMarsh);
35 delegate int MarshalBoolInDelegate (int arg, uint expected,
37 [MarshalAs (UnmanagedType.Bool)] bool bBoolCustMarsh,
38 [MarshalAs (UnmanagedType.I1)] bool bI1CustMarsh,
39 [MarshalAs (UnmanagedType.U1)] bool bU1CustMarsh,
40 [MarshalAs (UnmanagedType.VariantBool)] bool bVBCustMarsh);
42 delegate int MarshalBoolOutDelegate (int arg, uint testVal,
43 out bool bDefaultMarsh,
44 [MarshalAs (UnmanagedType.Bool)] out bool bBoolCustMarsh,
45 [MarshalAs (UnmanagedType.I1)] out bool bI1CustMarsh,
46 [MarshalAs (UnmanagedType.U1)] out bool bU1CustMarsh,
47 [MarshalAs (UnmanagedType.VariantBool)] out bool bVBCustMarsh);
49 delegate int MarshalBoolRefDelegate (int arg, uint expected, uint testVal,
50 ref bool bDefaultMarsh,
51 [MarshalAs (UnmanagedType.Bool)] ref bool bBoolCustMarsh,
52 [MarshalAs (UnmanagedType.I1)] ref bool bI1CustMarsh,
53 [MarshalAs (UnmanagedType.U1)] ref bool bU1CustMarsh,
54 [MarshalAs (UnmanagedType.VariantBool)] ref bool bVBCustMarsh);
56 [DllImport ("libtest")]
57 static extern int mono_test_managed_marshal_bool_in (int arg, uint expected, uint testVal, MarshalBoolInDelegate fcn);
59 [DllImport ("libtest")]
60 static extern int mono_test_managed_marshal_bool_out (int arg, uint expected, uint testVal, MarshalBoolOutDelegate fcn);
62 [DllImport ("libtest")]
63 static extern int mono_test_managed_marshal_bool_ref (int arg, uint expected, uint testVal,
64 uint outExpected, uint outTestVal, MarshalBoolRefDelegate fcn);
66 static int Main (string[] args)
68 return TestDriver.RunTests (typeof (marshalbool), args);
71 unsafe public static int test_0_Default_In_Native ()
75 ret = mono_test_marshal_bool_in (1, 0, false, false, false, false, false);
78 ret = mono_test_marshal_bool_in (1, 1, true, false, false, false, false);
83 bool* ptestVal = &testVal;
85 Marshal.WriteByte ((IntPtr)ptestVal, 0x22);
86 ret = mono_test_marshal_bool_in (1, 1, testVal, false, false, false, false);
93 unsafe public static int test_0_Bool_In_Native ()
97 ret = mono_test_marshal_bool_in (2, 0, false, false, false, false, false);
100 ret = mono_test_marshal_bool_in (2, 1, false, true, false, false, false);
104 bool testVal = false;
105 bool* ptestVal = &testVal;
107 Marshal.WriteByte ((IntPtr)ptestVal, 0x22);
108 ret = mono_test_marshal_bool_in (2, 1, false, testVal, false, false, false);
115 unsafe public static int test_0_I1_In_Native ()
119 ret = mono_test_marshal_bool_in (3, 0, false, false, false, false, false);
122 ret = mono_test_marshal_bool_in (3, 1, false, false, true, false, false);
126 bool testVal = false;
127 bool* ptestVal = &testVal;
129 Marshal.WriteByte ((IntPtr)ptestVal, 0x22);
130 ret = mono_test_marshal_bool_in (3, 1, false, false, testVal, false, false);
137 unsafe public static int test_0_U1_In_Native ()
141 ret = mono_test_marshal_bool_in (4, 0, false, false, false, false, false);
144 ret = mono_test_marshal_bool_in (4, 1, false, false, false, true, false);
148 bool testVal = false;
149 bool* ptestVal = &testVal;
151 Marshal.WriteByte ((IntPtr)ptestVal, 0x22);
152 ret = mono_test_marshal_bool_in (4, 1, false, false, false, testVal, false);
159 unsafe public static int test_0_VariantBool_In_Native ()
164 ret = mono_test_marshal_bool_in (5, 0, false, false, false, false, false);
167 ret = mono_test_marshal_bool_in (5, (uint)m1, false, false, false, false, true);
171 bool testVal = false;
172 bool* ptestVal = &testVal;
174 Marshal.WriteByte ((IntPtr)ptestVal, 0x22);
175 ret = mono_test_marshal_bool_in (5, (uint)m1, false, false, false, false, testVal);
182 unsafe public static int test_0_Default_Out_Native ()
184 bool testVal = false;
185 bool* ptestVal = &testVal;
189 ret = mono_test_marshal_bool_out (1, 0, out testVal, out d, out d, out d, out d);
195 ret = mono_test_marshal_bool_out (1, 1, out testVal, out d, out d, out d, out d);
198 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
201 ret = mono_test_marshal_bool_out (1, 0x22000000, out testVal, out d, out d, out d, out d);
204 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
210 unsafe public static int test_0_Bool_Out_Native ()
212 bool testVal = false;
213 bool* ptestVal = &testVal;
217 ret = mono_test_marshal_bool_out (2, 0, out d, out testVal, out d, out d, out d);
223 ret = mono_test_marshal_bool_out (2, 1, out d, out testVal, out d, out d, out d);
226 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
229 ret = mono_test_marshal_bool_out (2, 0x22000000, out d, out testVal, out d, out d, out d);
232 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
238 unsafe public static int test_0_I1_Out_Native ()
240 bool testVal = false;
241 bool* ptestVal = &testVal;
245 ret = mono_test_marshal_bool_out (3, 0, out d, out d, out testVal, out d, out d);
251 ret = mono_test_marshal_bool_out (3, 1, out d, out d, out testVal, out d, out d);
254 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
257 ret = mono_test_marshal_bool_out (3, 0x22, out d, out d, out testVal, out d, out d);
260 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
266 unsafe public static int test_0_U1_Out_Native ()
268 bool testVal = false;
269 bool* ptestVal = &testVal;
273 ret = mono_test_marshal_bool_out (4, 0, out d, out d, out d, out testVal, out d);
279 ret = mono_test_marshal_bool_out (4, 1, out d, out d, out d, out testVal, out d);
282 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
285 ret = mono_test_marshal_bool_out (4, 0x22, out d, out d, out d, out testVal, out d);
288 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
294 unsafe public static int test_0_VariantBool_Out_Native ()
296 bool testVal = false;
297 bool* ptestVal = &testVal;
301 ret = mono_test_marshal_bool_out (5, 0, out d, out d, out d, out d, out testVal);
307 ret = mono_test_marshal_bool_out (5, 1, out d, out d, out d, out d, out testVal);
310 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
313 ret = mono_test_marshal_bool_out (5, 0x2200, out d, out d, out d, out d, out testVal);
316 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
322 unsafe public static int test_0_Default_Ref_Native ()
324 bool testVal = false;
325 bool* ptestVal = &testVal;
329 ret = mono_test_marshal_bool_ref (1, 0, 0, ref testVal, ref d, ref d, ref d, ref d);
335 ret = mono_test_marshal_bool_ref (1, 0, 1, ref testVal, ref d, ref d, ref d, ref d);
338 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
341 ret = mono_test_marshal_bool_ref (1, 1, 0, ref testVal, ref d, ref d, ref d, ref d);
348 ret = mono_test_marshal_bool_ref (1, 1, 1, ref testVal, ref d, ref d, ref d, ref d);
351 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
355 ret = mono_test_marshal_bool_ref (1, 0, 0x22000000, ref testVal, ref d, ref d, ref d, ref d);
358 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
361 Marshal.WriteByte ((IntPtr)ptestVal, 0x22);
362 ret = mono_test_marshal_bool_ref (1, 1, 0, ref testVal, ref d, ref d, ref d, ref d);
368 Marshal.WriteByte ((IntPtr)ptestVal, 0x22);
369 ret = mono_test_marshal_bool_ref (1, 1, 0x22000000, ref testVal, ref d, ref d, ref d, ref d);
372 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
378 unsafe public static int test_0_Bool_Ref_Native ()
380 bool testVal = false;
381 bool* ptestVal = &testVal;
385 ret = mono_test_marshal_bool_ref (2, 0, 0, ref d, ref testVal, ref d, ref d, ref d);
391 ret = mono_test_marshal_bool_ref (2, 0, 1, ref d, ref testVal, ref d, ref d, ref d);
394 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
397 ret = mono_test_marshal_bool_ref (2, 1, 0, ref d, ref testVal, ref d, ref d, ref d);
404 ret = mono_test_marshal_bool_ref (2, 1, 1, ref d, ref testVal, ref d, ref d, ref d);
407 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
411 ret = mono_test_marshal_bool_ref (2, 0, 0x22000000, ref d, ref testVal, ref d, ref d, ref d);
414 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
417 Marshal.WriteByte ((IntPtr)ptestVal, 0x22);
418 ret = mono_test_marshal_bool_ref (2, 1, 0, ref d, ref testVal, ref d, ref d, ref d);
424 Marshal.WriteByte ((IntPtr)ptestVal, 0x22);
425 ret = mono_test_marshal_bool_ref (2, 1, 0x22000000, ref d, ref testVal, ref d, ref d, ref d);
428 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
434 unsafe public static int test_0_I1_Ref_Native ()
436 bool testVal = false;
437 bool* ptestVal = &testVal;
441 ret = mono_test_marshal_bool_ref (3, 0, 0, ref d, ref d, ref testVal, ref d, ref d);
447 ret = mono_test_marshal_bool_ref (3, 0, 1, ref d, ref d, ref testVal, ref d, ref d);
450 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
453 ret = mono_test_marshal_bool_ref (3, 1, 0, ref d, ref d, ref testVal, ref d, ref d);
460 ret = mono_test_marshal_bool_ref (3, 1, 1, ref d, ref d, ref testVal, ref d, ref d);
463 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
467 ret = mono_test_marshal_bool_ref (3, 0, 0x22, ref d, ref d, ref testVal, ref d, ref d);
470 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
473 Marshal.WriteByte ((IntPtr)ptestVal, 0x22);
474 ret = mono_test_marshal_bool_ref (3, 1, 0, ref d, ref d, ref testVal, ref d, ref d);
480 Marshal.WriteByte ((IntPtr)ptestVal, 0x22);
481 ret = mono_test_marshal_bool_ref (3, 1, 0x22, ref d, ref d, ref testVal, ref d, ref d);
484 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
490 unsafe public static int test_0_U1_Ref_Native ()
492 bool testVal = false;
493 bool* ptestVal = &testVal;
497 ret = mono_test_marshal_bool_ref (4, 0, 0, ref d, ref d, ref d, ref testVal, ref d);
503 ret = mono_test_marshal_bool_ref (4, 0, 1, ref d, ref d, ref d, ref testVal, ref d);
506 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
509 ret = mono_test_marshal_bool_ref (4, 1, 0, ref d, ref d, ref d, ref testVal, ref d);
516 ret = mono_test_marshal_bool_ref (4, 1, 1, ref d, ref d, ref d, ref testVal, ref d);
519 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
523 ret = mono_test_marshal_bool_ref (4, 0, 0x22, ref d, ref d, ref d, ref testVal, ref d);
526 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
529 Marshal.WriteByte ((IntPtr)ptestVal, 0x22);
530 ret = mono_test_marshal_bool_ref (4, 1, 0, ref d, ref d, ref d, ref testVal, ref d);
536 Marshal.WriteByte ((IntPtr)ptestVal, 0x22);
537 ret = mono_test_marshal_bool_ref (4, 1, 0x22, ref d, ref d, ref d, ref testVal, ref d);
540 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
546 unsafe public static int test_0_VariantBool_Ref_Native ()
548 bool testVal = false;
549 bool* ptestVal = &testVal;
553 ret = mono_test_marshal_bool_ref (5, 0, 0, ref d, ref d, ref d, ref d, ref testVal);
559 ret = mono_test_marshal_bool_ref (5, 0, 1, ref d, ref d, ref d, ref d, ref testVal);
562 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
565 ret = mono_test_marshal_bool_ref (5, 0xFFFF, 0, ref d, ref d, ref d, ref d, ref testVal);
572 ret = mono_test_marshal_bool_ref (5, 0xFFFF, 1, ref d, ref d, ref d, ref d, ref testVal);
575 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
579 ret = mono_test_marshal_bool_ref (5, 0, 0x2200, ref d, ref d, ref d, ref d, ref testVal);
582 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
585 Marshal.WriteByte ((IntPtr)ptestVal, 0x22);
586 ret = mono_test_marshal_bool_ref (5, 0xFFFF, 0, ref d, ref d, ref d, ref d, ref testVal);
592 Marshal.WriteByte ((IntPtr)ptestVal, 0x22);
593 ret = mono_test_marshal_bool_ref (5, 0xFFFF, 0x2200, ref d, ref d, ref d, ref d, ref testVal);
596 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
602 public static int test_0_Default_In_Managed ()
604 MarshalBoolInDelegate fcn = new MarshalBoolInDelegate (MarshalBoolInHelper);
607 ret = mono_test_managed_marshal_bool_in (1, 0, 0, fcn);
610 ret = mono_test_managed_marshal_bool_in (1, 1, 1, fcn);
613 ret = mono_test_managed_marshal_bool_in (1, 1, 0x22000000, fcn);
619 public static int test_0_Bool_In_Managed ()
621 MarshalBoolInDelegate fcn = new MarshalBoolInDelegate (MarshalBoolInHelper);
624 ret = mono_test_managed_marshal_bool_in (2, 0, 0, fcn);
627 ret = mono_test_managed_marshal_bool_in (2, 1, 1, fcn);
630 ret = mono_test_managed_marshal_bool_in (2, 1, 0x22000000, fcn);
636 public static int test_0_I1_In_Managed ()
638 MarshalBoolInDelegate fcn = new MarshalBoolInDelegate (MarshalBoolInHelper);
641 ret = mono_test_managed_marshal_bool_in (3, 0, 0, fcn);
644 ret = mono_test_managed_marshal_bool_in (3, 1, 1, fcn);
647 ret = mono_test_managed_marshal_bool_in (3, 1, 0x22, fcn);
653 public static int test_0_U1_In_Managed ()
655 MarshalBoolInDelegate fcn = new MarshalBoolInDelegate (MarshalBoolInHelper);
658 ret = mono_test_managed_marshal_bool_in (4, 0, 0, fcn);
661 ret = mono_test_managed_marshal_bool_in (4, 1, 1, fcn);
664 ret = mono_test_managed_marshal_bool_in (4, 1, 0x22, fcn);
670 public static int test_0_VariantBool_In_Managed ()
672 MarshalBoolInDelegate fcn = new MarshalBoolInDelegate (MarshalBoolInHelper);
675 ret = mono_test_managed_marshal_bool_in (5, 0, 0, fcn);
678 ret = mono_test_managed_marshal_bool_in (5, 1, 0xFFFF, fcn);
681 ret = mono_test_managed_marshal_bool_in (5, 1, 0x22, fcn);
687 public static int test_0_Default_Out_Managed ()
689 MarshalBoolOutDelegate fcn = new MarshalBoolOutDelegate (MarshalBoolOutHelper);
692 ret = mono_test_managed_marshal_bool_out (1, 0, 0, fcn);
694 return 0x010000 + ret;
695 ret = mono_test_managed_marshal_bool_out (1, 1, 1, fcn);
697 return 0x020000 + ret;
698 ret = mono_test_managed_marshal_bool_out (1, 1, 0x22, fcn);
700 return 0x030000 + ret;
704 public static int test_0_Bool_Out_Managed ()
706 MarshalBoolOutDelegate fcn = new MarshalBoolOutDelegate (MarshalBoolOutHelper);
709 ret = mono_test_managed_marshal_bool_out (2, 0, 0, fcn);
711 return 0x010000 + ret;
712 ret = mono_test_managed_marshal_bool_out (2, 1, 1, fcn);
714 return 0x020000 + ret;
715 ret = mono_test_managed_marshal_bool_out (2, 1, 0x22, fcn);
717 return 0x030000 + ret;
721 public static int test_0_I1_Out_Managed ()
723 MarshalBoolOutDelegate fcn = new MarshalBoolOutDelegate (MarshalBoolOutHelper);
726 ret = mono_test_managed_marshal_bool_out (3, 0, 0, fcn);
728 return 0x010000 + ret;
729 ret = mono_test_managed_marshal_bool_out (3, 1, 1, fcn);
731 return 0x020000 + ret;
732 ret = mono_test_managed_marshal_bool_out (3, 1, 0x22, fcn);
734 return 0x030000 + ret;
738 public static int test_0_U1_Out_Managed ()
740 MarshalBoolOutDelegate fcn = new MarshalBoolOutDelegate (MarshalBoolOutHelper);
743 ret = mono_test_managed_marshal_bool_out (4, 0, 0, fcn);
745 return 0x010000 + ret;
746 ret = mono_test_managed_marshal_bool_out (4, 1, 1, fcn);
748 return 0x020000 + ret;
749 ret = mono_test_managed_marshal_bool_out (4, 1, 0x22, fcn);
751 return 0x030000 + ret;
755 public static int test_0_VariantBool_Out_Managed ()
757 MarshalBoolOutDelegate fcn = new MarshalBoolOutDelegate (MarshalBoolOutHelper);
760 ret = mono_test_managed_marshal_bool_out (5, 0, 0, fcn);
762 return 0x010000 + ret;
763 ret = mono_test_managed_marshal_bool_out (5, 0xFFFF, 1, fcn);
765 return 0x020000 + ret;
766 ret = mono_test_managed_marshal_bool_out (5, 0xFFFF, 0x22, fcn);
768 return 0x030000 + ret;
772 public static int test_0_Default_Ref_Managed ()
774 MarshalBoolRefDelegate fcn = new MarshalBoolRefDelegate (MarshalBoolRefHelper);
777 ret = mono_test_managed_marshal_bool_ref (1, 0, 0, 0, 0, fcn);
779 return 0x010000 + ret;
780 ret = mono_test_managed_marshal_bool_ref (1, 1, 1, 0, 0, fcn);
782 return 0x020000 + ret;
783 ret = mono_test_managed_marshal_bool_ref (1, 0, 0, 1, 1, fcn);
785 return 0x030000 + ret;
786 ret = mono_test_managed_marshal_bool_ref (1, 1, 1, 1, 1, fcn);
788 return 0x040000 + ret;
789 ret = mono_test_managed_marshal_bool_ref (1, 1, 0x22000000, 0, 0, fcn);
791 return 0x050000 + ret;
792 ret = mono_test_managed_marshal_bool_ref (1, 0, 0, 1, 0x22, fcn);
794 return 0x060000 + ret;
795 ret = mono_test_managed_marshal_bool_ref (1, 1, 0x22000000, 1, 0x22, fcn);
797 return 0x070000 + ret;
801 public static int test_0_Bool_Ref_Managed ()
803 MarshalBoolRefDelegate fcn = new MarshalBoolRefDelegate (MarshalBoolRefHelper);
806 ret = mono_test_managed_marshal_bool_ref (2, 0, 0, 0, 0, fcn);
808 return 0x010000 + ret;
809 ret = mono_test_managed_marshal_bool_ref (2, 1, 1, 0, 0, fcn);
811 return 0x020000 + ret;
812 ret = mono_test_managed_marshal_bool_ref (2, 0, 0, 1, 1, fcn);
814 return 0x030000 + ret;
815 ret = mono_test_managed_marshal_bool_ref (2, 1, 1, 1, 1, fcn);
817 return 0x040000 + ret;
818 ret = mono_test_managed_marshal_bool_ref (2, 1, 0x22000000, 0, 0, fcn);
820 return 0x050000 + ret;
821 ret = mono_test_managed_marshal_bool_ref (2, 0, 0, 1, 0x22, fcn);
823 return 0x060000 + ret;
824 ret = mono_test_managed_marshal_bool_ref (2, 1, 0x22000000, 1, 0x22, fcn);
826 return 0x070000 + ret;
830 public static int test_0_I1_Ref_Managed ()
832 MarshalBoolRefDelegate fcn = new MarshalBoolRefDelegate (MarshalBoolRefHelper);
835 ret = mono_test_managed_marshal_bool_ref (3, 0, 0, 0, 0, fcn);
837 return 0x010000 + ret;
838 ret = mono_test_managed_marshal_bool_ref (3, 1, 1, 0, 0, fcn);
840 return 0x020000 + ret;
841 ret = mono_test_managed_marshal_bool_ref (3, 0, 0, 1, 1, fcn);
843 return 0x030000 + ret;
844 ret = mono_test_managed_marshal_bool_ref (3, 1, 1, 1, 1, fcn);
846 return 0x040000 + ret;
847 ret = mono_test_managed_marshal_bool_ref (3, 1, 0x22, 0, 0, fcn);
849 return 0x050000 + ret;
850 ret = mono_test_managed_marshal_bool_ref (3, 0, 0, 1, 0x22, fcn);
852 return 0x060000 + ret;
853 ret = mono_test_managed_marshal_bool_ref (3, 1, 0x22, 1, 0x22, fcn);
855 return 0x070000 + ret;
859 public static int test_0_U1_Ref_Managed ()
861 MarshalBoolRefDelegate fcn = new MarshalBoolRefDelegate (MarshalBoolRefHelper);
864 ret = mono_test_managed_marshal_bool_ref (4, 0, 0, 0, 0, fcn);
866 return 0x010000 + ret;
867 ret = mono_test_managed_marshal_bool_ref (4, 1, 1, 0, 0, fcn);
869 return 0x020000 + ret;
870 ret = mono_test_managed_marshal_bool_ref (4, 0, 0, 1, 1, fcn);
872 return 0x030000 + ret;
873 ret = mono_test_managed_marshal_bool_ref (4, 1, 1, 1, 1, fcn);
875 return 0x040000 + ret;
876 ret = mono_test_managed_marshal_bool_ref (4, 1, 0x22, 0, 0, fcn);
878 return 0x050000 + ret;
879 ret = mono_test_managed_marshal_bool_ref (4, 0, 0, 1, 0x22, fcn);
881 return 0x060000 + ret;
882 ret = mono_test_managed_marshal_bool_ref (4, 1, 0x22, 1, 0x22, fcn);
884 return 0x070000 + ret;
888 public static int test_0_VariantBool_Ref_Managed ()
890 MarshalBoolRefDelegate fcn = new MarshalBoolRefDelegate (MarshalBoolRefHelper);
893 ret = mono_test_managed_marshal_bool_ref (5, 0, 0, 0, 0, fcn);
895 return 0x010000 + ret;
896 ret = mono_test_managed_marshal_bool_ref (5, 1, 0xFFFF, 0, 0, fcn);
898 return 0x020000 + ret;
899 ret = mono_test_managed_marshal_bool_ref (5, 0, 0, 0xFFFF, 1, fcn);
901 return 0x030000 + ret;
902 ret = mono_test_managed_marshal_bool_ref (5, 1, 0xFFFF, 0xFFFF, 1, fcn);
904 return 0x040000 + ret;
905 ret = mono_test_managed_marshal_bool_ref (5, 1, 0x2200, 0, 0, fcn);
907 return 0x050000 + ret;
908 ret = mono_test_managed_marshal_bool_ref (5, 0, 0, 0xFFFF, 0x22, fcn);
910 return 0x060000 + ret;
911 ret = mono_test_managed_marshal_bool_ref (5, 1, 0x2200, 0xFFFF, 0x22, fcn);
913 return 0x070000 + ret;
917 ///////////////////////////////////////////////////////////////////
919 [MonoPInvokeCallback (typeof (MarshalBoolInDelegate))]
920 unsafe static int MarshalBoolInHelper (int arg, uint expected, bool bDefaultMarsh, bool bBoolCustMarsh, bool bI1CustMarsh,
921 bool bU1CustMarsh, bool bVBCustMarsh)
926 ptestVal = &bDefaultMarsh;
927 if (expected != Marshal.ReadByte ((IntPtr)ptestVal))
931 ptestVal = &bBoolCustMarsh;
932 if (expected != Marshal.ReadByte ((IntPtr)ptestVal))
936 ptestVal = &bI1CustMarsh;
937 if (expected != Marshal.ReadByte ((IntPtr)ptestVal))
941 ptestVal = &bU1CustMarsh;
942 if (expected != Marshal.ReadByte ((IntPtr)ptestVal))
946 ptestVal = &bVBCustMarsh;
947 if (expected != Marshal.ReadByte ((IntPtr)ptestVal))
956 [MonoPInvokeCallback (typeof (MarshalBoolOutDelegate))]
957 unsafe static int MarshalBoolOutHelper (int arg, uint testVal, out bool bDefaultMarsh, out bool bBoolCustMarsh,
958 out bool bI1CustMarsh, out bool bU1CustMarsh, out bool bVBCustMarsh)
960 bDefaultMarsh = bBoolCustMarsh = bI1CustMarsh = bU1CustMarsh = bVBCustMarsh = false;
963 fixed (bool*ptestVal = &bDefaultMarsh)
965 Marshal.WriteByte ((IntPtr)ptestVal, (byte)testVal);
969 fixed (bool*ptestVal = &bBoolCustMarsh)
971 Marshal.WriteByte ((IntPtr)ptestVal, (byte)testVal);
975 fixed (bool*ptestVal = &bI1CustMarsh)
977 Marshal.WriteByte ((IntPtr)ptestVal, (byte)testVal);
981 fixed (bool*ptestVal = &bU1CustMarsh)
983 Marshal.WriteByte ((IntPtr)ptestVal, (byte)testVal);
987 fixed (bool*ptestVal = &bVBCustMarsh)
989 Marshal.WriteByte ((IntPtr)ptestVal, (byte)testVal);
998 [MonoPInvokeCallback (typeof (MarshalBoolRefDelegate))]
999 unsafe static int MarshalBoolRefHelper (int arg, uint expected, uint testVal, ref bool bDefaultMarsh, ref bool bBoolCustMarsh,
1000 ref bool bI1CustMarsh, ref bool bU1CustMarsh, ref bool bVBCustMarsh)
1004 fixed (bool*ptestVal = &bDefaultMarsh)
1006 if (expected != Marshal.ReadByte ((IntPtr)ptestVal))
1008 Marshal.WriteByte ((IntPtr)ptestVal, (byte)testVal);
1012 fixed (bool*ptestVal = &bBoolCustMarsh)
1014 if (expected != Marshal.ReadByte ((IntPtr)ptestVal))
1016 Marshal.WriteByte ((IntPtr)ptestVal, (byte)testVal);
1020 fixed (bool*ptestVal = &bI1CustMarsh)
1022 if (expected != Marshal.ReadByte ((IntPtr)ptestVal))
1024 Marshal.WriteByte ((IntPtr)ptestVal, (byte)testVal);
1028 fixed (bool*ptestVal = &bU1CustMarsh)
1030 if (expected != Marshal.ReadByte ((IntPtr)ptestVal))
1032 Marshal.WriteByte ((IntPtr)ptestVal, (byte)testVal);
1036 fixed (bool*ptestVal = &bVBCustMarsh)
1038 if (expected != Marshal.ReadByte ((IntPtr)ptestVal))
1040 Marshal.WriteByte ((IntPtr)ptestVal, (byte)testVal);