tools/qdoc3/cppcodeparser.cpp
changeset 33 3e2da88830cd
parent 30 5dc02b23752f
equal deleted inserted replaced
30:5dc02b23752f 33:3e2da88830cd
   726         if (names.size() > 1) {
   726         if (names.size() > 1) {
   727             Node* n = tre->findNode(names[1].split("::"),Node::Class);
   727             Node* n = tre->findNode(names[1].split("::"),Node::Class);
   728             if (n)
   728             if (n)
   729                 classNode = static_cast<const ClassNode*>(n);
   729                 classNode = static_cast<const ClassNode*>(n);
   730         }
   730         }
   731         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);
   732     }
   735     }
   733     else if (command == COMMAND_QMLBASICTYPE) {
   736     else if (command == COMMAND_QMLBASICTYPE) {
   734 #if 0
       
   735         QStringList parts = arg.split(" ");
       
   736         qDebug() << command << parts;
       
   737         if (parts.size() > 1) {
       
   738             FakeNode* pageNode = static_cast<FakeNode*>(tre->root()->findNode(parts[1], Node::Fake));
       
   739             if (pageNode) {
       
   740                 qDebug() << "FOUND";
       
   741                 return new QmlBasicTypeNode(pageNode, parts[0]);
       
   742             }
       
   743         }
       
   744 #endif
       
   745         return new QmlBasicTypeNode(tre->root(), arg);
   737         return new QmlBasicTypeNode(tre->root(), arg);
   746     }
   738     }
   747     else if ((command == COMMAND_QMLSIGNAL) ||
   739     else if ((command == COMMAND_QMLSIGNAL) ||
   748              (command == COMMAND_QMLMETHOD) ||
   740              (command == COMMAND_QMLMETHOD) ||
   749              (command == COMMAND_QMLATTACHEDSIGNAL) ||
   741              (command == COMMAND_QMLATTACHEDSIGNAL) ||
   750              (command == COMMAND_QMLATTACHEDMETHOD)) {
   742              (command == COMMAND_QMLATTACHEDMETHOD)) {
   751         QString element;
   743         QString element;
   752         QString type;
   744         QString type;
   753         QmlClassNode* qmlClass = 0;
   745         QmlClassNode* qmlClass = 0;
   754         if (splitQmlMethodArg(doc,arg,type,element)) {
   746         if (splitQmlMethodArg(doc,arg,type,element)) {
       
   747             if (element.startsWith(QLatin1String("Qt")))
       
   748                 element = QLatin1String("QML:") + element;
   755             Node* n = tre->findNode(QStringList(element),Node::Fake);
   749             Node* n = tre->findNode(QStringList(element),Node::Fake);
   756             if (n && n->subType() == Node::QmlClass) {
   750             if (n && n->subType() == Node::QmlClass) {
   757                 qmlClass = static_cast<QmlClassNode*>(n);
   751                 qmlClass = static_cast<QmlClassNode*>(n);
   758                 if (command == COMMAND_QMLSIGNAL)
   752                 if (command == COMMAND_QMLSIGNAL)
   759                     return makeFunctionNode(doc,arg,qmlClass,Node::QmlSignal,false,COMMAND_QMLSIGNAL);
   753                     return makeFunctionNode(doc,arg,qmlClass,Node::QmlSignal,false,COMMAND_QMLSIGNAL);
  1124     else
  1118     else
  1125         return false;
  1119         return false;
  1126 }
  1120 }
  1127 
  1121 
  1128 /*!
  1122 /*!
       
  1123   Skip to \a target. If \a target is found before the end
       
  1124   of input, return true. Otherwise return false.
       
  1125  */
       
  1126 bool CppCodeParser::skipTo(int target)
       
  1127 {
       
  1128     while ((tok != Tok_Eoi) && (tok != target))
       
  1129         readToken();
       
  1130     return (tok == target ? true : false);
       
  1131 }
       
  1132 
       
  1133 /*!
  1129   If the current token is one of the keyword thingees that
  1134   If the current token is one of the keyword thingees that
  1130   are used in Qt, skip over it to the next token and return
  1135   are used in Qt, skip over it to the next token and return
  1131   true. Otherwise just return false without reading the
  1136   true. Otherwise just return false without reading the
  1132   next token.
  1137   next token.
  1133  */
  1138  */
  1366             compat = true;
  1371             compat = true;
  1367     }
  1372     }
  1368 
  1373 
  1369     if (!matchDataType(&returnType)) {
  1374     if (!matchDataType(&returnType)) {
  1370         if (tokenizer->parsingFnOrMacro()
  1375         if (tokenizer->parsingFnOrMacro()
  1371                 && (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)))
  1372             returnType = CodeChunk(previousLexeme());
  1379             returnType = CodeChunk(previousLexeme());
  1373         else {
  1380         else {
  1374             return false;
  1381             return false;
  1375         }
  1382         }
  1376     }
  1383     }
  1800     return true;
  1807     return true;
  1801 }
  1808 }
  1802 
  1809 
  1803 bool CppCodeParser::matchProperty(InnerNode *parent)
  1810 bool CppCodeParser::matchProperty(InnerNode *parent)
  1804 {
  1811 {
  1805     if (!match(Tok_Q_PROPERTY) &&
  1812     int expected_tok = Tok_LeftParen;
  1806         !match(Tok_Q_OVERRIDE) &&
  1813     if (match(Tok_Q_PRIVATE_PROPERTY)) {
  1807         !match(Tok_QDOC_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)) {
  1808         return false;
  1821         return false;
  1809     if (!match(Tok_LeftParen))
  1822     }
       
  1823     
       
  1824     if (!match(expected_tok))
  1810         return false;
  1825         return false;
  1811 
  1826 
  1812     QString name;
  1827     QString name;
  1813     CodeChunk dataType;
  1828     CodeChunk dataType;
  1814     if (!matchDataType(&dataType, &name))
  1829     if (!matchDataType(&dataType, &name))
  1848         if (key == "READ")
  1863         if (key == "READ")
  1849             tre->addPropertyFunction(property, value, PropertyNode::Getter);
  1864             tre->addPropertyFunction(property, value, PropertyNode::Getter);
  1850         else if (key == "WRITE") {
  1865         else if (key == "WRITE") {
  1851             tre->addPropertyFunction(property, value, PropertyNode::Setter);
  1866             tre->addPropertyFunction(property, value, PropertyNode::Setter);
  1852             property->setWritable(true);
  1867             property->setWritable(true);
  1853         } else if (key == "STORED")
  1868         }
       
  1869         else if (key == "STORED")
  1854             property->setStored(value.toLower() == "true");
  1870             property->setStored(value.toLower() == "true");
  1855         else if (key == "DESIGNABLE")
  1871         else if (key == "DESIGNABLE") {
  1856             property->setDesignable(value.toLower() == "true");
  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         }
  1857         else if (key == "RESET")
  1882         else if (key == "RESET")
  1858             tre->addPropertyFunction(property, value, PropertyNode::Resetter);
  1883             tre->addPropertyFunction(property, value, PropertyNode::Resetter);
  1859         else if (key == "NOTIFY") {
  1884         else if (key == "NOTIFY") {
  1860             tre->addPropertyFunction(property, value, PropertyNode::Notifier);
  1885             tre->addPropertyFunction(property, value, PropertyNode::Notifier);
  1861         }
  1886         }
  1862 
  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();
  1863     }
  1902     }
  1864     match(Tok_RightParen);
  1903     match(Tok_RightParen);
  1865     return true;
  1904     return true;
  1866 }
  1905 }
  1867 
  1906 
  1929         case Tok_Q_OBJECT:
  1968         case Tok_Q_OBJECT:
  1930             readToken();
  1969             readToken();
  1931             break;
  1970             break;
  1932         case Tok_Q_OVERRIDE:
  1971         case Tok_Q_OVERRIDE:
  1933         case Tok_Q_PROPERTY:
  1972         case Tok_Q_PROPERTY:
       
  1973         case Tok_Q_PRIVATE_PROPERTY:
  1934         case Tok_QDOC_PROPERTY:
  1974         case Tok_QDOC_PROPERTY:
  1935             matchProperty(parent);
  1975             matchProperty(parent);
  1936             break;
  1976             break;
  1937         case Tok_Q_DECLARE_SEQUENTIAL_ITERATOR:
  1977         case Tok_Q_DECLARE_SEQUENTIAL_ITERATOR:
  1938             readToken();
  1978             readToken();