* pinvoke3.cs libtest.c: Add test for byref string marshalling.
svn path=/trunk/mono/; revision=114586
+2008-10-01 Zoltan Varga <vargaz@gmail.com>
+
+ * pinvoke3.cs libtest.c: Add test for byref string marshalling.
+
2008-09-30 Mark Probst <mark.probst@gmail.com>
* generic-constrained.2.il: Test case for the constrained. prefix
return res;
}
+typedef int (STDCALL *ByrefStringDelegate) (char **s);
+
+LIBTEST_API int STDCALL
+mono_test_marshal_byref_string_delegate (ByrefStringDelegate d)
+{
+ char *s = (char*)"ABC";
+ int res;
+
+ res = d (&s);
+ if (res != 0)
+ return res;
+
+ if (!strcmp (s, "DEF"))
+ res = 0;
+ else
+ res = 2;
+
+ marshal_free (s);
+
+ return res;
+}
+
LIBTEST_API int STDCALL
add_delegate (int i, int j)
{
return mono_test_marshal_return_string_array_delegate (new ReturnArrayDelegate (return_array_delegate_null));
}
+ /*
+ * Byref string marshalling
+ */
+ public delegate int ByrefStringDelegate (ref string s);
+
+ [DllImport ("libtest", EntryPoint="mono_test_marshal_byref_string_delegate")]
+ public static extern int mono_test_marshal_byref_string_delegate (ByrefStringDelegate d);
+
+ public static int byref_string_delegate (ref string s) {
+ if (s != "ABC")
+ return 1;
+
+ s = "DEF";
+
+ return 0;
+ }
+
+ public static int test_0_marshal_byref_string_delegate () {
+ return mono_test_marshal_byref_string_delegate (new ByrefStringDelegate (byref_string_delegate));
+ }
}