4 // Tests for COM Interop related features
8 using System
.Runtime
.CompilerServices
;
9 using System
.Runtime
.InteropServices
;
14 [DllImport("libtest")]
15 public static extern int mono_test_marshal_bstr_in([MarshalAs(UnmanagedType
.BStr
)]string str
);
17 [DllImport("libtest")]
18 public static extern int mono_test_marshal_bstr_out([MarshalAs(UnmanagedType
.BStr
)] out string str
);
20 [DllImport("libtest")]
21 public static extern int mono_test_marshal_bstr_in_null([MarshalAs(UnmanagedType
.BStr
)]string str
);
23 [DllImport("libtest")]
24 public static extern int mono_test_marshal_bstr_out_null([MarshalAs(UnmanagedType
.BStr
)] out string str
);
26 [DllImport("libtest")]
27 public static extern int mono_test_marshal_variant_in_sbyte([MarshalAs(UnmanagedType
.Struct
)]object obj
);
29 [DllImport("libtest")]
30 public static extern int mono_test_marshal_variant_in_byte([MarshalAs(UnmanagedType
.Struct
)]object obj
);
32 [DllImport("libtest")]
33 public static extern int mono_test_marshal_variant_in_short([MarshalAs(UnmanagedType
.Struct
)]object obj
);
35 [DllImport("libtest")]
36 public static extern int mono_test_marshal_variant_in_ushort([MarshalAs(UnmanagedType
.Struct
)]object obj
);
38 [DllImport("libtest")]
39 public static extern int mono_test_marshal_variant_in_int([MarshalAs(UnmanagedType
.Struct
)]object obj
);
41 [DllImport("libtest")]
42 public static extern int mono_test_marshal_variant_in_uint([MarshalAs(UnmanagedType
.Struct
)]object obj
);
44 [DllImport("libtest")]
45 public static extern int mono_test_marshal_variant_in_long([MarshalAs(UnmanagedType
.Struct
)]object obj
);
47 [DllImport("libtest")]
48 public static extern int mono_test_marshal_variant_in_ulong([MarshalAs(UnmanagedType
.Struct
)]object obj
);
50 [DllImport("libtest")]
51 public static extern int mono_test_marshal_variant_in_float([MarshalAs(UnmanagedType
.Struct
)]object obj
);
53 [DllImport("libtest")]
54 public static extern int mono_test_marshal_variant_in_double([MarshalAs(UnmanagedType
.Struct
)]object obj
);
56 [DllImport("libtest")]
57 public static extern int mono_test_marshal_variant_in_bstr ([MarshalAs (UnmanagedType
.Struct
)]object obj
);
59 [DllImport ("libtest")]
60 public static extern int mono_test_marshal_variant_in_bool_true ([MarshalAs (UnmanagedType
.Struct
)]object obj
);
62 [DllImport ("libtest")]
63 public static extern int mono_test_marshal_variant_in_bool_false ([MarshalAs (UnmanagedType
.Struct
)]object obj
);
65 [DllImport("libtest")]
66 public static extern int mono_test_marshal_variant_out_sbyte([MarshalAs(UnmanagedType
.Struct
)]out object obj
);
68 [DllImport("libtest")]
69 public static extern int mono_test_marshal_variant_out_byte([MarshalAs(UnmanagedType
.Struct
)]out object obj
);
71 [DllImport("libtest")]
72 public static extern int mono_test_marshal_variant_out_short([MarshalAs(UnmanagedType
.Struct
)]out object obj
);
74 [DllImport("libtest")]
75 public static extern int mono_test_marshal_variant_out_ushort([MarshalAs(UnmanagedType
.Struct
)]out object obj
);
77 [DllImport("libtest")]
78 public static extern int mono_test_marshal_variant_out_int([MarshalAs(UnmanagedType
.Struct
)]out object obj
);
80 [DllImport("libtest")]
81 public static extern int mono_test_marshal_variant_out_uint([MarshalAs(UnmanagedType
.Struct
)]out object obj
);
83 [DllImport("libtest")]
84 public static extern int mono_test_marshal_variant_out_long([MarshalAs(UnmanagedType
.Struct
)]out object obj
);
86 [DllImport("libtest")]
87 public static extern int mono_test_marshal_variant_out_ulong([MarshalAs(UnmanagedType
.Struct
)]out object obj
);
89 [DllImport("libtest")]
90 public static extern int mono_test_marshal_variant_out_float([MarshalAs(UnmanagedType
.Struct
)]out object obj
);
92 [DllImport("libtest")]
93 public static extern int mono_test_marshal_variant_out_double([MarshalAs(UnmanagedType
.Struct
)]out object obj
);
95 [DllImport("libtest")]
96 public static extern int mono_test_marshal_variant_out_bstr ([MarshalAs (UnmanagedType
.Struct
)]out object obj
);
98 [DllImport("libtest")]
99 public static extern int mono_test_marshal_variant_out_bool_true ([MarshalAs (UnmanagedType
.Struct
)]out object obj
);
101 [DllImport ("libtest")]
102 public static extern int mono_test_marshal_variant_out_bool_false ([MarshalAs (UnmanagedType
.Struct
)]out object obj
);
105 public delegate int VarFunc (VarEnum vt
, [MarshalAs (UnmanagedType
.Struct
)] object obj
);
107 public delegate int VarRefFunc (VarEnum vt
, [MarshalAs (UnmanagedType
.Struct
)] ref object obj
);
109 [DllImport ("libtest")]
110 public static extern int mono_test_marshal_variant_in_sbyte_unmanaged (VarFunc func
);
112 [DllImport ("libtest")]
113 public static extern int mono_test_marshal_variant_in_byte_unmanaged (VarFunc func
);
115 [DllImport ("libtest")]
116 public static extern int mono_test_marshal_variant_in_short_unmanaged (VarFunc func
);
118 [DllImport ("libtest")]
119 public static extern int mono_test_marshal_variant_in_ushort_unmanaged (VarFunc func
);
121 [DllImport ("libtest")]
122 public static extern int mono_test_marshal_variant_in_int_unmanaged (VarFunc func
);
124 [DllImport ("libtest")]
125 public static extern int mono_test_marshal_variant_in_uint_unmanaged (VarFunc func
);
127 [DllImport ("libtest")]
128 public static extern int mono_test_marshal_variant_in_long_unmanaged (VarFunc func
);
130 [DllImport ("libtest")]
131 public static extern int mono_test_marshal_variant_in_ulong_unmanaged (VarFunc func
);
133 [DllImport ("libtest")]
134 public static extern int mono_test_marshal_variant_in_float_unmanaged (VarFunc func
);
136 [DllImport ("libtest")]
137 public static extern int mono_test_marshal_variant_in_double_unmanaged (VarFunc func
);
139 [DllImport ("libtest")]
140 public static extern int mono_test_marshal_variant_in_bstr_unmanaged (VarFunc func
);
142 [DllImport ("libtest")]
143 public static extern int mono_test_marshal_variant_in_bool_true_unmanaged (VarFunc func
);
145 [DllImport ("libtest")]
146 public static extern int mono_test_marshal_variant_in_bool_false_unmanaged (VarFunc func
);
148 [DllImport ("libtest")]
149 public static extern int mono_test_marshal_variant_out_sbyte_unmanaged (VarRefFunc func
);
151 [DllImport ("libtest")]
152 public static extern int mono_test_marshal_variant_out_byte_unmanaged (VarRefFunc func
);
154 [DllImport ("libtest")]
155 public static extern int mono_test_marshal_variant_out_short_unmanaged (VarRefFunc func
);
157 [DllImport ("libtest")]
158 public static extern int mono_test_marshal_variant_out_ushort_unmanaged (VarRefFunc func
);
160 [DllImport ("libtest")]
161 public static extern int mono_test_marshal_variant_out_int_unmanaged (VarRefFunc func
);
163 [DllImport ("libtest")]
164 public static extern int mono_test_marshal_variant_out_uint_unmanaged (VarRefFunc func
);
166 [DllImport ("libtest")]
167 public static extern int mono_test_marshal_variant_out_long_unmanaged (VarRefFunc func
);
169 [DllImport ("libtest")]
170 public static extern int mono_test_marshal_variant_out_ulong_unmanaged (VarRefFunc func
);
172 [DllImport ("libtest")]
173 public static extern int mono_test_marshal_variant_out_float_unmanaged (VarRefFunc func
);
175 [DllImport ("libtest")]
176 public static extern int mono_test_marshal_variant_out_double_unmanaged (VarRefFunc func
);
178 [DllImport ("libtest")]
179 public static extern int mono_test_marshal_variant_out_bstr_unmanaged (VarRefFunc func
);
181 [DllImport ("libtest")]
182 public static extern int mono_test_marshal_variant_out_bool_true_unmanaged (VarRefFunc func
);
184 [DllImport ("libtest")]
185 public static extern int mono_test_marshal_variant_out_bool_false_unmanaged (VarRefFunc func
);
187 [DllImport ("libtest")]
188 public static extern int mono_test_marshal_com_object_create (out IntPtr pUnk
);
190 [DllImport ("libtest")]
191 public static extern int mono_test_marshal_com_object_same (out IntPtr pUnk
);
193 [DllImport ("libtest")]
194 public static extern int mono_test_marshal_com_object_destroy (IntPtr pUnk
);
196 [DllImport ("libtest")]
197 public static extern int mono_test_marshal_com_object_ref_count (IntPtr pUnk
);
199 [DllImport ("libtest")]
200 public static extern int mono_test_marshal_ccw_identity ([MarshalAs (UnmanagedType
.Interface
)]ITest itest
);
202 [DllImport ("libtest")]
203 public static extern int mono_test_marshal_ccw_reflexive ([MarshalAs (UnmanagedType
.Interface
)]ITest itest
);
205 [DllImport ("libtest")]
206 public static extern int mono_test_marshal_ccw_transitive ([MarshalAs (UnmanagedType
.Interface
)]ITest itest
);
208 [DllImport ("libtest")]
209 public static extern int mono_test_marshal_ccw_itest ([MarshalAs (UnmanagedType
.Interface
)]ITest itest
);
211 [DllImport ("libtest")]
212 public static extern int mono_test_marshal_ccw_itest ([MarshalAs (UnmanagedType
.Interface
)]ITestPresSig itest
);
214 public static int Main() {
216 bool isWindows
= !(((int)Environment
.OSVersion
.Platform
== 4) ||
217 ((int)Environment
.OSVersion
.Platform
== 128));
222 if (mono_test_marshal_bstr_in ("mono_test_marshal_bstr_in") != 0)
224 if (mono_test_marshal_bstr_out (out str
) != 0 || str
!= "mono_test_marshal_bstr_out")
226 if (mono_test_marshal_bstr_in_null (null) != 0)
228 if (mono_test_marshal_bstr_out_null (out str
) != 0 || str
!= null)
231 #endregion // BSTR Tests
233 #region VARIANT Tests
236 if (mono_test_marshal_variant_in_sbyte ((sbyte)100) != 0)
238 if (mono_test_marshal_variant_in_byte ((byte)100) != 0)
240 if (mono_test_marshal_variant_in_short ((short)314) != 0)
242 if (mono_test_marshal_variant_in_ushort ((ushort)314) != 0)
244 if (mono_test_marshal_variant_in_int ((int)314) != 0)
246 if (mono_test_marshal_variant_in_uint ((uint)314) != 0)
248 if (mono_test_marshal_variant_in_long ((long)314) != 0)
250 if (mono_test_marshal_variant_in_ulong ((ulong)314) != 0)
252 if (mono_test_marshal_variant_in_float ((float)3.14) != 0)
254 if (mono_test_marshal_variant_in_double ((double)3.14) != 0)
256 if (mono_test_marshal_variant_in_bstr ("PI") != 0)
258 if (mono_test_marshal_variant_out_sbyte (out obj
) != 0 || (sbyte)obj
!= 100)
260 if (mono_test_marshal_variant_out_byte (out obj
) != 0 || (byte)obj
!= 100)
262 if (mono_test_marshal_variant_out_short (out obj
) != 0 || (short)obj
!= 314)
264 if (mono_test_marshal_variant_out_ushort (out obj
) != 0 || (ushort)obj
!= 314)
266 if (mono_test_marshal_variant_out_int (out obj
) != 0 || (int)obj
!= 314)
268 if (mono_test_marshal_variant_out_uint (out obj
) != 0 || (uint)obj
!= 314)
270 if (mono_test_marshal_variant_out_long (out obj
) != 0 || (long)obj
!= 314)
272 if (mono_test_marshal_variant_out_ulong (out obj
) != 0 || (ulong)obj
!= 314)
274 if (mono_test_marshal_variant_out_float (out obj
) != 0 || ((float)obj
- 3.14) / 3.14 > .001)
276 if (mono_test_marshal_variant_out_double (out obj
) != 0 || ((double)obj
- 3.14) / 3.14 > .001)
278 if (mono_test_marshal_variant_out_bstr (out obj
) != 0 || (string)obj
!= "PI")
281 VarFunc func
= new VarFunc (mono_test_marshal_variant_in_callback
);
282 if (mono_test_marshal_variant_in_sbyte_unmanaged (func
) != 0)
284 if (mono_test_marshal_variant_in_byte_unmanaged (func
) != 0)
286 if (mono_test_marshal_variant_in_short_unmanaged (func
) != 0)
288 if (mono_test_marshal_variant_in_ushort_unmanaged (func
) != 0)
290 if (mono_test_marshal_variant_in_int_unmanaged (func
) != 0)
292 if (mono_test_marshal_variant_in_uint_unmanaged (func
) != 0)
294 if (mono_test_marshal_variant_in_long_unmanaged (func
) != 0)
296 if (mono_test_marshal_variant_in_ulong_unmanaged (func
) != 0)
298 if (mono_test_marshal_variant_in_float_unmanaged (func
) != 0)
300 if (mono_test_marshal_variant_in_double_unmanaged (func
) != 0)
302 if (mono_test_marshal_variant_in_bstr_unmanaged (func
) != 0)
304 if (mono_test_marshal_variant_in_bool_true_unmanaged (func
) != 0)
307 VarRefFunc reffunc
= new VarRefFunc (mono_test_marshal_variant_out_callback
);
308 if (mono_test_marshal_variant_out_sbyte_unmanaged (reffunc
) != 0)
310 if (mono_test_marshal_variant_out_byte_unmanaged (reffunc
) != 0)
312 if (mono_test_marshal_variant_out_short_unmanaged (reffunc
) != 0)
314 if (mono_test_marshal_variant_out_ushort_unmanaged (reffunc
) != 0)
316 if (mono_test_marshal_variant_out_int_unmanaged (reffunc
) != 0)
318 if (mono_test_marshal_variant_out_uint_unmanaged (reffunc
) != 0)
320 if (mono_test_marshal_variant_out_long_unmanaged (reffunc
) != 0)
322 if (mono_test_marshal_variant_out_ulong_unmanaged (reffunc
) != 0)
324 if (mono_test_marshal_variant_out_float_unmanaged (reffunc
) != 0)
326 if (mono_test_marshal_variant_out_double_unmanaged (reffunc
) != 0)
328 if (mono_test_marshal_variant_out_bstr_unmanaged (reffunc
) != 0)
330 if (mono_test_marshal_variant_out_bool_true_unmanaged (reffunc
) != 0)
333 #endregion // VARIANT Tests
335 #region Runtime Callable Wrapper Tests
338 if (mono_test_marshal_com_object_create (out pUnk
) != 0)
341 if (mono_test_marshal_com_object_ref_count (pUnk
) != 1)
344 if (Marshal
.AddRef (pUnk
) != 2)
347 if (mono_test_marshal_com_object_ref_count (pUnk
) != 2)
350 if (Marshal
.Release (pUnk
) != 1)
353 if (mono_test_marshal_com_object_ref_count (pUnk
) != 1)
356 object com_obj
= Marshal
.GetObjectForIUnknown (pUnk
);
361 ITest itest
= com_obj
as ITest
;
367 if (mono_test_marshal_com_object_same (out pUnk2
) != 0)
370 object com_obj2
= Marshal
.GetObjectForIUnknown (pUnk2
);
372 if (com_obj
!= com_obj2
)
375 if (!com_obj
.Equals (com_obj2
))
379 if (mono_test_marshal_com_object_create (out pUnk3
) != 0)
382 object com_obj3
= Marshal
.GetObjectForIUnknown (pUnk3
);
383 if (com_obj
== com_obj3
)
386 if (com_obj
.Equals (com_obj3
))
389 // com_obj & com_obj2 share a RCW
390 if (Marshal
.ReleaseComObject (com_obj2
) != 1)
393 // com_obj3 should only have one RCW
394 if (Marshal
.ReleaseComObject (com_obj3
) != 0)
397 IntPtr iunknown
= Marshal
.GetIUnknownForObject (com_obj
);
398 if (iunknown
== IntPtr
.Zero
)
401 if (pUnk
!= iunknown
)
404 if (TestITest (itest
) != 0)
407 if (TestITestPresSig (itest
as ITestPresSig
) != 0)
410 #endregion // Runtime Callable Wrapper Tests
412 #region COM Callable Wrapper Tests
414 ManagedTest test
= new ManagedTest ();
416 mono_test_marshal_ccw_itest (test
);
418 if (test
.Status
!= 0)
421 ManagedTestPresSig test_pres_sig
= new ManagedTestPresSig ();
423 mono_test_marshal_ccw_itest (test_pres_sig
);
425 #endregion // COM Callable Wrapper Tests
433 [Guid ("00000000-0000-0000-0000-000000000001")]
434 [InterfaceType (ComInterfaceType
.InterfaceIsIUnknown
)]
435 public interface ITest
437 // properties need to go first since mcs puts them there
440 [return: MarshalAs (UnmanagedType
.Interface
)]
441 [MethodImpl (MethodImplOptions
.InternalCall
, MethodCodeType
= MethodCodeType
.Runtime
), DispId (5242884)]
445 [MethodImplAttribute (MethodImplOptions
.InternalCall
, MethodCodeType
= MethodCodeType
.Runtime
)]
446 void SByteIn (sbyte val
);
447 [MethodImplAttribute (MethodImplOptions
.InternalCall
, MethodCodeType
= MethodCodeType
.Runtime
)]
448 void ByteIn (byte val
);
449 [MethodImplAttribute (MethodImplOptions
.InternalCall
, MethodCodeType
= MethodCodeType
.Runtime
)]
450 void ShortIn (short val
);
451 [MethodImplAttribute (MethodImplOptions
.InternalCall
, MethodCodeType
= MethodCodeType
.Runtime
)]
452 void UShortIn (ushort val
);
453 [MethodImplAttribute (MethodImplOptions
.InternalCall
, MethodCodeType
= MethodCodeType
.Runtime
)]
454 void IntIn (int val
);
455 [MethodImplAttribute (MethodImplOptions
.InternalCall
, MethodCodeType
= MethodCodeType
.Runtime
)]
456 void UIntIn (uint val
);
457 [MethodImplAttribute (MethodImplOptions
.InternalCall
, MethodCodeType
= MethodCodeType
.Runtime
)]
458 void LongIn (long val
);
459 [MethodImplAttribute (MethodImplOptions
.InternalCall
, MethodCodeType
= MethodCodeType
.Runtime
)]
460 void ULongIn (ulong val
);
461 [MethodImplAttribute (MethodImplOptions
.InternalCall
, MethodCodeType
= MethodCodeType
.Runtime
)]
462 void FloatIn (float val
);
463 [MethodImplAttribute (MethodImplOptions
.InternalCall
, MethodCodeType
= MethodCodeType
.Runtime
)]
464 void DoubleIn (double val
);
465 [MethodImplAttribute (MethodImplOptions
.InternalCall
, MethodCodeType
= MethodCodeType
.Runtime
)]
466 void ITestIn ([MarshalAs (UnmanagedType
.Interface
)]ITest val
);
467 [MethodImplAttribute (MethodImplOptions
.InternalCall
, MethodCodeType
= MethodCodeType
.Runtime
)]
468 void ITestOut ([MarshalAs (UnmanagedType
.Interface
)]out ITest val
);
472 [Guid ("00000000-0000-0000-0000-000000000001")]
473 [InterfaceType (ComInterfaceType
.InterfaceIsIUnknown
)]
474 public interface ITestPresSig
476 // properties need to go first since mcs puts them there
479 [return: MarshalAs (UnmanagedType
.Interface
)]
480 [MethodImpl (MethodImplOptions
.InternalCall
, MethodCodeType
= MethodCodeType
.Runtime
), DispId (5242884)]
484 [MethodImplAttribute (MethodImplOptions
.InternalCall
, MethodCodeType
= MethodCodeType
.Runtime
)]
486 int SByteIn (sbyte val
);
487 [MethodImplAttribute (MethodImplOptions
.InternalCall
, MethodCodeType
= MethodCodeType
.Runtime
)]
489 int ByteIn (byte val
);
490 [MethodImplAttribute (MethodImplOptions
.InternalCall
, MethodCodeType
= MethodCodeType
.Runtime
)]
492 int ShortIn (short val
);
493 [MethodImplAttribute (MethodImplOptions
.InternalCall
, MethodCodeType
= MethodCodeType
.Runtime
)]
495 int UShortIn (ushort val
);
496 [MethodImplAttribute (MethodImplOptions
.InternalCall
, MethodCodeType
= MethodCodeType
.Runtime
)]
499 [MethodImplAttribute (MethodImplOptions
.InternalCall
, MethodCodeType
= MethodCodeType
.Runtime
)]
501 int UIntIn (uint val
);
502 [MethodImplAttribute (MethodImplOptions
.InternalCall
, MethodCodeType
= MethodCodeType
.Runtime
)]
504 int LongIn (long val
);
505 [MethodImplAttribute (MethodImplOptions
.InternalCall
, MethodCodeType
= MethodCodeType
.Runtime
)]
507 int ULongIn (ulong val
);
508 [MethodImplAttribute (MethodImplOptions
.InternalCall
, MethodCodeType
= MethodCodeType
.Runtime
)]
510 int FloatIn (float val
);
511 [MethodImplAttribute (MethodImplOptions
.InternalCall
, MethodCodeType
= MethodCodeType
.Runtime
)]
513 int DoubleIn (double val
);
514 [MethodImplAttribute (MethodImplOptions
.InternalCall
, MethodCodeType
= MethodCodeType
.Runtime
)]
516 int ITestIn ([MarshalAs (UnmanagedType
.Interface
)]ITestPresSig val
);
517 [MethodImplAttribute (MethodImplOptions
.InternalCall
, MethodCodeType
= MethodCodeType
.Runtime
)]
519 int ITestOut ([MarshalAs (UnmanagedType
.Interface
)]out ITestPresSig val
);
522 public class ManagedTestPresSig
: ITestPresSig
523 { // properties need to go first since mcs puts them there
524 public ITestPresSig Test
528 return new ManagedTestPresSig ();
532 public int SByteIn (sbyte val
)
539 public int ByteIn (byte val
)
546 public int ShortIn (short val
)
553 public int UShortIn (ushort val
)
560 public int IntIn (int val
)
567 public int UIntIn (uint val
)
574 public int LongIn (long val
)
581 public int ULongIn (ulong val
)
588 public int FloatIn (float val
)
590 if (Math
.Abs (val
- 3.14f
) > .000001)
595 public int DoubleIn (double val
)
597 if (Math
.Abs (val
- 3.14f
) > .000001)
602 public int ITestIn ([MarshalAs (UnmanagedType
.Interface
)]ITestPresSig val
)
606 if (null == val
as ManagedTestPresSig
)
611 public int ITestOut ([MarshalAs (UnmanagedType
.Interface
)]out ITestPresSig val
)
613 val
= new ManagedTestPresSig ();
618 public class ManagedTest
: ITest
620 private int status
= 0;
623 get { return status; }
625 public void SByteIn (sbyte val
)
631 public void ByteIn (byte val
)
637 public void ShortIn (short val
)
643 public void UShortIn (ushort val
)
649 public void IntIn (int val
)
655 public void UIntIn (uint val
)
661 public void LongIn (long val
)
667 public void ULongIn (ulong val
)
673 public void FloatIn (float val
)
675 if (Math
.Abs (val
- 3.14f
) > .000001)
679 public void DoubleIn (double val
)
681 if (Math
.Abs (val
- 3.14) > .000001)
685 public void ITestIn (ITest val
)
689 if (null == val
as ManagedTest
)
693 public void ITestOut (out ITest val
)
695 val
= new ManagedTest ();
702 return new ManagedTest ();
707 public static int mono_test_marshal_variant_in_callback (VarEnum vt
, object obj
)
712 if (obj
.GetType () != typeof (sbyte))
714 if ((sbyte)obj
!= -100)
718 if (obj
.GetType () != typeof (byte))
720 if ((byte)obj
!= 100)
724 if (obj
.GetType () != typeof (short))
726 if ((short)obj
!= -100)
730 if (obj
.GetType () != typeof (ushort))
732 if ((ushort)obj
!= 100)
736 if (obj
.GetType () != typeof (int))
738 if ((int)obj
!= -100)
742 if (obj
.GetType () != typeof (uint))
744 if ((uint)obj
!= 100)
748 if (obj
.GetType () != typeof (long))
750 if ((long)obj
!= -100)
754 if (obj
.GetType () != typeof (ulong))
756 if ((ulong)obj
!= 100)
760 if (obj
.GetType () != typeof (float))
762 if (Math
.Abs ((float)obj
- 3.14f
) > 1e-10)
766 if (obj
.GetType () != typeof (double))
768 if (Math
.Abs ((double)obj
- 3.14) > 1e-10)
771 case VarEnum
.VT_BSTR
:
772 if (obj
.GetType () != typeof (string))
774 if ((string)obj
!= "PI")
777 case VarEnum
.VT_BOOL
:
778 if (obj
.GetType () != typeof (bool))
780 if ((bool)obj
!= true)
787 public static int mono_test_marshal_variant_out_callback (VarEnum vt
, ref object obj
)
820 case VarEnum
.VT_BSTR
:
823 case VarEnum
.VT_BOOL
:
830 public static int TestITest (ITest itest
)
834 itest
.SByteIn (-100);
836 itest
.ShortIn (-100);
837 itest
.UShortIn (100);
842 itest
.FloatIn (3.14f
);
843 itest
.DoubleIn (3.14);
844 itest
.ITestIn (itest
);
845 itest
.ITestOut (out itest2
);
847 catch (Exception ex
) {
853 public static int TestITestPresSig (ITestPresSig itest
)
856 if (itest
.SByteIn (-100) != 0)
858 if (itest
.ByteIn (100) != 0)
860 if (itest
.ShortIn (-100) != 0)
862 if (itest
.UShortIn (100) != 0)
864 if (itest
.IntIn (-100) != 0)
866 if (itest
.UIntIn (100) != 0)
868 if (itest
.LongIn (-100) != 0)
870 if (itest
.ULongIn (100) != 0)
872 if (itest
.FloatIn (3.14f
) != 0)
874 if (itest
.DoubleIn (3.14) != 0)
876 if (itest
.ITestIn (itest
) != 0)
878 if (itest
.ITestOut (out itest2
) != 0)