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/tools/qdoc3/cppcodeparser.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)
     
    4444*/
    4545
    46 #include <QtCore>
    4746#include <qfile.h>
    4847
    4948#include <stdio.h>
    5049#include <errno.h>
     50#include <qdebug.h>
    5151
    5252#include "codechunk.h"
     
    9696#define COMMAND_QMLATTACHEDMETHOD       Doc::alias("qmlattachedmethod")
    9797#define COMMAND_QMLDEFAULT              Doc::alias("default")
     98#define COMMAND_QMLBASICTYPE            Doc::alias("qmlbasictype")
    9899#endif
    99100
     
    281282                                    Tree *tree)
    282283{
    283     FILE *in = fopen(QFile::encodeName(filePath), "r");
    284     if (!in) {
     284    QFile in(filePath);
     285    if (!in.open(QIODevice::ReadOnly)) {
    285286        location.error(tr("Cannot open C++ header file '%1'").arg(filePath));
    286287        return;
     
    295296    if (!fileTokenizer.version().isEmpty())
    296297        tree->setVersion(fileTokenizer.version());
    297     fclose(in);
     298    in.close();
    298299
    299300    if (fileLocation.fileName() == "qiterator.h")
     
    312313                                    Tree *tree)
    313314{
    314     FILE *in = fopen(QFile::encodeName(filePath), "r");
    315     if (!in) {
     315    QFile in(filePath);
     316    if (!in.open(QIODevice::ReadOnly)) {
    316317        location.error(tr("Cannot open C++ source file '%1' (%2)").arg(filePath).arg(strerror(errno)));
    317318        return;
     
    325326    usedNamespaces.clear();
    326327    matchDocsAndStuff();
    327     fclose(in);
     328    in.close();
    328329}
    329330
     
    492493                }
    493494
    494                
     495
    495496                /*
    496497                    There are several functions with the correct
     
    537538                           << COMMAND_QMLATTACHEDSIGNAL
    538539                           << COMMAND_QMLMETHOD
    539                            << COMMAND_QMLATTACHEDMETHOD;
     540                           << COMMAND_QMLATTACHEDMETHOD
     541                           << COMMAND_QMLBASICTYPE;
    540542#else
    541543                           << COMMAND_VARIABLE;
     
    544546
    545547/*!
    546   Process the topic \a command in context \a doc with argument \a arg. 
     548  Process the topic \a command in context \a doc with argument \a arg.
    547549 */
    548550Node *CppCodeParser::processTopicCommand(const Doc& doc,
     
    727729                classNode = static_cast<const ClassNode*>(n);
    728730        }
    729         return new QmlClassNode(tre->root(), names[0], classNode);
     731        if (names[0].startsWith("Qt"))
     732            return new QmlClassNode(tre->root(), QLatin1String("QML:")+names[0], classNode);
     733        else
     734            return new QmlClassNode(tre->root(), names[0], classNode);
     735    }
     736    else if (command == COMMAND_QMLBASICTYPE) {
     737        return new QmlBasicTypeNode(tre->root(), arg);
    730738    }
    731739    else if ((command == COMMAND_QMLSIGNAL) ||
     
    737745        QmlClassNode* qmlClass = 0;
    738746        if (splitQmlMethodArg(doc,arg,type,element)) {
     747            if (element.startsWith(QLatin1String("Qt")))
     748                element = QLatin1String("QML:") + element;
    739749            Node* n = tre->findNode(QStringList(element),Node::Fake);
    740750            if (n && n->subType() == Node::QmlClass) {
     
    897907                                << COMMAND_PREVIOUSPAGE
    898908                                << COMMAND_INDEXPAGE
    899 #ifdef QDOC_QML       
     909#ifdef QDOC_QML
    900910                                << COMMAND_STARTPAGE
    901911                                << COMMAND_QMLINHERITS
    902912                                << COMMAND_QMLDEFAULT;
    903 #else   
     913#else
    904914                                << COMMAND_STARTPAGE;
    905 #endif   
     915#endif
    906916}
    907917
     
    10181028    else if (command == COMMAND_QMLINHERITS) {
    10191029        setLink(node, Node::InheritsLink, arg);
    1020     }
     1030        if (node->subType() == Node::QmlClass) {
     1031            QmlClassNode::addInheritedBy(arg,node);
     1032        }
     1033   }
    10211034    else if (command == COMMAND_QMLDEFAULT) {
    10221035        QmlPropGroupNode* qpgn = static_cast<QmlPropGroupNode*>(node);
     
    11051118    else
    11061119        return false;
     1120}
     1121
     1122/*!
     1123  Skip to \a target. If \a target is found before the end
     1124  of input, return true. Otherwise return false.
     1125 */
     1126bool CppCodeParser::skipTo(int target)
     1127{
     1128    while ((tok != Tok_Eoi) && (tok != target))
     1129        readToken();
     1130    return (tok == target ? true : false);
    11071131}
    11081132
     
    13501374    if (!matchDataType(&returnType)) {
    13511375        if (tokenizer->parsingFnOrMacro()
    1352                 && (match(Tok_Q_DECLARE_FLAGS) || match(Tok_Q_PROPERTY)))
     1376                && (match(Tok_Q_DECLARE_FLAGS) ||
     1377                    match(Tok_Q_PROPERTY) ||
     1378                    match(Tok_Q_PRIVATE_PROPERTY)))
    13531379            returnType = CodeChunk(previousLexeme());
    13541380        else {
     
    16331659    QString namespaceName = previousLexeme();
    16341660    NamespaceNode *namespasse = 0;
    1635     if (parent)
     1661    if (parent) {
    16361662        namespasse = static_cast<NamespaceNode*>(parent->findNode(namespaceName, Node::Namespace));
     1663    }
    16371664    if (!namespasse) {
    16381665        namespasse = new NamespaceNode(parent, namespaceName);
     
    17831810bool CppCodeParser::matchProperty(InnerNode *parent)
    17841811{
    1785     if (!match(Tok_Q_PROPERTY) &&
    1786         !match(Tok_Q_OVERRIDE) &&
    1787         !match(Tok_QDOC_PROPERTY))
     1812    int expected_tok = Tok_LeftParen;
     1813    if (match(Tok_Q_PRIVATE_PROPERTY)) {
     1814        expected_tok = Tok_Comma;
     1815        if (!skipTo(Tok_Comma))
     1816            return false;
     1817    }
     1818    else if (!match(Tok_Q_PROPERTY) &&
     1819             !match(Tok_Q_OVERRIDE) &&
     1820             !match(Tok_QDOC_PROPERTY)) {
    17881821        return false;
    1789     if (!match(Tok_LeftParen))
     1822    }
     1823   
     1824    if (!match(expected_tok))
    17901825        return false;
    17911826
     
    18311866            tre->addPropertyFunction(property, value, PropertyNode::Setter);
    18321867            property->setWritable(true);
    1833         } else if (key == "STORED")
     1868        }
     1869        else if (key == "STORED")
    18341870            property->setStored(value.toLower() == "true");
    1835         else if (key == "DESIGNABLE")
    1836             property->setDesignable(value.toLower() == "true");
     1871        else if (key == "DESIGNABLE") {
     1872            QString v = value.toLower();
     1873            if (v == "true")
     1874                property->setDesignable(true);
     1875            else if (v == "false")
     1876                property->setDesignable(false);
     1877            else {
     1878                property->setDesignable(false);
     1879                property->setRuntimeDesFunc(value);
     1880            }
     1881        }
    18371882        else if (key == "RESET")
    18381883            tre->addPropertyFunction(property, value, PropertyNode::Resetter);
     
    18401885            tre->addPropertyFunction(property, value, PropertyNode::Notifier);
    18411886        }
    1842 
     1887        else if (key == "SCRIPTABLE") {
     1888            QString v = value.toLower();
     1889            if (v == "true")
     1890                property->setScriptable(true);
     1891            else if (v == "false")
     1892                property->setScriptable(false);
     1893            else {
     1894                property->setScriptable(false);
     1895                property->setRuntimeScrFunc(value);
     1896            }
     1897        }
     1898        else if (key == "COSTANT")
     1899            property->setConstant();
     1900        else if (key == "FINAL")
     1901            property->setFinal();
    18431902    }
    18441903    match(Tok_RightParen);
     
    19121971        case Tok_Q_OVERRIDE:
    19131972        case Tok_Q_PROPERTY:
     1973        case Tok_Q_PRIVATE_PROPERTY:
    19141974        case Tok_QDOC_PROPERTY:
    19151975            matchProperty(parent);
     
    21002160                    ++a;
    21012161                }
    2102 #endif               
     2162#endif
    21032163            }
    21042164
     
    22492309{
    22502310    QString examplePath = fake->name();
    2251 
    2252     // we can assume that this file always exists
    2253     QString proFileName = examplePath + "/" +
    2254         examplePath.split("/").last() + ".pro";
    2255 
     2311    QString proFileName = examplePath + "/" + examplePath.split("/").last() + ".pro";
    22562312    QString userFriendlyFilePath;
     2313
    22572314    QString fullPath = Config::findFile(fake->doc().location(),
    22582315                                        exampleFiles,
     
    22602317                                        proFileName,
    22612318                                        userFriendlyFilePath);
    2262    
     2319
    22632320    if (fullPath.isEmpty()) {
    22642321        QString tmp = proFileName;
     
    22712328                                    userFriendlyFilePath);
    22722329        if (fullPath.isEmpty()) {
    2273             fake->doc().location().warning(
    2274                tr("Cannot find file '%1' or '%2'").arg(tmp).arg(proFileName));
    2275             return;
     2330            proFileName = examplePath + "/" + examplePath.split("/").last() + ".qmlproject";
     2331            userFriendlyFilePath.clear();
     2332            fullPath = Config::findFile(fake->doc().location(),
     2333                                        exampleFiles,
     2334                                        exampleDirs,
     2335                                        proFileName,
     2336                                        userFriendlyFilePath);
     2337            if (fullPath.isEmpty()) {
     2338                fake->doc().location().warning(
     2339                    tr("Cannot find file '%1' or '%2'").arg(tmp).arg(proFileName));
     2340                return;
     2341            }
    22762342        }
    22772343    }
     
    22832349    QString imagesPath = fullPath + "/images";
    22842350    QStringList imageFiles = Config::getFilesHere(imagesPath,exampleImageFilter);
    2285 
    2286 #if 0   
    2287     qDebug() << "examplePath:" << examplePath;
    2288     qDebug() << " exampleFiles" <<  exampleFiles;
    2289     qDebug() << "imagesPath:" << imagesPath;
    2290     qDebug() << "fullPath:" << fullPath;
    2291     qDebug() << " imageFiles" <<  imageFiles;
    2292 #endif   
    22932351
    22942352    if (!exampleFiles.isEmpty()) {
     
    23042362            }
    23052363            else if (fileName.contains("/qrc_") || fileName.contains("/moc_")
    2306                     || fileName.contains("/ui_"))
     2364                || fileName.contains("/ui_"))
    23072365                i.remove();
    23082366        }
     
    23112369
    23122370        // add any qmake Qt resource files and qmake project files
    2313         exampleFiles += Config::getFilesHere(fullPath, "*.qrc *.pro");
     2371        exampleFiles += Config::getFilesHere(fullPath, "*.qrc *.pro qmldir");
    23142372    }
    23152373
Note: See TracChangeset for help on using the changeset viewer.