using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
+
public class Tests
{
[DllImport("libtest")]
public static extern int mono_test_marshal_variant_out_sbyte([MarshalAs(UnmanagedType.Struct)]out object obj);
+ [DllImport("libtest")]
+ public static extern int mono_test_marshal_variant_out_sbyte_byref([MarshalAs(UnmanagedType.Struct)]out object obj);
+
[DllImport("libtest")]
public static extern int mono_test_marshal_variant_out_byte([MarshalAs(UnmanagedType.Struct)]out object obj);
+ [DllImport("libtest")]
+ public static extern int mono_test_marshal_variant_out_byte_byref([MarshalAs(UnmanagedType.Struct)]out object obj);
+
[DllImport("libtest")]
public static extern int mono_test_marshal_variant_out_short([MarshalAs(UnmanagedType.Struct)]out object obj);
+ [DllImport("libtest")]
+ public static extern int mono_test_marshal_variant_out_short_byref([MarshalAs(UnmanagedType.Struct)]out object obj);
+
[DllImport("libtest")]
public static extern int mono_test_marshal_variant_out_ushort([MarshalAs(UnmanagedType.Struct)]out object obj);
+ [DllImport("libtest")]
+ public static extern int mono_test_marshal_variant_out_ushort_byref([MarshalAs(UnmanagedType.Struct)]out object obj);
+
[DllImport("libtest")]
public static extern int mono_test_marshal_variant_out_int([MarshalAs(UnmanagedType.Struct)]out object obj);
+ [DllImport("libtest")]
+ public static extern int mono_test_marshal_variant_out_int_byref([MarshalAs(UnmanagedType.Struct)]out object obj);
+
[DllImport("libtest")]
public static extern int mono_test_marshal_variant_out_uint([MarshalAs(UnmanagedType.Struct)]out object obj);
+ [DllImport("libtest")]
+ public static extern int mono_test_marshal_variant_out_uint_byref([MarshalAs(UnmanagedType.Struct)]out object obj);
+
[DllImport("libtest")]
public static extern int mono_test_marshal_variant_out_long([MarshalAs(UnmanagedType.Struct)]out object obj);
+ [DllImport("libtest")]
+ public static extern int mono_test_marshal_variant_out_long_byref([MarshalAs(UnmanagedType.Struct)]out object obj);
+
[DllImport("libtest")]
public static extern int mono_test_marshal_variant_out_ulong([MarshalAs(UnmanagedType.Struct)]out object obj);
+ [DllImport("libtest")]
+ public static extern int mono_test_marshal_variant_out_ulong_byref([MarshalAs(UnmanagedType.Struct)]out object obj);
+
[DllImport("libtest")]
public static extern int mono_test_marshal_variant_out_float([MarshalAs(UnmanagedType.Struct)]out object obj);
+ [DllImport("libtest")]
+ public static extern int mono_test_marshal_variant_out_float_byref([MarshalAs(UnmanagedType.Struct)]out object obj);
+
[DllImport("libtest")]
public static extern int mono_test_marshal_variant_out_double([MarshalAs(UnmanagedType.Struct)]out object obj);
+ [DllImport("libtest")]
+ public static extern int mono_test_marshal_variant_out_double_byref([MarshalAs(UnmanagedType.Struct)]out object obj);
+
[DllImport("libtest")]
public static extern int mono_test_marshal_variant_out_bstr ([MarshalAs (UnmanagedType.Struct)]out object obj);
+ [DllImport("libtest")]
+ public static extern int mono_test_marshal_variant_out_bstr_byref ([MarshalAs (UnmanagedType.Struct)]out object obj);
+
[DllImport("libtest")]
public static extern int mono_test_marshal_variant_out_bool_true ([MarshalAs (UnmanagedType.Struct)]out object obj);
+ [DllImport("libtest")]
+ public static extern int mono_test_marshal_variant_out_bool_true_byref ([MarshalAs (UnmanagedType.Struct)]out object obj);
+
[DllImport ("libtest")]
public static extern int mono_test_marshal_variant_out_bool_false ([MarshalAs (UnmanagedType.Struct)]out object obj);
+ [DllImport ("libtest")]
+ public static extern int mono_test_marshal_variant_out_bool_false_byref ([MarshalAs (UnmanagedType.Struct)]out object obj);
+
public delegate int VarFunc (VarEnum vt, [MarshalAs (UnmanagedType.Struct)] object obj);
if (mono_test_marshal_variant_out_bool_true_unmanaged (reffunc) != 0)
return 61;
+ if (mono_test_marshal_variant_out_sbyte_byref (out obj) != 0 || (sbyte)obj != 100)
+ return 97;
+ if (mono_test_marshal_variant_out_byte_byref (out obj) != 0 || (byte)obj != 100)
+ return 98;
+ if (mono_test_marshal_variant_out_short_byref (out obj) != 0 || (short)obj != 314)
+ return 99;
+ if (mono_test_marshal_variant_out_ushort_byref (out obj) != 0 || (ushort)obj != 314)
+ return 100;
+ if (mono_test_marshal_variant_out_int_byref (out obj) != 0 || (int)obj != 314)
+ return 101;
+ if (mono_test_marshal_variant_out_uint_byref (out obj) != 0 || (uint)obj != 314)
+ return 102;
+ if (mono_test_marshal_variant_out_long_byref (out obj) != 0 || (long)obj != 314)
+ return 103;
+ if (mono_test_marshal_variant_out_ulong_byref (out obj) != 0 || (ulong)obj != 314)
+ return 104;
+ if (mono_test_marshal_variant_out_float_byref (out obj) != 0 || ((float)obj - 3.14) / 3.14 > .001)
+ return 105;
+ if (mono_test_marshal_variant_out_double_byref (out obj) != 0 || ((double)obj - 3.14) / 3.14 > .001)
+ return 106;
+ if (mono_test_marshal_variant_out_bstr_byref (out obj) != 0 || (string)obj != "PI")
+ return 107;
+
#endregion // VARIANT Tests
#region Runtime Callable Wrapper Tests
+#if !MOBILE
+
IntPtr pUnk;
if (mono_test_marshal_com_object_create (out pUnk) != 0)
return 145;
if (TestITestDelegate (itest) != 0)
return 174;
+ if (TestIfaceNoIcall (itest as ITestPresSig) != 0)
+ return 201;
+
itest = new TestClass ();
if (TestITest (itest) != 0)
return 175;
+ itest = (ITest)System.Activator.CreateInstance (typeof(TestActivatorClass));
+
+ if (TestITest (itest) != 0)
+ return 176;
+
+
+#endif
+
#endregion // Runtime Callable Wrapper Tests
#region COM Callable Wrapper Tests
}
}
#endregion // SafeArray Tests
+
+ #region COM Visible Test
+ TestVisible test_vis = new TestVisible();
+ IntPtr pDisp = Marshal.GetIDispatchForObject(test_vis);
+ if (pDisp == IntPtr.Zero)
+ return 200;
+ #endregion
}
return 0;
void ITestIn ([MarshalAs (UnmanagedType.Interface)]ITest val);
[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
void ITestOut ([MarshalAs (UnmanagedType.Interface)]out ITest val);
+ int Return22NoICall();
}
[ComImport ()]
[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
[PreserveSig ()]
int ITestOut ([MarshalAs (UnmanagedType.Interface)]out ITestPresSig val);
+ [PreserveSig ()]
+ int Return22NoICall();
}
[System.Runtime.InteropServices.GuidAttribute ("00000000-0000-0000-0000-000000000002")]
public virtual extern void ITestIn ([MarshalAs (UnmanagedType.Interface)]ITest val);
[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
public virtual extern void ITestOut ([MarshalAs (UnmanagedType.Interface)]out ITest val);
+
+ [MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
+ public virtual extern int Return22NoICall();
}
[System.Runtime.InteropServices.GuidAttribute ("00000000-0000-0000-0000-000000000002")]
}
}
+ [System.Runtime.InteropServices.GuidAttribute ("00000000-0000-0000-0000-000000000003")]
+ public class TestActivatorClass : _TestClass
+ {
+ static TestActivatorClass ()
+ {
+ ExtensibleClassFactory.RegisterObjectCreationCallback (new ObjectCreationDelegate (CreateObject)); ;
+ }
+ private static System.IntPtr CreateObject (System.IntPtr aggr)
+ {
+ IntPtr pUnk3;
+ mono_test_marshal_com_object_create (out pUnk3);
+ return pUnk3;
+ }
+ }
delegate void SByteInDelegate (sbyte val);
delegate void ByteInDelegate (byte val);
val = new ManagedTestPresSig ();
return 0;
}
+
+ public int Return22NoICall()
+ {
+ return 88;
+ }
}
public class ManagedTest : ITest
return new ManagedTest ();
}
}
+
+ public int Return22NoICall()
+ {
+ return 99;
+ }
}
public static int mono_test_marshal_variant_in_callback (VarEnum vt, object obj)
}
return 0;
}
+
+ public static int TestIfaceNoIcall (ITestPresSig itest) {
+ return itest.Return22NoICall () == 22 ? 0 : 1;
+ }
+}
+
+public class TestVisible
+{
}