{
remember_type (work, oldmangled, *mangled - oldmangled);
}
- string_append(&tname, "::");
+ string_append(&tname, (work -> options & DMGL_JAVA) ? "." : "::");
string_prepends(declp, &tname);
if (work -> destructor & 1)
{
const char *old_p;
const char *start;
int symbol_len;
+ int is_java_array;
string temp;
(*mangled)++;
}
if (trawname)
string_appendn (trawname, *mangled, r);
- string_appendn (tname, *mangled, r);
+ is_java_array = (work -> options & DMGL_JAVA)
+ && strncmp (*mangled, "JArray1Z", 8) == 0;
+ if (! is_java_array)
+ {
+ string_appendn (tname, *mangled, r);
+ string_append (tname, "<");
+ }
*mangled += r;
- string_append (tname, "<");
/* get size of template parameter list */
if (!get_count (mangled, &r))
{
}
need_comma = 1;
}
- if (tname->p[-1] == '>')
- string_append (tname, " ");
- string_append (tname, ">");
+ if (is_java_array)
+ {
+ string_append (tname, "[]");
+ }
+ else
+ {
+ if (tname->p[-1] == '>')
+ string_append (tname, " ");
+ string_append (tname, ">");
+ }
/*
if (work -> static_type)
work -> constructor -= 1;
}
}
- string_prepend (declp, "::");
+ string_prepend (declp, (work -> options & DMGL_JAVA) ? "." : "::");
string_prepends (declp, &class_name);
success = 1;
}
{
if (p != NULL)
{
- string_append (declp, "::");
+ string_append (declp,
+ (work -> options & DMGL_JAVA) ? "." : "::");
(*mangled)++;
}
}
/* Consumed everything up to the cplus_marker, append the
variable name. */
(*mangled)++;
- string_append (declp, "::");
+ string_append (declp, (work -> options & DMGL_JAVA) ? "." : "::");
n = strlen (*mangled);
string_appendn (declp, *mangled, n);
(*mangled) += n;
}
if (qualifiers > 0)
{
- string_appendn (&temp, "::", 2);
+ string_append (&temp, (work -> options & DMGL_JAVA) ? "." : "::");
}
}
if (isfuncname && (work->constructor & 1 || work->destructor & 1))
{
- string_appendn (&temp, "::", 2);
+ string_append (&temp, (work -> options & DMGL_JAVA) ? "." : "::");
if (work -> destructor & 1)
{
string_append (&temp, "~");
{
if (!STRING_EMPTY (result))
{
- string_appendn (&temp, "::", 2);
+ string_append (&temp, (work -> options & DMGL_JAVA) ? "." : "::");
}
string_prepends (result, &temp);
}
case 'P':
case 'p':
(*mangled)++;
- string_prepend (&decl, "*");
+ if (! (work -> options & DMGL_JAVA))
+ string_prepend (&decl, "*");
break;
/* A reference type */
}
string_append (&decl, ")");
- string_prepend (&decl, "::");
+ string_prepend (&decl, (work -> options & DMGL_JAVA) ? "." : "::");
if (isdigit (**mangled))
{
n = consume_count (mangled);
#ifdef MAIN
+#include "getopt.h"
+
+static char *program_name;
+static char *program_version = VERSION;
+static int flags = DMGL_PARAMS | DMGL_ANSI;
+
+static void demangle_it PARAMS ((char *));
+static void usage PARAMS ((FILE *, int));
+static void fatal PARAMS ((char *));
+
static void
demangle_it (mangled_name)
char *mangled_name;
{
char *result;
- result = cplus_demangle (mangled_name, DMGL_PARAMS | DMGL_ANSI);
+ result = cplus_demangle (mangled_name, flags);
if (result == NULL)
{
printf ("%s\n", mangled_name);
}
}
-#include "getopt.h"
-
-static char *program_name;
-static char *program_version = VERSION;
-
static void
usage (stream, status)
FILE *stream;
char mbuffer[MBUF_SIZE];
/* Defined in the automatically-generated underscore.c. */
-extern int prepends_underscore;
+int prepends_underscore;
int strip_underscore = 0;
{"strip-underscores", no_argument, 0, '_'},
{"format", required_argument, 0, 's'},
{"help", no_argument, 0, 'h'},
+ {"java", no_argument, 0, 'j'},
{"no-strip-underscores", no_argument, 0, 'n'},
{"version", no_argument, 0, 'v'},
{0, no_argument, 0, 0}
strip_underscore = prepends_underscore;
- while ((c = getopt_long (argc, argv, "_ns:", long_options, (int *) 0)) != EOF)
+ while ((c = getopt_long (argc, argv, "_nsj:", long_options, (int *) 0)) != EOF)
{
switch (c)
{
case '_':
strip_underscore = 1;
break;
+ case 'j':
+ flags |= DMGL_JAVA;
+ break;
case 's':
if (strcmp (optarg, "gnu") == 0)
{
mbuffer[i] = 0;
- result = cplus_demangle (mbuffer + skip_first,
- DMGL_PARAMS | DMGL_ANSI);
+ result = cplus_demangle (mbuffer + skip_first, flags);
if (result)
{
if (mbuffer[0] == '.')