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:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • 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
Note: See TracChangeset for help on using the changeset viewer.