X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=ffi%2Fnative.c;h=25e0d1ccc9c7e0542f06ba47e85b61c1e770d7a1;hb=8d1996a73234eed84ba68dae7ef09b4faec2a7ea;hp=25c159adef1b840672eb888f2e93833a30e81c3b;hpb=66501b5950881002845adee90c609ae64594a8b9;p=mate.git diff --git a/ffi/native.c b/ffi/native.c index 25c159a..25e0d1c 100644 --- a/ffi/native.c +++ b/ffi/native.c @@ -1,5 +1,29 @@ #include +static char ascii(char s) { + if(s < 0x20) return '.'; + if(s > 0x7E) return '.'; + return s; +} + +void hexdump(void *d, int len) { + unsigned char *data; + int i, off; + data = (unsigned char*)d; + for (off=0; off=len) printf(" "); + else printf("%02x ",data[off+i]); + + printf(" "); + for(i=0; i<16; i++) + if((i+off)>=len) printf(" "); + else printf("%c",ascii(data[off+i])); + printf("\n"); + } +} + void tests_Native1__printSomething____V(void) { printf("printSomething: woot \\o/\n"); @@ -19,3 +43,45 @@ void java_io_PrintStream__printf___I_V(int a) { printf("printstream: 0x%08x\n", a); } + +struct integer { + unsigned int method_table_ptr; + int value; +}; + +void java_io_PrintStream__printf_0___Ljava_lang_String__V + (const char *fmt) +{ + printf("%s", fmt); +} + +void java_io_PrintStream__printf_1___Ljava_lang_String_Ljava_lang_Object__V + (struct integer *a1, const char *fmt) +{ + printf(fmt, a1->value); +} + +void java_io_PrintStream__printf_2___Ljava_lang_String_Ljava_lang_Object_Ljava_lang_Object__V + (struct integer *a2, struct integer *a1, const char *fmt) +{ + printf(fmt, a1->value, a2->value); +} + +void +java_io_PrintStream__printf_3___Ljava_lang_String_Ljava_lang_Object_Ljava_lang_Object_Ljava_lang_Object__V + (struct integer *a3, struct integer *a2, struct integer *a1, const char *fmt) +{ + printf(fmt, a1->value, a2->value, a3->value); +} + +void java_io_PrintStream__printf_4___Ljava_lang_String_Ljava_lang_Object_Ljava_lang_Object_Ljava_lang_Object_Ljava_lang_Object__V + (struct integer *a4, struct integer *a3, struct integer *a2, struct integer *a1, const char *fmt) +{ + printf(fmt, a1->value, a2->value, a3->value, a4->value); +} + +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 + (struct integer *a5, struct integer *a4, struct integer *a3, struct integer *a2, struct integer *a1, const char *fmt) +{ + printf(fmt, a1->value, a2->value, a3->value, a4->value, a5->value); +}