conv_arg = mono_mb_add_local (mb, &klass->byval_arg);
if (klass->delegate) {
- g_assert (!t->byref);
mono_mb_emit_byte (mb, MONO_CUSTOM_PREFIX);
mono_mb_emit_op (mb, CEE_MONO_CLASSCONST, klass);
mono_mb_emit_ldarg (mb, argnum);
+ if (t->byref)
+ mono_mb_emit_byte (mb, CEE_LDIND_I);
mono_mb_emit_icall (mb, conv_to_icall (MONO_MARSHAL_CONV_FTN_DEL));
mono_mb_emit_stloc (mb, conv_arg);
break;
break;
case MARSHAL_ACTION_MANAGED_CONV_OUT:
+ if (klass->delegate) {
+ if (t->byref) {
+ mono_mb_emit_ldarg (mb, argnum);
+ mono_mb_emit_ldloc (mb, conv_arg);
+ mono_mb_emit_icall (mb, conv_to_icall (MONO_MARSHAL_CONV_DEL_FTN));
+ mono_mb_emit_byte (mb, CEE_STIND_I);
+ break;
+ }
+ }
+
if (t->byref) {
/* Check for null */
mono_mb_emit_ldloc (mb, conv_arg);
[DllImport ("libtest", EntryPoint="mono_test_marshal_return_delegate_delegate")]
public static extern int mono_test_marshal_return_delegate_delegate (ReturnDelegateDelegate d);
+ [DllImport ("libtest", EntryPoint="mono_test_marshal_delegate_ref_delegate")]
+ public static extern int mono_test_marshal_delegate_ref_delegate (DelegateByrefDelegate del);
+
public delegate int TestDelegate (int a, ref SimpleStruct ss, int b);
public delegate SimpleStruct SimpleDelegate2 (SimpleStruct ss);
public delegate return_int_delegate ReturnDelegateDelegate ();
+ public delegate int DelegateByrefDelegate (ref return_int_delegate del);
+
public static int Main () {
return TestDriver.RunTests (typeof (Tests));
}
return mono_test_marshal_return_delegate_delegate (new ReturnDelegateDelegate (return_delegate));
}
+ public static int return_plus_1 (int i) {
+ return i + 1;
+ }
+
+ public static int ref_delegate_delegate (ref return_int_delegate del) {
+ del = return_plus_1;
+ return 0;
+ }
+
+ public static int test_55_marshal_delegate_ref_delegate () {
+ var del = new DelegateByrefDelegate (ref_delegate_delegate);
+ return mono_test_marshal_delegate_ref_delegate (del);
+ }
+
/* Passing and returning strings */
public delegate String ReturnStringDelegate (String s);