99d641c5934f55eea5202759df966ea736e01335
[mate.git] / ffi / native.c
1 #include <stdio.h>
2
3 static char ascii(char s) {
4         if(s < 0x20) return '.';
5         if(s > 0x7E) return '.';
6         return s;
7 }
8
9 void hexdump(void *d, int len) {
10         unsigned char *data;
11         int i, off;
12         data = (unsigned char*)d;
13         for (off=0; off<len; off += 16) {
14                 printf("%08x  ",off);
15                 for(i=0; i<16; i++)
16                         if((i+off)>=len) printf("   ");
17                         else printf("%02x ",data[off+i]);
18
19                 printf(" ");
20                 for(i=0; i<16; i++)
21                         if((i+off)>=len) printf(" ");
22                         else printf("%c",ascii(data[off+i]));
23                 printf("\n");
24         }
25 }
26
27 void tests_Native1__printSomething____V(void)
28 {
29         printf("printSomething: woot \\o/\n");
30 }
31
32 void tests_Native1__printSomething___I_V(int a)
33 {
34         printf("printSomething: 0x%08x\n", a);
35 }
36
37 void tests_Instance5__printX___I_V(int a)
38 {
39         printf("printX: 0x%08x\n", a);
40 }
41
42 void java_io_PrintStream__printf___I_V(int a)
43 {
44         printf("printstream: 0x%08x\n", a);
45 }
46
47 struct integer {
48         unsigned int method_table_ptr;
49         int value;
50 };
51
52 struct string {
53         unsigned int method_table_ptr;
54         struct chararray *value;
55 };
56
57 struct chararray {
58         unsigned int length;
59         char str;
60 };
61
62 void java_io_PrintStream__printf_0___Ljava_lang_String__V
63         (struct string *fmt)
64 {
65         printf("%s", &fmt->value->str);
66 }
67
68 void java_io_PrintStream__printf_1___Ljava_lang_String_Ljava_lang_Object__V
69         (struct integer *a1, struct string *fmt)
70 {
71 #if 0
72         printf("fmt:        0x%08x\n", (unsigned int) fmt);
73         printf("fmt->value: 0x%08x\n", (unsigned int) fmt->value);
74         printf("fmt->val.len: 0x%08x\n", (unsigned int) (*fmt->value).length);
75         printf("first: %d\n", fmt->value->length);
76         printf("*fmt: %s\n", &fmt->value->str);
77 #endif
78         printf(&fmt->value->str, a1->value);
79 }
80
81 void java_io_PrintStream__printf_2___Ljava_lang_String_Ljava_lang_Object_Ljava_lang_Object__V
82         (struct integer *a2, struct integer *a1, struct string *fmt)
83 {
84         printf(&fmt->value->str, a1->value, a2->value);
85 }
86
87 void
88 java_io_PrintStream__printf_3___Ljava_lang_String_Ljava_lang_Object_Ljava_lang_Object_Ljava_lang_Object__V
89         (struct integer *a3, struct integer *a2, struct integer *a1, struct string *fmt)
90 {
91         printf(&fmt->value->str, a1->value, a2->value, a3->value);
92 }
93
94 void java_io_PrintStream__printf_4___Ljava_lang_String_Ljava_lang_Object_Ljava_lang_Object_Ljava_lang_Object_Ljava_lang_Object__V
95         (struct integer *a4, struct integer *a3, struct integer *a2, struct integer *a1, struct string *fmt)
96 {
97         printf(&fmt->value->str, a1->value, a2->value, a3->value, a4->value);
98 }
99
100 void java_io_PrintStream__printf_5___Ljava_lang_String_Ljava_lang_Object_Ljava_lang_Object_Ljava_lang_Object_Ljava_lang_Object_Ljava_lang_Object__V
101         (struct integer *a5, struct integer *a4, struct integer *a3, struct integer *a2, struct integer *a1, struct string *fmt)
102 {
103         printf(&fmt->value->str, a1->value, a2->value, a3->value, a4->value, a5->value);
104 }
105
106 void gnu_classpath_VMSystemProperties__preInit___Ljava_util_Properties__V() {
107         return;
108 }