Ticket #6379: gcc4archiving.patch

File gcc4archiving.patch, 1.5 KB (added by yourpalal, 14 years ago)

patch to allow mangling & demangling of class names in namespaces under gcc4

  • src/kits/support/Archivable.cpp

     
    5757
    5858    out = "";
    5959
     60#if __GNUC__ >= 4
     61    if (name[0] == 'N')
     62        name++;
     63    int nameLen;
     64    bool first = true;
     65    while ((nameLen = strtoul(name, (char**)&name, 10))) {
     66        if (!first)
     67            out += "::";
     68        else
     69            first = false;
     70        out.Append(name, nameLen);
     71        name += nameLen;
     72    }
     73    if (first)
     74        return B_BAD_VALUE;
     75
     76#else
    6077    if (name[0] == 'Q') {
    6178        // The name is in a namespace
    6279        int namespaceCount = 0;
     
    87104
    88105    int nameLength = strtoul(name, (char**)&name, 10);
    89106    out.Append(name, nameLength);
     107#endif
    90108
    91109    return B_OK;
    92110}
     
    116134    }
    117135
    118136    //  Now mangle it into this:
     137    //      9testthree8testfour9Testthree8Testfour
     138    //          (for __GNUC__ > 2)
     139    //          this isn't always the proper mangled class name, it should
     140    //          actually have an 'N' prefix and 'E' suffix if the name is
     141    //          in > 0 namespaces, but these would have to be removed in
     142    //          build_function_name() (the only place this function is called)
     143    //          so we don't add them.
     144    //  or this:
    119145    //      Q49testthree8testfour9Testthree8Testfour
     146    //          (for __GNUC__ == 2)
     147
    120148    out = "";
     149#if __GNUC__ == 2
    121150    if (count > 1) {
    122151        out += 'Q';
    123152        if (count > 10)
     
    126155        if (count > 10)
    127156            out += '_';
    128157    }
     158#endif
    129159
    130160    for (unsigned int i = 0; i < spacenames.size(); ++i) {
    131161        out << (int)spacenames[i].length();