Changeset 846 for trunk/src/tools/moc


Ignore:
Timestamp:
May 5, 2011, 5:36:53 AM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
23 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/tools/moc/generator.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    174174    fprintf(out, "static const uint qt_meta_data_%s[] = {\n", qualifiedClassNameIdentifier.constData());
    175175    fprintf(out, "\n // content:\n");
    176     fprintf(out, "    %4d,       // revision\n", 4);
     176    fprintf(out, "    %4d,       // revision\n", 5);
    177177    fprintf(out, "    %4d,       // classname\n", strreg(cdef->qualified));
    178178    fprintf(out, "    %4d, %4d, // classinfo\n", cdef->classInfoList.count(), cdef->classInfoList.count() ? index : 0);
     
    483483void Generator::generateProperties()
    484484{
    485     //
    486     // specify get function, for compatibiliy we accept functions
    487     // returning pointers, or const char * for QByteArray.
    488     //
    489     for (int i = 0; i < cdef->propertyList.count(); ++i) {
    490         PropertyDef &p = cdef->propertyList[i];
    491         if (p.read.isEmpty())
    492             continue;
    493         for (int j = 0; j < cdef->publicList.count(); ++j) {
    494             const FunctionDef &f = cdef->publicList.at(j);
    495             if (f.name != p.read)
    496                 continue;
    497             if (!f.isConst) // get  functions must be const
    498                 continue;
    499             if (f.arguments.size()) // and must not take any arguments
    500                 continue;
    501             PropertyDef::Specification spec = PropertyDef::ValueSpec;
    502             QByteArray tmp = f.normalizedType;
    503             if (p.type == "QByteArray" && tmp == "const char *")
    504                     tmp = "QByteArray";
    505             if (tmp.left(6) == "const ")
    506                 tmp = tmp.mid(6);
    507             if (p.type != tmp && tmp.endsWith('*')) {
    508                 tmp.chop(1);
    509                 spec = PropertyDef::PointerSpec;
    510             } else if (f.type.name.endsWith('&')) { // raw type, not normalized type
    511                 spec = PropertyDef::ReferenceSpec;
    512             }
    513             if (p.type != tmp)
    514                 continue;
    515             p.gspec = spec;
    516             break;
    517         }
    518         if(!p.notify.isEmpty()) {
    519             int notifyId = -1;
    520             for (int j = 0; j < cdef->signalList.count(); ++j) {
    521                 const FunctionDef &f = cdef->signalList.at(j);
    522                 if(f.name != p.notify) {
    523                     continue;
    524                 } else {
    525                     notifyId = j /* Signal indexes start from 0 */;
    526                     break;
    527                 }
    528             }
    529             p.notifyId = notifyId;
    530         }
    531     }
    532 
    533485    //
    534486    // Create meta data
  • trunk/src/tools/moc/generator.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/tools/moc/keywords.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/tools/moc/main.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    362362
    363363    if (autoInclude) {
     364        int spos = filename.lastIndexOf(QDir::separator().toLatin1());
    364365        int ppos = filename.lastIndexOf('.');
    365         moc.noInclude = (ppos >= 0
    366                          && tolower(filename[ppos + 1]) != 'h'
    367                          && tolower(filename[ppos + 1]) != QDir::separator().toLatin1()
    368                         );
     366        // spos >= -1 && ppos > spos => ppos >= 0
     367        moc.noInclude = (ppos > spos && tolower(filename[ppos + 1]) != 'h');
    369368    }
    370369    if (moc.includeFiles.isEmpty()) {
  • trunk/src/tools/moc/moc.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    231231    }
    232232    while (test(CONST) || test(VOLATILE) || test(SIGNED) || test(UNSIGNED)
    233            || test(STAR) || test(AND)) {
     233           || test(STAR) || test(AND) || test(ANDAND)) {
    234234        type.name += ' ';
    235235        type.name += lexem();
    236236        if (lookup(0) == AND)
    237237            type.referenceType = Type::Reference;
     238        else if (lookup(0) == ANDAND)
     239            type.referenceType = Type::RValueReference;
    238240        else if (lookup(0) == STAR)
    239241            type.referenceType = Type::Pointer;
     
    726728
    727729            checkSuperClasses(&def);
     730            checkProperties(&def);
    728731
    729732            classList += def;
     
    12071210        }
    12081211    }
     1212
     1213    //when searching commas within the default argument, we should take care of template depth (anglecount)
     1214    // unfortunatelly, we do not have enough semantic information to know if '<' is the operator< or
     1215    // the beginning of a template type. so we just use heuristics.
     1216    int possible = -1;
     1217
    12091218    while (index < symbols.size()) {
    12101219        Token t = symbols.at(index++).token;
     
    12251234            && brackCount <= 0
    12261235            && parenCount <= 0
    1227             && (target != RANGLE || angleCount <= 0))
     1236            && (target != RANGLE || angleCount <= 0)) {
     1237            if (target != COMMA || angleCount <= 0)
     1238                return true;
     1239            possible = index;
     1240        }
     1241
     1242        if (target == COMMA && t == EQ && possible != -1) {
     1243            index = possible;
    12281244            return true;
     1245        }
    12291246
    12301247        if (braceCount < 0 || brackCount < 0 || parenCount < 0
     
    12341251        }
    12351252    }
     1253
     1254    if(target == COMMA && angleCount != 0 && possible != -1) {
     1255        index = possible;
     1256        return true;
     1257    }
     1258
    12361259    return false;
    12371260}
     
    12911314}
    12921315
     1316void Moc::checkProperties(ClassDef *cdef)
     1317{
     1318    //
     1319    // specify get function, for compatibiliy we accept functions
     1320    // returning pointers, or const char * for QByteArray.
     1321    //
     1322    for (int i = 0; i < cdef->propertyList.count(); ++i) {
     1323        PropertyDef &p = cdef->propertyList[i];
     1324        if (p.read.isEmpty())
     1325            continue;
     1326        for (int j = 0; j < cdef->publicList.count(); ++j) {
     1327            const FunctionDef &f = cdef->publicList.at(j);
     1328            if (f.name != p.read)
     1329                continue;
     1330            if (!f.isConst) // get  functions must be const
     1331                continue;
     1332            if (f.arguments.size()) // and must not take any arguments
     1333                continue;
     1334            PropertyDef::Specification spec = PropertyDef::ValueSpec;
     1335            QByteArray tmp = f.normalizedType;
     1336            if (p.type == "QByteArray" && tmp == "const char *")
     1337                tmp = "QByteArray";
     1338            if (tmp.left(6) == "const ")
     1339                tmp = tmp.mid(6);
     1340            if (p.type != tmp && tmp.endsWith('*')) {
     1341                tmp.chop(1);
     1342                spec = PropertyDef::PointerSpec;
     1343            } else if (f.type.name.endsWith('&')) { // raw type, not normalized type
     1344                spec = PropertyDef::ReferenceSpec;
     1345            }
     1346            if (p.type != tmp)
     1347                continue;
     1348            p.gspec = spec;
     1349            break;
     1350        }
     1351        if(!p.notify.isEmpty()) {
     1352            int notifyId = -1;
     1353            for (int j = 0; j < cdef->signalList.count(); ++j) {
     1354                const FunctionDef &f = cdef->signalList.at(j);
     1355                if(f.name != p.notify) {
     1356                    continue;
     1357                } else {
     1358                    notifyId = j /* Signal indexes start from 0 */;
     1359                    break;
     1360                }
     1361            }
     1362            p.notifyId = notifyId;
     1363            if (notifyId == -1) {
     1364                QByteArray msg = "NOTIFY signal '" + p.notify + "' of property '" + p.name
     1365                        + "' does not exist in class " + cdef->classname + ".";
     1366                error(msg.constData());
     1367            }
     1368        }
     1369    }
     1370}
     1371
     1372
    12931373
    12941374QT_END_NAMESPACE
  • trunk/src/tools/moc/moc.h

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    5656struct Type
    5757{
    58     enum ReferenceType { NoReference, Reference, Pointer };
     58    enum ReferenceType { NoReference, Reference, RValueReference, Pointer };
    5959
    6060    inline Type() : isVolatile(false), isScoped(false), firstToken(NOTOKEN), referenceType(NoReference) {}
     
    239239
    240240    void checkSuperClasses(ClassDef *def);
     241    void checkProperties(ClassDef* cdef);
    241242};
    242243
    243244inline QByteArray noRef(const QByteArray &type)
    244245{
    245     if (type.endsWith('&'))
     246    if (type.endsWith('&')) {
     247        if (type.endsWith("&&"))
     248            return type.left(type.length()-2);
    246249        return type.left(type.length()-1);
     250    }
    247251    return type;
    248252}
  • trunk/src/tools/moc/mwerks_mac.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/tools/moc/mwerks_mac.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/tools/moc/outputrevision.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/tools/moc/parser.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/tools/moc/parser.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/tools/moc/ppkeywords.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/tools/moc/preprocessor.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/tools/moc/preprocessor.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/tools/moc/symbols.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/tools/moc/token.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/tools/moc/token.h

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/tools/moc/util/generate.sh

    r651 r846  
    22#############################################################################
    33##
    4 ## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     4## Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    55## All rights reserved.
    66## Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/tools/moc/util/generate_keywords.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/tools/moc/util/generate_keywords.pro

    r2 r846  
    1111SOURCES += generate_keywords.cpp
    1212CONFIG += qt create_prl link_prl
    13 OBJECTS_DIR=.obj/debug-shared
  • trunk/src/tools/moc/util/licenseheader.txt

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/tools/moc/utils.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
Note: See TracChangeset for help on using the changeset viewer.