9 #define STDCALL __stdcall
15 extern __declspec(dllimport) __stdcall void CoTaskMemFree(void *ptr);
18 typedef int (STDCALL *SimpleDelegate) (int a);
20 static void marshal_free (void *ptr)
29 STDCALL unsigned short*
30 test_lpwstr_marshal (unsigned short* chars, long length)
35 res = malloc (2 * (length + 1));
37 // printf("test_lpwstr_marshal()\n");
39 while ( i < length ) {
40 // printf("X|%u|\n", chars[i]);
57 mono_union_test_1 (union_test_1_type u1) {
58 // printf ("Got values %d %d %d\n", u1.b, u1.a, u1.c);
59 return u1.a + u1.b + u1.c;
63 mono_return_int (int a) {
64 // printf ("Got value %d\n", a);
74 mono_return_int_ss (struct ss a) {
75 // printf ("Got value %d\n", a.i);
80 mono_return_ss (struct ss a) {
81 // printf ("Got value %d\n", a.i);
92 mono_return_sc1 (struct sc1 a) {
93 // printf ("Got value %d\n", a.c[0]);
105 mono_return_sc3 (struct sc3 a) {
106 // printf ("Got values %d %d %d\n", a.c[0], a.c[1], a.c[2]);
119 mono_return_sc5 (struct sc5 a) {
120 // printf ("Got values %d %d %d %d %d\n", a.c[0], a.c[1], a.c[2], a.c[3], a.c[4]);
136 mono_return_int_su (union su a) {
137 // printf ("Got value %d\n", a.i1);
142 mono_test_many_int_arguments (int a, int b, int c, int d, int e,
143 int f, int g, int h, int i, int j);
145 mono_test_many_short_arguments (short a, short b, short c, short d, short e,
146 short f, short g, short h, short i, short j);
148 mono_test_many_char_arguments (char a, char b, char c, char d, char e,
149 char f, char g, char h, char i, char j);
152 mono_test_many_int_arguments (int a, int b, int c, int d, int e, int f, int g, int h, int i, int j)
154 return a + b + c + d + e + f + g + h + i + j;
158 mono_test_many_short_arguments (short a, short b, short c, short d, short e, short f, short g, short h, short i, short j)
160 return a + b + c + d + e + f + g + h + i + j;
164 mono_test_many_byte_arguments (char a, char b, char c, char d, char e, char f, char g, char h, char i, char j)
166 return a + b + c + d + e + f + g + h + i + j;
170 mono_test_many_float_arguments (float a, float b, float c, float d, float e, float f, float g, float h, float i, float j)
172 return a + b + c + d + e + f + g + h + i + j;
176 mono_test_many_double_arguments (double a, double b, double c, double d, double e, double f, double g, double h, double i, double j)
178 return a + b + c + d + e + f + g + h + i + j;
182 mono_test_split_double_arguments (double a, double b, float c, double d, double e)
184 return a + b + c + d + e;
188 mono_test_puts_static (char *s)
190 // printf ("TEST %s\n", s);
194 typedef int (STDCALL *SimpleDelegate3) (int a, int b);
197 mono_invoke_delegate (SimpleDelegate3 delegate)
201 // printf ("start invoke %p\n", delegate);
203 res = delegate (2, 3);
205 // printf ("end invoke\n");
211 mono_test_marshal_char (short a1)
220 mono_test_marshal_char_array (gunichar2 *s)
222 const char m[] = "abcdef";
226 s2 = g_utf8_to_utf16 (m, -1, NULL, &len, NULL);
235 mono_test_empty_pinvoke (int i)
241 mono_test_marshal_bool_byref (int a, int *b, int c)
251 mono_test_marshal_array (int *a1)
255 for (i = 0; i < 50; i++)
262 mono_test_marshal_inout_array (int *a1)
266 for (i = 0; i < 50; i++) {
268 a1 [i] = 50 - a1 [i];
275 mono_test_marshal_out_array (int *a1)
279 for (i = 0; i < 50; i++) {
287 mono_test_marshal_inout_nonblittable_array (gunichar2 *a1)
291 for (i = 0; i < 10; i++) {
307 mono_test_return_vtype (int i)
310 static gunichar2 test2 [] = { 'T', 'E', 'S', 'T', '2', 0 };
322 mono_test_delegate_struct (void)
324 // printf ("TEST\n");
327 typedef char* (STDCALL *ReturnStringDelegate) (const char *s);
330 mono_test_return_string (ReturnStringDelegate func)
334 // printf ("mono_test_return_string\n");
339 // printf ("got string: %s\n", res);
340 return g_strdup ("12345");
343 typedef int (STDCALL *RefVTypeDelegate) (int a, simplestruct *ss, int b);
346 mono_test_ref_vtype (int a, simplestruct *ss, int b, RefVTypeDelegate func)
348 if (a == 1 && b == 2 && ss->a == 0 && ss->b == 1 && ss->c == 0 &&
349 !strcmp (ss->d, "TEST1")) {
355 return func (a, ss, b);
361 typedef int (STDCALL *OutVTypeDelegate) (int a, simplestruct *ss, int b);
364 mono_test_marshal_out_struct (int a, simplestruct *ss, int b, OutVTypeDelegate func)
366 /* Check that the input pointer is ignored */
367 ss->d = (gpointer)0x12345678;
371 if (ss->a && ss->b && ss->c && !strcmp (ss->d, "TEST3"))
379 SimpleDelegate func, func2;
382 STDCALL DelegateStruct
383 mono_test_marshal_delegate_struct (DelegateStruct ds)
387 res.a = ds.func (ds.a) + ds.func2 (ds.a);
389 res.func2 = ds.func2;
395 mono_test_marshal_struct (simplestruct ss)
397 if (ss.a == 0 && ss.b == 1 && ss.c == 0 &&
398 !strcmp (ss.d, "TEST"))
405 mono_test_marshal_byref_struct (simplestruct *ss, int a, int b, int c, char *d)
407 gboolean res = (ss->a == a && ss->b == b && ss->c == c && strcmp (ss->d, d) == 0);
412 ss->d = g_strdup ("DEF");
429 mono_test_marshal_struct2 (simplestruct2 ss)
431 if (ss.a == 0 && ss.b == 1 && ss.c == 0 &&
432 !strcmp (ss.d, "TEST") &&
433 ss.e == 99 && ss.f == 1.5 && ss.g == 42 && ss.h == (guint64)123)
439 /* on HP some of the struct should be on the stack and not in registers */
441 mono_test_marshal_struct2_2 (int i, int j, int k, simplestruct2 ss)
443 if (i != 10 || j != 11 || k != 12)
445 if (ss.a == 0 && ss.b == 1 && ss.c == 0 &&
446 !strcmp (ss.d, "TEST") &&
447 ss.e == 99 && ss.f == 1.5 && ss.g == 42 && ss.h == (guint64)123)
454 mono_test_marshal_struct_array (simplestruct2 *ss)
456 if (! (ss[0].a == 0 && ss[0].b == 1 && ss[0].c == 0 &&
457 !strcmp (ss[0].d, "TEST") &&
458 ss[0].e == 99 && ss[0].f == 1.5 && ss[0].g == 42 && ss[0].h == (guint64)123))
461 if (! (ss[1].a == 0 && ss[1].b == 0 && ss[1].c == 0 &&
462 !strcmp (ss[1].d, "TEST2") &&
463 ss[1].e == 100 && ss[1].f == 2.5 && ss[1].g == 43 && ss[1].h == (guint64)124))
469 typedef struct long_align_struct {
476 mono_test_marshal_long_align_struct_array (long_align_struct *ss)
478 return ss[0].a + ss[0].b + ss[0].c + ss[1].a + ss[1].b + ss[1].c;
481 STDCALL simplestruct2 *
482 mono_test_marshal_class (int i, int j, int k, simplestruct2 *ss, int l)
489 if (i != 10 || j != 11 || k != 12 || l != 14)
491 if (! (ss->a == 0 && ss->b == 1 && ss->c == 0 &&
492 !strcmp (ss->d, "TEST") &&
493 ss->e == 99 && ss->f == 1.5 && ss->g == 42 && ss->h == (guint64)123))
496 res = g_new0 (simplestruct2, 1);
497 memcpy (res, ss, sizeof (simplestruct2));
498 res->d = g_strdup ("TEST");
503 mono_test_marshal_byref_class (simplestruct2 **ssp)
505 simplestruct2 *ss = *ssp;
508 if (! (ss->a == 0 && ss->b == 1 && ss->c == 0 &&
509 !strcmp (ss->d, "TEST") &&
510 ss->e == 99 && ss->f == 1.5 && ss->g == 42 && ss->h == (guint64)123))
513 res = g_new0 (simplestruct2, 1);
514 memcpy (res, ss, sizeof (simplestruct2));
515 res->d = g_strdup ("TEST-RES");
532 reliable_delegate (int a)
538 * Checks whether get_sp() works as expected. It doesn't work with gcc-2.95.3 on linux.
541 is_get_sp_reliable (void)
545 reliable_delegate(1);
547 reliable_delegate(1);
553 mono_test_marshal_delegate (SimpleDelegate delegate)
557 /* Check that the delegate wrapper is stdcall */
562 if (is_get_sp_reliable())
563 g_assert (sp1 == sp2);
568 STDCALL SimpleDelegate
569 mono_test_marshal_return_delegate (SimpleDelegate delegate)
575 return_plus_one (int i)
580 STDCALL SimpleDelegate
581 mono_test_marshal_return_delegate_2 ()
583 return return_plus_one;
586 typedef simplestruct (STDCALL *SimpleDelegate2) (simplestruct ss);
589 is_utf16_equals (gunichar2 *s1, const char *s2)
594 s = g_utf16_to_utf8 (s1, -1, NULL, NULL, NULL);
595 res = strcmp (s, s2);
602 mono_test_marshal_delegate2 (SimpleDelegate2 delegate)
604 simplestruct ss, res;
610 ss.d2 = g_utf8_to_utf16 ("TEST2", -1, NULL, NULL, NULL);
613 if (! (res.a && !res.b && res.c && !strcmp (res.d, "TEST-RES") && is_utf16_equals (res.d2, "TEST2-RES")))
619 typedef simplestruct* (STDCALL *SimpleDelegate4) (simplestruct *ss);
622 mono_test_marshal_delegate4 (SimpleDelegate4 delegate)
633 res = delegate (&ss);
637 /* Check return value */
638 if (! (!res->a && res->b && !res->c && !strcmp (res->d, "TEST")))
641 /* Check NULL argument and NULL result */
642 res = delegate (NULL);
649 typedef int (STDCALL *SimpleDelegate5) (simplestruct **ss);
652 mono_test_marshal_delegate5 (SimpleDelegate5 delegate)
665 res = delegate (&ptr);
669 if (!(ptr->a && !ptr->b && ptr->c && !strcmp (ptr->d, "RES")))
676 mono_test_marshal_delegate6 (SimpleDelegate5 delegate)
680 res = delegate (NULL);
685 typedef int (STDCALL *SimpleDelegate7) (simplestruct **ss);
688 mono_test_marshal_delegate7 (SimpleDelegate7 delegate)
693 /* Check that the input pointer is ignored */
694 ptr = (gpointer)0x12345678;
696 res = delegate (&ptr);
700 if (!(ptr->a && !ptr->b && ptr->c && !strcmp (ptr->d, "RES")))
706 typedef int (STDCALL *SimpleDelegate8) (gunichar2 *s);
709 mono_test_marshal_delegate8 (SimpleDelegate8 delegate, gunichar2 *s)
714 typedef int (STDCALL *return_int_fnt) (int i);
715 typedef int (STDCALL *SimpleDelegate9) (return_int_fnt d);
718 mono_test_marshal_delegate9 (SimpleDelegate9 delegate, gpointer ftn)
720 return delegate (ftn);
730 mono_test_marshal_delegate10 (SimpleDelegate9 delegate)
732 return delegate (return_self);
735 typedef int (STDCALL *PrimitiveByrefDelegate) (int *i);
738 mono_test_marshal_primitive_byref_delegate (PrimitiveByrefDelegate delegate)
742 int res = delegate (&i);
752 typedef int (STDCALL *return_int_delegate) (int i);
754 typedef return_int_delegate (STDCALL *ReturnDelegateDelegate) (void);
757 mono_test_marshal_return_delegate_delegate (ReturnDelegateDelegate d)
763 mono_test_marshal_stringbuilder (char *s, int n)
765 const char m[] = "This is my message. Isn't it nice?";
767 if (strcmp (s, "ABCD") != 0)
774 mono_test_marshal_stringbuilder_unicode (gunichar2 *s, int n)
776 const char m[] = "This is my message. Isn't it nice?";
780 s2 = g_utf8_to_utf16 (m, -1, NULL, &len, NULL);
799 mono_test_marshal_empty_string_array (char **array)
801 return (array == NULL) ? 0 : 1;
805 mono_test_marshal_string_array (char **array)
807 if (strcmp (array [0], "ABC"))
809 if (strcmp (array [1], "DEF"))
812 if (array [2] != NULL)
819 mono_test_marshal_byref_string_array (char ***array)
824 if (strcmp ((*array) [0], "Alpha"))
826 if (strcmp ((*array) [1], "Beta"))
828 if (strcmp ((*array) [2], "Gamma"))
835 mono_test_marshal_stringbuilder_array (char **array)
837 if (strcmp (array [0], "ABC"))
839 if (strcmp (array [1], "DEF"))
842 strcpy (array [0], "DEF");
843 strcpy (array [1], "ABC");
849 mono_test_marshal_unicode_string_array (gunichar2 **array, char **array2)
851 GError *error = NULL;
854 s = g_utf16_to_utf8 (array [0], -1, NULL, NULL, &error);
855 if (strcmp (s, "ABC")) {
862 s = g_utf16_to_utf8 (array [1], -1, NULL, NULL, &error);
863 if (strcmp (s, "DEF")) {
870 if (strcmp (array2 [0], "ABC"))
873 if (strcmp (array2 [1], "DEF"))
879 /* this does not work on Redhat gcc 2.96 */
881 mono_test_empty_struct (int a, EmptyStruct es, int b)
883 // printf ("mono_test_empty_struct %d %d\n", a, b);
885 // Intel icc on ia64 passes 'es' in 2 registers
886 #if defined(__ia64) && defined(__INTEL_COMPILER)
889 if (a == 1 && b == 2)
899 STDCALL ByValStrStruct *
900 mono_test_byvalstr_gen (void)
904 ret = malloc(sizeof(ByValStrStruct));
905 memset(ret, 'a', sizeof(ByValStrStruct)-1);
906 ret->a[sizeof(ByValStrStruct)-1] = 0;
912 mono_test_byvalstr_check (ByValStrStruct* data, char* correctString)
916 ret = strcmp(data->a, correctString);
917 // printf ("T1: %s\n", data->a);
918 // printf ("T2: %s\n", correctString);
925 NameManglingAnsi (char *data)
927 return data [0] + data [1] + data [2];
931 NameManglingAnsiA (char *data)
933 g_assert_not_reached ();
937 NameManglingAnsiW (char *data)
939 g_assert_not_reached ();
943 NameManglingAnsi2A (char *data)
945 return data [0] + data [1] + data [2];
949 NameManglingAnsi2W (char *data)
951 g_assert_not_reached ();
955 NameManglingUnicode (char *data)
957 g_assert_not_reached ();
961 NameManglingUnicodeW (gunichar2 *data)
963 return data [0] + data [1] + data [2];
967 NameManglingUnicode2 (gunichar2 *data)
969 return data [0] + data [1] + data [2];
973 NameManglingAutoW (char *data)
976 return (data [0] + data [1] + data [2]) == 131 ? 0 : 1;
978 g_assert_not_reached ();
983 NameManglingAuto (char *data)
986 return (data [0] + data [1] + data [2]) == 198 ? 0 : 1;
988 g_assert_not_reached ();
992 typedef int (STDCALL *intcharFunc)(const char*);
995 callFunction (intcharFunc f)
1006 class_marshal_test0 (SimpleObj *obj1)
1008 // printf ("class_marshal_test0 %s %d\n", obj1->str, obj1->i);
1010 if (strcmp(obj1->str, "T1"))
1019 class_marshal_test4 (SimpleObj *obj1)
1028 class_marshal_test1 (SimpleObj **obj1)
1030 SimpleObj *res = malloc (sizeof (SimpleObj));
1032 res->str = g_strdup ("ABC");
1039 class_marshal_test2 (SimpleObj **obj1)
1041 // printf ("class_marshal_test2 %s %d\n", (*obj1)->str, (*obj1)->i);
1043 if (strcmp((*obj1)->str, "ABC"))
1045 if ((*obj1)->i != 5)
1052 string_marshal_test0 (char *str)
1054 if (strcmp (str, "TEST0"))
1061 string_marshal_test1 (const char **str)
1067 string_marshal_test2 (char **str)
1069 // printf ("string_marshal_test2 %s\n", *str);
1071 if (strcmp (*str, "TEST1"))
1078 string_marshal_test3 (char *str)
1092 TestVectorList (VectorList *vl)
1096 // printf ("TestVectorList %d %d\n", vl->a, vl->b);
1101 res = g_new0 (VectorList, 1);
1102 memcpy (res, vl, sizeof (VectorList));
1107 typedef struct _OSVERSIONINFO
1114 GetVersionEx (OSVERSIONINFO *osvi)
1117 // printf ("GOT %d %d\n", osvi->a, osvi->b);
1122 return osvi->a + osvi->b;
1126 BugGetVersionEx (int a, int b, int c, int d, int e, int f, int g, int h, OSVERSIONINFO *osvi)
1129 // printf ("GOT %d %d\n", osvi->a, osvi->b);
1134 return osvi->a + osvi->b;
1143 mono_test_marshal_point (point pt)
1145 // printf("point %g %g\n", pt.x, pt.y);
1146 if (pt.x == 1.25 && pt.y == 3.5)
1158 mono_test_marshal_mixed_point (mixed_point pt)
1160 // printf("mixed point %d %g\n", pt.x, pt.y);
1161 if (pt.x == 5 && pt.y == 6.75)
1168 mono_test_marshal_mixed_point_2 (mixed_point *pt)
1170 if (pt->x != 5 || pt->y != 6.75)
1180 marshal_test_ref_bool(int i, char *b1, short *b2, int *b3)
1183 if (*b1 != 0 && *b1 != 1)
1185 if (*b2 != 0 && *b2 != -1) /* variant_bool */
1187 if (*b3 != 0 && *b3 != 1)
1189 if (i == ((*b1 << 2) | (-*b2 << 1) | *b3))
1201 short b2; /* variant_bool */
1206 marshal_test_bool_struct(struct BoolStruct *s)
1209 if (s->b1 != 0 && s->b1 != 1)
1211 if (s->b2 != 0 && s->b2 != -1)
1213 if (s->b3 != 0 && s->b3 != 1)
1215 if (s->i == ((s->b1 << 2) | (-s->b2 << 1) | s->b3))
1224 extern __declspec(dllimport) __stdcall void SetLastError(int x);
1228 mono_test_last_error (int err)
1238 mono_test_asany (void *ptr, int what)
1242 return (*(int*)ptr == 5) ? 0 : 1;
1244 return strcmp (ptr, "ABC") == 0 ? 0 : 1;
1246 simplestruct2 ss = *(simplestruct2*)ptr;
1248 if (ss.a == 0 && ss.b == 1 && ss.c == 0 &&
1249 !strcmp (ss.d, "TEST") &&
1250 ss.e == 99 && ss.f == 1.5 && ss.g == 42 && ss.h == (guint64)123)
1256 GError *error = NULL;
1259 s = g_utf16_to_utf8 (ptr, -1, NULL, NULL, &error);
1260 if (!strcmp (s, "ABC")) {
1270 g_assert_not_reached ();
1277 * AMD64 marshalling tests.
1280 typedef struct amd64_struct1 {
1287 STDCALL amd64_struct1
1288 mono_test_marshal_amd64_pass_return_struct1 (amd64_struct1 s)
1298 typedef struct amd64_struct2 {
1303 STDCALL amd64_struct2
1304 mono_test_marshal_amd64_pass_return_struct2 (amd64_struct2 s)
1312 typedef struct amd64_struct3 {
1316 STDCALL amd64_struct3
1317 mono_test_marshal_amd64_pass_return_struct3 (amd64_struct3 s)
1324 typedef struct amd64_struct4 {
1328 STDCALL amd64_struct4
1329 mono_test_marshal_amd64_pass_return_struct4 (amd64_struct4 s)
1338 * IA64 marshalling tests.
1340 typedef struct test_struct5 {
1344 STDCALL test_struct5
1345 mono_test_marshal_ia64_pass_return_struct5 (double d1, double d2, test_struct5 s, double d3, double d4)
1353 typedef struct test_struct6 {
1357 STDCALL test_struct6
1358 mono_test_marshal_ia64_pass_return_struct6 (double d1, double d2, test_struct6 s, double d3, double d4)
1366 static guint32 custom_res [2];
1369 mono_test_marshal_pass_return_custom (int i, guint32 *ptr, int j)
1371 /* ptr will be freed by CleanupNative, so make a copy */
1372 custom_res [0] = 0; /* not allocated by AllocHGlobal */
1373 custom_res [1] = ptr [1];
1379 mono_test_marshal_pass_out_custom (int i, guint32 **ptr, int j)
1382 custom_res [1] = i + j + 10;
1390 mono_test_marshal_pass_byref_custom (int i, guint32 **ptr, int j)
1398 mono_test_marshal_pass_return_custom2 (int i, guint32 *ptr, int j)
1400 g_assert_not_reached ();
1406 mono_test_marshal_pass_return_custom_null (int i, guint32 *ptr, int j)
1408 g_assert (ptr == NULL);
1413 typedef void *(STDCALL *PassReturnPtrDelegate) (void *ptr);
1416 mono_test_marshal_pass_return_custom_in_delegate (PassReturnPtrDelegate del)
1430 /* FIXME: Freed with FreeHGlobal */
1439 mono_test_marshal_pass_return_custom_null_in_delegate (PassReturnPtrDelegate del)
1441 void *ptr = del (NULL);
1443 return (ptr == NULL) ? 15 : 0;
1446 typedef int (STDCALL *ReturnEnumDelegate) (int e);
1449 mono_test_marshal_return_enum_delegate (ReturnEnumDelegate func)
1459 typedef BlittableStruct (STDCALL *SimpleDelegate10) (BlittableStruct ss);
1462 mono_test_marshal_blittable_struct_delegate (SimpleDelegate10 delegate)
1464 BlittableStruct ss, res;
1471 res = delegate (ss);
1472 if (! ((res.a == -1) && (res.b == -2) && (res.c == -3) && (res.d == -55)))
1479 mono_test_stdcall_name_mangling (int a, int b, int c)
1485 * PASSING AND RETURNING SMALL STRUCTURES FROM DELEGATES TESTS
1492 typedef SmallStruct1 (STDCALL *SmallStructDelegate1) (SmallStruct1 ss);
1495 mono_test_marshal_small_struct_delegate1 (SmallStructDelegate1 delegate)
1497 SmallStruct1 ss, res;
1501 res = delegate (ss);
1502 if (! (res.i == -1))
1512 typedef SmallStruct2 (STDCALL *SmallStructDelegate2) (SmallStruct2 ss);
1515 mono_test_marshal_small_struct_delegate2 (SmallStructDelegate2 delegate)
1517 SmallStruct2 ss, res;
1522 res = delegate (ss);
1523 if (! ((res.i == -2) && (res.j == -3)))
1534 typedef SmallStruct3 (STDCALL *SmallStructDelegate3) (SmallStruct3 ss);
1537 mono_test_marshal_small_struct_delegate3 (SmallStructDelegate3 delegate)
1539 SmallStruct3 ss, res;
1544 res = delegate (ss);
1545 if (! ((res.i == -1) && (res.j == -2)))
1555 typedef SmallStruct4 (STDCALL *SmallStructDelegate4) (SmallStruct4 ss);
1558 mono_test_marshal_small_struct_delegate4 (SmallStructDelegate4 delegate)
1560 SmallStruct4 ss, res;
1564 res = delegate (ss);
1565 if (! (res.i == -1))
1575 typedef SmallStruct5 (STDCALL *SmallStructDelegate5) (SmallStruct5 ss);
1578 mono_test_marshal_small_struct_delegate5 (SmallStructDelegate5 delegate)
1580 SmallStruct5 ss, res;
1584 res = delegate (ss);
1585 if (! (res.i == -5))
1595 typedef SmallStruct6 (STDCALL *SmallStructDelegate6) (SmallStruct6 ss);
1598 mono_test_marshal_small_struct_delegate6 (SmallStructDelegate6 delegate)
1600 SmallStruct6 ss, res;
1605 res = delegate (ss);
1606 if (! ((res.i == -1) && (res.j == -2)))
1617 typedef SmallStruct7 (STDCALL *SmallStructDelegate7) (SmallStruct7 ss);
1620 mono_test_marshal_small_struct_delegate7 (SmallStructDelegate7 delegate)
1622 SmallStruct7 ss, res;
1627 res = delegate (ss);
1628 if (! ((res.i == -1) && (res.j == -2)))
1638 typedef SmallStruct8 (STDCALL *SmallStructDelegate8) (SmallStruct8 ss);
1641 mono_test_marshal_small_struct_delegate8 (SmallStructDelegate8 delegate)
1643 SmallStruct8 ss, res;
1647 res = delegate (ss);
1648 if (! ((res.i == -1.0)))
1658 typedef SmallStruct9 (STDCALL *SmallStructDelegate9) (SmallStruct9 ss);
1661 mono_test_marshal_small_struct_delegate9 (SmallStructDelegate9 delegate)
1663 SmallStruct9 ss, res;
1667 res = delegate (ss);
1668 if (! ((res.i == -1.0)))
1678 typedef SmallStruct10 (STDCALL *SmallStructDelegate10) (SmallStruct10 ss);
1681 mono_test_marshal_small_struct_delegate10 (SmallStructDelegate10 delegate)
1683 SmallStruct10 ss, res;
1688 res = delegate (ss);
1689 if (! ((res.i == -1.0) && (res.j == -2.0)))
1700 typedef SmallStruct11 (STDCALL *SmallStructDelegate11) (SmallStruct11 ss);
1703 mono_test_marshal_small_struct_delegate11 (SmallStructDelegate11 delegate)
1705 SmallStruct11 ss, res;
1710 res = delegate (ss);
1711 if (! ((res.i == -1.0) && (res.j == -2)))
1717 typedef int (STDCALL *ArrayDelegate) (int i, char *j, void *arr);
1720 mono_test_marshal_array_delegate (void *arr, int len, ArrayDelegate del)
1722 return del (len, NULL, arr);
1726 mono_test_marshal_out_array_delegate (int *arr, int len, ArrayDelegate del)
1728 del (len, NULL, arr);
1730 if ((arr [0] != 1) || (arr [1] != 2))
1737 mono_test_marshal_out_string_array_delegate (char **arr, int len, ArrayDelegate del)
1739 del (len, NULL, arr);
1741 if (!strcmp (arr [0], "ABC") && !strcmp (arr [1], "DEF"))
1747 typedef int (*CdeclDelegate) (int i, int j);
1750 mono_test_marshal_cdecl_delegate (CdeclDelegate del)
1754 for (i = 0; i < 1000; ++i)
1760 typedef char** (*ReturnStringArrayDelegate) (int i);
1763 mono_test_marshal_return_string_array_delegate (ReturnStringArrayDelegate d)
1771 if (strcmp (arr [0], "ABC") || strcmp (arr [1], "DEF"))