From c216fe9d1328f6fb771fcb531778adb7f4220015 Mon Sep 17 00:00:00 2001 From: Alex Wilson Date: Mon, 26 Jul 2010 05:10:17 +0000 Subject: [PATCH] Update (de)mangle_class_name() functions to be compiler version aware. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37750 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/support/Archivable.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/kits/support/Archivable.cpp b/src/kits/support/Archivable.cpp index 13c7102b4b..2b08106446 100644 --- a/src/kits/support/Archivable.cpp +++ b/src/kits/support/Archivable.cpp @@ -57,6 +57,23 @@ demangle_class_name(const char* name, BString& out) out = ""; +#if __GNUC__ >= 4 + if (name[0] == 'N') + name++; + int nameLen; + bool first = true; + while ((nameLen = strtoul(name, (char**)&name, 10))) { + if (!first) + out += "::"; + else + first = false; + out.Append(name, nameLen); + name += nameLen; + } + if (first) + return B_BAD_VALUE; + +#else if (name[0] == 'Q') { // The name is in a namespace int namespaceCount = 0; @@ -87,6 +104,7 @@ demangle_class_name(const char* name, BString& out) int nameLength = strtoul(name, (char**)&name, 10); out.Append(name, nameLength); +#endif return B_OK; } @@ -116,8 +134,19 @@ mangle_class_name(const char* name, BString& out) } // Now mangle it into this: + // 9testthree8testfour9Testthree8Testfour + // (for __GNUC__ > 2) + // this isn't always the proper mangled class name, it should + // actually have an 'N' prefix and 'E' suffix if the name is + // in > 0 namespaces, but these would have to be removed in + // build_function_name() (the only place this function is called) + // so we don't add them. + // or this: // Q49testthree8testfour9Testthree8Testfour + // (for __GNUC__ == 2) + out = ""; +#if __GNUC__ == 2 if (count > 1) { out += 'Q'; if (count > 10) @@ -126,6 +155,7 @@ mangle_class_name(const char* name, BString& out) if (count > 10) out += '_'; } +#endif for (unsigned int i = 0; i < spacenames.size(); ++i) { out << (int)spacenames[i].length();