[mono-api-info] First filter, then order, and use ordinal comparison.
[mono-project.git] / mono / tests / marshalbool.cs
blob263dd16a134b06399f58dfa11ffe23c8b5e6d714
1 using System;
2 using System.Runtime.InteropServices;
4 public class marshalbool
6 [DllImport ("libtest")]
7 static extern int mono_test_marshal_bool_in (int arg, uint expected,
8 bool bDefaultMarsh,
9 [MarshalAs (UnmanagedType.Bool)] bool bBoolCustMarsh,
10 [MarshalAs (UnmanagedType.I1)] bool bI1CustMarsh,
11 [MarshalAs (UnmanagedType.U1)] bool bU1CustMarsh,
12 [MarshalAs (UnmanagedType.VariantBool)] bool bVBCustMarsh);
14 [DllImport ("libtest")]
15 static extern int mono_test_marshal_bool_out (int arg, uint testVal,
16 out bool bDefaultMarsh,
17 [MarshalAs (UnmanagedType.Bool)] out bool bBoolCustMarsh,
18 [MarshalAs (UnmanagedType.I1)] out bool bI1CustMarsh,
19 [MarshalAs (UnmanagedType.U1)] out bool bU1CustMarsh,
20 [MarshalAs (UnmanagedType.VariantBool)] out bool bVBCustMarsh);
22 [DllImport ("libtest")]
23 static extern int mono_test_marshal_bool_ref (int arg, uint expected, uint testVal,
24 ref bool bDefaultMarsh,
25 [MarshalAs (UnmanagedType.Bool)] ref bool bBoolCustMarsh,
26 [MarshalAs (UnmanagedType.I1)] ref bool bI1CustMarsh,
27 [MarshalAs (UnmanagedType.U1)] ref bool bU1CustMarsh,
28 [MarshalAs (UnmanagedType.VariantBool)] ref bool bVBCustMarsh);
30 delegate int MarshalBoolInDelegate (int arg, uint expected,
31 bool bDefaultMarsh,
32 [MarshalAs (UnmanagedType.Bool)] bool bBoolCustMarsh,
33 [MarshalAs (UnmanagedType.I1)] bool bI1CustMarsh,
34 [MarshalAs (UnmanagedType.U1)] bool bU1CustMarsh,
35 [MarshalAs (UnmanagedType.VariantBool)] bool bVBCustMarsh);
37 delegate int MarshalBoolOutDelegate (int arg, uint testVal,
38 out bool bDefaultMarsh,
39 [MarshalAs (UnmanagedType.Bool)] out bool bBoolCustMarsh,
40 [MarshalAs (UnmanagedType.I1)] out bool bI1CustMarsh,
41 [MarshalAs (UnmanagedType.U1)] out bool bU1CustMarsh,
42 [MarshalAs (UnmanagedType.VariantBool)] out bool bVBCustMarsh);
44 delegate int MarshalBoolRefDelegate (int arg, uint expected, uint testVal,
45 ref bool bDefaultMarsh,
46 [MarshalAs (UnmanagedType.Bool)] ref bool bBoolCustMarsh,
47 [MarshalAs (UnmanagedType.I1)] ref bool bI1CustMarsh,
48 [MarshalAs (UnmanagedType.U1)] ref bool bU1CustMarsh,
49 [MarshalAs (UnmanagedType.VariantBool)] ref bool bVBCustMarsh);
51 [DllImport ("libtest")]
52 static extern int mono_test_managed_marshal_bool_in (int arg, uint expected, uint testVal, MarshalBoolInDelegate fcn);
54 [DllImport ("libtest")]
55 static extern int mono_test_managed_marshal_bool_out (int arg, uint expected, uint testVal, MarshalBoolOutDelegate fcn);
57 [DllImport ("libtest")]
58 static extern int mono_test_managed_marshal_bool_ref (int arg, uint expected, uint testVal,
59 uint outExpected, uint outTestVal, MarshalBoolRefDelegate fcn);
61 static int Main (string[] args)
63 return TestDriver.RunTests (typeof (marshalbool), args);
66 unsafe public static int test_0_Default_In_Native ()
68 int ret;
70 ret = mono_test_marshal_bool_in (1, 0, false, false, false, false, false);
71 if (ret != 0)
72 return 0x0100 + ret;
73 ret = mono_test_marshal_bool_in (1, 1, true, false, false, false, false);
74 if (ret != 0)
75 return 0x0200 + ret;
77 bool testVal = false;
78 bool* ptestVal = &testVal;
80 Marshal.WriteByte ((IntPtr)ptestVal, 0x22);
81 ret = mono_test_marshal_bool_in (1, 1, testVal, false, false, false, false);
82 if (ret != 0)
83 return 0x0300 + ret;
85 return 0;
88 unsafe public static int test_0_Bool_In_Native ()
90 int ret;
92 ret = mono_test_marshal_bool_in (2, 0, false, false, false, false, false);
93 if (ret != 0)
94 return 0x0100 + ret;
95 ret = mono_test_marshal_bool_in (2, 1, false, true, false, false, false);
96 if (ret != 0)
97 return 0x0200 + ret;
99 bool testVal = false;
100 bool* ptestVal = &testVal;
102 Marshal.WriteByte ((IntPtr)ptestVal, 0x22);
103 ret = mono_test_marshal_bool_in (2, 1, false, testVal, false, false, false);
104 if (ret != 0)
105 return 0x0300 + ret;
107 return 0;
110 unsafe public static int test_0_I1_In_Native ()
112 int ret;
114 ret = mono_test_marshal_bool_in (3, 0, false, false, false, false, false);
115 if (ret != 0)
116 return 0x0100 + ret;
117 ret = mono_test_marshal_bool_in (3, 1, false, false, true, false, false);
118 if (ret != 0)
119 return 0x0200 + ret;
121 bool testVal = false;
122 bool* ptestVal = &testVal;
124 Marshal.WriteByte ((IntPtr)ptestVal, 0x22);
125 ret = mono_test_marshal_bool_in (3, 1, false, false, testVal, false, false);
126 if (ret != 0)
127 return 0x0300 + ret;
129 return 0;
132 unsafe public static int test_0_U1_In_Native ()
134 int ret;
136 ret = mono_test_marshal_bool_in (4, 0, false, false, false, false, false);
137 if (ret != 0)
138 return 0x0100 + ret;
139 ret = mono_test_marshal_bool_in (4, 1, false, false, false, true, false);
140 if (ret != 0)
141 return 0x0200 + ret;
143 bool testVal = false;
144 bool* ptestVal = &testVal;
146 Marshal.WriteByte ((IntPtr)ptestVal, 0x22);
147 ret = mono_test_marshal_bool_in (4, 1, false, false, false, testVal, false);
148 if (ret != 0)
149 return 0x0300 + ret;
151 return 0;
154 unsafe public static int test_0_VariantBool_In_Native ()
156 int ret;
157 int m1 = -1;
159 ret = mono_test_marshal_bool_in (5, 0, false, false, false, false, false);
160 if (ret != 0)
161 return 0x0100 + ret;
162 ret = mono_test_marshal_bool_in (5, (uint)m1, false, false, false, false, true);
163 if (ret != 0)
164 return 0x0200 + ret;
166 bool testVal = false;
167 bool* ptestVal = &testVal;
169 Marshal.WriteByte ((IntPtr)ptestVal, 0x22);
170 ret = mono_test_marshal_bool_in (5, (uint)m1, false, false, false, false, testVal);
171 if (ret != 0)
172 return 0x0300 + ret;
174 return 0;
177 unsafe public static int test_0_Default_Out_Native ()
179 bool testVal = false;
180 bool* ptestVal = &testVal;
181 bool d = false;
182 int ret;
184 ret = mono_test_marshal_bool_out (1, 0, out testVal, out d, out d, out d, out d);
185 if (ret != 0)
186 return 0x0100 + ret;
187 if (testVal)
188 return 0x0200;
190 ret = mono_test_marshal_bool_out (1, 1, out testVal, out d, out d, out d, out d);
191 if (ret != 0)
192 return 0x0300 + ret;
193 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
194 return 0x0400;
196 ret = mono_test_marshal_bool_out (1, 0x22000000, out testVal, out d, out d, out d, out d);
197 if (ret != 0)
198 return 0x0500 + ret;
199 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
200 return 0x0600;
202 return 0;
205 unsafe public static int test_0_Bool_Out_Native ()
207 bool testVal = false;
208 bool* ptestVal = &testVal;
209 bool d = false;
210 int ret;
212 ret = mono_test_marshal_bool_out (2, 0, out d, out testVal, out d, out d, out d);
213 if (ret != 0)
214 return 0x0100 + ret;
215 if (testVal)
216 return 0x0200;
218 ret = mono_test_marshal_bool_out (2, 1, out d, out testVal, out d, out d, out d);
219 if (ret != 0)
220 return 0x0300 + ret;
221 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
222 return 0x0400;
224 ret = mono_test_marshal_bool_out (2, 0x22000000, out d, out testVal, out d, out d, out d);
225 if (ret != 0)
226 return 0x0500 + ret;
227 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
228 return 0x0600;
230 return 0;
233 unsafe public static int test_0_I1_Out_Native ()
235 bool testVal = false;
236 bool* ptestVal = &testVal;
237 bool d = false;
238 int ret;
240 ret = mono_test_marshal_bool_out (3, 0, out d, out d, out testVal, out d, out d);
241 if (ret != 0)
242 return 0x0100 + ret;
243 if (testVal)
244 return 0x0200;
246 ret = mono_test_marshal_bool_out (3, 1, out d, out d, out testVal, out d, out d);
247 if (ret != 0)
248 return 0x0300 + ret;
249 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
250 return 0x0400;
252 ret = mono_test_marshal_bool_out (3, 0x22, out d, out d, out testVal, out d, out d);
253 if (ret != 0)
254 return 0x0500 + ret;
255 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
256 return 0x0600;
258 return 0;
261 unsafe public static int test_0_U1_Out_Native ()
263 bool testVal = false;
264 bool* ptestVal = &testVal;
265 bool d = false;
266 int ret;
268 ret = mono_test_marshal_bool_out (4, 0, out d, out d, out d, out testVal, out d);
269 if (ret != 0)
270 return 0x0100 + ret;
271 if (testVal)
272 return 0x0200;
274 ret = mono_test_marshal_bool_out (4, 1, out d, out d, out d, out testVal, out d);
275 if (ret != 0)
276 return 0x0300 + ret;
277 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
278 return 0x0400;
280 ret = mono_test_marshal_bool_out (4, 0x22, out d, out d, out d, out testVal, out d);
281 if (ret != 0)
282 return 0x0500 + ret;
283 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
284 return 0x0600;
286 return 0;
289 unsafe public static int test_0_VariantBool_Out_Native ()
291 bool testVal = false;
292 bool* ptestVal = &testVal;
293 bool d = false;
294 int ret;
296 ret = mono_test_marshal_bool_out (5, 0, out d, out d, out d, out d, out testVal);
297 if (ret != 0)
298 return 0x0100 + ret;
299 if (testVal)
300 return 0x0200;
302 ret = mono_test_marshal_bool_out (5, 1, out d, out d, out d, out d, out testVal);
303 if (ret != 0)
304 return 0x0100 + ret;
305 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
306 return 0x0200;
308 ret = mono_test_marshal_bool_out (5, 0x2200, out d, out d, out d, out d, out testVal);
309 if (ret != 0)
310 return 0x0100 + ret;
311 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
312 return 0x0200;
314 return 0;
317 unsafe public static int test_0_Default_Ref_Native ()
319 bool testVal = false;
320 bool* ptestVal = &testVal;
321 bool d = false;
322 int ret;
324 ret = mono_test_marshal_bool_ref (1, 0, 0, ref testVal, ref d, ref d, ref d, ref d);
325 if (ret != 0)
326 return 0x0100 + ret;
327 if (testVal)
328 return 0x0200;
330 ret = mono_test_marshal_bool_ref (1, 0, 1, ref testVal, ref d, ref d, ref d, ref d);
331 if (ret != 0)
332 return 0x0300 + ret;
333 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
334 return 0x0400;
336 ret = mono_test_marshal_bool_ref (1, 1, 0, ref testVal, ref d, ref d, ref d, ref d);
337 if (ret != 0)
338 return 0x0500 + ret;
339 if (testVal)
340 return 0x0600;
342 testVal = true;
343 ret = mono_test_marshal_bool_ref (1, 1, 1, ref testVal, ref d, ref d, ref d, ref d);
344 if (ret != 0)
345 return 0x0700 + ret;
346 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
347 return 0x08800;
349 testVal = false;
350 ret = mono_test_marshal_bool_ref (1, 0, 0x22000000, ref testVal, ref d, ref d, ref d, ref d);
351 if (ret != 0)
352 return 0x0900 + ret;
353 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
354 return 0x1000;
356 Marshal.WriteByte ((IntPtr)ptestVal, 0x22);
357 ret = mono_test_marshal_bool_ref (1, 1, 0, ref testVal, ref d, ref d, ref d, ref d);
358 if (ret != 0)
359 return 0x1100 + ret;
360 if (testVal)
361 return 0x1200;
363 Marshal.WriteByte ((IntPtr)ptestVal, 0x22);
364 ret = mono_test_marshal_bool_ref (1, 1, 0x22000000, ref testVal, ref d, ref d, ref d, ref d);
365 if (ret != 0)
366 return 0x1300 + ret;
367 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
368 return 0x1400;
370 return 0;
373 unsafe public static int test_0_Bool_Ref_Native ()
375 bool testVal = false;
376 bool* ptestVal = &testVal;
377 bool d = false;
378 int ret;
380 ret = mono_test_marshal_bool_ref (2, 0, 0, ref d, ref testVal, ref d, ref d, ref d);
381 if (ret != 0)
382 return 0x0100 + ret;
383 if (testVal)
384 return 0x0200;
386 ret = mono_test_marshal_bool_ref (2, 0, 1, ref d, ref testVal, ref d, ref d, ref d);
387 if (ret != 0)
388 return 0x0300 + ret;
389 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
390 return 0x0400;
392 ret = mono_test_marshal_bool_ref (2, 1, 0, ref d, ref testVal, ref d, ref d, ref d);
393 if (ret != 0)
394 return 0x0500 + ret;
395 if (testVal)
396 return 0x0600;
398 testVal = true;
399 ret = mono_test_marshal_bool_ref (2, 1, 1, ref d, ref testVal, ref d, ref d, ref d);
400 if (ret != 0)
401 return 0x0700 + ret;
402 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
403 return 0x0800;
405 testVal = false;
406 ret = mono_test_marshal_bool_ref (2, 0, 0x22000000, ref d, ref testVal, ref d, ref d, ref d);
407 if (ret != 0)
408 return 0x0900 + ret;
409 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
410 return 0x1000;
412 Marshal.WriteByte ((IntPtr)ptestVal, 0x22);
413 ret = mono_test_marshal_bool_ref (2, 1, 0, ref d, ref testVal, ref d, ref d, ref d);
414 if (ret != 0)
415 return 0x1100 + ret;
416 if (testVal)
417 return 0x1200;
419 Marshal.WriteByte ((IntPtr)ptestVal, 0x22);
420 ret = mono_test_marshal_bool_ref (2, 1, 0x22000000, ref d, ref testVal, ref d, ref d, ref d);
421 if (ret != 0)
422 return 0x1300 + ret;
423 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
424 return 0x1400;
426 return 0;
429 unsafe public static int test_0_I1_Ref_Native ()
431 bool testVal = false;
432 bool* ptestVal = &testVal;
433 bool d = false;
434 int ret;
436 ret = mono_test_marshal_bool_ref (3, 0, 0, ref d, ref d, ref testVal, ref d, ref d);
437 if (ret != 0)
438 return 0x0100 + ret;
439 if (testVal)
440 return 0x0200;
442 ret = mono_test_marshal_bool_ref (3, 0, 1, ref d, ref d, ref testVal, ref d, ref d);
443 if (ret != 0)
444 return 0x0300 + ret;
445 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
446 return 0x0400;
448 ret = mono_test_marshal_bool_ref (3, 1, 0, ref d, ref d, ref testVal, ref d, ref d);
449 if (ret != 0)
450 return 0x0500 + ret;
451 if (testVal)
452 return 0x0600;
454 testVal = true;
455 ret = mono_test_marshal_bool_ref (3, 1, 1, ref d, ref d, ref testVal, ref d, ref d);
456 if (ret != 0)
457 return 0x0700 + ret;
458 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
459 return 0x0800;
461 testVal = false;
462 ret = mono_test_marshal_bool_ref (3, 0, 0x22, ref d, ref d, ref testVal, ref d, ref d);
463 if (ret != 0)
464 return 0x0900 + ret;
465 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
466 return 0x1000;
468 Marshal.WriteByte ((IntPtr)ptestVal, 0x22);
469 ret = mono_test_marshal_bool_ref (3, 1, 0, ref d, ref d, ref testVal, ref d, ref d);
470 if (ret != 0)
471 return 0x1100 + ret;
472 if (testVal)
473 return 0x1200;
475 Marshal.WriteByte ((IntPtr)ptestVal, 0x22);
476 ret = mono_test_marshal_bool_ref (3, 1, 0x22, ref d, ref d, ref testVal, ref d, ref d);
477 if (ret != 0)
478 return 0x1300 + ret;
479 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
480 return 0x1400;
482 return 0;
485 unsafe public static int test_0_U1_Ref_Native ()
487 bool testVal = false;
488 bool* ptestVal = &testVal;
489 bool d = false;
490 int ret;
492 ret = mono_test_marshal_bool_ref (4, 0, 0, ref d, ref d, ref d, ref testVal, ref d);
493 if (ret != 0)
494 return 0x0100 + ret;
495 if (testVal)
496 return 0x0200;
498 ret = mono_test_marshal_bool_ref (4, 0, 1, ref d, ref d, ref d, ref testVal, ref d);
499 if (ret != 0)
500 return 0x0300 + ret;
501 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
502 return 0x0400;
504 ret = mono_test_marshal_bool_ref (4, 1, 0, ref d, ref d, ref d, ref testVal, ref d);
505 if (ret != 0)
506 return 0x0500 + ret;
507 if (testVal)
508 return 0x0600;
510 testVal = true;
511 ret = mono_test_marshal_bool_ref (4, 1, 1, ref d, ref d, ref d, ref testVal, ref d);
512 if (ret != 0)
513 return 0x0700 + ret;
514 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
515 return 0x0800;
517 testVal = false;
518 ret = mono_test_marshal_bool_ref (4, 0, 0x22, ref d, ref d, ref d, ref testVal, ref d);
519 if (ret != 0)
520 return 0x0900 + ret;
521 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
522 return 0x1000;
524 Marshal.WriteByte ((IntPtr)ptestVal, 0x22);
525 ret = mono_test_marshal_bool_ref (4, 1, 0, ref d, ref d, ref d, ref testVal, ref d);
526 if (ret != 0)
527 return 0x1100 + ret;
528 if (testVal)
529 return 0x1200;
531 Marshal.WriteByte ((IntPtr)ptestVal, 0x22);
532 ret = mono_test_marshal_bool_ref (4, 1, 0x22, ref d, ref d, ref d, ref testVal, ref d);
533 if (ret != 0)
534 return 0x1300 + ret;
535 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
536 return 0x1400;
538 return 0;
541 unsafe public static int test_0_VariantBool_Ref_Native ()
543 bool testVal = false;
544 bool* ptestVal = &testVal;
545 bool d = false;
546 int ret;
548 ret = mono_test_marshal_bool_ref (5, 0, 0, ref d, ref d, ref d, ref d, ref testVal);
549 if (ret != 0)
550 return 0x0100 + ret;
551 if (testVal)
552 return 0x0200;
554 ret = mono_test_marshal_bool_ref (5, 0, 1, ref d, ref d, ref d, ref d, ref testVal);
555 if (ret != 0)
556 return 0x0300 + ret;
557 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
558 return 0x0400;
560 ret = mono_test_marshal_bool_ref (5, 0xFFFF, 0, ref d, ref d, ref d, ref d, ref testVal);
561 if (ret != 0)
562 return 0x0500 + ret;
563 if (testVal)
564 return 0x0600;
566 testVal = true;
567 ret = mono_test_marshal_bool_ref (5, 0xFFFF, 1, ref d, ref d, ref d, ref d, ref testVal);
568 if (ret != 0)
569 return 0x0700 + ret;
570 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
571 return 0x0800;
573 testVal = false;
574 ret = mono_test_marshal_bool_ref (5, 0, 0x2200, ref d, ref d, ref d, ref d, ref testVal);
575 if (ret != 0)
576 return 0x0900 + ret;
577 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
578 return 0x1000;
580 Marshal.WriteByte ((IntPtr)ptestVal, 0x22);
581 ret = mono_test_marshal_bool_ref (5, 0xFFFF, 0, ref d, ref d, ref d, ref d, ref testVal);
582 if (ret != 0)
583 return 0x1100 + ret;
584 if (testVal)
585 return 0x1200;
587 Marshal.WriteByte ((IntPtr)ptestVal, 0x22);
588 ret = mono_test_marshal_bool_ref (5, 0xFFFF, 0x2200, ref d, ref d, ref d, ref d, ref testVal);
589 if (ret != 0)
590 return 0x1300 + ret;
591 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
592 return 0x1400;
594 return 0;
597 public static int test_0_Default_In_Managed ()
599 MarshalBoolInDelegate fcn = new MarshalBoolInDelegate (new marshalbool ().MarshalBoolInHelper);
600 int ret;
602 ret = mono_test_managed_marshal_bool_in (1, 0, 0, fcn);
603 if (ret != 0)
604 return 0x0100 + ret;
605 ret = mono_test_managed_marshal_bool_in (1, 1, 1, fcn);
606 if (ret != 0)
607 return 0x0200 + ret;
608 ret = mono_test_managed_marshal_bool_in (1, 1, 0x22000000, fcn);
609 if (ret != 0)
610 return 0x0300 + ret;
611 return 0;
614 public static int test_0_Bool_In_Managed ()
616 MarshalBoolInDelegate fcn = new MarshalBoolInDelegate (new marshalbool ().MarshalBoolInHelper);
617 int ret;
619 ret = mono_test_managed_marshal_bool_in (2, 0, 0, fcn);
620 if (ret != 0)
621 return 0x0100 + ret;
622 ret = mono_test_managed_marshal_bool_in (2, 1, 1, fcn);
623 if (ret != 0)
624 return 0x0200 + ret;
625 ret = mono_test_managed_marshal_bool_in (2, 1, 0x22000000, fcn);
626 if (ret != 0)
627 return 0x0300 + ret;
628 return 0;
631 public static int test_0_I1_In_Managed ()
633 MarshalBoolInDelegate fcn = new MarshalBoolInDelegate (new marshalbool ().MarshalBoolInHelper);
634 int ret;
636 ret = mono_test_managed_marshal_bool_in (3, 0, 0, fcn);
637 if (ret != 0)
638 return 0x0100 + ret;
639 ret = mono_test_managed_marshal_bool_in (3, 1, 1, fcn);
640 if (ret != 0)
641 return 0x0200 + ret;
642 ret = mono_test_managed_marshal_bool_in (3, 1, 0x22, fcn);
643 if (ret != 0)
644 return 0x0300 + ret;
645 return 0;
648 public static int test_0_U1_In_Managed ()
650 MarshalBoolInDelegate fcn = new MarshalBoolInDelegate (new marshalbool ().MarshalBoolInHelper);
651 int ret;
653 ret = mono_test_managed_marshal_bool_in (4, 0, 0, fcn);
654 if (ret != 0)
655 return 0x0100 + ret;
656 ret = mono_test_managed_marshal_bool_in (4, 1, 1, fcn);
657 if (ret != 0)
658 return 0x0200 + ret;
659 ret = mono_test_managed_marshal_bool_in (4, 1, 0x22, fcn);
660 if (ret != 0)
661 return 0x0300 + ret;
662 return 0;
665 public static int test_0_VariantBool_In_Managed ()
667 MarshalBoolInDelegate fcn = new MarshalBoolInDelegate (new marshalbool ().MarshalBoolInHelper);
668 int ret;
670 ret = mono_test_managed_marshal_bool_in (5, 0, 0, fcn);
671 if (ret != 0)
672 return 0x0100 + ret;
673 ret = mono_test_managed_marshal_bool_in (5, 1, 0xFFFF, fcn);
674 if (ret != 0)
675 return 0x0200 + ret;
676 ret = mono_test_managed_marshal_bool_in (5, 1, 0x22, fcn);
677 if (ret != 0)
678 return 0x0300 + ret;
679 return 0;
682 public static int test_0_Default_Out_Managed ()
684 MarshalBoolOutDelegate fcn = new MarshalBoolOutDelegate (new marshalbool ().MarshalBoolOutHelper);
685 int ret;
687 ret = mono_test_managed_marshal_bool_out (1, 0, 0, fcn);
688 if (ret != 0)
689 return 0x010000 + ret;
690 ret = mono_test_managed_marshal_bool_out (1, 1, 1, fcn);
691 if (ret != 0)
692 return 0x020000 + ret;
693 ret = mono_test_managed_marshal_bool_out (1, 1, 0x22, fcn);
694 if (ret != 0)
695 return 0x030000 + ret;
696 return 0;
699 public static int test_0_Bool_Out_Managed ()
701 MarshalBoolOutDelegate fcn = new MarshalBoolOutDelegate (new marshalbool ().MarshalBoolOutHelper);
702 int ret;
704 ret = mono_test_managed_marshal_bool_out (2, 0, 0, fcn);
705 if (ret != 0)
706 return 0x010000 + ret;
707 ret = mono_test_managed_marshal_bool_out (2, 1, 1, fcn);
708 if (ret != 0)
709 return 0x020000 + ret;
710 ret = mono_test_managed_marshal_bool_out (2, 1, 0x22, fcn);
711 if (ret != 0)
712 return 0x030000 + ret;
713 return 0;
716 public static int test_0_I1_Out_Managed ()
718 MarshalBoolOutDelegate fcn = new MarshalBoolOutDelegate (new marshalbool ().MarshalBoolOutHelper);
719 int ret;
721 ret = mono_test_managed_marshal_bool_out (3, 0, 0, fcn);
722 if (ret != 0)
723 return 0x010000 + ret;
724 ret = mono_test_managed_marshal_bool_out (3, 1, 1, fcn);
725 if (ret != 0)
726 return 0x020000 + ret;
727 ret = mono_test_managed_marshal_bool_out (3, 1, 0x22, fcn);
728 if (ret != 0)
729 return 0x030000 + ret;
730 return 0;
733 public static int test_0_U1_Out_Managed ()
735 MarshalBoolOutDelegate fcn = new MarshalBoolOutDelegate (new marshalbool ().MarshalBoolOutHelper);
736 int ret;
738 ret = mono_test_managed_marshal_bool_out (4, 0, 0, fcn);
739 if (ret != 0)
740 return 0x010000 + ret;
741 ret = mono_test_managed_marshal_bool_out (4, 1, 1, fcn);
742 if (ret != 0)
743 return 0x020000 + ret;
744 ret = mono_test_managed_marshal_bool_out (4, 1, 0x22, fcn);
745 if (ret != 0)
746 return 0x030000 + ret;
747 return 0;
750 public static int test_0_VariantBool_Out_Managed ()
752 MarshalBoolOutDelegate fcn = new MarshalBoolOutDelegate (new marshalbool ().MarshalBoolOutHelper);
753 int ret;
755 ret = mono_test_managed_marshal_bool_out (5, 0, 0, fcn);
756 if (ret != 0)
757 return 0x010000 + ret;
758 ret = mono_test_managed_marshal_bool_out (5, 0xFFFF, 1, fcn);
759 if (ret != 0)
760 return 0x020000 + ret;
761 ret = mono_test_managed_marshal_bool_out (5, 0xFFFF, 0x22, fcn);
762 if (ret != 0)
763 return 0x030000 + ret;
764 return 0;
767 public static int test_0_Default_Ref_Managed ()
769 MarshalBoolRefDelegate fcn = new MarshalBoolRefDelegate (new marshalbool ().MarshalBoolRefHelper);
770 int ret;
772 ret = mono_test_managed_marshal_bool_ref (1, 0, 0, 0, 0, fcn);
773 if (ret != 0)
774 return 0x010000 + ret;
775 ret = mono_test_managed_marshal_bool_ref (1, 1, 1, 0, 0, fcn);
776 if (ret != 0)
777 return 0x020000 + ret;
778 ret = mono_test_managed_marshal_bool_ref (1, 0, 0, 1, 1, fcn);
779 if (ret != 0)
780 return 0x030000 + ret;
781 ret = mono_test_managed_marshal_bool_ref (1, 1, 1, 1, 1, fcn);
782 if (ret != 0)
783 return 0x040000 + ret;
784 ret = mono_test_managed_marshal_bool_ref (1, 1, 0x22000000, 0, 0, fcn);
785 if (ret != 0)
786 return 0x050000 + ret;
787 ret = mono_test_managed_marshal_bool_ref (1, 0, 0, 1, 0x22, fcn);
788 if (ret != 0)
789 return 0x060000 + ret;
790 ret = mono_test_managed_marshal_bool_ref (1, 1, 0x22000000, 1, 0x22, fcn);
791 if (ret != 0)
792 return 0x070000 + ret;
793 return 0;
796 public static int test_0_Bool_Ref_Managed ()
798 MarshalBoolRefDelegate fcn = new MarshalBoolRefDelegate (new marshalbool ().MarshalBoolRefHelper);
799 int ret;
801 ret = mono_test_managed_marshal_bool_ref (2, 0, 0, 0, 0, fcn);
802 if (ret != 0)
803 return 0x010000 + ret;
804 ret = mono_test_managed_marshal_bool_ref (2, 1, 1, 0, 0, fcn);
805 if (ret != 0)
806 return 0x020000 + ret;
807 ret = mono_test_managed_marshal_bool_ref (2, 0, 0, 1, 1, fcn);
808 if (ret != 0)
809 return 0x030000 + ret;
810 ret = mono_test_managed_marshal_bool_ref (2, 1, 1, 1, 1, fcn);
811 if (ret != 0)
812 return 0x040000 + ret;
813 ret = mono_test_managed_marshal_bool_ref (2, 1, 0x22000000, 0, 0, fcn);
814 if (ret != 0)
815 return 0x050000 + ret;
816 ret = mono_test_managed_marshal_bool_ref (2, 0, 0, 1, 0x22, fcn);
817 if (ret != 0)
818 return 0x060000 + ret;
819 ret = mono_test_managed_marshal_bool_ref (2, 1, 0x22000000, 1, 0x22, fcn);
820 if (ret != 0)
821 return 0x070000 + ret;
822 return 0;
825 public static int test_0_I1_Ref_Managed ()
827 MarshalBoolRefDelegate fcn = new MarshalBoolRefDelegate (new marshalbool ().MarshalBoolRefHelper);
828 int ret;
830 ret = mono_test_managed_marshal_bool_ref (3, 0, 0, 0, 0, fcn);
831 if (ret != 0)
832 return 0x010000 + ret;
833 ret = mono_test_managed_marshal_bool_ref (3, 1, 1, 0, 0, fcn);
834 if (ret != 0)
835 return 0x020000 + ret;
836 ret = mono_test_managed_marshal_bool_ref (3, 0, 0, 1, 1, fcn);
837 if (ret != 0)
838 return 0x030000 + ret;
839 ret = mono_test_managed_marshal_bool_ref (3, 1, 1, 1, 1, fcn);
840 if (ret != 0)
841 return 0x040000 + ret;
842 ret = mono_test_managed_marshal_bool_ref (3, 1, 0x22, 0, 0, fcn);
843 if (ret != 0)
844 return 0x050000 + ret;
845 ret = mono_test_managed_marshal_bool_ref (3, 0, 0, 1, 0x22, fcn);
846 if (ret != 0)
847 return 0x060000 + ret;
848 ret = mono_test_managed_marshal_bool_ref (3, 1, 0x22, 1, 0x22, fcn);
849 if (ret != 0)
850 return 0x070000 + ret;
851 return 0;
854 public static int test_0_U1_Ref_Managed ()
856 MarshalBoolRefDelegate fcn = new MarshalBoolRefDelegate (new marshalbool ().MarshalBoolRefHelper);
857 int ret;
859 ret = mono_test_managed_marshal_bool_ref (4, 0, 0, 0, 0, fcn);
860 if (ret != 0)
861 return 0x010000 + ret;
862 ret = mono_test_managed_marshal_bool_ref (4, 1, 1, 0, 0, fcn);
863 if (ret != 0)
864 return 0x020000 + ret;
865 ret = mono_test_managed_marshal_bool_ref (4, 0, 0, 1, 1, fcn);
866 if (ret != 0)
867 return 0x030000 + ret;
868 ret = mono_test_managed_marshal_bool_ref (4, 1, 1, 1, 1, fcn);
869 if (ret != 0)
870 return 0x040000 + ret;
871 ret = mono_test_managed_marshal_bool_ref (4, 1, 0x22, 0, 0, fcn);
872 if (ret != 0)
873 return 0x050000 + ret;
874 ret = mono_test_managed_marshal_bool_ref (4, 0, 0, 1, 0x22, fcn);
875 if (ret != 0)
876 return 0x060000 + ret;
877 ret = mono_test_managed_marshal_bool_ref (4, 1, 0x22, 1, 0x22, fcn);
878 if (ret != 0)
879 return 0x070000 + ret;
880 return 0;
883 public static int test_0_VariantBool_Ref_Managed ()
885 MarshalBoolRefDelegate fcn = new MarshalBoolRefDelegate (new marshalbool ().MarshalBoolRefHelper);
886 int ret;
888 ret = mono_test_managed_marshal_bool_ref (5, 0, 0, 0, 0, fcn);
889 if (ret != 0)
890 return 0x010000 + ret;
891 ret = mono_test_managed_marshal_bool_ref (5, 1, 0xFFFF, 0, 0, fcn);
892 if (ret != 0)
893 return 0x020000 + ret;
894 ret = mono_test_managed_marshal_bool_ref (5, 0, 0, 0xFFFF, 1, fcn);
895 if (ret != 0)
896 return 0x030000 + ret;
897 ret = mono_test_managed_marshal_bool_ref (5, 1, 0xFFFF, 0xFFFF, 1, fcn);
898 if (ret != 0)
899 return 0x040000 + ret;
900 ret = mono_test_managed_marshal_bool_ref (5, 1, 0x2200, 0, 0, fcn);
901 if (ret != 0)
902 return 0x050000 + ret;
903 ret = mono_test_managed_marshal_bool_ref (5, 0, 0, 0xFFFF, 0x22, fcn);
904 if (ret != 0)
905 return 0x060000 + ret;
906 ret = mono_test_managed_marshal_bool_ref (5, 1, 0x2200, 0xFFFF, 0x22, fcn);
907 if (ret != 0)
908 return 0x070000 + ret;
909 return 0;
912 ///////////////////////////////////////////////////////////////////
914 unsafe int MarshalBoolInHelper (int arg, uint expected, bool bDefaultMarsh, bool bBoolCustMarsh, bool bI1CustMarsh,
915 bool bU1CustMarsh, bool bVBCustMarsh)
917 bool* ptestVal;
918 switch (arg) {
919 case 1 :
920 ptestVal = &bDefaultMarsh;
921 if (expected != Marshal.ReadByte ((IntPtr)ptestVal))
922 return 1;
923 break;
924 case 2 :
925 ptestVal = &bBoolCustMarsh;
926 if (expected != Marshal.ReadByte ((IntPtr)ptestVal))
927 return 2;
928 break;
929 case 3 :
930 ptestVal = &bI1CustMarsh;
931 if (expected != Marshal.ReadByte ((IntPtr)ptestVal))
932 return 3;
933 break;
934 case 4 :
935 ptestVal = &bU1CustMarsh;
936 if (expected != Marshal.ReadByte ((IntPtr)ptestVal))
937 return 4;
938 break;
939 case 5 :
940 ptestVal = &bVBCustMarsh;
941 if (expected != Marshal.ReadByte ((IntPtr)ptestVal))
942 return 5;
943 break;
944 default :
945 return 99;
947 return 0;
950 unsafe int MarshalBoolOutHelper (int arg, uint testVal, out bool bDefaultMarsh, out bool bBoolCustMarsh,
951 out bool bI1CustMarsh, out bool bU1CustMarsh, out bool bVBCustMarsh)
953 bDefaultMarsh = bBoolCustMarsh = bI1CustMarsh = bU1CustMarsh = bVBCustMarsh = false;
954 switch (arg) {
955 case 1:
956 fixed (bool*ptestVal = &bDefaultMarsh)
958 Marshal.WriteByte ((IntPtr)ptestVal, (byte)testVal);
960 break;
961 case 2:
962 fixed (bool*ptestVal = &bBoolCustMarsh)
964 Marshal.WriteByte ((IntPtr)ptestVal, (byte)testVal);
966 break;
967 case 3:
968 fixed (bool*ptestVal = &bI1CustMarsh)
970 Marshal.WriteByte ((IntPtr)ptestVal, (byte)testVal);
972 break;
973 case 4:
974 fixed (bool*ptestVal = &bU1CustMarsh)
976 Marshal.WriteByte ((IntPtr)ptestVal, (byte)testVal);
978 break;
979 case 5:
980 fixed (bool*ptestVal = &bVBCustMarsh)
982 Marshal.WriteByte ((IntPtr)ptestVal, (byte)testVal);
984 break;
985 default :
986 return 99;
988 return 0;
991 unsafe int MarshalBoolRefHelper (int arg, uint expected, uint testVal, ref bool bDefaultMarsh, ref bool bBoolCustMarsh,
992 ref bool bI1CustMarsh, ref bool bU1CustMarsh, ref bool bVBCustMarsh)
994 switch (arg) {
995 case 1:
996 fixed (bool*ptestVal = &bDefaultMarsh)
998 if (expected != Marshal.ReadByte ((IntPtr)ptestVal))
999 return 1;
1000 Marshal.WriteByte ((IntPtr)ptestVal, (byte)testVal);
1002 break;
1003 case 2:
1004 fixed (bool*ptestVal = &bBoolCustMarsh)
1006 if (expected != Marshal.ReadByte ((IntPtr)ptestVal))
1007 return 2;
1008 Marshal.WriteByte ((IntPtr)ptestVal, (byte)testVal);
1010 break;
1011 case 3:
1012 fixed (bool*ptestVal = &bI1CustMarsh)
1014 if (expected != Marshal.ReadByte ((IntPtr)ptestVal))
1015 return 3;
1016 Marshal.WriteByte ((IntPtr)ptestVal, (byte)testVal);
1018 break;
1019 case 4:
1020 fixed (bool*ptestVal = &bU1CustMarsh)
1022 if (expected != Marshal.ReadByte ((IntPtr)ptestVal))
1023 return 4;
1024 Marshal.WriteByte ((IntPtr)ptestVal, (byte)testVal);
1026 break;
1027 case 5:
1028 fixed (bool*ptestVal = &bVBCustMarsh)
1030 if (expected != Marshal.ReadByte ((IntPtr)ptestVal))
1031 return 5;
1032 Marshal.WriteByte ((IntPtr)ptestVal, (byte)testVal);
1034 break;
1035 default :
1036 return 99;
1038 return 0;