home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Geek Gadgets 1
/
ADE-1.bin
/
ade-dist
/
kaffe-0.5p4-src.tgz
/
tar.out
/
contrib
/
kaffe
/
kaffeh
/
sigs.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-09-28
|
3KB
|
179 lines
/*
* sigs.c
* Translate a class into stubs.
*
* Copyright (c) 1996 Systems Architecture Research Centre,
* City University, London, UK.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
* Written by Tim Wilkinson <tim@sarc.city.ac.uk>, February 1996.
*/
#include <stdio.h>
static char fp[100];
/*
* Translate signature into argument count.
*/
char*
translateSig(char* str, char** nstr, int* argp)
{
int j;
int arg;
int k;
switch (*str++) {
case 'L':
arg = 1;
strcpy(fp, "struct H");
k = strlen(fp);
for (j = 0; str[j] != ';'; j++, k++) {
if (str[j] == '/') {
fp[k] = '_';
}
else {
fp[k] = str[j];
}
}
fp[k] = '*';
fp[k+1] = 0;
str += j + 1;
break;
case '[':
arg = 1;
switch (*str++) {
case 'B':
strcpy(fp, "HArrayOfByte*");
break;
case 'C':
strcpy(fp, "HArrayOfChar*");
break;
case 'D':
strcpy(fp, "HArrayOfDouble*");
break;
case 'F':
strcpy(fp, "HArrayOfFloat*");
break;
case 'I':
case 'Z': /* Bool */
strcpy(fp, "HArrayOfInt*");
break;
case 'S':
strcpy(fp, "HArrayOfShort*");
break;
case 'J':
strcpy(fp, "HArrayOfLong*");
break;
case '[':
strcpy(fp, "HArrayOfArray*");
/* Skip rest of definition */
while (*str == '[') {
str++;
}
if (*str++ == 'L') {
while (*str++ != ';')
;
}
break;
case 'L':
strcpy(fp, "HArrayOfObject*");
while (*str++ != ';')
;
break;
}
break;
case 'B':
arg = 1;
strcpy(fp, "jint /* byte */");
break;
case 'C':
arg = 1;
strcpy(fp, "jint /* char */");
break;
case 'D':
arg = 2;
strcpy(fp, "jdouble");
break;
case 'F':
arg = 1;
strcpy(fp, "jfloat");
break;
case 'I':
arg = 1;
strcpy(fp, "jint");
break;
case 'J':
arg = 2;
strcpy(fp, "jlong");
break;
case 'S':
arg = 1;
strcpy(fp, "jint /* short */");
break;
case 'Z':
arg = 1;
strcpy(fp, "jint /* bool */");
break;
case 'V':
arg = 0;
strcpy(fp, "void");
break;
default:
abort();
}
if (argp != 0) {
(*argp) += arg;
}
if (nstr != 0) {
(*nstr) = str;
}
return (fp);
}
/*
* Translate signature to union type.
*/
char*
translateSigType(char* str, char* type)
{
switch (*str++) {
case 'L':
type[0] = 'p';
while (*str != ';') {
str++;
}
str++;
break;
case '[':
type[0] = 'p';
if (*str++ == 'L') {
while (*str != ';') {
str++;
}
str++;
}
break;
case 'B': case 'C': case 'I': case 'S': case 'Z':
type[0] = 'i';
break;
case 'D':
type[0] = 'd';
break;
case 'F':
type[0] = 'f';
break;
case 'J':
type[0] = 'l';
break;
case 'V':
type[0] = 'v';
break;
}
return (str);
}