[System] Tweak socket test
[mono-project.git] / mono / tests / marshalbool.cs
blob67cf19636328e473993d78d75f13ea12f257f72a
1 using System;
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,
13 bool bDefaultMarsh,
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,
36 bool bDefaultMarsh,
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 ()
73 int ret;
75 ret = mono_test_marshal_bool_in (1, 0, false, false, false, false, false);
76 if (ret != 0)
77 return 0x0100 + ret;
78 ret = mono_test_marshal_bool_in (1, 1, true, false, false, false, false);
79 if (ret != 0)
80 return 0x0200 + ret;
82 bool testVal = 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);
87 if (ret != 0)
88 return 0x0300 + ret;
90 return 0;
93 unsafe public static int test_0_Bool_In_Native ()
95 int ret;
97 ret = mono_test_marshal_bool_in (2, 0, false, false, false, false, false);
98 if (ret != 0)
99 return 0x0100 + ret;
100 ret = mono_test_marshal_bool_in (2, 1, false, true, false, false, false);
101 if (ret != 0)
102 return 0x0200 + ret;
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);
109 if (ret != 0)
110 return 0x0300 + ret;
112 return 0;
115 unsafe public static int test_0_I1_In_Native ()
117 int ret;
119 ret = mono_test_marshal_bool_in (3, 0, false, false, false, false, false);
120 if (ret != 0)
121 return 0x0100 + ret;
122 ret = mono_test_marshal_bool_in (3, 1, false, false, true, false, false);
123 if (ret != 0)
124 return 0x0200 + ret;
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);
131 if (ret != 0)
132 return 0x0300 + ret;
134 return 0;
137 unsafe public static int test_0_U1_In_Native ()
139 int ret;
141 ret = mono_test_marshal_bool_in (4, 0, false, false, false, false, false);
142 if (ret != 0)
143 return 0x0100 + ret;
144 ret = mono_test_marshal_bool_in (4, 1, false, false, false, true, false);
145 if (ret != 0)
146 return 0x0200 + ret;
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);
153 if (ret != 0)
154 return 0x0300 + ret;
156 return 0;
159 unsafe public static int test_0_VariantBool_In_Native ()
161 int ret;
162 int m1 = -1;
164 ret = mono_test_marshal_bool_in (5, 0, false, false, false, false, false);
165 if (ret != 0)
166 return 0x0100 + ret;
167 ret = mono_test_marshal_bool_in (5, (uint)m1, false, false, false, false, true);
168 if (ret != 0)
169 return 0x0200 + ret;
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);
176 if (ret != 0)
177 return 0x0300 + ret;
179 return 0;
182 unsafe public static int test_0_Default_Out_Native ()
184 bool testVal = false;
185 bool* ptestVal = &testVal;
186 bool d = false;
187 int ret;
189 ret = mono_test_marshal_bool_out (1, 0, out testVal, out d, out d, out d, out d);
190 if (ret != 0)
191 return 0x0100 + ret;
192 if (testVal)
193 return 0x0200;
195 ret = mono_test_marshal_bool_out (1, 1, out testVal, out d, out d, out d, out d);
196 if (ret != 0)
197 return 0x0300 + ret;
198 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
199 return 0x0400;
201 ret = mono_test_marshal_bool_out (1, 0x22000000, out testVal, out d, out d, out d, out d);
202 if (ret != 0)
203 return 0x0500 + ret;
204 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
205 return 0x0600;
207 return 0;
210 unsafe public static int test_0_Bool_Out_Native ()
212 bool testVal = false;
213 bool* ptestVal = &testVal;
214 bool d = false;
215 int ret;
217 ret = mono_test_marshal_bool_out (2, 0, out d, out testVal, out d, out d, out d);
218 if (ret != 0)
219 return 0x0100 + ret;
220 if (testVal)
221 return 0x0200;
223 ret = mono_test_marshal_bool_out (2, 1, out d, out testVal, out d, out d, out d);
224 if (ret != 0)
225 return 0x0300 + ret;
226 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
227 return 0x0400;
229 ret = mono_test_marshal_bool_out (2, 0x22000000, out d, out testVal, out d, out d, out d);
230 if (ret != 0)
231 return 0x0500 + ret;
232 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
233 return 0x0600;
235 return 0;
238 unsafe public static int test_0_I1_Out_Native ()
240 bool testVal = false;
241 bool* ptestVal = &testVal;
242 bool d = false;
243 int ret;
245 ret = mono_test_marshal_bool_out (3, 0, out d, out d, out testVal, out d, out d);
246 if (ret != 0)
247 return 0x0100 + ret;
248 if (testVal)
249 return 0x0200;
251 ret = mono_test_marshal_bool_out (3, 1, out d, out d, out testVal, out d, out d);
252 if (ret != 0)
253 return 0x0300 + ret;
254 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
255 return 0x0400;
257 ret = mono_test_marshal_bool_out (3, 0x22, out d, out d, out testVal, out d, out d);
258 if (ret != 0)
259 return 0x0500 + ret;
260 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
261 return 0x0600;
263 return 0;
266 unsafe public static int test_0_U1_Out_Native ()
268 bool testVal = false;
269 bool* ptestVal = &testVal;
270 bool d = false;
271 int ret;
273 ret = mono_test_marshal_bool_out (4, 0, out d, out d, out d, out testVal, out d);
274 if (ret != 0)
275 return 0x0100 + ret;
276 if (testVal)
277 return 0x0200;
279 ret = mono_test_marshal_bool_out (4, 1, out d, out d, out d, out testVal, out d);
280 if (ret != 0)
281 return 0x0300 + ret;
282 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
283 return 0x0400;
285 ret = mono_test_marshal_bool_out (4, 0x22, out d, out d, out d, out testVal, out d);
286 if (ret != 0)
287 return 0x0500 + ret;
288 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
289 return 0x0600;
291 return 0;
294 unsafe public static int test_0_VariantBool_Out_Native ()
296 bool testVal = false;
297 bool* ptestVal = &testVal;
298 bool d = false;
299 int ret;
301 ret = mono_test_marshal_bool_out (5, 0, out d, out d, out d, out d, out testVal);
302 if (ret != 0)
303 return 0x0100 + ret;
304 if (testVal)
305 return 0x0200;
307 ret = mono_test_marshal_bool_out (5, 1, out d, out d, out d, out d, out testVal);
308 if (ret != 0)
309 return 0x0100 + ret;
310 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
311 return 0x0200;
313 ret = mono_test_marshal_bool_out (5, 0x2200, out d, out d, out d, out d, out testVal);
314 if (ret != 0)
315 return 0x0100 + ret;
316 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
317 return 0x0200;
319 return 0;
322 unsafe public static int test_0_Default_Ref_Native ()
324 bool testVal = false;
325 bool* ptestVal = &testVal;
326 bool d = false;
327 int ret;
329 ret = mono_test_marshal_bool_ref (1, 0, 0, ref testVal, ref d, ref d, ref d, ref d);
330 if (ret != 0)
331 return 0x0100 + ret;
332 if (testVal)
333 return 0x0200;
335 ret = mono_test_marshal_bool_ref (1, 0, 1, ref testVal, ref d, ref d, ref d, ref d);
336 if (ret != 0)
337 return 0x0300 + ret;
338 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
339 return 0x0400;
341 ret = mono_test_marshal_bool_ref (1, 1, 0, ref testVal, ref d, ref d, ref d, ref d);
342 if (ret != 0)
343 return 0x0500 + ret;
344 if (testVal)
345 return 0x0600;
347 testVal = true;
348 ret = mono_test_marshal_bool_ref (1, 1, 1, ref testVal, ref d, ref d, ref d, ref d);
349 if (ret != 0)
350 return 0x0700 + ret;
351 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
352 return 0x08800;
354 testVal = false;
355 ret = mono_test_marshal_bool_ref (1, 0, 0x22000000, ref testVal, ref d, ref d, ref d, ref d);
356 if (ret != 0)
357 return 0x0900 + ret;
358 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
359 return 0x1000;
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);
363 if (ret != 0)
364 return 0x1100 + ret;
365 if (testVal)
366 return 0x1200;
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);
370 if (ret != 0)
371 return 0x1300 + ret;
372 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
373 return 0x1400;
375 return 0;
378 unsafe public static int test_0_Bool_Ref_Native ()
380 bool testVal = false;
381 bool* ptestVal = &testVal;
382 bool d = false;
383 int ret;
385 ret = mono_test_marshal_bool_ref (2, 0, 0, ref d, ref testVal, ref d, ref d, ref d);
386 if (ret != 0)
387 return 0x0100 + ret;
388 if (testVal)
389 return 0x0200;
391 ret = mono_test_marshal_bool_ref (2, 0, 1, ref d, ref testVal, ref d, ref d, ref d);
392 if (ret != 0)
393 return 0x0300 + ret;
394 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
395 return 0x0400;
397 ret = mono_test_marshal_bool_ref (2, 1, 0, ref d, ref testVal, ref d, ref d, ref d);
398 if (ret != 0)
399 return 0x0500 + ret;
400 if (testVal)
401 return 0x0600;
403 testVal = true;
404 ret = mono_test_marshal_bool_ref (2, 1, 1, ref d, ref testVal, ref d, ref d, ref d);
405 if (ret != 0)
406 return 0x0700 + ret;
407 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
408 return 0x0800;
410 testVal = false;
411 ret = mono_test_marshal_bool_ref (2, 0, 0x22000000, ref d, ref testVal, ref d, ref d, ref d);
412 if (ret != 0)
413 return 0x0900 + ret;
414 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
415 return 0x1000;
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);
419 if (ret != 0)
420 return 0x1100 + ret;
421 if (testVal)
422 return 0x1200;
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);
426 if (ret != 0)
427 return 0x1300 + ret;
428 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
429 return 0x1400;
431 return 0;
434 unsafe public static int test_0_I1_Ref_Native ()
436 bool testVal = false;
437 bool* ptestVal = &testVal;
438 bool d = false;
439 int ret;
441 ret = mono_test_marshal_bool_ref (3, 0, 0, ref d, ref d, ref testVal, ref d, ref d);
442 if (ret != 0)
443 return 0x0100 + ret;
444 if (testVal)
445 return 0x0200;
447 ret = mono_test_marshal_bool_ref (3, 0, 1, ref d, ref d, ref testVal, ref d, ref d);
448 if (ret != 0)
449 return 0x0300 + ret;
450 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
451 return 0x0400;
453 ret = mono_test_marshal_bool_ref (3, 1, 0, ref d, ref d, ref testVal, ref d, ref d);
454 if (ret != 0)
455 return 0x0500 + ret;
456 if (testVal)
457 return 0x0600;
459 testVal = true;
460 ret = mono_test_marshal_bool_ref (3, 1, 1, ref d, ref d, ref testVal, ref d, ref d);
461 if (ret != 0)
462 return 0x0700 + ret;
463 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
464 return 0x0800;
466 testVal = false;
467 ret = mono_test_marshal_bool_ref (3, 0, 0x22, ref d, ref d, ref testVal, ref d, ref d);
468 if (ret != 0)
469 return 0x0900 + ret;
470 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
471 return 0x1000;
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);
475 if (ret != 0)
476 return 0x1100 + ret;
477 if (testVal)
478 return 0x1200;
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);
482 if (ret != 0)
483 return 0x1300 + ret;
484 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
485 return 0x1400;
487 return 0;
490 unsafe public static int test_0_U1_Ref_Native ()
492 bool testVal = false;
493 bool* ptestVal = &testVal;
494 bool d = false;
495 int ret;
497 ret = mono_test_marshal_bool_ref (4, 0, 0, ref d, ref d, ref d, ref testVal, ref d);
498 if (ret != 0)
499 return 0x0100 + ret;
500 if (testVal)
501 return 0x0200;
503 ret = mono_test_marshal_bool_ref (4, 0, 1, ref d, ref d, ref d, ref testVal, ref d);
504 if (ret != 0)
505 return 0x0300 + ret;
506 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
507 return 0x0400;
509 ret = mono_test_marshal_bool_ref (4, 1, 0, ref d, ref d, ref d, ref testVal, ref d);
510 if (ret != 0)
511 return 0x0500 + ret;
512 if (testVal)
513 return 0x0600;
515 testVal = true;
516 ret = mono_test_marshal_bool_ref (4, 1, 1, ref d, ref d, ref d, ref testVal, ref d);
517 if (ret != 0)
518 return 0x0700 + ret;
519 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
520 return 0x0800;
522 testVal = false;
523 ret = mono_test_marshal_bool_ref (4, 0, 0x22, ref d, ref d, ref d, ref testVal, ref d);
524 if (ret != 0)
525 return 0x0900 + ret;
526 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
527 return 0x1000;
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);
531 if (ret != 0)
532 return 0x1100 + ret;
533 if (testVal)
534 return 0x1200;
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);
538 if (ret != 0)
539 return 0x1300 + ret;
540 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
541 return 0x1400;
543 return 0;
546 unsafe public static int test_0_VariantBool_Ref_Native ()
548 bool testVal = false;
549 bool* ptestVal = &testVal;
550 bool d = false;
551 int ret;
553 ret = mono_test_marshal_bool_ref (5, 0, 0, ref d, ref d, ref d, ref d, ref testVal);
554 if (ret != 0)
555 return 0x0100 + ret;
556 if (testVal)
557 return 0x0200;
559 ret = mono_test_marshal_bool_ref (5, 0, 1, ref d, ref d, ref d, ref d, ref testVal);
560 if (ret != 0)
561 return 0x0300 + ret;
562 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
563 return 0x0400;
565 ret = mono_test_marshal_bool_ref (5, 0xFFFF, 0, ref d, ref d, ref d, ref d, ref testVal);
566 if (ret != 0)
567 return 0x0500 + ret;
568 if (testVal)
569 return 0x0600;
571 testVal = true;
572 ret = mono_test_marshal_bool_ref (5, 0xFFFF, 1, ref d, ref d, ref d, ref d, ref testVal);
573 if (ret != 0)
574 return 0x0700 + ret;
575 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
576 return 0x0800;
578 testVal = false;
579 ret = mono_test_marshal_bool_ref (5, 0, 0x2200, ref d, ref d, ref d, ref d, ref testVal);
580 if (ret != 0)
581 return 0x0900 + ret;
582 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
583 return 0x1000;
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);
587 if (ret != 0)
588 return 0x1100 + ret;
589 if (testVal)
590 return 0x1200;
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);
594 if (ret != 0)
595 return 0x1300 + ret;
596 if (1 != Marshal.ReadByte ((IntPtr)ptestVal))
597 return 0x1400;
599 return 0;
602 public static int test_0_Default_In_Managed ()
604 MarshalBoolInDelegate fcn = new MarshalBoolInDelegate (MarshalBoolInHelper);
605 int ret;
607 ret = mono_test_managed_marshal_bool_in (1, 0, 0, fcn);
608 if (ret != 0)
609 return 0x0100 + ret;
610 ret = mono_test_managed_marshal_bool_in (1, 1, 1, fcn);
611 if (ret != 0)
612 return 0x0200 + ret;
613 ret = mono_test_managed_marshal_bool_in (1, 1, 0x22000000, fcn);
614 if (ret != 0)
615 return 0x0300 + ret;
616 return 0;
619 public static int test_0_Bool_In_Managed ()
621 MarshalBoolInDelegate fcn = new MarshalBoolInDelegate (MarshalBoolInHelper);
622 int ret;
624 ret = mono_test_managed_marshal_bool_in (2, 0, 0, fcn);
625 if (ret != 0)
626 return 0x0100 + ret;
627 ret = mono_test_managed_marshal_bool_in (2, 1, 1, fcn);
628 if (ret != 0)
629 return 0x0200 + ret;
630 ret = mono_test_managed_marshal_bool_in (2, 1, 0x22000000, fcn);
631 if (ret != 0)
632 return 0x0300 + ret;
633 return 0;
636 public static int test_0_I1_In_Managed ()
638 MarshalBoolInDelegate fcn = new MarshalBoolInDelegate (MarshalBoolInHelper);
639 int ret;
641 ret = mono_test_managed_marshal_bool_in (3, 0, 0, fcn);
642 if (ret != 0)
643 return 0x0100 + ret;
644 ret = mono_test_managed_marshal_bool_in (3, 1, 1, fcn);
645 if (ret != 0)
646 return 0x0200 + ret;
647 ret = mono_test_managed_marshal_bool_in (3, 1, 0x22, fcn);
648 if (ret != 0)
649 return 0x0300 + ret;
650 return 0;
653 public static int test_0_U1_In_Managed ()
655 MarshalBoolInDelegate fcn = new MarshalBoolInDelegate (MarshalBoolInHelper);
656 int ret;
658 ret = mono_test_managed_marshal_bool_in (4, 0, 0, fcn);
659 if (ret != 0)
660 return 0x0100 + ret;
661 ret = mono_test_managed_marshal_bool_in (4, 1, 1, fcn);
662 if (ret != 0)
663 return 0x0200 + ret;
664 ret = mono_test_managed_marshal_bool_in (4, 1, 0x22, fcn);
665 if (ret != 0)
666 return 0x0300 + ret;
667 return 0;
670 public static int test_0_VariantBool_In_Managed ()
672 MarshalBoolInDelegate fcn = new MarshalBoolInDelegate (MarshalBoolInHelper);
673 int ret;
675 ret = mono_test_managed_marshal_bool_in (5, 0, 0, fcn);
676 if (ret != 0)
677 return 0x0100 + ret;
678 ret = mono_test_managed_marshal_bool_in (5, 1, 0xFFFF, fcn);
679 if (ret != 0)
680 return 0x0200 + ret;
681 ret = mono_test_managed_marshal_bool_in (5, 1, 0x22, fcn);
682 if (ret != 0)
683 return 0x0300 + ret;
684 return 0;
687 public static int test_0_Default_Out_Managed ()
689 MarshalBoolOutDelegate fcn = new MarshalBoolOutDelegate (MarshalBoolOutHelper);
690 int ret;
692 ret = mono_test_managed_marshal_bool_out (1, 0, 0, fcn);
693 if (ret != 0)
694 return 0x010000 + ret;
695 ret = mono_test_managed_marshal_bool_out (1, 1, 1, fcn);
696 if (ret != 0)
697 return 0x020000 + ret;
698 ret = mono_test_managed_marshal_bool_out (1, 1, 0x22, fcn);
699 if (ret != 0)
700 return 0x030000 + ret;
701 return 0;
704 public static int test_0_Bool_Out_Managed ()
706 MarshalBoolOutDelegate fcn = new MarshalBoolOutDelegate (MarshalBoolOutHelper);
707 int ret;
709 ret = mono_test_managed_marshal_bool_out (2, 0, 0, fcn);
710 if (ret != 0)
711 return 0x010000 + ret;
712 ret = mono_test_managed_marshal_bool_out (2, 1, 1, fcn);
713 if (ret != 0)
714 return 0x020000 + ret;
715 ret = mono_test_managed_marshal_bool_out (2, 1, 0x22, fcn);
716 if (ret != 0)
717 return 0x030000 + ret;
718 return 0;
721 public static int test_0_I1_Out_Managed ()
723 MarshalBoolOutDelegate fcn = new MarshalBoolOutDelegate (MarshalBoolOutHelper);
724 int ret;
726 ret = mono_test_managed_marshal_bool_out (3, 0, 0, fcn);
727 if (ret != 0)
728 return 0x010000 + ret;
729 ret = mono_test_managed_marshal_bool_out (3, 1, 1, fcn);
730 if (ret != 0)
731 return 0x020000 + ret;
732 ret = mono_test_managed_marshal_bool_out (3, 1, 0x22, fcn);
733 if (ret != 0)
734 return 0x030000 + ret;
735 return 0;
738 public static int test_0_U1_Out_Managed ()
740 MarshalBoolOutDelegate fcn = new MarshalBoolOutDelegate (MarshalBoolOutHelper);
741 int ret;
743 ret = mono_test_managed_marshal_bool_out (4, 0, 0, fcn);
744 if (ret != 0)
745 return 0x010000 + ret;
746 ret = mono_test_managed_marshal_bool_out (4, 1, 1, fcn);
747 if (ret != 0)
748 return 0x020000 + ret;
749 ret = mono_test_managed_marshal_bool_out (4, 1, 0x22, fcn);
750 if (ret != 0)
751 return 0x030000 + ret;
752 return 0;
755 public static int test_0_VariantBool_Out_Managed ()
757 MarshalBoolOutDelegate fcn = new MarshalBoolOutDelegate (MarshalBoolOutHelper);
758 int ret;
760 ret = mono_test_managed_marshal_bool_out (5, 0, 0, fcn);
761 if (ret != 0)
762 return 0x010000 + ret;
763 ret = mono_test_managed_marshal_bool_out (5, 0xFFFF, 1, fcn);
764 if (ret != 0)
765 return 0x020000 + ret;
766 ret = mono_test_managed_marshal_bool_out (5, 0xFFFF, 0x22, fcn);
767 if (ret != 0)
768 return 0x030000 + ret;
769 return 0;
772 public static int test_0_Default_Ref_Managed ()
774 MarshalBoolRefDelegate fcn = new MarshalBoolRefDelegate (MarshalBoolRefHelper);
775 int ret;
777 ret = mono_test_managed_marshal_bool_ref (1, 0, 0, 0, 0, fcn);
778 if (ret != 0)
779 return 0x010000 + ret;
780 ret = mono_test_managed_marshal_bool_ref (1, 1, 1, 0, 0, fcn);
781 if (ret != 0)
782 return 0x020000 + ret;
783 ret = mono_test_managed_marshal_bool_ref (1, 0, 0, 1, 1, fcn);
784 if (ret != 0)
785 return 0x030000 + ret;
786 ret = mono_test_managed_marshal_bool_ref (1, 1, 1, 1, 1, fcn);
787 if (ret != 0)
788 return 0x040000 + ret;
789 ret = mono_test_managed_marshal_bool_ref (1, 1, 0x22000000, 0, 0, fcn);
790 if (ret != 0)
791 return 0x050000 + ret;
792 ret = mono_test_managed_marshal_bool_ref (1, 0, 0, 1, 0x22, fcn);
793 if (ret != 0)
794 return 0x060000 + ret;
795 ret = mono_test_managed_marshal_bool_ref (1, 1, 0x22000000, 1, 0x22, fcn);
796 if (ret != 0)
797 return 0x070000 + ret;
798 return 0;
801 public static int test_0_Bool_Ref_Managed ()
803 MarshalBoolRefDelegate fcn = new MarshalBoolRefDelegate (MarshalBoolRefHelper);
804 int ret;
806 ret = mono_test_managed_marshal_bool_ref (2, 0, 0, 0, 0, fcn);
807 if (ret != 0)
808 return 0x010000 + ret;
809 ret = mono_test_managed_marshal_bool_ref (2, 1, 1, 0, 0, fcn);
810 if (ret != 0)
811 return 0x020000 + ret;
812 ret = mono_test_managed_marshal_bool_ref (2, 0, 0, 1, 1, fcn);
813 if (ret != 0)
814 return 0x030000 + ret;
815 ret = mono_test_managed_marshal_bool_ref (2, 1, 1, 1, 1, fcn);
816 if (ret != 0)
817 return 0x040000 + ret;
818 ret = mono_test_managed_marshal_bool_ref (2, 1, 0x22000000, 0, 0, fcn);
819 if (ret != 0)
820 return 0x050000 + ret;
821 ret = mono_test_managed_marshal_bool_ref (2, 0, 0, 1, 0x22, fcn);
822 if (ret != 0)
823 return 0x060000 + ret;
824 ret = mono_test_managed_marshal_bool_ref (2, 1, 0x22000000, 1, 0x22, fcn);
825 if (ret != 0)
826 return 0x070000 + ret;
827 return 0;
830 public static int test_0_I1_Ref_Managed ()
832 MarshalBoolRefDelegate fcn = new MarshalBoolRefDelegate (MarshalBoolRefHelper);
833 int ret;
835 ret = mono_test_managed_marshal_bool_ref (3, 0, 0, 0, 0, fcn);
836 if (ret != 0)
837 return 0x010000 + ret;
838 ret = mono_test_managed_marshal_bool_ref (3, 1, 1, 0, 0, fcn);
839 if (ret != 0)
840 return 0x020000 + ret;
841 ret = mono_test_managed_marshal_bool_ref (3, 0, 0, 1, 1, fcn);
842 if (ret != 0)
843 return 0x030000 + ret;
844 ret = mono_test_managed_marshal_bool_ref (3, 1, 1, 1, 1, fcn);
845 if (ret != 0)
846 return 0x040000 + ret;
847 ret = mono_test_managed_marshal_bool_ref (3, 1, 0x22, 0, 0, fcn);
848 if (ret != 0)
849 return 0x050000 + ret;
850 ret = mono_test_managed_marshal_bool_ref (3, 0, 0, 1, 0x22, fcn);
851 if (ret != 0)
852 return 0x060000 + ret;
853 ret = mono_test_managed_marshal_bool_ref (3, 1, 0x22, 1, 0x22, fcn);
854 if (ret != 0)
855 return 0x070000 + ret;
856 return 0;
859 public static int test_0_U1_Ref_Managed ()
861 MarshalBoolRefDelegate fcn = new MarshalBoolRefDelegate (MarshalBoolRefHelper);
862 int ret;
864 ret = mono_test_managed_marshal_bool_ref (4, 0, 0, 0, 0, fcn);
865 if (ret != 0)
866 return 0x010000 + ret;
867 ret = mono_test_managed_marshal_bool_ref (4, 1, 1, 0, 0, fcn);
868 if (ret != 0)
869 return 0x020000 + ret;
870 ret = mono_test_managed_marshal_bool_ref (4, 0, 0, 1, 1, fcn);
871 if (ret != 0)
872 return 0x030000 + ret;
873 ret = mono_test_managed_marshal_bool_ref (4, 1, 1, 1, 1, fcn);
874 if (ret != 0)
875 return 0x040000 + ret;
876 ret = mono_test_managed_marshal_bool_ref (4, 1, 0x22, 0, 0, fcn);
877 if (ret != 0)
878 return 0x050000 + ret;
879 ret = mono_test_managed_marshal_bool_ref (4, 0, 0, 1, 0x22, fcn);
880 if (ret != 0)
881 return 0x060000 + ret;
882 ret = mono_test_managed_marshal_bool_ref (4, 1, 0x22, 1, 0x22, fcn);
883 if (ret != 0)
884 return 0x070000 + ret;
885 return 0;
888 public static int test_0_VariantBool_Ref_Managed ()
890 MarshalBoolRefDelegate fcn = new MarshalBoolRefDelegate (MarshalBoolRefHelper);
891 int ret;
893 ret = mono_test_managed_marshal_bool_ref (5, 0, 0, 0, 0, fcn);
894 if (ret != 0)
895 return 0x010000 + ret;
896 ret = mono_test_managed_marshal_bool_ref (5, 1, 0xFFFF, 0, 0, fcn);
897 if (ret != 0)
898 return 0x020000 + ret;
899 ret = mono_test_managed_marshal_bool_ref (5, 0, 0, 0xFFFF, 1, fcn);
900 if (ret != 0)
901 return 0x030000 + ret;
902 ret = mono_test_managed_marshal_bool_ref (5, 1, 0xFFFF, 0xFFFF, 1, fcn);
903 if (ret != 0)
904 return 0x040000 + ret;
905 ret = mono_test_managed_marshal_bool_ref (5, 1, 0x2200, 0, 0, fcn);
906 if (ret != 0)
907 return 0x050000 + ret;
908 ret = mono_test_managed_marshal_bool_ref (5, 0, 0, 0xFFFF, 0x22, fcn);
909 if (ret != 0)
910 return 0x060000 + ret;
911 ret = mono_test_managed_marshal_bool_ref (5, 1, 0x2200, 0xFFFF, 0x22, fcn);
912 if (ret != 0)
913 return 0x070000 + ret;
914 return 0;
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)
923 bool* ptestVal;
924 switch (arg) {
925 case 1 :
926 ptestVal = &bDefaultMarsh;
927 if (expected != Marshal.ReadByte ((IntPtr)ptestVal))
928 return 1;
929 break;
930 case 2 :
931 ptestVal = &bBoolCustMarsh;
932 if (expected != Marshal.ReadByte ((IntPtr)ptestVal))
933 return 2;
934 break;
935 case 3 :
936 ptestVal = &bI1CustMarsh;
937 if (expected != Marshal.ReadByte ((IntPtr)ptestVal))
938 return 3;
939 break;
940 case 4 :
941 ptestVal = &bU1CustMarsh;
942 if (expected != Marshal.ReadByte ((IntPtr)ptestVal))
943 return 4;
944 break;
945 case 5 :
946 ptestVal = &bVBCustMarsh;
947 if (expected != Marshal.ReadByte ((IntPtr)ptestVal))
948 return 5;
949 break;
950 default :
951 return 99;
953 return 0;
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;
961 switch (arg) {
962 case 1:
963 fixed (bool*ptestVal = &bDefaultMarsh)
965 Marshal.WriteByte ((IntPtr)ptestVal, (byte)testVal);
967 break;
968 case 2:
969 fixed (bool*ptestVal = &bBoolCustMarsh)
971 Marshal.WriteByte ((IntPtr)ptestVal, (byte)testVal);
973 break;
974 case 3:
975 fixed (bool*ptestVal = &bI1CustMarsh)
977 Marshal.WriteByte ((IntPtr)ptestVal, (byte)testVal);
979 break;
980 case 4:
981 fixed (bool*ptestVal = &bU1CustMarsh)
983 Marshal.WriteByte ((IntPtr)ptestVal, (byte)testVal);
985 break;
986 case 5:
987 fixed (bool*ptestVal = &bVBCustMarsh)
989 Marshal.WriteByte ((IntPtr)ptestVal, (byte)testVal);
991 break;
992 default :
993 return 99;
995 return 0;
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)
1002 switch (arg) {
1003 case 1:
1004 fixed (bool*ptestVal = &bDefaultMarsh)
1006 if (expected != Marshal.ReadByte ((IntPtr)ptestVal))
1007 return 1;
1008 Marshal.WriteByte ((IntPtr)ptestVal, (byte)testVal);
1010 break;
1011 case 2:
1012 fixed (bool*ptestVal = &bBoolCustMarsh)
1014 if (expected != Marshal.ReadByte ((IntPtr)ptestVal))
1015 return 2;
1016 Marshal.WriteByte ((IntPtr)ptestVal, (byte)testVal);
1018 break;
1019 case 3:
1020 fixed (bool*ptestVal = &bI1CustMarsh)
1022 if (expected != Marshal.ReadByte ((IntPtr)ptestVal))
1023 return 3;
1024 Marshal.WriteByte ((IntPtr)ptestVal, (byte)testVal);
1026 break;
1027 case 4:
1028 fixed (bool*ptestVal = &bU1CustMarsh)
1030 if (expected != Marshal.ReadByte ((IntPtr)ptestVal))
1031 return 4;
1032 Marshal.WriteByte ((IntPtr)ptestVal, (byte)testVal);
1034 break;
1035 case 5:
1036 fixed (bool*ptestVal = &bVBCustMarsh)
1038 if (expected != Marshal.ReadByte ((IntPtr)ptestVal))
1039 return 5;
1040 Marshal.WriteByte ((IntPtr)ptestVal, (byte)testVal);
1042 break;
1043 default :
1044 return 99;
1046 return 0;