7 test_lpwstr_marshal (unsigned short* chars, long length)
12 res = malloc (2 * (length + 1));
14 printf("test_lpwstr_marshal()\n");
16 while ( i < length ) {
17 printf("X|%u|\n", chars[i]);
33 int mono_union_test_1 (union_test_1_type u1) {
34 printf ("Got values %d %d %d\n", u1.b, u1.a, u1.c);
35 return u1.a + u1.b + u1.c;
38 int mono_return_int (int a) {
39 printf ("Got value %d\n", a);
48 int mono_return_int_ss (struct ss a) {
49 printf ("Got value %d\n", a.i);
53 struct ss mono_return_ss (struct ss a) {
54 printf ("Got value %d\n", a.i);
64 struct sc1 mono_return_sc1 (struct sc1 a) {
65 printf ("Got value %d\n", a.c[0]);
76 struct sc3 mono_return_sc3 (struct sc3 a) {
77 printf ("Got values %d %d %d\n", a.c[0], a.c[1], a.c[2]);
89 struct sc5 mono_return_sc5 (struct sc5 a) {
90 printf ("Got values %d %d %d\n", a.c[0], a.c[1], a.c[2], a.c[3], a.c[4]);
105 int mono_return_int_su (union su a) {
106 printf ("Got value %d\n", a.i1);
110 int mono_test_many_int_arguments (int a, int b, int c, int d, int e,
111 int f, int g, int h, int i, int j);
112 short mono_test_many_short_arguments (short a, short b, short c, short d, short e,
113 short f, short g, short h, short i, short j);
114 char mono_test_many_char_arguments (char a, char b, char c, char d, char e,
115 char f, char g, char h, char i, char j);
118 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)
120 return a + b + c + d + e + f + g + h + i + j;
124 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)
126 return a + b + c + d + e + f + g + h + i + j;
130 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)
132 return a + b + c + d + e + f + g + h + i + j;
136 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)
138 return a + b + c + d + e + f + g + h + i + j;
142 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)
144 return a + b + c + d + e + f + g + h + i + j;
148 mono_test_puts_static (char *s)
150 printf ("TEST %s\n", s);
154 typedef int (*SimpleDelegate3) (int a, int b);
157 mono_invoke_delegate (SimpleDelegate3 delegate)
161 printf ("start invoke %p\n", delegate);
163 res = delegate (2, 3);
165 printf ("end invoke\n");
171 mono_test_marshal_char (short a1)
180 mono_test_marshal_array (int *a1)
184 for (i = 0; i < 50; i++)
198 mono_test_return_vtype (void)
206 printf ("mono_test_return_vtype\n");
211 mono_test_delegate_struct (void)
216 typedef simplestruct (*ReturnVTypeDelegate) (simplestruct ss);
219 mono_test_return_vtype2 (ReturnVTypeDelegate func)
228 printf ("mono_test_return_vtype2\n");
232 printf ("UA: %d\n", res1.a);
233 printf ("UB: %d\n", res1.b);
234 printf ("UC: %d\n", res1.c);
235 printf ("UD: %s\n", res1.d);
240 typedef char* (*ReturnStringDelegate) (const char *s);
243 mono_test_return_string (ReturnStringDelegate func)
247 printf ("mono_test_return_string\n");
251 printf ("got string: %s\n", res);
255 typedef int (*RefVTypeDelegate) (int a, simplestruct *ss, int b);
258 mono_test_ref_vtype (int a, simplestruct *ss, int b, RefVTypeDelegate func)
260 if (a == 1 && b == 2 && ss->a == 0 && ss->b == 1 && ss->c == 0 &&
261 !strcmp (ss->d, "TEST1")) {
267 return func (a, ss, b);
279 mono_test_marshal_delegate_struct (DelegateStruct ds)
281 return ds.func (ds.a);
285 mono_test_marshal_struct (simplestruct ss)
287 if (ss.a == 0 && ss.b == 1 && ss.c == 0 &&
288 !strcmp (ss.d, "TEST"))
306 mono_test_marshal_struct2 (simplestruct2 ss)
308 if (ss.a == 0 && ss.b == 1 && ss.c == 0 &&
309 !strcmp (ss.d, "TEST") &&
310 ss.e == 99 && ss.f == 1.5 && ss.g == 42 && ss.h == (guint64)123)
316 /* on HP some of the struct should be on the stack and not in registers */
318 mono_test_marshal_struct2_2 (int i, int j, int k, simplestruct2 ss)
320 if (i != 10 || j != 11 || k != 12)
322 if (ss.a == 0 && ss.b == 0 && ss.c == 0 &&
323 !strcmp (ss.d, "TEST2") &&
324 ss.e == 100 && ss.f == 2.5 && ss.g == 43 && ss.h == (guint64)124)
331 mono_test_marshal_struct_array (simplestruct2 *ss)
333 if (! (ss[0].a == 0 && ss[0].b == 1 && ss[0].c == 0 &&
334 !strcmp (ss[0].d, "TEST") &&
335 ss[0].e == 99 && ss[0].f == 1.5 && ss[0].g == 42 && ss[0].h == (guint64)123))
338 if (! (ss[1].a == 0 && ss[1].b == 0 && ss[1].c == 0 &&
339 !strcmp (ss[1].d, "TEST2") &&
340 ss[1].e == 100 && ss[1].f == 2.5 && ss[1].g == 43 && ss[1].h == (guint64)124))
346 typedef int (*SimpleDelegate) (int a);
349 mono_test_marshal_delegate (SimpleDelegate delegate)
354 typedef int (*SimpleDelegate2) (simplestruct ss);
357 mono_test_marshal_delegate2 (SimpleDelegate2 delegate)
367 printf ("Calling delegate from unmanaged code\n");
369 printf ("GOT %d\n", res);
375 mono_test_marshal_stringbuilder (char *s, int n)
377 const char m[] = "This is my message. Isn't it nice?";
388 mono_test_marshal_string_array (char **array)
390 printf ("%p\n", array);
395 /* this does not work on Redhat gcc 2.96 */
397 mono_test_empty_struct (int a, EmptyStruct es, int b)
399 printf ("mono_test_empty_struct %d %d\n", a, b);
401 if (a == 1 && b == 2)
412 mono_test_byvalstr_gen (void)
416 ret = malloc(sizeof(ByValStrStruct));
417 memset(ret, 'a', sizeof(ByValStrStruct)-1);
418 ret->a[sizeof(ByValStrStruct)-1] = 0;
424 mono_test_byvalstr_check (ByValStrStruct* data, char* correctString)
428 ret = strcmp(data->a, correctString);
429 printf ("T1: %s\n", data->a);
430 printf ("T2: %s\n", correctString);
442 printf ("HEXDUMP DEFAULT VERSION\n");
445 for (i=0; i < 8; ++i)
448 printf("%0x ", (int) *(p++));
461 printf ("HEXDUMP ANSI VERSION\n");
464 for (i=0; i < 8; ++i)
467 printf("%0x ", (int) *(p++));
475 HexDump1W(char *data)
480 printf ("HEXDUMP UNICODE VERSION\n");
483 for (i=0; i < 8; ++i)
486 printf("%0x ", (int) *(p++));
490 return res + 1000000;
493 typedef int (*intcharFunc)(const char*);
496 callFunction (intcharFunc f)
502 printInt (int* number)
504 printf( "<%d>\n", *number );
515 class_marshal_test0 (SimpleObj *obj1)
517 printf ("class_marshal_test0 %s %d\n", obj1->str, obj1->i);
519 if (strcmp(obj1->str, "T1"))
528 class_marshal_test4 (SimpleObj *obj1)
537 class_marshal_test1 (SimpleObj **obj1)
539 SimpleObj *res = malloc (sizeof (SimpleObj));
548 class_marshal_test2 (SimpleObj **obj1)
550 printf ("class_marshal_test2 %s %d\n", (*obj1)->str, (*obj1)->i);
552 if (strcmp((*obj1)->str, "ABC"))
561 string_marshal_test0 (char *str)
563 if (strcmp (str, "TEST0"))
570 string_marshal_test1 (const char **str)
576 string_marshal_test2 (char **str)
578 printf ("string_marshal_test2 %s\n", *str);
580 if (strcmp (*str, "TEST1"))
587 string_marshal_test3 (char *str)
596 functionReturningString (void)
607 VectorList* TestVectorList (VectorList *vl)
609 printf ("TestVectorList %d %d\n", vl->a, vl->b);
618 typedef struct _OSVERSIONINFO
625 GetVersionEx (OSVERSIONINFO *osvi)
628 printf ("GOT %d %d\n", osvi->a, osvi->b);
633 return osvi->a + osvi->b;
642 mono_test_marshal_point (point pt)
644 printf("point %g %g\n", pt.x, pt.y);
645 if (pt.x == 1.25 && pt.y == 3.5)
657 mono_test_marshal_mixed_point (mixed_point pt)
659 printf("mixed point %d %g\n", pt.x, pt.y);
660 if (pt.x == 5 && pt.y == 6.75)
667 marshal_test_ref_bool(int i, char *b1, short *b2, int *b3)
670 if (*b1 != 0 && *b1 != 1)
672 if (*b2 != 0 && *b2 != -1) /* variant_bool */
674 if (*b3 != 0 && *b3 != 1)
676 if (i == ((*b1 << 2) | (-*b2 << 1) | *b3))
688 short b2; /* variant_bool */
693 marshal_test_bool_struct(struct BoolStruct *s)
696 if (s->b1 != 0 && s->b1 != 1)
698 if (s->b2 != 0 && s->b2 != -1)
700 if (s->b3 != 0 && s->b3 != 1)
702 if (s->i == ((s->b1 << 2) | (-s->b2 << 1) | s->b3))