need_free = mono_marshal_need_free (&klass->element_class->byval_arg,
m->piinfo, spec);
+ if ((t->attrs & PARAM_ATTRIBUTE_OUT) && spec && spec->native == MONO_NATIVE_LPARRAY && spec->data.array_data.param_num != -1) {
+ int param_num = spec->data.array_data.param_num;
+ MonoType *param_type;
+
+ param_type = m->sig->params [param_num];
+
+ if (param_type->byref && param_type->type != MONO_TYPE_I4) {
+ char *msg = g_strdup ("Not implemented.");
+ mono_mb_emit_exception_marshal_directive (mb, msg);
+ break;
+ }
+
+ mono_mb_emit_ldarg (mb, argnum);
+
+ /* Create the managed array */
+ mono_mb_emit_ldarg (mb, param_num);
+ if (m->sig->params [param_num]->byref)
+ // FIXME: Support other types
+ mono_mb_emit_byte (mb, CEE_LDIND_I4);
+ mono_mb_emit_byte (mb, CEE_CONV_OVF_I);
+ mono_mb_emit_op (mb, CEE_NEWARR, klass->element_class);
+ /* Store into argument */
+ mono_mb_emit_byte (mb, CEE_STIND_I);
+ }
+
if (need_convert || need_free) {
/* FIXME: Optimize blittable case */
MonoClass *eklass;
/* free memory allocated (if any) by MONO_MARSHAL_CONV_ARRAY_LPARRAY */
mono_mb_emit_ldarg (mb, argnum);
+ if (t->byref)
+ mono_mb_emit_byte (mb, CEE_LDIND_REF);
mono_mb_emit_ldloc (mb, conv_arg);
mono_mb_emit_icall (mb, conv_to_icall (MONO_MARSHAL_FREE_LPARRAY));
}
int type, param_shift = 0;
static MonoMethodSignature *get_last_error_sig = NULL;
+ memset (&m, 0, sizeof (m));
m.mb = mb;
+ m.sig = sig;
m.piinfo = piinfo;
/* we copy the signature, so that we can set pinvoke to 0 */
csig->hasthis = 0;
csig->pinvoke = 1;
+ memset (&m, 0, sizeof (m));
m.mb = mb;
m.sig = sig;
m.piinfo = NULL;
csig->hasthis = 0;
csig->pinvoke = 1;
+ memset (&m, 0, sizeof (m));
m.mb = mb;
m.sig = sig;
m.piinfo = NULL;
[DllImport ("libtest", EntryPoint="mono_test_marshal_out_array")]
public static extern int mono_test_marshal_out_array ([Out] [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] int [] a1, int n);
+ [DllImport ("libtest", EntryPoint="mono_test_marshal_out_byref_array_out_size_param")]
+ public static extern int mono_test_marshal_out_byref_array_out_size_param ([Out] [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] out int [] a1, out int n);
+
[DllImport ("libtest", EntryPoint="mono_test_marshal_inout_nonblittable_array", CharSet = CharSet.Unicode)]
public static extern int mono_test_marshal_inout_nonblittable_array ([In, Out] char [] a1);
return 0;
}
+ public static int test_0_marshal_out_byref_array_out_size_param () {
+ int [] a1 = null;
+ int len;
+
+ int res = mono_test_marshal_out_byref_array_out_size_param (out a1, out len);
+ if (len != 4)
+ return 1;
+ for (int i = 0; i < len; i++)
+ if (a1 [i] != i)
+ return 2;
+ return 0;
+ }
+
public static int test_0_marshal_inout_nonblittable_array () {
char [] a1 = new char [10];
for (int i = 0; i < 10; i++)