+ /* Array with size param of type long */
+
+ public delegate int ArrayDelegate8_2 (long i,
+ string j,
+ [In, MarshalAs(UnmanagedType.LPArray,
+ ArraySubType=UnmanagedType.LPStr, SizeParamIndex=0)] string[] arr);
+
+ [DllImport ("libtest", EntryPoint="mono_test_marshal_array_delegate_long")]
+ public static extern int mono_test_marshal_array_delegate8_2 (string[] arr, long len, ArrayDelegate8_2 d);
+
+ public static int array_delegate8_2 (long i, string j, string[] arr) {
+ if (arr.Length != 2)
+ return 1;
+ if ((arr [0] != "ABC") || (arr [1] != "DEF"))
+ return 2;
+ return 0;
+ }
+
+ public static int test_0_marshal_array_delegate_long_param () {
+ string[] arr = new string [] { "ABC", "DEF" };
+ return mono_test_marshal_array_delegate8_2 (arr, arr.Length, new ArrayDelegate8_2 (array_delegate8_2));
+ }
+
+
+ /*
+ * [Out] blittable arrays
+ */
+
+ public delegate int ArrayDelegate9 (int i, string j,
+ [Out, MarshalAs(UnmanagedType.LPArray,
+ SizeParamIndex=0)]
+ int[] arr);
+
+ [DllImport ("libtest", EntryPoint="mono_test_marshal_out_array_delegate")]
+ public static extern int mono_test_marshal_out_array_delegate (int[] arr, int len, ArrayDelegate9 d);
+
+ public static int array_delegate9 (int i, string j, int[] arr) {
+ if (arr.Length != 2)
+ return 1;
+
+ arr [0] = 1;
+ arr [1] = 2;
+
+ return 0;
+ }
+
+ public static int test_0_marshal_out_array_delegate () {
+ int[] arr = new int [] { 42, 43 };
+ return mono_test_marshal_out_array_delegate (arr, 2, new ArrayDelegate9 (array_delegate9));
+ }
+
+ /*
+ * [Out] string arrays
+ */
+
+ public delegate int ArrayDelegate10 (int i,
+ string j,
+ [Out, MarshalAs(UnmanagedType.LPArray,
+ ArraySubType=UnmanagedType.LPStr, SizeConst=2)] string[] arr);
+
+ [DllImport ("libtest", EntryPoint="mono_test_marshal_out_string_array_delegate")]
+ public static extern int mono_test_marshal_out_string_array_delegate (string[] arr, int len, ArrayDelegate10 d);
+
+ public static int array_delegate10 (int i, string j, string[] arr) {
+ if (arr.Length != 2)
+ return 1;
+
+ arr [0] = "ABC";
+ arr [1] = "DEF";
+
+ return 0;
+ }
+
+ public static int test_0_marshal_out_string_array_delegate () {
+ string[] arr = new string [] { "", "" };
+ return mono_test_marshal_out_string_array_delegate (arr, 2, new ArrayDelegate10 (array_delegate10));
+ }
+
+ /*
+ * [In, Out] classes
+ */
+
+ public delegate int InOutByvalClassDelegate ([In, Out] SimpleClass ss);
+
+ [DllImport ("libtest", EntryPoint="mono_test_marshal_inout_byval_class_delegate")]
+ public static extern int mono_test_marshal_inout_byval_class_delegate (InOutByvalClassDelegate d);
+
+ public static int delegate_test_byval_class_inout (SimpleClass ss) {
+ if ((ss.a != false) || (ss.b != true) || (ss.c != false) || (ss.d != "FOO"))
+ return 1;
+
+ ss.a = true;
+ ss.b = false;
+ ss.c = true;
+ ss.d = "RES";
+
+ return 0;
+ }
+
+ public static int test_0_marshal_inout_byval_class_delegate () {
+ return mono_test_marshal_inout_byval_class_delegate (new InOutByvalClassDelegate (delegate_test_byval_class_inout));
+ }
+
+ /*
+ * Returning unicode strings
+ */
+ [return: MarshalAs(UnmanagedType.LPWStr)]
+ public delegate string ReturnUnicodeStringDelegate([MarshalAs(UnmanagedType.LPWStr)] string message);
+
+ [DllImport ("libtest", EntryPoint="mono_test_marshal_return_unicode_string_delegate")]
+ public static extern int mono_test_marshal_return_unicode_string_delegate (ReturnUnicodeStringDelegate d);
+
+ public static String return_unicode_string_delegate (string message) {
+ return message;
+ }
+
+ public static int test_0_marshal_return_unicode_string_delegate () {
+ return mono_test_marshal_return_unicode_string_delegate (new ReturnUnicodeStringDelegate (return_unicode_string_delegate));
+ }
+
+ /*
+ * Returning string arrays
+ */
+ public delegate string[] ReturnArrayDelegate (int i);
+
+ [DllImport ("libtest", EntryPoint="mono_test_marshal_return_string_array_delegate")]
+ public static extern int mono_test_marshal_return_string_array_delegate (ReturnArrayDelegate d);
+
+ public static String[] return_array_delegate (int i) {
+ String[] arr = new String [2];
+
+ arr [0] = "ABC";
+ arr [1] = "DEF";
+
+ return arr;
+ }
+
+ public static String[] return_array_delegate_null (int i) {
+ return null;
+ }
+
+ public static int test_0_marshal_return_string_array_delegate () {
+ return mono_test_marshal_return_string_array_delegate (new ReturnArrayDelegate (return_array_delegate));
+ }
+
+ public static int test_3_marshal_return_string_array_delegate_null () {
+ 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));
+ }