8 test_lpwstr_marshal (unsigned short* chars, long length)
13 res = malloc (2 * (length + 1));
15 printf("test_lpwstr_marshal()\n");
17 while ( i < length ) {
18 printf("X|%u|\n", chars[i]);
34 int mono_union_test_1 (union_test_1_type u1) {
35 printf ("Got values %d %d %d\n", u1.b, u1.a, u1.c);
36 return u1.a + u1.b + u1.c;
39 int mono_return_int (int a) {
40 printf ("Got value %d\n", a);
49 int mono_return_int_ss (struct ss a) {
50 printf ("Got value %d\n", a.i);
54 struct ss mono_return_ss (struct ss a) {
55 printf ("Got value %d\n", a.i);
65 struct sc1 mono_return_sc1 (struct sc1 a) {
66 printf ("Got value %d\n", a.c[0]);
77 struct sc3 mono_return_sc3 (struct sc3 a) {
78 printf ("Got values %d %d %d\n", a.c[0], a.c[1], a.c[2]);
90 struct sc5 mono_return_sc5 (struct sc5 a) {
91 printf ("Got values %d %d %d %d %d\n", a.c[0], a.c[1], a.c[2], a.c[3], a.c[4]);
106 int mono_return_int_su (union su a) {
107 printf ("Got value %d\n", a.i1);
111 int mono_test_many_int_arguments (int a, int b, int c, int d, int e,
112 int f, int g, int h, int i, int j);
113 short mono_test_many_short_arguments (short a, short b, short c, short d, short e,
114 short f, short g, short h, short i, short j);
115 char mono_test_many_char_arguments (char a, char b, char c, char d, char e,
116 char f, char g, char h, char i, char j);
119 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)
121 return a + b + c + d + e + f + g + h + i + j;
125 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)
127 return a + b + c + d + e + f + g + h + i + j;
131 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)
133 return a + b + c + d + e + f + g + h + i + j;
137 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)
139 return a + b + c + d + e + f + g + h + i + j;
143 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)
145 return a + b + c + d + e + f + g + h + i + j;
149 mono_test_split_double_arguments (double a, double b, float c, double d, double e)
151 return a + b + c + d + e;
155 mono_test_puts_static (char *s)
157 printf ("TEST %s\n", s);
161 typedef int (*SimpleDelegate3) (int a, int b);
164 mono_invoke_delegate (SimpleDelegate3 delegate)
168 printf ("start invoke %p\n", delegate);
170 res = delegate (2, 3);
172 printf ("end invoke\n");
178 mono_test_marshal_char (short a1)
187 mono_test_empty_pinvoke (int i)
193 mono_test_marshal_bool_byref (int a, int *b, int c)
203 mono_test_marshal_array (int *a1)
207 for (i = 0; i < 50; i++)
214 mono_test_marshal_inout_array (int *a1)
218 for (i = 0; i < 50; i++) {
220 a1 [i] = 50 - a1 [i];
227 mono_test_marshal_inout_nonblittable_array (gunichar2 *a1)
231 for (i = 0; i < 10; i++) {
246 mono_test_return_vtype (int i)
259 mono_test_delegate_struct (void)
264 typedef char* (*ReturnStringDelegate) (const char *s);
267 mono_test_return_string (ReturnStringDelegate func)
271 printf ("mono_test_return_string\n");
275 printf ("got string: %s\n", res);
279 typedef int (*RefVTypeDelegate) (int a, simplestruct *ss, int b);
282 mono_test_ref_vtype (int a, simplestruct *ss, int b, RefVTypeDelegate func)
284 if (a == 1 && b == 2 && ss->a == 0 && ss->b == 1 && ss->c == 0 &&
285 !strcmp (ss->d, "TEST1")) {
291 return func (a, ss, b);
303 mono_test_marshal_delegate_struct (DelegateStruct ds)
305 return ds.func (ds.a);
309 mono_test_marshal_struct (simplestruct ss)
311 if (ss.a == 0 && ss.b == 1 && ss.c == 0 &&
312 !strcmp (ss.d, "TEST"))
330 mono_test_marshal_struct2 (simplestruct2 ss)
332 if (ss.a == 0 && ss.b == 1 && ss.c == 0 &&
333 !strcmp (ss.d, "TEST") &&
334 ss.e == 99 && ss.f == 1.5 && ss.g == 42 && ss.h == (guint64)123)
340 /* on HP some of the struct should be on the stack and not in registers */
342 mono_test_marshal_struct2_2 (int i, int j, int k, simplestruct2 ss)
344 if (i != 10 || j != 11 || k != 12)
346 if (ss.a == 0 && ss.b == 1 && ss.c == 0 &&
347 !strcmp (ss.d, "TEST") &&
348 ss.e == 99 && ss.f == 1.5 && ss.g == 42 && ss.h == (guint64)123)
355 mono_test_marshal_struct_array (simplestruct2 *ss)
357 if (! (ss[0].a == 0 && ss[0].b == 1 && ss[0].c == 0 &&
358 !strcmp (ss[0].d, "TEST") &&
359 ss[0].e == 99 && ss[0].f == 1.5 && ss[0].g == 42 && ss[0].h == (guint64)123))
362 if (! (ss[1].a == 0 && ss[1].b == 0 && ss[1].c == 0 &&
363 !strcmp (ss[1].d, "TEST2") &&
364 ss[1].e == 100 && ss[1].f == 2.5 && ss[1].g == 43 && ss[1].h == (guint64)124))
371 mono_test_marshal_class (int i, int j, int k, simplestruct2 *ss, int l)
378 if (i != 10 || j != 11 || k != 12 || l != 14)
380 if (! (ss->a == 0 && ss->b == 1 && ss->c == 0 &&
381 !strcmp (ss->d, "TEST") &&
382 ss->e == 99 && ss->f == 1.5 && ss->g == 42 && ss->h == (guint64)123))
385 res = g_new0 (simplestruct2, 1);
386 memcpy (res, ss, sizeof (simplestruct2));
391 mono_test_marshal_byref_class (simplestruct2 **ssp)
393 simplestruct2 *ss = *ssp;
396 if (! (ss->a == 0 && ss->b == 1 && ss->c == 0 &&
397 !strcmp (ss->d, "TEST") &&
398 ss->e == 99 && ss->f == 1.5 && ss->g == 42 && ss->h == (guint64)123))
401 res = g_new0 (simplestruct2, 1);
402 memcpy (res, ss, sizeof (simplestruct2));
403 res->d = (char*)"TEST-RES";
410 typedef int (__stdcall *SimpleDelegate) (int a);
412 typedef int (*SimpleDelegate) (int a);
426 mono_test_marshal_delegate (SimpleDelegate delegate)
430 /* Check that the delegate wrapper is stdcall */
435 g_assert (sp1 == sp2);
440 typedef simplestruct (*SimpleDelegate2) (simplestruct ss);
443 mono_test_marshal_delegate2 (SimpleDelegate2 delegate)
445 simplestruct ss, res;
453 if (! (res.a && !res.b && res.c && !strcmp (res.d, "TEST-RES")))
459 typedef simplestruct* (*SimpleDelegate4) (simplestruct *ss);
462 mono_test_marshal_delegate4 (SimpleDelegate4 delegate)
473 res = delegate (&ss);
477 /* Check return value */
478 if (! (!res->a && res->b && !res->c && !strcmp (res->d, "TEST")))
481 /* Check NULL argument and NULL result */
482 res = delegate (NULL);
489 typedef int (*SimpleDelegate5) (simplestruct **ss);
492 mono_test_marshal_delegate5 (SimpleDelegate5 delegate)
505 res = delegate (&ptr);
509 if (!(ptr->a && !ptr->b && ptr->c && !strcmp (ptr->d, "RES")))
516 mono_test_marshal_delegate6 (SimpleDelegate5 delegate)
520 res = delegate (NULL);
525 typedef int (*SimpleDelegate7) (simplestruct **ss);
528 mono_test_marshal_delegate7 (SimpleDelegate7 delegate)
533 /* Check that the input pointer is ignored */
534 ptr = (gpointer)0x12345678;
536 res = delegate (&ptr);
540 if (!(ptr->a && !ptr->b && ptr->c && !strcmp (ptr->d, "RES")))
547 mono_test_marshal_stringbuilder (char *s, int n)
549 const char m[] = "This is my message. Isn't it nice?";
561 mono_test_marshal_string_array (char **array)
563 printf ("%p\n", array);
567 /* this does not work on Redhat gcc 2.96 */
569 mono_test_empty_struct (int a, EmptyStruct es, int b)
571 printf ("mono_test_empty_struct %d %d\n", a, b);
573 if (a == 1 && b == 2)
583 mono_test_byvalstr_gen (void)
587 ret = malloc(sizeof(ByValStrStruct));
588 memset(ret, 'a', sizeof(ByValStrStruct)-1);
589 ret->a[sizeof(ByValStrStruct)-1] = 0;
595 mono_test_byvalstr_check (ByValStrStruct* data, char* correctString)
599 ret = strcmp(data->a, correctString);
600 printf ("T1: %s\n", data->a);
601 printf ("T2: %s\n", correctString);
613 printf ("HEXDUMP DEFAULT VERSION\n");
616 for (i=0; i < 8; ++i)
619 printf("%0x ", (int) *(p++));
632 printf ("HEXDUMP ANSI VERSION\n");
635 for (i=0; i < 8; ++i)
638 printf("%0x ", (int) *(p++));
646 HexDump1W(char *data)
651 printf ("HEXDUMP UNICODE VERSION\n");
654 for (i=0; i < 8; ++i)
657 printf("%0x ", (int) *(p++));
661 return res + 1000000;
664 typedef int (*intcharFunc)(const char*);
667 callFunction (intcharFunc f)
673 printInt (int* number)
675 printf( "<%d>\n", *number );
686 class_marshal_test0 (SimpleObj *obj1)
688 printf ("class_marshal_test0 %s %d\n", obj1->str, obj1->i);
690 if (strcmp(obj1->str, "T1"))
699 class_marshal_test4 (SimpleObj *obj1)
708 class_marshal_test1 (SimpleObj **obj1)
710 SimpleObj *res = malloc (sizeof (SimpleObj));
719 class_marshal_test2 (SimpleObj **obj1)
721 printf ("class_marshal_test2 %s %d\n", (*obj1)->str, (*obj1)->i);
723 if (strcmp((*obj1)->str, "ABC"))
732 string_marshal_test0 (char *str)
734 if (strcmp (str, "TEST0"))
741 string_marshal_test1 (const char **str)
747 string_marshal_test2 (char **str)
749 printf ("string_marshal_test2 %s\n", *str);
751 if (strcmp (*str, "TEST1"))
758 string_marshal_test3 (char *str)
767 functionReturningString (void)
778 VectorList* TestVectorList (VectorList *vl)
780 printf ("TestVectorList %d %d\n", vl->a, vl->b);
789 typedef struct _OSVERSIONINFO
796 GetVersionEx (OSVERSIONINFO *osvi)
799 printf ("GOT %d %d\n", osvi->a, osvi->b);
804 return osvi->a + osvi->b;
808 BugGetVersionEx (int a, int b, int c, int d, int e, int f, int g, int h, OSVERSIONINFO *osvi)
811 printf ("GOT %d %d\n", osvi->a, osvi->b);
816 return osvi->a + osvi->b;
825 mono_test_marshal_point (point pt)
827 printf("point %g %g\n", pt.x, pt.y);
828 if (pt.x == 1.25 && pt.y == 3.5)
840 mono_test_marshal_mixed_point (mixed_point pt)
842 printf("mixed point %d %g\n", pt.x, pt.y);
843 if (pt.x == 5 && pt.y == 6.75)
850 marshal_test_ref_bool(int i, char *b1, short *b2, int *b3)
853 if (*b1 != 0 && *b1 != 1)
855 if (*b2 != 0 && *b2 != -1) /* variant_bool */
857 if (*b3 != 0 && *b3 != 1)
859 if (i == ((*b1 << 2) | (-*b2 << 1) | *b3))
871 short b2; /* variant_bool */
876 marshal_test_bool_struct(struct BoolStruct *s)
879 if (s->b1 != 0 && s->b1 != 1)
881 if (s->b2 != 0 && s->b2 != -1)
883 if (s->b3 != 0 && s->b3 != 1)
885 if (s->i == ((s->b1 << 2) | (-s->b2 << 1) | s->b3))
894 mono_test_last_error (int err)