From 21a0db19a4d64ceac59f07b41ad9179dc80c71d0 Mon Sep 17 00:00:00 2001 From: tromey Date: Tue, 15 Feb 2000 22:17:55 +0000 Subject: [PATCH] * gjavah.c (jni_print_char): New function. (print_full_cxx_name): Use it. (decode_signature_piece): Likewise. (print_cxx_classname): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@31989 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/java/ChangeLog | 7 +++++++ gcc/java/gjavah.c | 61 ++++++++++++++++++++++++++++++++---------------------- 2 files changed, 43 insertions(+), 25 deletions(-) diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index 315cf0b..895a14c 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,10 @@ +2000-02-15 Tom Tromey + + * gjavah.c (jni_print_char): New function. + (print_full_cxx_name): Use it. + (decode_signature_piece): Likewise. + (print_cxx_classname): Likewise. + 2000-02-15 Kaveh R. Ghazi * Makefile.in (jv-scan, jcf-dump, gcjh): Depend on and link with diff --git a/gcc/java/gjavah.c b/gcc/java/gjavah.c index c679491..a8b9c36 100644 --- a/gcc/java/gjavah.c +++ b/gcc/java/gjavah.c @@ -248,6 +248,38 @@ DEFUN(print_name, (stream, jcf, name_index), JPOOL_UTF_LENGTH (jcf, name_index)); } +/* Print a character, appropriately mangled for JNI. */ + +static void +jni_print_char (stream, ch) + FILE *stream; + int ch; +{ + if (! flag_jni) + jcf_print_char (stream, ch); + else if (ch == '(' || ch == ')') + { + /* Ignore. */ + } + else if (ch == '_') + fputs ("_1", stream); + else if (ch == ';') + fputs ("_2", stream); + else if (ch == '[') + fputs ("_3", stream); + else if (ch == '/') + fputs ("_", stream); + else if ((ch >= '0' && ch <= '9') + || (ch >= 'a' && ch <= 'z') + || (ch >= 'A' && ch <= 'Z')) + fputc (ch, stream); + else + { + /* "Unicode" character. */ + fprintf (stream, "_0%04x", ch); + } +} + /* Print base name of class. The base name is everything after the final separator. */ @@ -888,7 +920,7 @@ decode_signature_piece (stream, signature, limit, need_space) break; default: *need_space = 1; - jcf_print_char (stream, *signature++); + jni_print_char (stream, *signature++); break; printit: signature++; @@ -1006,33 +1038,12 @@ DEFUN(print_full_cxx_name, (stream, jcf, name_index, signature_index, while (signature < limit) { int ch = UTF8_GET (signature, limit); - if (ch == '(') - { - /* Ignore. */ - } - else if (ch == ')') + jni_print_char (stream, ch); + if (ch == ')') { /* Done. */ break; } - else if (ch == '_') - fputs ("_1", stream); - else if (ch == ';') - fputs ("_2", stream); - else if (ch == '[') - fputs ("_3", stream); - else if (ch == '/') - fputs ("_", stream); - else if ((ch >= '0' && ch <= '9') - || (ch >= 'a' && ch <= 'z') - || (ch >= 'A' && ch <= 'Z')) - fputc (ch, stream); - else - { - /* "Unicode" character. FIXME: upper or lower case - letters? */ - fprintf (stream, "_0%04x", ch); - } } } } @@ -1223,7 +1234,7 @@ print_cxx_classname (stream, prefix, jcf, index) if (c == '/') fputs (flag_jni ? "_" : "::", stream); else - jcf_print_char (stream, c); + jni_print_char (stream, c); } return 1; -- 2.7.4