diff options
author | aph <aph@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-06-29 17:50:59 +0000 |
---|---|---|
committer | aph <aph@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-06-29 17:50:59 +0000 |
commit | fce8df1021b8e76afd5e8f909557826fcbf3ff19 (patch) | |
tree | 3cfe7282cd5664c854b8f591c178d778224cc35e /libjava/classpath | |
parent | d6d765b4a20ee056454dc87d9e002cd2f5ebb42d (diff) | |
download | gcc-fce8df1021b8e76afd5e8f909557826fcbf3ff19.tar.gz |
2009-06-29 Andrew Haley <aph@redhat.com>
PR java/40590
* tools/gnu/classpath/tools/javah/FieldHelper.java (print):
Use printName().
* tools/gnu/classpath/tools/javah/MethodHelper.java (print):
Use printName().
* tools/gnu/classpath/tools/javah/CniStubPrinter.java (printDecl):
Use printName().
* tools/gnu/classpath/tools/javah/Keywords.java (words): Replace
with keywords list from gcc/java/mangle.c.
* tools/gnu/classpath/tools/javah/ClassWrapper.java (printMethods):
Don't pre-convert a C++ keyword.
(print(CniPrintStream)): Call CniPrintStream.printName().
(printContents): Likewise.
* tools/gnu/classpath/tools/javah/CniPrintStream.java
(getClassName): Don't call replaceAll("/", "::").
(print(Type)): Add ""::" befor name, " *" after. Use printName(), not
print.
(printName(PrintStream, String), printName(String), printlnName):
New methods.
(moveToPackage): Use printName().
2009-06-29 Andrew Haley <aph@redhat.com>
PR java/40590
* java-tree.h (cxx_keyword_p): New declaration.
* mangle_name.c (utf8_cmp): Move here from mangle.c.
(cxx_keywords): Likewise.
(cxx_keyword_p): Likewise.
(MANGLE_CXX_KEYWORDS): New macro.
(append_gpp_mangled_name): Use MANGLE_CXX_KEYWORDS.
(append_gpp_mangled_name): Likewise.
* mangle.c: Move code to mangle_name.c.
(mangle_member_name): Don't call cxx_keyword_p.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@149059 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/classpath')
13 files changed, 176 insertions, 34 deletions
diff --git a/libjava/classpath/ChangeLog b/libjava/classpath/ChangeLog index c6ec810e0e8..445649aae84 100644 --- a/libjava/classpath/ChangeLog +++ b/libjava/classpath/ChangeLog @@ -1,3 +1,26 @@ +2009-06-29 Andrew Haley <aph@redhat.com> + + PR java/40590 + * tools/gnu/classpath/tools/javah/FieldHelper.java (print): + Use printName(). + * tools/gnu/classpath/tools/javah/MethodHelper.java (print): + Use printName(). + * tools/gnu/classpath/tools/javah/CniStubPrinter.java (printDecl): + Use printName(). + * tools/gnu/classpath/tools/javah/Keywords.java (words): Replace + with keywords list from gcc/java/mangle.c. + * tools/gnu/classpath/tools/javah/ClassWrapper.java (printMethods): + Don't pre-convert a C++ keyword. + (print(CniPrintStream)): Call CniPrintStream.printName(). + (printContents): Likewise. + * tools/gnu/classpath/tools/javah/CniPrintStream.java + (getClassName): Don't call replaceAll("/", "::"). + (print(Type)): Add ""::" befor name, " *" after. Use printName(), not + print. + (printName(PrintStream, String), printName(String), printlnName): + New methods. + (moveToPackage): Use printName(). + 2009-03-01 Ralf Wildenhues <Ralf.Wildenhues@gmx.de> * configure: Regenerate. diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/ClassWrapper.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/ClassWrapper.class Binary files differindex 5c20124acbb..e853782fc85 100644 --- a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/ClassWrapper.class +++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/ClassWrapper.class diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/CniPrintStream.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/CniPrintStream.class Binary files differindex 1f0d890b789..0c7915ce042 100644 --- a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/CniPrintStream.class +++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/CniPrintStream.class diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/CniStubPrinter.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/CniStubPrinter.class Binary files differindex 8726cdd216e..e226ffbd5d7 100644 --- a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/CniStubPrinter.class +++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/CniStubPrinter.class diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/FieldHelper.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/FieldHelper.class Binary files differindex 9b7169fe519..3d6f235bb2b 100644 --- a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/FieldHelper.class +++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/FieldHelper.class diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Keywords.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Keywords.class Binary files differindex 7b6b063d7db..592ff470550 100644 --- a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Keywords.class +++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/Keywords.class diff --git a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/MethodHelper.class b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/MethodHelper.class Binary files differindex 2bd32023281..71974cc7d10 100644 --- a/libjava/classpath/tools/classes/gnu/classpath/tools/javah/MethodHelper.class +++ b/libjava/classpath/tools/classes/gnu/classpath/tools/javah/MethodHelper.class diff --git a/libjava/classpath/tools/gnu/classpath/tools/javah/ClassWrapper.java b/libjava/classpath/tools/gnu/classpath/tools/javah/ClassWrapper.java index 43f31a2fd9c..22278eba84c 100644 --- a/libjava/classpath/tools/gnu/classpath/tools/javah/ClassWrapper.java +++ b/libjava/classpath/tools/gnu/classpath/tools/javah/ClassWrapper.java @@ -260,7 +260,7 @@ public class ClassWrapper if (bridgeTargets.contains(sum)) nameToUse = (String) methodNameMap.get(sum); else - nameToUse = Keywords.getCxxName(m.name); + nameToUse = m.name; methodNameMap.put(sum, nameToUse); MethodHelper.print(out, m, this, nameToUse); } @@ -291,7 +291,8 @@ public class ClassWrapper public void print(CniPrintStream out) { - out.print("::" + name.replaceAll("/", "::")); + out.print("::"); + out.printName(name); } // This prints the body of a class to a CxxPrintStream. @@ -303,7 +304,7 @@ public class ClassWrapper out.print("class "); // Don't use our print() -- we don't want the leading "::". - out.print(name.replaceAll("/", "::")); + out.printName(name); if (superClass != null) { out.print(" : public "); diff --git a/libjava/classpath/tools/gnu/classpath/tools/javah/CniPrintStream.java b/libjava/classpath/tools/gnu/classpath/tools/javah/CniPrintStream.java index 64ba537d4d3..315fd8ae326 100644 --- a/libjava/classpath/tools/gnu/classpath/tools/javah/CniPrintStream.java +++ b/libjava/classpath/tools/gnu/classpath/tools/javah/CniPrintStream.java @@ -125,9 +125,10 @@ public class CniPrintStream // Add the plain class name; we'll handle it when // we process namespaces. allClasses.add(name); - return "::" + name.replaceAll("/", "::") + " *"; + return name; } + // Print the C++ form of TYPE, mangling C++ keywords. public void print(Type type) { int arrayCount = 0; @@ -141,7 +142,9 @@ public class CniPrintStream } if (type.getSort() == Type.OBJECT) { - print(getClassName(type)); + print("::"); + printName(getClassName(type)); + print(" *"); } else { @@ -156,6 +159,34 @@ public class CniPrintStream } } + // Print NAME, converting into C++ syntax and mangling C++ keywords + // as we go. + public final static void printName(PrintStream out, String name) + { + String[] parts = name.split("::|/"); + for (int i = 0; i < parts.length; i++) + { + if (i != 0) + out.print("::"); + out.print(Keywords.getCxxName(parts[i])); + } + } + + // Println NAME, converting into C++ syntax and mangling C++ + // keywords as we go. + public final static void printlnName(PrintStream out, String name) + { + printName(out, name); + out.println(); + } + + // Print NAME, converting into C++ syntax and mangling C++ keywords + // as we go. + final void printName(String name) + { + printName(this, name); + } + private void indent(PrintStream out, int n) { for (int i = 0; i < n; ++i) @@ -186,7 +217,7 @@ public class CniPrintStream { indent(out, j + 1); out.print("namespace "); - out.println(pkgParts[j]); + printlnName(out, pkgParts[j]); indent(out, j + 1); out.println("{"); } @@ -202,7 +233,7 @@ public class CniPrintStream moveToPackage(out, pkgParts); indent(out, pkgParts.length + 2); out.print("class "); - out.print(className); + printName(out, className); out.println(";"); } diff --git a/libjava/classpath/tools/gnu/classpath/tools/javah/CniStubPrinter.java b/libjava/classpath/tools/gnu/classpath/tools/javah/CniStubPrinter.java index 3acec232889..bbdda9249a1 100644 --- a/libjava/classpath/tools/gnu/classpath/tools/javah/CniStubPrinter.java +++ b/libjava/classpath/tools/gnu/classpath/tools/javah/CniStubPrinter.java @@ -59,9 +59,9 @@ public class CniStubPrinter private void printDecl(CniPrintStream out, String className, MethodNode method) { - out.print(className); + out.printName(className); out.print("::"); - out.print(method.name); + out.printName(method.name); out.print("("); Type[] argTypes = Type.getArgumentTypes(method.desc); for (int j = 0; j < argTypes.length; ++j) diff --git a/libjava/classpath/tools/gnu/classpath/tools/javah/FieldHelper.java b/libjava/classpath/tools/gnu/classpath/tools/javah/FieldHelper.java index f1c369af267..84b1fce8bf9 100644 --- a/libjava/classpath/tools/gnu/classpath/tools/javah/FieldHelper.java +++ b/libjava/classpath/tools/gnu/classpath/tools/javah/FieldHelper.java @@ -66,7 +66,7 @@ public class FieldHelper out.print(")))) "); result = true; } - out.print(Keywords.getCxxName(field.name)); + out.printName(field.name); if (hasMethodName) out.print("__"); if (Modifier.isStatic(field.access)) diff --git a/libjava/classpath/tools/gnu/classpath/tools/javah/Keywords.java b/libjava/classpath/tools/gnu/classpath/tools/javah/Keywords.java index 46543ba45df..b281197c5e9 100644 --- a/libjava/classpath/tools/gnu/classpath/tools/javah/Keywords.java +++ b/libjava/classpath/tools/gnu/classpath/tools/javah/Keywords.java @@ -42,28 +42,115 @@ import java.util.HashSet; public class Keywords { - private static final String[] words = { "and", "and_eq", "asm", "auto", - "bitand", "bitor", "bool", "break", - "case", "catch", "char", "class", - "compl", "const", "const_cast", - "continue", "default", "delete", "do", - "double", "dynamic_cast", "else", - "enum", "explicit", "export", - "extern", "false", "float", "for", - "friend", "goto", "if", "inline", - "int", "long", "mutable", "namespace", - "new", "not", "not_eq", "operator", - "or", "or_eq", "private", "protected", - "public", "register", - "reinterpret_cast", "return", "short", - "signed", "sizeof", "static", - "static_cast", "struct", "switch", - "template", "this", "throw", "true", - "try", "typedef", "typeid", - "typename", "typeof", "union", - "unsigned", "using", "virtual", - "void", "volatile", "wchar_t", - "while", "xor", "xor_eq" }; +/* A sorted list of all C++ keywords. This is identical to the list + in gcc/java/mangle.c. */ + private static final String[] words = + { + "_Complex", + "__alignof", + "__alignof__", + "__asm", + "__asm__", + "__attribute", + "__attribute__", + "__builtin_va_arg", + "__complex", + "__complex__", + "__const", + "__const__", + "__extension__", + "__imag", + "__imag__", + "__inline", + "__inline__", + "__label__", + "__null", + "__real", + "__real__", + "__restrict", + "__restrict__", + "__signed", + "__signed__", + "__typeof", + "__typeof__", + "__volatile", + "__volatile__", + "and", + "and_eq", + "asm", + "auto", + "bitand", + "bitor", + "bool", + "break", + "case", + "catch", + "char", + "class", + "compl", + "const", + "const_cast", + "continue", + "default", + "delete", + "do", + "double", + "dynamic_cast", + "else", + "enum", + "explicit", + "export", + "extern", + "false", + "float", + "for", + "friend", + "goto", + "if", + "inline", + "int", + "long", + "mutable", + "namespace", + "new", + "not", + "not_eq", + "operator", + "or", + "or_eq", + "private", + "protected", + "public", + "register", + "reinterpret_cast", + "return", + "short", + "signed", + "sizeof", + "static", + "static_cast", + "struct", + "switch", + "template", + "this", + "throw", + "true", + "try", + "typedef", + "typeid", + "typename", + "typeof", + "union", + "unsigned", + "using", + "virtual", + "void", + "volatile", + "wchar_t", + "while", + "xor", + "xor_eq" + }; private static final HashSet keywords; static diff --git a/libjava/classpath/tools/gnu/classpath/tools/javah/MethodHelper.java b/libjava/classpath/tools/gnu/classpath/tools/javah/MethodHelper.java index 4359523ba05..e12e47c540e 100644 --- a/libjava/classpath/tools/gnu/classpath/tools/javah/MethodHelper.java +++ b/libjava/classpath/tools/gnu/classpath/tools/javah/MethodHelper.java @@ -97,14 +97,14 @@ public class MethodHelper { out.print(Type.getReturnType(meth.desc)); out.print(" "); - out.print(realMethodName); + out.printName(realMethodName); } else { String name = declarer.name; int index = name.lastIndexOf('/'); name = name.substring(index + 1); - out.print(name); + out.printName(name); } out.print("("); Type[] argTypes = Type.getArgumentTypes(meth.desc); |