16 #define STDCALL __stdcall
22 #pragma GCC diagnostic ignored "-Wmissing-prototypes"
26 extern __declspec(dllimport) __stdcall void CoTaskMemFree(void *ptr);
29 typedef int (STDCALL *SimpleDelegate) (int a);
31 static void marshal_free (void *ptr)
40 static void* marshal_alloc (gsize size)
43 return CoTaskMemAlloc (size);
45 return g_malloc (size);
49 STDCALL unsigned short*
50 test_lpwstr_marshal (unsigned short* chars, long length)
55 res = marshal_alloc (2 * (length + 1));
57 // printf("test_lpwstr_marshal()\n");
59 while ( i < length ) {
60 // printf("X|%u|\n", chars[i]);
72 test_lpwstr_marshal_out (unsigned short** chars)
75 const char abc[] = "ABC";
76 glong len = strlen(abc);
78 *chars = marshal_alloc (2 * (len + 1));
81 (*chars) [i] = abc[i];
95 mono_union_test_1 (union_test_1_type u1) {
96 // printf ("Got values %d %d %d\n", u1.b, u1.a, u1.c);
97 return u1.a + u1.b + u1.c;
101 mono_return_int (int a) {
102 // printf ("Got value %d\n", a);
112 mono_return_int_ss (struct ss a) {
113 // printf ("Got value %d\n", a.i);
118 mono_return_ss (struct ss a) {
119 // printf ("Got value %d\n", a.i);
130 mono_return_sc1 (struct sc1 a) {
131 // printf ("Got value %d\n", a.c[0]);
143 mono_return_sc3 (struct sc3 a) {
144 // printf ("Got values %d %d %d\n", a.c[0], a.c[1], a.c[2]);
157 mono_return_sc5 (struct sc5 a) {
158 // printf ("Got values %d %d %d %d %d\n", a.c[0], a.c[1], a.c[2], a.c[3], a.c[4]);
174 mono_return_int_su (union su a) {
175 // printf ("Got value %d\n", a.i1);
180 mono_test_many_int_arguments (int a, int b, int c, int d, int e,
181 int f, int g, int h, int i, int j);
183 mono_test_many_short_arguments (short a, short b, short c, short d, short e,
184 short f, short g, short h, short i, short j);
186 mono_test_many_char_arguments (char a, char b, char c, char d, char e,
187 char f, char g, char h, char i, char j);
190 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)
192 return a + b + c + d + e + f + g + h + i + j;
196 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)
198 return a + b + c + d + e + f + g + h + i + j;
202 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)
204 return a + b + c + d + e + f + g + h + i + j;
208 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)
210 return a + b + c + d + e + f + g + h + i + j;
214 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)
216 return a + b + c + d + e + f + g + h + i + j;
220 mono_test_split_double_arguments (double a, double b, float c, double d, double e)
222 return a + b + c + d + e;
226 mono_test_puts_static (char *s)
228 // printf ("TEST %s\n", s);
232 typedef int (STDCALL *SimpleDelegate3) (int a, int b);
235 mono_invoke_delegate (SimpleDelegate3 delegate)
239 // printf ("start invoke %p\n", delegate);
241 res = delegate (2, 3);
243 // printf ("end invoke\n");
249 mono_test_marshal_char (short a1)
258 mono_test_marshal_char_array (gunichar2 *s)
260 const char m[] = "abcdef";
264 s2 = g_utf8_to_utf16 (m, -1, NULL, &len, NULL);
273 mono_test_empty_pinvoke (int i)
279 mono_test_marshal_bool_byref (int a, int *b, int c)
289 mono_test_marshal_bool_in_as_I1_U1 (char bTrue, char bFalse)
299 mono_test_marshal_bool_out_as_I1_U1 (char* bTrue, char* bFalse)
301 if (!bTrue || !bFalse)
311 mono_test_marshal_bool_ref_as_I1_U1 (char* bTrue, char* bFalse)
313 if (!bTrue || !bFalse)
328 mono_test_marshal_array (int *a1)
332 for (i = 0; i < 50; i++)
339 mono_test_marshal_inout_array (int *a1)
343 for (i = 0; i < 50; i++) {
345 a1 [i] = 50 - a1 [i];
352 mono_test_marshal_out_array (int *a1)
356 for (i = 0; i < 50; i++) {
364 mono_test_marshal_inout_nonblittable_array (gunichar2 *a1)
368 for (i = 0; i < 10; i++) {
389 mono_test_return_vtype (int i)
392 static gunichar2 test2 [] = { 'T', 'E', 'S', 'T', '2', 0 };
404 mono_test_delegate_struct (void)
406 // printf ("TEST\n");
409 typedef char* (STDCALL *ReturnStringDelegate) (const char *s);
412 mono_test_return_string (ReturnStringDelegate func)
416 // printf ("mono_test_return_string\n");
421 // printf ("got string: %s\n", res);
422 return g_strdup ("12345");
425 typedef int (STDCALL *RefVTypeDelegate) (int a, simplestruct *ss, int b);
428 mono_test_ref_vtype (int a, simplestruct *ss, int b, RefVTypeDelegate func)
430 if (a == 1 && b == 2 && ss->a == 0 && ss->b == 1 && ss->c == 0 &&
431 !strcmp (ss->d, "TEST1")) {
437 return func (a, ss, b);
443 typedef int (STDCALL *OutVTypeDelegate) (int a, simplestruct *ss, int b);
446 mono_test_marshal_out_struct (int a, simplestruct *ss, int b, OutVTypeDelegate func)
448 /* Check that the input pointer is ignored */
449 ss->d = (gpointer)0x12345678;
453 if (ss->a && ss->b && ss->c && !strcmp (ss->d, "TEST3"))
461 SimpleDelegate func, func2;
464 STDCALL DelegateStruct
465 mono_test_marshal_delegate_struct (DelegateStruct ds)
469 res.a = ds.func (ds.a) + ds.func2 (ds.a);
471 res.func2 = ds.func2;
477 mono_test_marshal_struct (simplestruct ss)
479 if (ss.a == 0 && ss.b == 1 && ss.c == 0 &&
480 !strcmp (ss.d, "TEST"))
487 mono_test_marshal_byref_struct (simplestruct *ss, int a, int b, int c, char *d)
489 gboolean res = (ss->a == a && ss->b == b && ss->c == c && strcmp (ss->d, d) == 0);
491 marshal_free ((char*)ss->d);
496 ss->d = g_strdup ("DEF");
513 mono_test_marshal_struct2 (simplestruct2 ss)
515 if (ss.a == 0 && ss.b == 1 && ss.c == 0 &&
516 !strcmp (ss.d, "TEST") &&
517 ss.e == 99 && ss.f == 1.5 && ss.g == 42 && ss.h == (guint64)123)
523 /* on HP some of the struct should be on the stack and not in registers */
525 mono_test_marshal_struct2_2 (int i, int j, int k, simplestruct2 ss)
527 if (i != 10 || j != 11 || k != 12)
529 if (ss.a == 0 && ss.b == 1 && ss.c == 0 &&
530 !strcmp (ss.d, "TEST") &&
531 ss.e == 99 && ss.f == 1.5 && ss.g == 42 && ss.h == (guint64)123)
538 mono_test_marshal_lpstruct (simplestruct *ss)
540 if (ss->a == 0 && ss->b == 1 && ss->c == 0 &&
541 !strcmp (ss->d, "TEST"))
548 mono_test_marshal_lpstruct_blittable (point *p)
550 if (p->x == 1.0 && p->y == 2.0)
557 mono_test_marshal_struct_array (simplestruct2 *ss)
559 if (! (ss[0].a == 0 && ss[0].b == 1 && ss[0].c == 0 &&
560 !strcmp (ss[0].d, "TEST") &&
561 ss[0].e == 99 && ss[0].f == 1.5 && ss[0].g == 42 && ss[0].h == (guint64)123))
564 if (! (ss[1].a == 0 && ss[1].b == 0 && ss[1].c == 0 &&
565 !strcmp (ss[1].d, "TEST2") &&
566 ss[1].e == 100 && ss[1].f == 2.5 && ss[1].g == 43 && ss[1].h == (guint64)124))
572 typedef struct long_align_struct {
579 mono_test_marshal_long_align_struct_array (long_align_struct *ss)
581 return ss[0].a + ss[0].b + ss[0].c + ss[1].a + ss[1].b + ss[1].c;
584 STDCALL simplestruct2 *
585 mono_test_marshal_class (int i, int j, int k, simplestruct2 *ss, int l)
592 if (i != 10 || j != 11 || k != 12 || l != 14)
594 if (! (ss->a == 0 && ss->b == 1 && ss->c == 0 &&
595 !strcmp (ss->d, "TEST") &&
596 ss->e == 99 && ss->f == 1.5 && ss->g == 42 && ss->h == (guint64)123))
599 res = g_new0 (simplestruct2, 1);
600 memcpy (res, ss, sizeof (simplestruct2));
601 res->d = g_strdup ("TEST");
606 mono_test_marshal_byref_class (simplestruct2 **ssp)
608 simplestruct2 *ss = *ssp;
611 if (! (ss->a == 0 && ss->b == 1 && ss->c == 0 &&
612 !strcmp (ss->d, "TEST") &&
613 ss->e == 99 && ss->f == 1.5 && ss->g == 42 && ss->h == (guint64)123))
616 res = g_new0 (simplestruct2, 1);
617 memcpy (res, ss, sizeof (simplestruct2));
618 res->d = g_strdup ("TEST-RES");
630 /* Yes, this is correct, we are only trying to determine the value of the stack here */
636 reliable_delegate (int a)
642 * Checks whether get_sp() works as expected. It doesn't work with gcc-2.95.3 on linux.
645 is_get_sp_reliable (void)
649 reliable_delegate(1);
651 reliable_delegate(1);
657 mono_test_marshal_delegate (SimpleDelegate delegate)
661 /* Check that the delegate wrapper is stdcall */
666 if (is_get_sp_reliable())
667 g_assert (sp1 == sp2);
672 STDCALL SimpleDelegate
673 mono_test_marshal_return_delegate (SimpleDelegate delegate)
679 return_plus_one (int i)
684 STDCALL SimpleDelegate
685 mono_test_marshal_return_delegate_2 (void)
687 return return_plus_one;
690 typedef simplestruct (STDCALL *SimpleDelegate2) (simplestruct ss);
693 is_utf16_equals (gunichar2 *s1, const char *s2)
698 s = g_utf16_to_utf8 (s1, -1, NULL, NULL, NULL);
699 res = strcmp (s, s2);
706 mono_test_marshal_delegate2 (SimpleDelegate2 delegate)
708 simplestruct ss, res;
714 ss.d2 = g_utf8_to_utf16 ("TEST2", -1, NULL, NULL, NULL);
717 if (! (res.a && !res.b && res.c && !strcmp (res.d, "TEST-RES") && is_utf16_equals (res.d2, "TEST2-RES")))
723 typedef simplestruct* (STDCALL *SimpleDelegate4) (simplestruct *ss);
726 mono_test_marshal_delegate4 (SimpleDelegate4 delegate)
737 res = delegate (&ss);
741 /* Check return value */
742 if (! (!res->a && res->b && !res->c && !strcmp (res->d, "TEST")))
745 /* Check NULL argument and NULL result */
746 res = delegate (NULL);
753 typedef int (STDCALL *SimpleDelegate5) (simplestruct **ss);
756 mono_test_marshal_delegate5 (SimpleDelegate5 delegate)
769 res = delegate (&ptr);
773 if (!(ptr->a && !ptr->b && ptr->c && !strcmp (ptr->d, "RES")))
780 mono_test_marshal_delegate6 (SimpleDelegate5 delegate)
784 res = delegate (NULL);
789 typedef int (STDCALL *SimpleDelegate7) (simplestruct **ss);
792 mono_test_marshal_delegate7 (SimpleDelegate7 delegate)
797 /* Check that the input pointer is ignored */
798 ptr = (gpointer)0x12345678;
800 res = delegate (&ptr);
804 if (!(ptr->a && !ptr->b && ptr->c && !strcmp (ptr->d, "RES")))
810 typedef int (STDCALL *InOutByvalClassDelegate) (simplestruct *ss);
813 mono_test_marshal_inout_byval_class_delegate (InOutByvalClassDelegate delegate)
821 ss.d = g_strdup_printf ("%s", "FOO");
823 res = delegate (&ss);
827 if (!(ss.a && !ss.b && ss.c && !strcmp (ss.d, "RES")))
833 typedef int (STDCALL *SimpleDelegate8) (gunichar2 *s);
836 mono_test_marshal_delegate8 (SimpleDelegate8 delegate, gunichar2 *s)
841 typedef int (STDCALL *return_int_fnt) (int i);
842 typedef int (STDCALL *SimpleDelegate9) (return_int_fnt d);
845 mono_test_marshal_delegate9 (SimpleDelegate9 delegate, gpointer ftn)
847 return delegate (ftn);
857 mono_test_marshal_delegate10 (SimpleDelegate9 delegate)
859 return delegate (return_self);
862 typedef int (STDCALL *PrimitiveByrefDelegate) (int *i);
865 mono_test_marshal_primitive_byref_delegate (PrimitiveByrefDelegate delegate)
869 int res = delegate (&i);
879 typedef int (STDCALL *return_int_delegate) (int i);
881 typedef return_int_delegate (STDCALL *ReturnDelegateDelegate) (void);
884 mono_test_marshal_return_delegate_delegate (ReturnDelegateDelegate d)
890 mono_test_marshal_stringbuilder (char *s, int n)
892 const char m[] = "This is my message. Isn't it nice?";
894 if (strcmp (s, "ABCD") != 0)
902 mono_test_marshal_stringbuilder_default (char *s, int n)
904 const char m[] = "This is my message. Isn't it nice?";
912 mono_test_marshal_stringbuilder_unicode (gunichar2 *s, int n)
914 const char m[] = "This is my message. Isn't it nice?";
918 s2 = g_utf8_to_utf16 (m, -1, NULL, &len, NULL);
937 mono_test_marshal_empty_string_array (char **array)
939 return (array == NULL) ? 0 : 1;
943 mono_test_marshal_string_array (char **array)
945 if (strcmp (array [0], "ABC"))
947 if (strcmp (array [1], "DEF"))
950 if (array [2] != NULL)
957 mono_test_marshal_byref_string_array (char ***array)
962 if (strcmp ((*array) [0], "Alpha"))
964 if (strcmp ((*array) [1], "Beta"))
966 if (strcmp ((*array) [2], "Gamma"))
973 mono_test_marshal_stringbuilder_array (char **array)
975 if (strcmp (array [0], "ABC"))
977 if (strcmp (array [1], "DEF"))
980 strcpy (array [0], "DEF");
981 strcpy (array [1], "ABC");
987 mono_test_marshal_unicode_string_array (gunichar2 **array, char **array2)
989 GError *error = NULL;
992 s = g_utf16_to_utf8 (array [0], -1, NULL, NULL, &error);
993 if (strcmp (s, "ABC")) {
1000 s = g_utf16_to_utf8 (array [1], -1, NULL, NULL, &error);
1001 if (strcmp (s, "DEF")) {
1008 if (strcmp (array2 [0], "ABC"))
1011 if (strcmp (array2 [1], "DEF"))
1017 /* this does not work on Redhat gcc 2.96 */
1019 mono_test_empty_struct (int a, EmptyStruct es, int b)
1021 // printf ("mono_test_empty_struct %d %d\n", a, b);
1023 // Intel icc on ia64 passes 'es' in 2 registers
1024 #if defined(__ia64) && defined(__INTEL_COMPILER)
1027 if (a == 1 && b == 2)
1037 STDCALL ByValStrStruct *
1038 mono_test_byvalstr_gen (void)
1040 ByValStrStruct *ret;
1042 ret = malloc(sizeof(ByValStrStruct));
1043 memset(ret, 'a', sizeof(ByValStrStruct)-1);
1044 ret->a[sizeof(ByValStrStruct)-1] = 0;
1050 mono_test_byvalstr_check (ByValStrStruct* data, char* correctString)
1054 ret = strcmp(data->a, correctString);
1055 // printf ("T1: %s\n", data->a);
1056 // printf ("T2: %s\n", correctString);
1058 marshal_free (data);
1065 } ByValStrStruct_Unicode;
1068 mono_test_byvalstr_check_unicode (ByValStrStruct_Unicode *ref, int test)
1070 if (ref->flag != 0x1234abcd){
1071 printf ("overwritten data");
1075 if (test == 1 || test == 3){
1076 if (ref->a [0] != '1' ||
1077 ref->a [1] != '2' ||
1083 if (ref->a [0] != '1' ||
1092 NameManglingAnsi (char *data)
1094 return data [0] + data [1] + data [2];
1098 NameManglingAnsiA (char *data)
1100 g_assert_not_reached ();
1104 NameManglingAnsiW (char *data)
1106 g_assert_not_reached ();
1110 NameManglingAnsi2A (char *data)
1112 return data [0] + data [1] + data [2];
1116 NameManglingAnsi2W (char *data)
1118 g_assert_not_reached ();
1122 NameManglingUnicode (char *data)
1124 g_assert_not_reached ();
1128 NameManglingUnicodeW (gunichar2 *data)
1130 return data [0] + data [1] + data [2];
1134 NameManglingUnicode2 (gunichar2 *data)
1136 return data [0] + data [1] + data [2];
1140 NameManglingAutoW (char *data)
1143 return (data [0] + data [1] + data [2]) == 131 ? 0 : 1;
1145 g_assert_not_reached ();
1150 NameManglingAuto (char *data)
1153 return (data [0] + data [1] + data [2]) == 198 ? 0 : 1;
1155 g_assert_not_reached ();
1159 typedef int (STDCALL *intcharFunc)(const char*);
1162 callFunction (intcharFunc f)
1173 class_marshal_test0 (SimpleObj *obj1)
1175 // printf ("class_marshal_test0 %s %d\n", obj1->str, obj1->i);
1177 if (strcmp(obj1->str, "T1"))
1186 class_marshal_test4 (SimpleObj *obj1)
1195 class_marshal_test1 (SimpleObj **obj1)
1197 SimpleObj *res = malloc (sizeof (SimpleObj));
1199 res->str = g_strdup ("ABC");
1206 class_marshal_test2 (SimpleObj **obj1)
1208 // printf ("class_marshal_test2 %s %d\n", (*obj1)->str, (*obj1)->i);
1210 if (strcmp((*obj1)->str, "ABC"))
1212 if ((*obj1)->i != 5)
1219 string_marshal_test0 (char *str)
1221 if (strcmp (str, "TEST0"))
1228 string_marshal_test1 (const char **str)
1230 *str = g_strdup ("TEST1");
1234 string_marshal_test2 (char **str)
1236 // printf ("string_marshal_test2 %s\n", *str);
1238 if (strcmp (*str, "TEST1"))
1245 string_marshal_test3 (char *str)
1258 STDCALL BlittableClass*
1259 TestBlittableClass (BlittableClass *vl)
1261 BlittableClass *res;
1263 // printf ("TestBlittableClass %d %d\n", vl->a, vl->b);
1269 res = g_new0 (BlittableClass, 1);
1270 memcpy (res, vl, sizeof (BlittableClass));
1272 res = g_new0 (BlittableClass, 1);
1280 typedef struct OSVERSIONINFO_STRUCT
1284 } OSVERSIONINFO_STRUCT;
1287 MyGetVersionEx (OSVERSIONINFO_STRUCT *osvi)
1290 // printf ("GOT %d %d\n", osvi->a, osvi->b);
1295 return osvi->a + osvi->b;
1299 BugGetVersionEx (int a, int b, int c, int d, int e, int f, int g, int h, OSVERSIONINFO_STRUCT *osvi)
1302 // printf ("GOT %d %d\n", osvi->a, osvi->b);
1307 return osvi->a + osvi->b;
1311 mono_test_marshal_point (point pt)
1313 // printf("point %g %g\n", pt.x, pt.y);
1314 if (pt.x == 1.25 && pt.y == 3.5)
1326 mono_test_marshal_mixed_point (mixed_point pt)
1328 // printf("mixed point %d %g\n", pt.x, pt.y);
1329 if (pt.x == 5 && pt.y == 6.75)
1336 mono_test_marshal_mixed_point_2 (mixed_point *pt)
1338 if (pt->x != 5 || pt->y != 6.75)
1348 marshal_test_ref_bool(int i, char *b1, short *b2, int *b3)
1351 if (*b1 != 0 && *b1 != 1)
1353 if (*b2 != 0 && *b2 != -1) /* variant_bool */
1355 if (*b3 != 0 && *b3 != 1)
1357 if (i == ((*b1 << 2) | (-*b2 << 1) | *b3))
1369 short b2; /* variant_bool */
1374 marshal_test_bool_struct(struct BoolStruct *s)
1377 if (s->b1 != 0 && s->b1 != 1)
1379 if (s->b2 != 0 && s->b2 != -1)
1381 if (s->b3 != 0 && s->b3 != 1)
1383 if (s->i == ((s->b1 << 2) | (-s->b2 << 1) | s->b3))
1392 mono_test_last_error (int err)
1402 mono_test_asany (void *ptr, int what)
1406 return (*(int*)ptr == 5) ? 0 : 1;
1408 return strcmp (ptr, "ABC") == 0 ? 0 : 1;
1410 simplestruct2 ss = *(simplestruct2*)ptr;
1412 if (ss.a == 0 && ss.b == 1 && ss.c == 0 &&
1413 !strcmp (ss.d, "TEST") &&
1414 ss.e == 99 && ss.f == 1.5 && ss.g == 42 && ss.h == (guint64)123)
1420 GError *error = NULL;
1423 s = g_utf16_to_utf8 (ptr, -1, NULL, NULL, &error);
1424 if (!strcmp (s, "ABC")) {
1434 g_assert_not_reached ();
1449 mono_test_marshal_asany_in (void* ptr)
1451 AsAnyStruct* asAny = ptr;
1452 int res = asAny->i + asAny->j + asAny->k;
1458 mono_test_marshal_asany_inout (void* ptr)
1460 AsAnyStruct* asAny = ptr;
1461 int res = asAny->i + asAny->j + asAny->k;
1463 marshal_free (asAny->s);
1474 mono_test_marshal_asany_out (void* ptr)
1476 AsAnyStruct* asAny = ptr;
1477 int res = asAny->i + asAny->j + asAny->k;
1488 * AMD64 marshalling tests.
1491 typedef struct amd64_struct1 {
1498 STDCALL amd64_struct1
1499 mono_test_marshal_amd64_pass_return_struct1 (amd64_struct1 s)
1509 typedef struct amd64_struct2 {
1514 STDCALL amd64_struct2
1515 mono_test_marshal_amd64_pass_return_struct2 (amd64_struct2 s)
1523 typedef struct amd64_struct3 {
1527 STDCALL amd64_struct3
1528 mono_test_marshal_amd64_pass_return_struct3 (amd64_struct3 s)
1535 typedef struct amd64_struct4 {
1539 STDCALL amd64_struct4
1540 mono_test_marshal_amd64_pass_return_struct4 (amd64_struct4 s)
1549 * IA64 marshalling tests.
1551 typedef struct test_struct5 {
1555 STDCALL test_struct5
1556 mono_test_marshal_ia64_pass_return_struct5 (double d1, double d2, test_struct5 s, double d3, double d4)
1564 typedef struct test_struct6 {
1568 STDCALL test_struct6
1569 mono_test_marshal_ia64_pass_return_struct6 (double d1, double d2, test_struct6 s, double d3, double d4)
1577 static guint32 custom_res [2];
1580 mono_test_marshal_pass_return_custom (int i, guint32 *ptr, int j)
1582 /* ptr will be freed by CleanupNative, so make a copy */
1583 custom_res [0] = 0; /* not allocated by AllocHGlobal */
1584 custom_res [1] = ptr [1];
1590 mono_test_marshal_pass_out_custom (int i, guint32 **ptr, int j)
1593 custom_res [1] = i + j + 10;
1601 mono_test_marshal_pass_inout_custom (int i, guint32 *ptr, int j)
1604 ptr [1] = i + ptr [1] + j;
1610 mono_test_marshal_pass_out_byval_custom (int i, guint32 *ptr, int j)
1612 return ptr == NULL ? 0 : 1;
1616 mono_test_marshal_pass_byref_custom (int i, guint32 **ptr, int j)
1624 mono_test_marshal_pass_return_custom2 (int i, guint32 *ptr, int j)
1626 g_assert_not_reached ();
1632 mono_test_marshal_pass_return_custom_null (int i, guint32 *ptr, int j)
1634 g_assert (ptr == NULL);
1639 typedef void *(STDCALL *PassReturnPtrDelegate) (void *ptr);
1642 mono_test_marshal_pass_return_custom_in_delegate (PassReturnPtrDelegate del)
1656 /* FIXME: Freed with FreeHGlobal */
1665 mono_test_marshal_pass_return_custom_null_in_delegate (PassReturnPtrDelegate del)
1667 void *ptr = del (NULL);
1669 return (ptr == NULL) ? 15 : 0;
1672 typedef void (STDCALL *CustomOutParamDelegate) (void **pptr);
1675 mono_test_marshal_custom_out_param_delegate (CustomOutParamDelegate del)
1687 typedef int (STDCALL *ReturnEnumDelegate) (int e);
1690 mono_test_marshal_return_enum_delegate (ReturnEnumDelegate func)
1700 typedef BlittableStruct (STDCALL *SimpleDelegate10) (BlittableStruct ss);
1703 mono_test_marshal_blittable_struct_delegate (SimpleDelegate10 delegate)
1705 BlittableStruct ss, res;
1712 res = delegate (ss);
1713 if (! ((res.a == -1) && (res.b == -2) && (res.c == -3) && (res.d == -55)))
1720 mono_test_stdcall_name_mangling (int a, int b, int c)
1726 * PASSING AND RETURNING SMALL STRUCTURES FROM DELEGATES TESTS
1733 typedef SmallStruct1 (STDCALL *SmallStructDelegate1) (SmallStruct1 ss);
1736 mono_test_marshal_small_struct_delegate1 (SmallStructDelegate1 delegate)
1738 SmallStruct1 ss, res;
1742 res = delegate (ss);
1743 if (! (res.i == -1))
1753 typedef SmallStruct2 (STDCALL *SmallStructDelegate2) (SmallStruct2 ss);
1756 mono_test_marshal_small_struct_delegate2 (SmallStructDelegate2 delegate)
1758 SmallStruct2 ss, res;
1763 res = delegate (ss);
1764 if (! ((res.i == -2) && (res.j == -3)))
1775 typedef SmallStruct3 (STDCALL *SmallStructDelegate3) (SmallStruct3 ss);
1778 mono_test_marshal_small_struct_delegate3 (SmallStructDelegate3 delegate)
1780 SmallStruct3 ss, res;
1785 res = delegate (ss);
1786 if (! ((res.i == -1) && (res.j == -2)))
1796 typedef SmallStruct4 (STDCALL *SmallStructDelegate4) (SmallStruct4 ss);
1799 mono_test_marshal_small_struct_delegate4 (SmallStructDelegate4 delegate)
1801 SmallStruct4 ss, res;
1805 res = delegate (ss);
1806 if (! (res.i == -1))
1816 typedef SmallStruct5 (STDCALL *SmallStructDelegate5) (SmallStruct5 ss);
1819 mono_test_marshal_small_struct_delegate5 (SmallStructDelegate5 delegate)
1821 SmallStruct5 ss, res;
1825 res = delegate (ss);
1826 if (! (res.i == -5))
1836 typedef SmallStruct6 (STDCALL *SmallStructDelegate6) (SmallStruct6 ss);
1839 mono_test_marshal_small_struct_delegate6 (SmallStructDelegate6 delegate)
1841 SmallStruct6 ss, res;
1846 res = delegate (ss);
1847 if (! ((res.i == -1) && (res.j == -2)))
1858 typedef SmallStruct7 (STDCALL *SmallStructDelegate7) (SmallStruct7 ss);
1861 mono_test_marshal_small_struct_delegate7 (SmallStructDelegate7 delegate)
1863 SmallStruct7 ss, res;
1868 res = delegate (ss);
1869 if (! ((res.i == -1) && (res.j == -2)))
1879 typedef SmallStruct8 (STDCALL *SmallStructDelegate8) (SmallStruct8 ss);
1882 mono_test_marshal_small_struct_delegate8 (SmallStructDelegate8 delegate)
1884 SmallStruct8 ss, res;
1888 res = delegate (ss);
1889 if (! ((res.i == -1.0)))
1899 typedef SmallStruct9 (STDCALL *SmallStructDelegate9) (SmallStruct9 ss);
1902 mono_test_marshal_small_struct_delegate9 (SmallStructDelegate9 delegate)
1904 SmallStruct9 ss, res;
1908 res = delegate (ss);
1909 if (! ((res.i == -1.0)))
1919 typedef SmallStruct10 (STDCALL *SmallStructDelegate10) (SmallStruct10 ss);
1922 mono_test_marshal_small_struct_delegate10 (SmallStructDelegate10 delegate)
1924 SmallStruct10 ss, res;
1929 res = delegate (ss);
1930 if (! ((res.i == -1.0) && (res.j == -2.0)))
1941 typedef SmallStruct11 (STDCALL *SmallStructDelegate11) (SmallStruct11 ss);
1944 mono_test_marshal_small_struct_delegate11 (SmallStructDelegate11 delegate)
1946 SmallStruct11 ss, res;
1951 res = delegate (ss);
1952 if (! ((res.i == -1.0) && (res.j == -2)))
1958 typedef int (STDCALL *ArrayDelegate) (int i, char *j, void *arr);
1961 mono_test_marshal_array_delegate (void *arr, int len, ArrayDelegate del)
1963 return del (len, NULL, arr);
1967 mono_test_marshal_out_array_delegate (int *arr, int len, ArrayDelegate del)
1969 del (len, NULL, arr);
1971 if ((arr [0] != 1) || (arr [1] != 2))
1977 typedef gunichar2* (STDCALL *UnicodeStringDelegate) (gunichar2 *message);
1980 mono_test_marshal_return_unicode_string_delegate (UnicodeStringDelegate del)
1982 const char m[] = "abcdef";
1983 gunichar2 *s2, *res;
1986 s2 = g_utf8_to_utf16 (m, -1, NULL, &len, NULL);
1996 mono_test_marshal_out_string_array_delegate (char **arr, int len, ArrayDelegate del)
1998 del (len, NULL, arr);
2000 if (!strcmp (arr [0], "ABC") && !strcmp (arr [1], "DEF"))
2006 typedef int (*CdeclDelegate) (int i, int j);
2009 mono_test_marshal_cdecl_delegate (CdeclDelegate del)
2013 for (i = 0; i < 1000; ++i)
2019 typedef char** (*ReturnStringArrayDelegate) (int i);
2022 mono_test_marshal_return_string_array_delegate (ReturnStringArrayDelegate d)
2030 if (strcmp (arr [0], "ABC") || strcmp (arr [1], "DEF"))
2041 add_delegate (int i, int j)
2047 mono_test_marshal_return_fnptr (void)
2049 return &add_delegate;
2055 printf ("codigo %x\n", code);
2064 mono_xr_as_handle (int code)
2079 mono_safe_handle_struct_ref (HandleStructs *x)
2081 printf ("Dingus Ref! \n");
2082 printf ("Values: %d %d %p %p\n", x->a, x->b, x->handle1, x->handle2);
2088 if (x->handle1 != (void*) 0x7080feed)
2091 if (x->handle2 != (void*) 0x1234abcd)
2098 mono_safe_handle_struct (HandleStructs x)
2100 printf ("Dingus Standard! \n");
2101 printf ("Values: %d %d %p %p\n", x.a, x.b, x.handle1, x.handle2);
2107 if (x.handle1 != (void*) 0x7080feed)
2110 if (x.handle2 != (void*) 0x1234abcd)
2121 mono_safe_handle_struct_simple (TrivialHandle x)
2123 printf ("The value is %p\n", x.a);
2124 return ((int)(gsize)x.a) * 2;
2128 mono_safe_handle_return (void)
2134 mono_safe_handle_ref (void **handle)
2137 *handle = (void *) 0xbad;
2141 *handle = (void *) 0x800d;
2150 mono_test_marshal_bstr_in(BSTR bstr)
2152 if (!wcscmp(bstr, L"mono_test_marshal_bstr_in"))
2158 mono_test_marshal_bstr_out(BSTR* bstr)
2160 *bstr = SysAllocString(L"mono_test_marshal_bstr_out");
2165 mono_test_marshal_bstr_in_null(BSTR bstr)
2173 mono_test_marshal_bstr_out_null(BSTR* bstr)
2180 mono_test_marshal_variant_in_sbyte(VARIANT variant)
2182 if (variant.vt == VT_I1 && variant.cVal == 100)
2188 mono_test_marshal_variant_in_byte(VARIANT variant)
2190 if (variant.vt == VT_UI1 && variant.bVal == 100)
2196 mono_test_marshal_variant_in_short(VARIANT variant)
2198 if (variant.vt == VT_I2 && variant.iVal == 314)
2204 mono_test_marshal_variant_in_ushort(VARIANT variant)
2206 if (variant.vt == VT_UI2 && variant.uiVal == 314)
2212 mono_test_marshal_variant_in_int(VARIANT variant)
2214 if (variant.vt == VT_I4 && variant.lVal == 314)
2220 mono_test_marshal_variant_in_uint(VARIANT variant)
2222 if (variant.vt == VT_UI4 && variant.ulVal == 314)
2228 mono_test_marshal_variant_in_long(VARIANT variant)
2230 if (variant.vt == VT_I8 && variant.llVal == 314)
2236 mono_test_marshal_variant_in_ulong(VARIANT variant)
2238 if (variant.vt == VT_UI8 && variant.ullVal == 314)
2244 mono_test_marshal_variant_in_float(VARIANT variant)
2246 if (variant.vt == VT_R4 && (variant.fltVal - 3.14)/3.14 < .001)
2252 mono_test_marshal_variant_in_double(VARIANT variant)
2254 if (variant.vt == VT_R8 && (variant.dblVal - 3.14)/3.14 < .001)
2260 mono_test_marshal_variant_in_bstr(VARIANT variant)
2262 if (variant.vt == VT_BSTR && !wcscmp(variant.bstrVal, L"PI"))
2268 mono_test_marshal_variant_in_bool_true (VARIANT variant)
2270 if (variant.vt == VT_BOOL && variant.boolVal == VARIANT_TRUE)
2276 mono_test_marshal_variant_in_bool_false (VARIANT variant)
2278 if (variant.vt == VT_BOOL && variant.boolVal == VARIANT_FALSE)
2284 mono_test_marshal_variant_out_sbyte(VARIANT* variant)
2286 variant->vt = VT_I1;
2287 variant->cVal = 100;
2293 mono_test_marshal_variant_out_byte(VARIANT* variant)
2295 variant->vt = VT_UI1;
2296 variant->bVal = 100;
2302 mono_test_marshal_variant_out_short(VARIANT* variant)
2304 variant->vt = VT_I2;
2305 variant->iVal = 314;
2311 mono_test_marshal_variant_out_ushort(VARIANT* variant)
2313 variant->vt = VT_UI2;
2314 variant->uiVal = 314;
2320 mono_test_marshal_variant_out_int(VARIANT* variant)
2322 variant->vt = VT_I4;
2323 variant->lVal = 314;
2329 mono_test_marshal_variant_out_uint(VARIANT* variant)
2331 variant->vt = VT_UI4;
2332 variant->ulVal = 314;
2338 mono_test_marshal_variant_out_long(VARIANT* variant)
2340 variant->vt = VT_I8;
2341 variant->llVal = 314;
2347 mono_test_marshal_variant_out_ulong(VARIANT* variant)
2349 variant->vt = VT_UI8;
2350 variant->ullVal = 314;
2356 mono_test_marshal_variant_out_float(VARIANT* variant)
2358 variant->vt = VT_R4;
2359 variant->fltVal = 3.14;
2365 mono_test_marshal_variant_out_double(VARIANT* variant)
2367 variant->vt = VT_R8;
2368 variant->dblVal = 3.14;
2374 mono_test_marshal_variant_out_bstr(VARIANT* variant)
2376 variant->vt = VT_BSTR;
2377 variant->bstrVal = SysAllocString(L"PI");
2383 mono_test_marshal_variant_out_bool_true (VARIANT* variant)
2385 variant->vt = VT_BOOL;
2386 variant->boolVal = VARIANT_TRUE;
2392 mono_test_marshal_variant_out_bool_false (VARIANT* variant)
2394 variant->vt = VT_BOOL;
2395 variant->boolVal = VARIANT_FALSE;
2400 typedef int (STDCALL *VarFunc) (int vt, VARIANT variant);
2401 typedef int (STDCALL *VarRefFunc) (int vt, VARIANT* variant);
2404 mono_test_marshal_variant_in_sbyte_unmanaged(VarFunc func)
2409 return func (VT_I1, vt);
2413 mono_test_marshal_variant_in_byte_unmanaged(VarFunc func)
2418 return func (VT_UI1, vt);
2422 mono_test_marshal_variant_in_short_unmanaged(VarFunc func)
2427 return func (VT_I2, vt);
2431 mono_test_marshal_variant_in_ushort_unmanaged(VarFunc func)
2436 return func (VT_UI2, vt);
2440 mono_test_marshal_variant_in_int_unmanaged(VarFunc func)
2445 return func (VT_I4, vt);
2449 mono_test_marshal_variant_in_uint_unmanaged(VarFunc func)
2454 return func (VT_UI4, vt);
2458 mono_test_marshal_variant_in_long_unmanaged(VarFunc func)
2463 return func (VT_I8, vt);
2467 mono_test_marshal_variant_in_ulong_unmanaged(VarFunc func)
2472 return func (VT_UI8, vt);
2476 mono_test_marshal_variant_in_float_unmanaged(VarFunc func)
2481 return func (VT_R4, vt);
2485 mono_test_marshal_variant_in_double_unmanaged(VarFunc func)
2490 return func (VT_R8, vt);
2494 mono_test_marshal_variant_in_bstr_unmanaged(VarFunc func)
2498 vt.bstrVal = SysAllocString(L"PI");
2499 return func (VT_BSTR, vt);
2503 mono_test_marshal_variant_in_bool_true_unmanaged(VarFunc func)
2507 vt.boolVal = VARIANT_TRUE;
2508 return func (VT_BOOL, vt);
2512 mono_test_marshal_variant_in_bool_false_unmanaged(VarFunc func)
2516 vt.boolVal = VARIANT_FALSE;
2517 return func (VT_BOOL, vt);
2521 mono_test_marshal_variant_out_sbyte_unmanaged(VarRefFunc func)
2526 if (vt.vt == VT_I1 && vt.cVal == -100)
2532 mono_test_marshal_variant_out_byte_unmanaged(VarRefFunc func)
2537 if (vt.vt == VT_UI1 && vt.bVal == 100)
2543 mono_test_marshal_variant_out_short_unmanaged(VarRefFunc func)
2548 if (vt.vt == VT_I2 && vt.iVal == -100)
2554 mono_test_marshal_variant_out_ushort_unmanaged(VarRefFunc func)
2559 if (vt.vt == VT_UI2 && vt.uiVal == 100)
2565 mono_test_marshal_variant_out_int_unmanaged(VarRefFunc func)
2570 if (vt.vt == VT_I4 && vt.lVal == -100)
2576 mono_test_marshal_variant_out_uint_unmanaged(VarRefFunc func)
2581 if (vt.vt == VT_UI4 && vt.ulVal == 100)
2587 mono_test_marshal_variant_out_long_unmanaged(VarRefFunc func)
2592 if (vt.vt == VT_I8 && vt.llVal == -100)
2598 mono_test_marshal_variant_out_ulong_unmanaged(VarRefFunc func)
2603 if (vt.vt == VT_UI8 && vt.ullVal == 100)
2609 mono_test_marshal_variant_out_float_unmanaged(VarRefFunc func)
2614 if (vt.vt == VT_R4 && fabs (vt.fltVal - 3.14f) < 1e-10)
2620 mono_test_marshal_variant_out_double_unmanaged(VarRefFunc func)
2625 if (vt.vt == VT_R8 && fabs (vt.dblVal - 3.14) < 1e-10)
2631 mono_test_marshal_variant_out_bstr_unmanaged(VarRefFunc func)
2635 func (VT_BSTR, &vt);
2636 if (vt.vt == VT_BSTR && !wcscmp(vt.bstrVal, L"PI"))
2642 mono_test_marshal_variant_out_bool_true_unmanaged(VarRefFunc func)
2646 func (VT_BOOL, &vt);
2647 if (vt.vt == VT_BOOL && vt.boolVal == VARIANT_TRUE)
2653 mono_test_marshal_variant_out_bool_false_unmanaged(VarRefFunc func)
2657 func (VT_BOOL, &vt);
2658 if (vt.vt == VT_BOOL && vt.boolVal == VARIANT_TRUE)
2663 typedef struct MonoComObject MonoComObject;
2667 int (STDCALL *QueryInterface)(MonoComObject* pUnk, gpointer riid, gpointer* ppv);
2668 int (STDCALL *AddRef)(MonoComObject* pUnk);
2669 int (STDCALL *Release)(MonoComObject* pUnk);
2670 int (STDCALL *get_ITest)(MonoComObject* pUnk, MonoComObject* *ppUnk);
2671 int (STDCALL *SByteIn)(MonoComObject* pUnk, char a);
2672 int (STDCALL *ByteIn)(MonoComObject* pUnk, unsigned char a);
2673 int (STDCALL *ShortIn)(MonoComObject* pUnk, short a);
2674 int (STDCALL *UShortIn)(MonoComObject* pUnk, unsigned short a);
2675 int (STDCALL *IntIn)(MonoComObject* pUnk, int a);
2676 int (STDCALL *UIntIn)(MonoComObject* pUnk, unsigned int a);
2677 int (STDCALL *LongIn)(MonoComObject* pUnk, LONGLONG a);
2678 int (STDCALL *ULongIn)(MonoComObject* pUnk, ULONGLONG a);
2679 int (STDCALL *FloatIn)(MonoComObject* pUnk, float a);
2680 int (STDCALL *DoubleIn)(MonoComObject* pUnk, double a);
2681 int (STDCALL *ITestIn)(MonoComObject* pUnk, MonoComObject* pUnk2);
2682 int (STDCALL *ITestOut)(MonoComObject* pUnk, MonoComObject* *ppUnk);
2685 struct MonoComObject
2691 DEFINE_GUID(IID_ITest, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
2692 DEFINE_GUID(IID_IMonoUnknown, 0, 0, 0, 0xC0, 0, 0, 0, 0, 0, 0, 0x46);
2693 DEFINE_GUID(IID_IMonoDispatch, 0x00020400, 0, 0, 0xC0, 0, 0, 0, 0, 0, 0, 0x46);
2695 int STDCALL MonoQueryInterface(MonoComObject* pUnk, gpointer riid, gpointer* ppv)
2698 if (!memcmp(riid, &IID_IMonoUnknown, sizeof(GUID))) {
2702 else if (!memcmp(riid, &IID_ITest, sizeof(GUID))) {
2706 else if (!memcmp(riid, &IID_IMonoDispatch, sizeof(GUID))) {
2710 return E_NOINTERFACE;
2713 int STDCALL MonoAddRef(MonoComObject* pUnk)
2715 return ++(pUnk->m_ref);
2718 int STDCALL MonoRelease(MonoComObject* pUnk)
2720 return --(pUnk->m_ref);
2723 int STDCALL SByteIn(MonoComObject* pUnk, char a)
2728 int STDCALL ByteIn(MonoComObject* pUnk, unsigned char a)
2733 int STDCALL ShortIn(MonoComObject* pUnk, short a)
2738 int STDCALL UShortIn(MonoComObject* pUnk, unsigned short a)
2743 int STDCALL IntIn(MonoComObject* pUnk, int a)
2748 int STDCALL UIntIn(MonoComObject* pUnk, unsigned int a)
2753 int STDCALL LongIn(MonoComObject* pUnk, LONGLONG a)
2758 int STDCALL ULongIn(MonoComObject* pUnk, ULONGLONG a)
2763 int STDCALL FloatIn(MonoComObject* pUnk, float a)
2768 int STDCALL DoubleIn(MonoComObject* pUnk, double a)
2773 int STDCALL ITestIn(MonoComObject* pUnk, MonoComObject *pUnk2)
2778 int STDCALL ITestOut(MonoComObject* pUnk, MonoComObject* *ppUnk)
2783 int STDCALL get_ITest(MonoComObject* pUnk, MonoComObject* *ppUnk)
2788 static void create_com_object (MonoComObject** pOut)
2790 *pOut = g_new0 (MonoComObject, 1);
2791 (*pOut)->vtbl = g_new0 (MonoIUnknown, 1);
2794 (*pOut)->vtbl->QueryInterface = MonoQueryInterface;
2795 (*pOut)->vtbl->AddRef = MonoAddRef;
2796 (*pOut)->vtbl->Release = MonoRelease;
2797 (*pOut)->vtbl->SByteIn = SByteIn;
2798 (*pOut)->vtbl->ByteIn = ByteIn;
2799 (*pOut)->vtbl->ShortIn = ShortIn;
2800 (*pOut)->vtbl->UShortIn = UShortIn;
2801 (*pOut)->vtbl->IntIn = IntIn;
2802 (*pOut)->vtbl->UIntIn = UIntIn;
2803 (*pOut)->vtbl->LongIn = LongIn;
2804 (*pOut)->vtbl->ULongIn = ULongIn;
2805 (*pOut)->vtbl->FloatIn = FloatIn;
2806 (*pOut)->vtbl->DoubleIn = DoubleIn;
2807 (*pOut)->vtbl->ITestIn = ITestIn;
2808 (*pOut)->vtbl->ITestOut = ITestOut;
2809 (*pOut)->vtbl->get_ITest = get_ITest;
2812 static MonoComObject* same_object = NULL;
2815 mono_test_marshal_com_object_create(MonoComObject* *pUnk)
2817 create_com_object (pUnk);
2820 same_object = *pUnk;
2826 mono_test_marshal_com_object_same(MonoComObject* *pUnk)
2828 *pUnk = same_object;
2834 mono_test_marshal_com_object_destroy(MonoComObject *pUnk)
2836 int ref = --(pUnk->m_ref);
2844 mono_test_marshal_com_object_ref_count(MonoComObject *pUnk)
2850 mono_test_marshal_ccw_itest (MonoComObject *pUnk)
2853 MonoComObject* pTest;
2858 hr = pUnk->vtbl->SByteIn (pUnk, -100);
2861 hr = pUnk->vtbl->ByteIn (pUnk, 100);
2864 hr = pUnk->vtbl->ShortIn (pUnk, -100);
2867 hr = pUnk->vtbl->UShortIn (pUnk, 100);
2870 hr = pUnk->vtbl->IntIn (pUnk, -100);
2873 hr = pUnk->vtbl->UIntIn (pUnk, 100);
2876 hr = pUnk->vtbl->LongIn (pUnk, -100);
2879 hr = pUnk->vtbl->ULongIn (pUnk, 100);
2882 hr = pUnk->vtbl->FloatIn (pUnk, 3.14f);
2885 hr = pUnk->vtbl->DoubleIn (pUnk, 3.14);
2888 hr = pUnk->vtbl->ITestIn (pUnk, pUnk);
2891 hr = pUnk->vtbl->ITestOut (pUnk, &pTest);
2903 * mono_method_get_unmanaged_thunk tests
2906 #if defined(__GNUC__) && defined(__i386__) && (defined(__linux__) || defined (__APPLE__))
2907 #define ALIGN(size) __attribute__ ((aligned(size)))
2913 /* thunks.cs:TestStruct */
2914 typedef struct _TestStruct {
2916 double B ALIGN(8); /* align according to mono's struct layout */
2919 /* Searches for mono symbols in all loaded modules */
2921 lookup_mono_symbol (char *symbol_name)
2924 if (g_module_symbol (g_module_open (NULL, G_MODULE_BIND_LAZY), symbol_name, &symbol))
2931 * test_method_thunk:
2933 * @test_id: the test number
2934 * @test_method_handle: MonoMethod* of the C# test method
2935 * @create_object_method_handle: MonoMethod* of thunks.cs:Test.CreateObject
2938 test_method_thunk (int test_id, gpointer test_method_handle, gpointer create_object_method_handle)
2940 gpointer (*mono_method_get_unmanaged_thunk)(gpointer)
2941 = lookup_mono_symbol ("mono_method_get_unmanaged_thunk");
2943 gpointer (*mono_string_new_wrapper)(char *)
2944 = lookup_mono_symbol ("mono_string_new_wrapper");
2946 char* (*mono_string_to_utf8)(gpointer)
2947 = lookup_mono_symbol ("mono_string_to_utf8");
2949 gpointer (*mono_object_unbox)(gpointer)
2950 = lookup_mono_symbol ("mono_object_unbox");
2952 gpointer test_method, ex = NULL;
2953 gpointer (STDCALL *CreateObject)(gpointer*);
2956 if (!mono_method_get_unmanaged_thunk)
2959 test_method = mono_method_get_unmanaged_thunk (test_method_handle);
2963 CreateObject = mono_method_get_unmanaged_thunk (create_object_method_handle);
2971 /* thunks.cs:Test.Test0 */
2972 void (STDCALL *F)(gpointer*) = test_method;
2978 /* thunks.cs:Test.Test1 */
2979 int (STDCALL *F)(gpointer*) = test_method;
2986 /* thunks.cs:Test.Test2 */
2987 gpointer (STDCALL *F)(gpointer, gpointer*) = test_method;
2988 gpointer str = mono_string_new_wrapper ("foo");
2989 if (str != F (str, &ex))
2995 /* thunks.cs:Test.Test3 */
2996 gpointer (STDCALL *F)(gpointer, gpointer, gpointer*);
3001 obj = CreateObject (&ex);
3002 str = mono_string_new_wrapper ("bar");
3004 if (str != F (obj, str, &ex))
3010 /* thunks.cs:Test.Test4 */
3011 int (STDCALL *F)(gpointer, gpointer, int, gpointer*);
3016 obj = CreateObject (&ex);
3017 str = mono_string_new_wrapper ("bar");
3019 if (42 != F (obj, str, 42, &ex))
3026 /* thunks.cs:Test.Test5 */
3027 int (STDCALL *F)(gpointer, gpointer, int, gpointer*);
3032 obj = CreateObject (&ex);
3033 str = mono_string_new_wrapper ("bar");
3035 F (obj, str, 42, &ex);
3043 /* thunks.cs:Test.Test6 */
3044 int (STDCALL *F)(gpointer, guint8, gint16, gint32, gint64, float, double,
3045 gpointer, gpointer*);
3047 gpointer str = mono_string_new_wrapper ("Test6");
3051 obj = CreateObject (&ex);
3053 res = F (obj, 254, 32700, -245378, 6789600, 3.1415, 3.1415, str, &ex);
3064 /* thunks.cs:Test.Test7 */
3065 gint64 (STDCALL *F)(gpointer*) = test_method;
3066 if (F (&ex) != G_MAXINT64)
3072 /* thunks.cs:Test.Test8 */
3073 void (STDCALL *F)(guint8*, gint16*, gint32*, gint64*, float*, double*,
3074 gpointer*, gpointer*);
3086 F (&a1, &a2, &a3, &a4, &a5, &a6, &a7, &ex);
3094 (fabs (a5 - 3.1415) < 0.001) &&
3095 (fabs (a6 - 3.1415) < 0.001) &&
3096 strcmp (mono_string_to_utf8 (a7), "Test8") == 0))
3103 /* thunks.cs:Test.Test9 */
3104 void (STDCALL *F)(guint8*, gint16*, gint32*, gint64*, float*, double*,
3105 gpointer*, gpointer*);
3117 F (&a1, &a2, &a3, &a4, &a5, &a6, &a7, &ex);
3125 /* thunks.cs:Test.Test10 */
3126 void (STDCALL *F)(gpointer*, gpointer*);
3128 gpointer obj1, obj2;
3130 obj1 = obj2 = CreateObject (&ex);
3147 /* thunks.cs:TestStruct.Test0 */
3148 int (STDCALL *F)(gpointer*, gpointer*);
3154 obj = CreateObject (&ex);
3161 a1 = mono_object_unbox (obj);
3177 /* check whether the call was really by value */
3178 if (a1->A != 42 || a1->B != 3.1415)
3185 /* thunks.cs:TestStruct.Test1 */
3186 void (STDCALL *F)(gpointer, gpointer*);
3191 obj = CreateObject (&ex);
3198 a1 = mono_object_unbox (obj);
3211 if (!fabs (a1->B - 3.1415) < 0.001)
3218 /* thunks.cs:TestStruct.Test2 */
3219 gpointer (STDCALL *F)(gpointer*);
3233 a1 = mono_object_unbox (obj);
3238 if (!fabs (a1->B - 3.1415) < 0.001)
3245 /* thunks.cs:TestStruct.Test3 */
3246 void (STDCALL *F)(gpointer, gpointer*);
3251 obj = CreateObject (&ex);
3258 a1 = mono_object_unbox (obj);