mirror of
https://github.com/gcc-mirror/gcc.git
synced 2026-05-06 14:59:39 +02:00
re PR java/40590 (namespace namespace broken in CNI)
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. From-SVN: r149059
This commit is contained in:
committed by
Andrew Haley
parent
356ecb1530
commit
3ad1aba1f8
@@ -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.
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -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 ");
|
||||
|
||||
@@ -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(";");
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user