mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-02-10 17:49:40 +08:00
gjavah.c (add_class_decl): Only generate `#include' if outer class is not the name of the class we are...
* gjavah.c (add_class_decl): Only generate `#include' if outer class is not the name of the class we are processing. Correctly append `.h' in #include. (process_file): Clean up newlines around generated `#include's. (decode_signature_piece): Correctly handle inner classes. (struct include): New structure. (all_includes): New global. (print_include): New function. (add_class_decl): Use it. (process_file): Likewise. (add_class_decl): Generate include for java-array.h if array seen. (process_file): Don't generate java-array.h include. From-SVN: r25460
This commit is contained in:
parent
5f56af5a8d
commit
686fb23678
@ -1,5 +1,19 @@
|
|||||||
1999-02-26 Tom Tromey <tromey@cygnus.com>
|
1999-02-26 Tom Tromey <tromey@cygnus.com>
|
||||||
|
|
||||||
|
* gjavah.c (add_class_decl): Only generate `#include' if outer
|
||||||
|
class is not the name of the class we are processing. Correctly
|
||||||
|
append `.h' in #include.
|
||||||
|
(process_file): Clean up newlines around generated `#include's.
|
||||||
|
(decode_signature_piece): Correctly handle inner classes.
|
||||||
|
(struct include): New structure.
|
||||||
|
(all_includes): New global.
|
||||||
|
(print_include): New function.
|
||||||
|
(add_class_decl): Use it.
|
||||||
|
(process_file): Likewise.
|
||||||
|
(add_class_decl): Generate include for java-array.h if array
|
||||||
|
seen.
|
||||||
|
(process_file): Don't generate java-array.h include.
|
||||||
|
|
||||||
* gjavah.c (add_namelet): Check for standard package names here.
|
* gjavah.c (add_namelet): Check for standard package names here.
|
||||||
(add_class_decl): Don't check for standard package names here.
|
(add_class_decl): Don't check for standard package names here.
|
||||||
|
|
||||||
|
@ -650,7 +650,8 @@ decode_signature_piece (stream, signature, limit, need_space)
|
|||||||
while (*signature && *signature != ';')
|
while (*signature && *signature != ';')
|
||||||
{
|
{
|
||||||
int ch = UTF8_GET (signature, limit);
|
int ch = UTF8_GET (signature, limit);
|
||||||
if (ch == '/')
|
/* `$' is the separator for an inner class. */
|
||||||
|
if (ch == '/' || ch == '$')
|
||||||
fputs ("::", stream);
|
fputs ("::", stream);
|
||||||
else
|
else
|
||||||
jcf_print_char (stream, ch);
|
jcf_print_char (stream, ch);
|
||||||
@ -832,6 +833,52 @@ super_class_name (derived_jcf, len)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* We keep track of all the `#include's we generate, so we can avoid
|
||||||
|
duplicates. */
|
||||||
|
struct include
|
||||||
|
{
|
||||||
|
char *name;
|
||||||
|
struct include *next;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* List of all includes. */
|
||||||
|
static struct include *all_includes = NULL;
|
||||||
|
|
||||||
|
/* Generate a #include. */
|
||||||
|
static void
|
||||||
|
print_include (out, utf8, len)
|
||||||
|
FILE *out;
|
||||||
|
unsigned char *utf8;
|
||||||
|
int len;
|
||||||
|
{
|
||||||
|
struct include *incl;
|
||||||
|
|
||||||
|
if (! out)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (len == -1)
|
||||||
|
len = strlen (utf8);
|
||||||
|
|
||||||
|
for (incl = all_includes; incl; incl = incl->next)
|
||||||
|
{
|
||||||
|
if (! strncmp (incl->name, utf8, len))
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
incl = (struct include *) malloc (sizeof (struct include));
|
||||||
|
incl->name = malloc (len + 1);
|
||||||
|
strncpy (incl->name, utf8, len);
|
||||||
|
incl->name[len] = '\0';
|
||||||
|
incl->next = all_includes;
|
||||||
|
all_includes = incl;
|
||||||
|
|
||||||
|
fputs ("#include <", out);
|
||||||
|
jcf_print_utf8 (out, utf8, len);
|
||||||
|
fputs (".h>\n", out);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* This is used to represent part of a package or class name. */
|
/* This is used to represent part of a package or class name. */
|
||||||
struct namelet
|
struct namelet
|
||||||
{
|
{
|
||||||
@ -975,27 +1022,47 @@ add_class_decl (out, jcf, signature)
|
|||||||
unsigned char *s = JPOOL_UTF_DATA (jcf, signature);
|
unsigned char *s = JPOOL_UTF_DATA (jcf, signature);
|
||||||
int len = JPOOL_UTF_LENGTH (jcf, signature);
|
int len = JPOOL_UTF_LENGTH (jcf, signature);
|
||||||
int i;
|
int i;
|
||||||
|
/* Name of class we are processing. */
|
||||||
|
int name_index = JPOOL_USHORT1 (jcf, jcf->this_class);
|
||||||
|
int tlen = JPOOL_UTF_LENGTH (jcf, name_index);
|
||||||
|
char *tname = JPOOL_UTF_DATA (jcf, name_index);
|
||||||
|
|
||||||
for (i = 0; i < len; ++i)
|
for (i = 0; i < len; ++i)
|
||||||
{
|
{
|
||||||
int start;
|
int start, saw_dollar;
|
||||||
|
|
||||||
|
/* If we see an array, then we include the array header. */
|
||||||
|
if (s[i] == '[')
|
||||||
|
{
|
||||||
|
print_include (out, "java-array", -1);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
/* We're looking for `L<stuff>;' -- everything else is
|
/* We're looking for `L<stuff>;' -- everything else is
|
||||||
ignorable. */
|
ignorable. */
|
||||||
if (s[i] != 'L')
|
if (s[i] != 'L')
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
saw_dollar = 0;
|
||||||
for (start = ++i; i < len && s[i] != ';'; ++i)
|
for (start = ++i; i < len && s[i] != ';'; ++i)
|
||||||
{
|
{
|
||||||
if (s[i] == '$' && out)
|
if (! saw_dollar && s[i] == '$' && out)
|
||||||
{
|
{
|
||||||
|
saw_dollar = 1;
|
||||||
/* If this class represents an inner class, then
|
/* If this class represents an inner class, then
|
||||||
generate a `#include' for the outer class. */
|
generate a `#include' for the outer class. However,
|
||||||
fputs ("#include <", out);
|
don't generate the include if the outer class is the
|
||||||
jcf_print_utf8 (out, &s[start], i - start);
|
class we are processing. */
|
||||||
fputs (">\n", out);
|
if (i - start < tlen || strncmp (&s[start], tname, i - start))
|
||||||
|
print_include (out, &s[start], i - start);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
add_namelet (&s[start], &s[i], &root);
|
/* If we saw an inner class, then the generated #include will
|
||||||
|
declare the class. So in this case we needn't bother. */
|
||||||
|
if (! saw_dollar)
|
||||||
|
add_namelet (&s[start], &s[i], &root);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1082,7 +1149,7 @@ DEFUN(process_file, (jcf, out),
|
|||||||
/* We do this to ensure that inline methods won't be `outlined'
|
/* We do this to ensure that inline methods won't be `outlined'
|
||||||
by g++. This works as long as method and fields are not
|
by g++. This works as long as method and fields are not
|
||||||
added by the user. */
|
added by the user. */
|
||||||
fprintf (out, "#pragma interface\n\n");
|
fprintf (out, "#pragma interface\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jcf->super_class && out)
|
if (jcf->super_class && out)
|
||||||
@ -1090,18 +1157,8 @@ DEFUN(process_file, (jcf, out),
|
|||||||
int super_length;
|
int super_length;
|
||||||
unsigned char *supername = super_class_name (jcf, &super_length);
|
unsigned char *supername = super_class_name (jcf, &super_length);
|
||||||
|
|
||||||
fputs ("#include <", out);
|
|
||||||
jcf_print_utf8 (out, supername, super_length);
|
|
||||||
fputs (".h>\n", out);
|
|
||||||
|
|
||||||
/* FIXME: If our superclass is Object, then we include
|
|
||||||
java-array.h. The right thing to do here is look at all the
|
|
||||||
methods and fields and see if an array is in use. Only then
|
|
||||||
would we need to include java-array.h. */
|
|
||||||
if (! utf8_cmp (supername, super_length, "java/lang/Object"))
|
|
||||||
fputs ("#include <java-array.h>\n", out);
|
|
||||||
|
|
||||||
fputs ("\n", out);
|
fputs ("\n", out);
|
||||||
|
print_include (out, supername, super_length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We want to parse the methods first. But we need to find where
|
/* We want to parse the methods first. But we need to find where
|
||||||
@ -1119,6 +1176,7 @@ DEFUN(process_file, (jcf, out),
|
|||||||
|
|
||||||
if (out)
|
if (out)
|
||||||
{
|
{
|
||||||
|
fputs ("\n", out);
|
||||||
print_class_decls (out, jcf, jcf->this_class);
|
print_class_decls (out, jcf, jcf->this_class);
|
||||||
|
|
||||||
for (i = 0; i < prepend_count; ++i)
|
for (i = 0; i < prepend_count; ++i)
|
||||||
|
Loading…
Reference in New Issue
Block a user