1 using System; 2 using System.Runtime.InteropServices; 3 4 public class marshalbool 5 { 6 [AttributeUsage (AttributeTargets.Method)] 7 sealed class MonoPInvokeCallbackAttribute : Attribute { MonoPInvokeCallbackAttribute(Type t)8 public MonoPInvokeCallbackAttribute (Type t) {} 9 } 10 11 [DllImport ("libtest")] mono_test_marshal_bool_in(int arg, uint expected, bool bDefaultMarsh, [MarshalAs (UnmanagedType.Bool)] bool bBoolCustMarsh, [MarshalAs (UnmanagedType.I1)] bool bI1CustMarsh, [MarshalAs (UnmanagedType.U1)] bool bU1CustMarsh, [MarshalAs (UnmanagedType.VariantBool)] bool bVBCustMarsh)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); 18 19 [DllImport ("libtest")] mono_test_marshal_bool_out(int arg, uint testVal, out bool bDefaultMarsh, [MarshalAs (UnmanagedType.Bool)] out bool bBoolCustMarsh, [MarshalAs (UnmanagedType.I1)] out bool bI1CustMarsh, [MarshalAs (UnmanagedType.U1)] out bool bU1CustMarsh, [MarshalAs (UnmanagedType.VariantBool)] out bool bVBCustMarsh)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); 26 27 [DllImport ("libtest")] mono_test_marshal_bool_ref(int arg, uint expected, uint testVal, ref bool bDefaultMarsh, [MarshalAs (UnmanagedType.Bool)] ref bool bBoolCustMarsh, [MarshalAs (UnmanagedType.I1)] ref bool bI1CustMarsh, [MarshalAs (UnmanagedType.U1)] ref bool bU1CustMarsh, [MarshalAs (UnmanagedType.VariantBool)] ref bool bVBCustMarsh)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); 34 MarshalBoolInDelegate(int arg, uint expected, bool bDefaultMarsh, [MarshalAs (UnmanagedType.Bool)] bool bBoolCustMarsh, [MarshalAs (UnmanagedType.I1)] bool bI1CustMarsh, [MarshalAs (UnmanagedType.U1)] bool bU1CustMarsh, [MarshalAs (UnmanagedType.VariantBool)] 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); 41 MarshalBoolOutDelegate(int arg, uint testVal, out bool bDefaultMarsh, [MarshalAs (UnmanagedType.Bool)] out bool bBoolCustMarsh, [MarshalAs (UnmanagedType.I1)] out bool bI1CustMarsh, [MarshalAs (UnmanagedType.U1)] out bool bU1CustMarsh, [MarshalAs (UnmanagedType.VariantBool)] out 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); 48 MarshalBoolRefDelegate(int arg, uint expected, uint testVal, ref bool bDefaultMarsh, [MarshalAs (UnmanagedType.Bool)] ref bool bBoolCustMarsh, [MarshalAs (UnmanagedType.I1)] ref bool bI1CustMarsh, [MarshalAs (UnmanagedType.U1)] ref bool bU1CustMarsh, [MarshalAs (UnmanagedType.VariantBool)] ref 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); 55 56 [DllImport ("libtest")] mono_test_managed_marshal_bool_in(int arg, uint expected, uint testVal, MarshalBoolInDelegate fcn)57 static extern int mono_test_managed_marshal_bool_in (int arg, uint expected, uint testVal, MarshalBoolInDelegate fcn); 58 59 [DllImport ("libtest")] mono_test_managed_marshal_bool_out(int arg, uint expected, uint testVal, MarshalBoolOutDelegate fcn)60 static extern int mono_test_managed_marshal_bool_out (int arg, uint expected, uint testVal, MarshalBoolOutDelegate fcn); 61 62 [DllImport ("libtest")] mono_test_managed_marshal_bool_ref(int arg, uint expected, uint testVal, uint outExpected, uint outTestVal, MarshalBoolRefDelegate fcn)63 static extern int mono_test_managed_marshal_bool_ref (int arg, uint expected, uint testVal, 64 uint outExpected, uint outTestVal, MarshalBoolRefDelegate fcn); 65 Main(string[] args)66 static int Main (string[] args) 67 { 68 return TestDriver.RunTests (typeof (marshalbool), args); 69 } 70 test_0_Default_In_Native()71 unsafe public static int test_0_Default_In_Native () 72 { 73 int ret; 74 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; 81 82 bool testVal = false; 83 bool* ptestVal = &testVal; 84 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; 89 90 return 0; 91 } 92 test_0_Bool_In_Native()93 unsafe public static int test_0_Bool_In_Native () 94 { 95 int ret; 96 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; 103 104 bool testVal = false; 105 bool* ptestVal = &testVal; 106 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; 111 112 return 0; 113 } 114 test_0_I1_In_Native()115 unsafe public static int test_0_I1_In_Native () 116 { 117 int ret; 118 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; 125 126 bool testVal = false; 127 bool* ptestVal = &testVal; 128 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; 133 134 return 0; 135 } 136 test_0_U1_In_Native()137 unsafe public static int test_0_U1_In_Native () 138 { 139 int ret; 140 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; 147 148 bool testVal = false; 149 bool* ptestVal = &testVal; 150 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; 155 156 return 0; 157 } 158 test_0_VariantBool_In_Native()159 unsafe public static int test_0_VariantBool_In_Native () 160 { 161 int ret; 162 int m1 = -1; 163 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; 170 171 bool testVal = false; 172 bool* ptestVal = &testVal; 173 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; 178 179 return 0; 180 } 181 test_0_Default_Out_Native()182 unsafe public static int test_0_Default_Out_Native () 183 { 184 bool testVal = false; 185 bool* ptestVal = &testVal; 186 bool d = false; 187 int ret; 188 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; 194 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; 200 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; 206 207 return 0; 208 } 209 test_0_Bool_Out_Native()210 unsafe public static int test_0_Bool_Out_Native () 211 { 212 bool testVal = false; 213 bool* ptestVal = &testVal; 214 bool d = false; 215 int ret; 216 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; 222 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; 228 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; 234 235 return 0; 236 } 237 test_0_I1_Out_Native()238 unsafe public static int test_0_I1_Out_Native () 239 { 240 bool testVal = false; 241 bool* ptestVal = &testVal; 242 bool d = false; 243 int ret; 244 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; 250 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; 256 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; 262 263 return 0; 264 } 265 test_0_U1_Out_Native()266 unsafe public static int test_0_U1_Out_Native () 267 { 268 bool testVal = false; 269 bool* ptestVal = &testVal; 270 bool d = false; 271 int ret; 272 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; 278 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; 284 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; 290 291 return 0; 292 } 293 test_0_VariantBool_Out_Native()294 unsafe public static int test_0_VariantBool_Out_Native () 295 { 296 bool testVal = false; 297 bool* ptestVal = &testVal; 298 bool d = false; 299 int ret; 300 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; 306 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; 312 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; 318 319 return 0; 320 } 321 test_0_Default_Ref_Native()322 unsafe public static int test_0_Default_Ref_Native () 323 { 324 bool testVal = false; 325 bool* ptestVal = &testVal; 326 bool d = false; 327 int ret; 328 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; 334 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; 340 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; 346 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; 353 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; 360 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; 367 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; 374 375 return 0; 376 } 377 test_0_Bool_Ref_Native()378 unsafe public static int test_0_Bool_Ref_Native () 379 { 380 bool testVal = false; 381 bool* ptestVal = &testVal; 382 bool d = false; 383 int ret; 384 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; 390 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; 396 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; 402 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; 409 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; 416 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; 423 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; 430 431 return 0; 432 } 433 test_0_I1_Ref_Native()434 unsafe public static int test_0_I1_Ref_Native () 435 { 436 bool testVal = false; 437 bool* ptestVal = &testVal; 438 bool d = false; 439 int ret; 440 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; 446 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; 452 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; 458 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; 465 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; 472 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; 479 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; 486 487 return 0; 488 } 489 test_0_U1_Ref_Native()490 unsafe public static int test_0_U1_Ref_Native () 491 { 492 bool testVal = false; 493 bool* ptestVal = &testVal; 494 bool d = false; 495 int ret; 496 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; 502 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; 508 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; 514 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; 521 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; 528 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; 535 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; 542 543 return 0; 544 } 545 test_0_VariantBool_Ref_Native()546 unsafe public static int test_0_VariantBool_Ref_Native () 547 { 548 bool testVal = false; 549 bool* ptestVal = &testVal; 550 bool d = false; 551 int ret; 552 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; 558 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; 564 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; 570 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; 577 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; 584 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; 591 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; 598 599 return 0; 600 } 601 test_0_Default_In_Managed()602 public static int test_0_Default_In_Managed () 603 { 604 MarshalBoolInDelegate fcn = new MarshalBoolInDelegate (MarshalBoolInHelper); 605 int ret; 606 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; 617 } 618 test_0_Bool_In_Managed()619 public static int test_0_Bool_In_Managed () 620 { 621 MarshalBoolInDelegate fcn = new MarshalBoolInDelegate (MarshalBoolInHelper); 622 int ret; 623 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; 634 } 635 test_0_I1_In_Managed()636 public static int test_0_I1_In_Managed () 637 { 638 MarshalBoolInDelegate fcn = new MarshalBoolInDelegate (MarshalBoolInHelper); 639 int ret; 640 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; 651 } 652 test_0_U1_In_Managed()653 public static int test_0_U1_In_Managed () 654 { 655 MarshalBoolInDelegate fcn = new MarshalBoolInDelegate (MarshalBoolInHelper); 656 int ret; 657 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; 668 } 669 test_0_VariantBool_In_Managed()670 public static int test_0_VariantBool_In_Managed () 671 { 672 MarshalBoolInDelegate fcn = new MarshalBoolInDelegate (MarshalBoolInHelper); 673 int ret; 674 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; 685 } 686 test_0_Default_Out_Managed()687 public static int test_0_Default_Out_Managed () 688 { 689 MarshalBoolOutDelegate fcn = new MarshalBoolOutDelegate (MarshalBoolOutHelper); 690 int ret; 691 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; 702 } 703 test_0_Bool_Out_Managed()704 public static int test_0_Bool_Out_Managed () 705 { 706 MarshalBoolOutDelegate fcn = new MarshalBoolOutDelegate (MarshalBoolOutHelper); 707 int ret; 708 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; 719 } 720 test_0_I1_Out_Managed()721 public static int test_0_I1_Out_Managed () 722 { 723 MarshalBoolOutDelegate fcn = new MarshalBoolOutDelegate (MarshalBoolOutHelper); 724 int ret; 725 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; 736 } 737 test_0_U1_Out_Managed()738 public static int test_0_U1_Out_Managed () 739 { 740 MarshalBoolOutDelegate fcn = new MarshalBoolOutDelegate (MarshalBoolOutHelper); 741 int ret; 742 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; 753 } 754 test_0_VariantBool_Out_Managed()755 public static int test_0_VariantBool_Out_Managed () 756 { 757 MarshalBoolOutDelegate fcn = new MarshalBoolOutDelegate (MarshalBoolOutHelper); 758 int ret; 759 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; 770 } 771 test_0_Default_Ref_Managed()772 public static int test_0_Default_Ref_Managed () 773 { 774 MarshalBoolRefDelegate fcn = new MarshalBoolRefDelegate (MarshalBoolRefHelper); 775 int ret; 776 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; 799 } 800 test_0_Bool_Ref_Managed()801 public static int test_0_Bool_Ref_Managed () 802 { 803 MarshalBoolRefDelegate fcn = new MarshalBoolRefDelegate (MarshalBoolRefHelper); 804 int ret; 805 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; 828 } 829 test_0_I1_Ref_Managed()830 public static int test_0_I1_Ref_Managed () 831 { 832 MarshalBoolRefDelegate fcn = new MarshalBoolRefDelegate (MarshalBoolRefHelper); 833 int ret; 834 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; 857 } 858 test_0_U1_Ref_Managed()859 public static int test_0_U1_Ref_Managed () 860 { 861 MarshalBoolRefDelegate fcn = new MarshalBoolRefDelegate (MarshalBoolRefHelper); 862 int ret; 863 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; 886 } 887 test_0_VariantBool_Ref_Managed()888 public static int test_0_VariantBool_Ref_Managed () 889 { 890 MarshalBoolRefDelegate fcn = new MarshalBoolRefDelegate (MarshalBoolRefHelper); 891 int ret; 892 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; 915 } 916 917 /////////////////////////////////////////////////////////////////// 918 919 [MonoPInvokeCallback (typeof (MarshalBoolInDelegate))] MarshalBoolInHelper(int arg, uint expected, bool bDefaultMarsh, bool bBoolCustMarsh, bool bI1CustMarsh, bool bU1CustMarsh, bool bVBCustMarsh)920 unsafe static int MarshalBoolInHelper (int arg, uint expected, bool bDefaultMarsh, bool bBoolCustMarsh, bool bI1CustMarsh, 921 bool bU1CustMarsh, bool bVBCustMarsh) 922 { 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; 952 } 953 return 0; 954 } 955 956 [MonoPInvokeCallback (typeof (MarshalBoolOutDelegate))] MarshalBoolOutHelper(int arg, uint testVal, out bool bDefaultMarsh, out bool bBoolCustMarsh, out bool bI1CustMarsh, out bool bU1CustMarsh, out bool bVBCustMarsh)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) 959 { 960 bDefaultMarsh = bBoolCustMarsh = bI1CustMarsh = bU1CustMarsh = bVBCustMarsh = false; 961 switch (arg) { 962 case 1: 963 fixed (bool*ptestVal = &bDefaultMarsh) 964 { 965 Marshal.WriteByte ((IntPtr)ptestVal, (byte)testVal); 966 } 967 break; 968 case 2: 969 fixed (bool*ptestVal = &bBoolCustMarsh) 970 { 971 Marshal.WriteByte ((IntPtr)ptestVal, (byte)testVal); 972 } 973 break; 974 case 3: 975 fixed (bool*ptestVal = &bI1CustMarsh) 976 { 977 Marshal.WriteByte ((IntPtr)ptestVal, (byte)testVal); 978 } 979 break; 980 case 4: 981 fixed (bool*ptestVal = &bU1CustMarsh) 982 { 983 Marshal.WriteByte ((IntPtr)ptestVal, (byte)testVal); 984 } 985 break; 986 case 5: 987 fixed (bool*ptestVal = &bVBCustMarsh) 988 { 989 Marshal.WriteByte ((IntPtr)ptestVal, (byte)testVal); 990 } 991 break; 992 default : 993 return 99; 994 } 995 return 0; 996 } 997 998 [MonoPInvokeCallback (typeof (MarshalBoolRefDelegate))] MarshalBoolRefHelper(int arg, uint expected, uint testVal, ref bool bDefaultMarsh, ref bool bBoolCustMarsh, ref bool bI1CustMarsh, ref bool bU1CustMarsh, ref bool bVBCustMarsh)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) 1001 { 1002 switch (arg) { 1003 case 1: 1004 fixed (bool*ptestVal = &bDefaultMarsh) 1005 { 1006 if (expected != Marshal.ReadByte ((IntPtr)ptestVal)) 1007 return 1; 1008 Marshal.WriteByte ((IntPtr)ptestVal, (byte)testVal); 1009 } 1010 break; 1011 case 2: 1012 fixed (bool*ptestVal = &bBoolCustMarsh) 1013 { 1014 if (expected != Marshal.ReadByte ((IntPtr)ptestVal)) 1015 return 2; 1016 Marshal.WriteByte ((IntPtr)ptestVal, (byte)testVal); 1017 } 1018 break; 1019 case 3: 1020 fixed (bool*ptestVal = &bI1CustMarsh) 1021 { 1022 if (expected != Marshal.ReadByte ((IntPtr)ptestVal)) 1023 return 3; 1024 Marshal.WriteByte ((IntPtr)ptestVal, (byte)testVal); 1025 } 1026 break; 1027 case 4: 1028 fixed (bool*ptestVal = &bU1CustMarsh) 1029 { 1030 if (expected != Marshal.ReadByte ((IntPtr)ptestVal)) 1031 return 4; 1032 Marshal.WriteByte ((IntPtr)ptestVal, (byte)testVal); 1033 } 1034 break; 1035 case 5: 1036 fixed (bool*ptestVal = &bVBCustMarsh) 1037 { 1038 if (expected != Marshal.ReadByte ((IntPtr)ptestVal)) 1039 return 5; 1040 Marshal.WriteByte ((IntPtr)ptestVal, (byte)testVal); 1041 } 1042 break; 1043 default : 1044 return 99; 1045 } 1046 return 0; 1047 } 1048 1049 } 1050 1051