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_puts_static (char *s)
151 printf ("TEST %s\n", s);
155 typedef int (*SimpleDelegate3) (int a, int b);
158 mono_invoke_delegate (SimpleDelegate3 delegate)
162 printf ("start invoke %p\n", delegate);
164 res = delegate (2, 3);
166 printf ("end invoke\n");
172 mono_test_marshal_char (short a1)
181 mono_test_empty_pinvoke (int i)
187 mono_test_marshal_bool_byref (int a, int *b, int c)
197 mono_test_marshal_array (int *a1)
201 for (i = 0; i < 50; i++)
208 mono_test_marshal_inout_array (int *a1)
212 for (i = 0; i < 50; i++) {
214 a1 [i] = 50 - a1 [i];
221 mono_test_marshal_inout_nonblittable_array (gunichar2 *a1)
225 for (i = 0; i < 10; i++) {
240 mono_test_return_vtype (int i)
253 mono_test_delegate_struct (void)
258 typedef char* (*ReturnStringDelegate) (const char *s);
261 mono_test_return_string (ReturnStringDelegate func)
265 printf ("mono_test_return_string\n");
269 printf ("got string: %s\n", res);
273 typedef int (*RefVTypeDelegate) (int a, simplestruct *ss, int b);
276 mono_test_ref_vtype (int a, simplestruct *ss, int b, RefVTypeDelegate func)
278 if (a == 1 && b == 2 && ss->a == 0 && ss->b == 1 && ss->c == 0 &&
279 !strcmp (ss->d, "TEST1")) {
285 return func (a, ss, b);
297 mono_test_marshal_delegate_struct (DelegateStruct ds)
299 return ds.func (ds.a);
303 mono_test_marshal_struct (simplestruct ss)
305 if (ss.a == 0 && ss.b == 1 && ss.c == 0 &&
306 !strcmp (ss.d, "TEST"))
324 mono_test_marshal_struct2 (simplestruct2 ss)
326 if (ss.a == 0 && ss.b == 1 && ss.c == 0 &&
327 !strcmp (ss.d, "TEST") &&
328 ss.e == 99 && ss.f == 1.5 && ss.g == 42 && ss.h == (guint64)123)
334 /* on HP some of the struct should be on the stack and not in registers */
336 mono_test_marshal_struct2_2 (int i, int j, int k, simplestruct2 ss)
338 if (i != 10 || j != 11 || k != 12)
340 if (ss.a == 0 && ss.b == 1 && ss.c == 0 &&
341 !strcmp (ss.d, "TEST") &&
342 ss.e == 99 && ss.f == 1.5 && ss.g == 42 && ss.h == (guint64)123)
349 mono_test_marshal_struct_array (simplestruct2 *ss)
351 if (! (ss[0].a == 0 && ss[0].b == 1 && ss[0].c == 0 &&
352 !strcmp (ss[0].d, "TEST") &&
353 ss[0].e == 99 && ss[0].f == 1.5 && ss[0].g == 42 && ss[0].h == (guint64)123))
356 if (! (ss[1].a == 0 && ss[1].b == 0 && ss[1].c == 0 &&
357 !strcmp (ss[1].d, "TEST2") &&
358 ss[1].e == 100 && ss[1].f == 2.5 && ss[1].g == 43 && ss[1].h == (guint64)124))
365 mono_test_marshal_class (int i, int j, int k, simplestruct2 *ss, int l)
372 if (i != 10 || j != 11 || k != 12 || l != 14)
374 if (! (ss->a == 0 && ss->b == 1 && ss->c == 0 &&
375 !strcmp (ss->d, "TEST") &&
376 ss->e == 99 && ss->f == 1.5 && ss->g == 42 && ss->h == (guint64)123))
379 res = g_new0 (simplestruct2, 1);
380 memcpy (res, ss, sizeof (simplestruct2));
385 mono_test_marshal_byref_class (simplestruct2 **ssp)
387 simplestruct2 *ss = *ssp;
390 if (! (ss->a == 0 && ss->b == 1 && ss->c == 0 &&
391 !strcmp (ss->d, "TEST") &&
392 ss->e == 99 && ss->f == 1.5 && ss->g == 42 && ss->h == (guint64)123))
395 res = g_new0 (simplestruct2, 1);
396 memcpy (res, ss, sizeof (simplestruct2));
397 res->d = (char*)"TEST-RES";
404 typedef int (__stdcall *SimpleDelegate) (int a);
406 typedef int (*SimpleDelegate) (int a);
420 mono_test_marshal_delegate (SimpleDelegate delegate)
424 /* Check that the delegate wrapper is stdcall */
429 g_assert (sp1 == sp2);
434 typedef simplestruct (*SimpleDelegate2) (simplestruct ss);
437 mono_test_marshal_delegate2 (SimpleDelegate2 delegate)
439 simplestruct ss, res;
447 if (! (res.a && !res.b && res.c && !strcmp (res.d, "TEST-RES")))
453 typedef simplestruct* (*SimpleDelegate4) (simplestruct *ss);
456 mono_test_marshal_delegate4 (SimpleDelegate4 delegate)
467 res = delegate (&ss);
471 /* Check return value */
472 if (! (!res->a && res->b && !res->c && !strcmp (res->d, "TEST")))
475 /* Check NULL argument and NULL result */
476 res = delegate (NULL);
483 typedef int (*SimpleDelegate5) (simplestruct **ss);
486 mono_test_marshal_delegate5 (SimpleDelegate5 delegate)
499 res = delegate (&ptr);
503 if (!(ptr->a && !ptr->b && ptr->c && !strcmp (ptr->d, "RES")))
510 mono_test_marshal_delegate6 (SimpleDelegate5 delegate)
514 res = delegate (NULL);
519 typedef int (*SimpleDelegate7) (simplestruct **ss);
522 mono_test_marshal_delegate7 (SimpleDelegate7 delegate)
527 /* Check that the input pointer is ignored */
528 ptr = (gpointer)0x12345678;
530 res = delegate (&ptr);
534 if (!(ptr->a && !ptr->b && ptr->c && !strcmp (ptr->d, "RES")))
541 mono_test_marshal_stringbuilder (char *s, int n)
543 const char m[] = "This is my message. Isn't it nice?";
555 mono_test_marshal_string_array (char **array)
557 printf ("%p\n", array);
561 /* this does not work on Redhat gcc 2.96 */
563 mono_test_empty_struct (int a, EmptyStruct es, int b)
565 printf ("mono_test_empty_struct %d %d\n", a, b);
567 if (a == 1 && b == 2)
577 mono_test_byvalstr_gen (void)
581 ret = malloc(sizeof(ByValStrStruct));
582 memset(ret, 'a', sizeof(ByValStrStruct)-1);
583 ret->a[sizeof(ByValStrStruct)-1] = 0;
589 mono_test_byvalstr_check (ByValStrStruct* data, char* correctString)
593 ret = strcmp(data->a, correctString);
594 printf ("T1: %s\n", data->a);
595 printf ("T2: %s\n", correctString);
607 printf ("HEXDUMP DEFAULT VERSION\n");
610 for (i=0; i < 8; ++i)
613 printf("%0x ", (int) *(p++));
626 printf ("HEXDUMP ANSI VERSION\n");
629 for (i=0; i < 8; ++i)
632 printf("%0x ", (int) *(p++));
640 HexDump1W(char *data)
645 printf ("HEXDUMP UNICODE VERSION\n");
648 for (i=0; i < 8; ++i)
651 printf("%0x ", (int) *(p++));
655 return res + 1000000;
658 typedef int (*intcharFunc)(const char*);
661 callFunction (intcharFunc f)
667 printInt (int* number)
669 printf( "<%d>\n", *number );
680 class_marshal_test0 (SimpleObj *obj1)
682 printf ("class_marshal_test0 %s %d\n", obj1->str, obj1->i);
684 if (strcmp(obj1->str, "T1"))
693 class_marshal_test4 (SimpleObj *obj1)
702 class_marshal_test1 (SimpleObj **obj1)
704 SimpleObj *res = malloc (sizeof (SimpleObj));
713 class_marshal_test2 (SimpleObj **obj1)
715 printf ("class_marshal_test2 %s %d\n", (*obj1)->str, (*obj1)->i);
717 if (strcmp((*obj1)->str, "ABC"))
726 string_marshal_test0 (char *str)
728 if (strcmp (str, "TEST0"))
735 string_marshal_test1 (const char **str)
741 string_marshal_test2 (char **str)
743 printf ("string_marshal_test2 %s\n", *str);
745 if (strcmp (*str, "TEST1"))
752 string_marshal_test3 (char *str)
761 functionReturningString (void)
772 VectorList* TestVectorList (VectorList *vl)
774 printf ("TestVectorList %d %d\n", vl->a, vl->b);
783 typedef struct _OSVERSIONINFO
790 GetVersionEx (OSVERSIONINFO *osvi)
793 printf ("GOT %d %d\n", osvi->a, osvi->b);
798 return osvi->a + osvi->b;
802 BugGetVersionEx (int a, int b, int c, int d, int e, int f, int g, int h, OSVERSIONINFO *osvi)
805 printf ("GOT %d %d\n", osvi->a, osvi->b);
810 return osvi->a + osvi->b;
819 mono_test_marshal_point (point pt)
821 printf("point %g %g\n", pt.x, pt.y);
822 if (pt.x == 1.25 && pt.y == 3.5)
834 mono_test_marshal_mixed_point (mixed_point pt)
836 printf("mixed point %d %g\n", pt.x, pt.y);
837 if (pt.x == 5 && pt.y == 6.75)
844 marshal_test_ref_bool(int i, char *b1, short *b2, int *b3)
847 if (*b1 != 0 && *b1 != 1)
849 if (*b2 != 0 && *b2 != -1) /* variant_bool */
851 if (*b3 != 0 && *b3 != 1)
853 if (i == ((*b1 << 2) | (-*b2 << 1) | *b3))
865 short b2; /* variant_bool */
870 marshal_test_bool_struct(struct BoolStruct *s)
873 if (s->b1 != 0 && s->b1 != 1)
875 if (s->b2 != 0 && s->b2 != -1)
877 if (s->b3 != 0 && s->b3 != 1)
879 if (s->i == ((s->b1 << 2) | (-s->b2 << 1) | s->b3))
888 mono_test_last_error (int err)