9 test_lpwstr_marshal (unsigned short* chars, long length)
14 res = malloc (2 * (length + 1));
16 printf("test_lpwstr_marshal()\n");
18 while ( i < length ) {
19 printf("X|%u|\n", chars[i]);
35 int mono_union_test_1 (union_test_1_type u1) {
36 printf ("Got values %d %d %d\n", u1.b, u1.a, u1.c);
37 return u1.a + u1.b + u1.c;
40 int mono_return_int (int a) {
41 printf ("Got value %d\n", a);
50 int mono_return_int_ss (struct ss a) {
51 printf ("Got value %d\n", a.i);
55 struct ss mono_return_ss (struct ss a) {
56 printf ("Got value %d\n", a.i);
66 struct sc1 mono_return_sc1 (struct sc1 a) {
67 printf ("Got value %d\n", a.c[0]);
78 struct sc3 mono_return_sc3 (struct sc3 a) {
79 printf ("Got values %d %d %d\n", a.c[0], a.c[1], a.c[2]);
91 struct sc5 mono_return_sc5 (struct sc5 a) {
92 printf ("Got values %d %d %d %d %d\n", a.c[0], a.c[1], a.c[2], a.c[3], a.c[4]);
107 int mono_return_int_su (union su a) {
108 printf ("Got value %d\n", a.i1);
112 int mono_test_many_int_arguments (int a, int b, int c, int d, int e,
113 int f, int g, int h, int i, int j);
114 short mono_test_many_short_arguments (short a, short b, short c, short d, short e,
115 short f, short g, short h, short i, short j);
116 char mono_test_many_char_arguments (char a, char b, char c, char d, char e,
117 char f, char g, char h, char i, char j);
120 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)
122 return a + b + c + d + e + f + g + h + i + j;
126 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)
128 return a + b + c + d + e + f + g + h + i + j;
132 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)
134 return a + b + c + d + e + f + g + h + i + j;
138 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)
140 return a + b + c + d + e + f + g + h + i + j;
144 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)
146 return a + b + c + d + e + f + g + h + i + j;
150 mono_test_split_double_arguments (double a, double b, float c, double d, double e)
152 return a + b + c + d + e;
156 mono_test_puts_static (char *s)
158 printf ("TEST %s\n", s);
162 typedef int (*SimpleDelegate3) (int a, int b);
165 mono_invoke_delegate (SimpleDelegate3 delegate)
169 printf ("start invoke %p\n", delegate);
171 res = delegate (2, 3);
173 printf ("end invoke\n");
179 mono_test_marshal_char (short a1)
188 mono_test_empty_pinvoke (int i)
194 mono_test_marshal_bool_byref (int a, int *b, int c)
204 mono_test_marshal_array (int *a1)
208 for (i = 0; i < 50; i++)
215 mono_test_marshal_inout_array (int *a1)
219 for (i = 0; i < 50; i++) {
221 a1 [i] = 50 - a1 [i];
228 mono_test_marshal_inout_nonblittable_array (gunichar2 *a1)
232 for (i = 0; i < 10; i++) {
247 mono_test_return_vtype (int i)
260 mono_test_delegate_struct (void)
265 typedef char* (*ReturnStringDelegate) (const char *s);
268 mono_test_return_string (ReturnStringDelegate func)
272 printf ("mono_test_return_string\n");
276 printf ("got string: %s\n", res);
280 typedef int (*RefVTypeDelegate) (int a, simplestruct *ss, int b);
283 mono_test_ref_vtype (int a, simplestruct *ss, int b, RefVTypeDelegate func)
285 if (a == 1 && b == 2 && ss->a == 0 && ss->b == 1 && ss->c == 0 &&
286 !strcmp (ss->d, "TEST1")) {
292 return func (a, ss, b);
304 mono_test_marshal_delegate_struct (DelegateStruct ds)
306 return ds.func (ds.a);
310 mono_test_marshal_struct (simplestruct ss)
312 if (ss.a == 0 && ss.b == 1 && ss.c == 0 &&
313 !strcmp (ss.d, "TEST"))
331 mono_test_marshal_struct2 (simplestruct2 ss)
333 if (ss.a == 0 && ss.b == 1 && ss.c == 0 &&
334 !strcmp (ss.d, "TEST") &&
335 ss.e == 99 && ss.f == 1.5 && ss.g == 42 && ss.h == (guint64)123)
341 /* on HP some of the struct should be on the stack and not in registers */
343 mono_test_marshal_struct2_2 (int i, int j, int k, simplestruct2 ss)
345 if (i != 10 || j != 11 || k != 12)
347 if (ss.a == 0 && ss.b == 1 && ss.c == 0 &&
348 !strcmp (ss.d, "TEST") &&
349 ss.e == 99 && ss.f == 1.5 && ss.g == 42 && ss.h == (guint64)123)
356 mono_test_marshal_struct_array (simplestruct2 *ss)
358 if (! (ss[0].a == 0 && ss[0].b == 1 && ss[0].c == 0 &&
359 !strcmp (ss[0].d, "TEST") &&
360 ss[0].e == 99 && ss[0].f == 1.5 && ss[0].g == 42 && ss[0].h == (guint64)123))
363 if (! (ss[1].a == 0 && ss[1].b == 0 && ss[1].c == 0 &&
364 !strcmp (ss[1].d, "TEST2") &&
365 ss[1].e == 100 && ss[1].f == 2.5 && ss[1].g == 43 && ss[1].h == (guint64)124))
372 mono_test_marshal_class (int i, int j, int k, simplestruct2 *ss, int l)
379 if (i != 10 || j != 11 || k != 12 || l != 14)
381 if (! (ss->a == 0 && ss->b == 1 && ss->c == 0 &&
382 !strcmp (ss->d, "TEST") &&
383 ss->e == 99 && ss->f == 1.5 && ss->g == 42 && ss->h == (guint64)123))
386 res = g_new0 (simplestruct2, 1);
387 memcpy (res, ss, sizeof (simplestruct2));
392 mono_test_marshal_byref_class (simplestruct2 **ssp)
394 simplestruct2 *ss = *ssp;
397 if (! (ss->a == 0 && ss->b == 1 && ss->c == 0 &&
398 !strcmp (ss->d, "TEST") &&
399 ss->e == 99 && ss->f == 1.5 && ss->g == 42 && ss->h == (guint64)123))
402 res = g_new0 (simplestruct2, 1);
403 memcpy (res, ss, sizeof (simplestruct2));
404 res->d = (char*)"TEST-RES";
411 typedef int (__stdcall *SimpleDelegate) (int a);
413 typedef int (*SimpleDelegate) (int a);
427 mono_test_marshal_delegate (SimpleDelegate delegate)
431 /* Check that the delegate wrapper is stdcall */
436 g_assert (sp1 == sp2);
441 typedef simplestruct (*SimpleDelegate2) (simplestruct ss);
444 mono_test_marshal_delegate2 (SimpleDelegate2 delegate)
446 simplestruct ss, res;
454 if (! (res.a && !res.b && res.c && !strcmp (res.d, "TEST-RES")))
460 typedef simplestruct* (*SimpleDelegate4) (simplestruct *ss);
463 mono_test_marshal_delegate4 (SimpleDelegate4 delegate)
474 res = delegate (&ss);
478 /* Check return value */
479 if (! (!res->a && res->b && !res->c && !strcmp (res->d, "TEST")))
482 /* Check NULL argument and NULL result */
483 res = delegate (NULL);
490 typedef int (*SimpleDelegate5) (simplestruct **ss);
493 mono_test_marshal_delegate5 (SimpleDelegate5 delegate)
506 res = delegate (&ptr);
510 if (!(ptr->a && !ptr->b && ptr->c && !strcmp (ptr->d, "RES")))
517 mono_test_marshal_delegate6 (SimpleDelegate5 delegate)
521 res = delegate (NULL);
526 typedef int (*SimpleDelegate7) (simplestruct **ss);
529 mono_test_marshal_delegate7 (SimpleDelegate7 delegate)
534 /* Check that the input pointer is ignored */
535 ptr = (gpointer)0x12345678;
537 res = delegate (&ptr);
541 if (!(ptr->a && !ptr->b && ptr->c && !strcmp (ptr->d, "RES")))
548 mono_test_marshal_stringbuilder (char *s, int n)
550 const char m[] = "This is my message. Isn't it nice?";
556 mono_test_marshal_stringbuilder_unicode (gunichar2 *s, int n)
558 const char m[] = "This is my message. Isn't it nice?";
562 s2 = g_utf8_to_utf16 (m, -1, NULL, &len, NULL);
581 mono_test_marshal_string_array (char **array)
583 printf ("%p\n", array);
587 /* this does not work on Redhat gcc 2.96 */
589 mono_test_empty_struct (int a, EmptyStruct es, int b)
591 printf ("mono_test_empty_struct %d %d\n", a, b);
593 if (a == 1 && b == 2)
603 mono_test_byvalstr_gen (void)
607 ret = malloc(sizeof(ByValStrStruct));
608 memset(ret, 'a', sizeof(ByValStrStruct)-1);
609 ret->a[sizeof(ByValStrStruct)-1] = 0;
615 mono_test_byvalstr_check (ByValStrStruct* data, char* correctString)
619 ret = strcmp(data->a, correctString);
620 printf ("T1: %s\n", data->a);
621 printf ("T2: %s\n", correctString);
633 printf ("HEXDUMP DEFAULT VERSION\n");
636 for (i=0; i < 8; ++i)
639 printf("%0x ", (int) *(p++));
652 printf ("HEXDUMP ANSI VERSION\n");
655 for (i=0; i < 8; ++i)
658 printf("%0x ", (int) *(p++));
666 HexDump1W(char *data)
671 printf ("HEXDUMP UNICODE VERSION\n");
674 for (i=0; i < 8; ++i)
677 printf("%0x ", (int) *(p++));
681 return res + 1000000;
684 typedef int (*intcharFunc)(const char*);
687 callFunction (intcharFunc f)
693 printInt (int* number)
695 printf( "<%d>\n", *number );
706 class_marshal_test0 (SimpleObj *obj1)
708 printf ("class_marshal_test0 %s %d\n", obj1->str, obj1->i);
710 if (strcmp(obj1->str, "T1"))
719 class_marshal_test4 (SimpleObj *obj1)
728 class_marshal_test1 (SimpleObj **obj1)
730 SimpleObj *res = malloc (sizeof (SimpleObj));
739 class_marshal_test2 (SimpleObj **obj1)
741 printf ("class_marshal_test2 %s %d\n", (*obj1)->str, (*obj1)->i);
743 if (strcmp((*obj1)->str, "ABC"))
752 string_marshal_test0 (char *str)
754 if (strcmp (str, "TEST0"))
761 string_marshal_test1 (const char **str)
767 string_marshal_test2 (char **str)
769 printf ("string_marshal_test2 %s\n", *str);
771 if (strcmp (*str, "TEST1"))
778 string_marshal_test3 (char *str)
787 functionReturningString (void)
798 VectorList* TestVectorList (VectorList *vl)
800 printf ("TestVectorList %d %d\n", vl->a, vl->b);
809 typedef struct _OSVERSIONINFO
816 GetVersionEx (OSVERSIONINFO *osvi)
819 printf ("GOT %d %d\n", osvi->a, osvi->b);
824 return osvi->a + osvi->b;
828 BugGetVersionEx (int a, int b, int c, int d, int e, int f, int g, int h, OSVERSIONINFO *osvi)
831 printf ("GOT %d %d\n", osvi->a, osvi->b);
836 return osvi->a + osvi->b;
845 mono_test_marshal_point (point pt)
847 printf("point %g %g\n", pt.x, pt.y);
848 if (pt.x == 1.25 && pt.y == 3.5)
860 mono_test_marshal_mixed_point (mixed_point pt)
862 printf("mixed point %d %g\n", pt.x, pt.y);
863 if (pt.x == 5 && pt.y == 6.75)
872 return sizeof (time_t);
876 mono_test_marshal_time_t (time_t *t)
878 /* Skip forward an hour */
883 marshal_test_ref_bool(int i, char *b1, short *b2, int *b3)
886 if (*b1 != 0 && *b1 != 1)
888 if (*b2 != 0 && *b2 != -1) /* variant_bool */
890 if (*b3 != 0 && *b3 != 1)
892 if (i == ((*b1 << 2) | (-*b2 << 1) | *b3))
904 short b2; /* variant_bool */
909 marshal_test_bool_struct(struct BoolStruct *s)
912 if (s->b1 != 0 && s->b1 != 1)
914 if (s->b2 != 0 && s->b2 != -1)
916 if (s->b3 != 0 && s->b3 != 1)
918 if (s->i == ((s->b1 << 2) | (-s->b2 << 1) | s->b3))
927 mono_test_last_error (int err)