This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH: Correct output from gjavah
- From: Mark Mitchell <mark at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 27 Dec 2002 22:26:59 -0800
- Subject: PATCH: Correct output from gjavah
- Reply-to: mark at codesourcery dot com
This patch makes the output from gjavah legal; previously we were
generating several C++ constructs which the new parser (correctly)
flagged as errors.
Tested on i686-pc-linux-gnu, applied on the mainline.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com
2002-12-27 Mark Mitchell <mark@codesourcery.com>
* gjavah.c (print_name_for_stub_or_jni): Adjust call to
print_cxx_classname.
(print_cxx_classname): Add add_scope parameter.
(print_class_decls): Do not emit a semicolon after the extern
"Java" block.
(process_file): Adjust calls to print_cxx_classname.
Index: gjavah.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/gjavah.c,v
retrieving revision 1.96
retrieving revision 1.90.4.4
diff -c -5 -p -r1.96 -r1.90.4.4
*** gjavah.c 16 Dec 2002 18:22:33 -0000 1.96
--- gjavah.c 28 Dec 2002 02:43:09 -0000 1.90.4.4
*************** struct method_name
*** 120,130 ****
/* List of method names we've seen. */
static struct method_name *method_name_list;
static void print_field_info PARAMS ((FILE*, JCF*, int, int, JCF_u2));
static void print_mangled_classname PARAMS ((FILE*, JCF*, const char*, int));
! static int print_cxx_classname PARAMS ((FILE*, const char*, JCF*, int));
static void print_method_info PARAMS ((FILE*, JCF*, int, int, JCF_u2));
static void print_c_decl PARAMS ((FILE*, JCF*, int, int, int, const char *,
int));
static void print_stub_or_jni PARAMS ((FILE*, JCF*, int, int, int,
const char *, int));
--- 120,130 ----
/* List of method names we've seen. */
static struct method_name *method_name_list;
static void print_field_info PARAMS ((FILE*, JCF*, int, int, JCF_u2));
static void print_mangled_classname PARAMS ((FILE*, JCF*, const char*, int));
! static int print_cxx_classname PARAMS ((FILE*, const char*, JCF*, int, int));
static void print_method_info PARAMS ((FILE*, JCF*, int, int, JCF_u2));
static void print_c_decl PARAMS ((FILE*, JCF*, int, int, int, const char *,
int));
static void print_stub_or_jni PARAMS ((FILE*, JCF*, int, int, int,
const char *, int));
*************** DEFUN (print_name_for_stub_or_jni, (stre
*** 1531,1541 ****
FILE *stream AND JCF *jcf
AND int name_index AND int signature_index
AND int is_init AND const char *name_override AND int flags)
{
const char *const prefix = flag_jni ? "Java_" : "";
! print_cxx_classname (stream, prefix, jcf, jcf->this_class);
fputs (flag_jni ? "_" : "::", stream);
print_full_cxx_name (stream, jcf, name_index,
signature_index, is_init, name_override,
flags);
}
--- 1531,1541 ----
FILE *stream AND JCF *jcf
AND int name_index AND int signature_index
AND int is_init AND const char *name_override AND int flags)
{
const char *const prefix = flag_jni ? "Java_" : "";
! print_cxx_classname (stream, prefix, jcf, jcf->this_class, 1);
fputs (flag_jni ? "_" : "::", stream);
print_full_cxx_name (stream, jcf, name_index,
signature_index, is_init, name_override,
flags);
}
*************** DEFUN(print_mangled_classname, (stream,
*** 1639,1653 ****
/* Print PREFIX, then a class name in C++ format. If the name refers
to an array, ignore it and don't print PREFIX. Returns 1 if
something was printed, 0 otherwise. */
static int
! print_cxx_classname (stream, prefix, jcf, index)
FILE *stream;
const char *prefix;
JCF *jcf;
int index;
{
int name_index = JPOOL_USHORT1 (jcf, index);
int len, c;
const unsigned char *s, *p, *limit;
--- 1639,1654 ----
/* Print PREFIX, then a class name in C++ format. If the name refers
to an array, ignore it and don't print PREFIX. Returns 1 if
something was printed, 0 otherwise. */
static int
! print_cxx_classname (stream, prefix, jcf, index, add_scope)
FILE *stream;
const char *prefix;
JCF *jcf;
int index;
+ int add_scope;
{
int name_index = JPOOL_USHORT1 (jcf, index);
int len, c;
const unsigned char *s, *p, *limit;
*************** print_cxx_classname (stream, prefix, jcf
*** 1662,1672 ****
return 0;
fputs (prefix, stream);
/* Print a leading "::" so we look in the right namespace. */
! if (! flag_jni && ! stubs)
fputs ("::", stream);
while (s < limit)
{
c = UTF8_GET (s, limit);
--- 1663,1673 ----
return 0;
fputs (prefix, stream);
/* Print a leading "::" so we look in the right namespace. */
! if (! flag_jni && ! stubs && add_scope)
fputs ("::", stream);
while (s < limit)
{
c = UTF8_GET (s, limit);
*************** print_class_decls (out, jcf, self)
*** 1952,1962 ****
{
fputs ("extern \"Java\"\n{\n", out);
/* We use an initial offset of 0 because the root namelet
doesn't cause anything to print. */
print_namelet (out, &root, 0);
! fputs ("};\n\n", out);
}
}
--- 1953,1963 ----
{
fputs ("extern \"Java\"\n{\n", out);
/* We use an initial offset of 0 because the root namelet
doesn't cause anything to print. */
print_namelet (out, &root, 0);
! fputs ("}\n\n", out);
}
}
*************** DEFUN(process_file, (jcf, out),
*** 2128,2147 ****
if (prepend_count > 0)
fputc ('\n', out);
if (! stubs)
{
! if (! print_cxx_classname (out, "class ", jcf, jcf->this_class))
{
fprintf (stderr, "class is of array type\n");
found_error = 1;
return;
}
if (jcf->super_class)
{
if (! print_cxx_classname (out, " : public ",
! jcf, jcf->super_class))
{
fprintf (stderr, "base class is of array type\n");
found_error = 1;
return;
}
--- 2129,2149 ----
if (prepend_count > 0)
fputc ('\n', out);
if (! stubs)
{
! if (! print_cxx_classname (out, "class ", jcf,
! jcf->this_class, 0))
{
fprintf (stderr, "class is of array type\n");
found_error = 1;
return;
}
if (jcf->super_class)
{
if (! print_cxx_classname (out, " : public ",
! jcf, jcf->super_class, 1))
{
fprintf (stderr, "base class is of array type\n");
found_error = 1;
return;
}