Changeset 846 for trunk/tools/qdoc3/cppcodeparser.cpp
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/tools/qdoc3/cppcodeparser.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 44 44 */ 45 45 46 #include <QtCore>47 46 #include <qfile.h> 48 47 49 48 #include <stdio.h> 50 49 #include <errno.h> 50 #include <qdebug.h> 51 51 52 52 #include "codechunk.h" … … 96 96 #define COMMAND_QMLATTACHEDMETHOD Doc::alias("qmlattachedmethod") 97 97 #define COMMAND_QMLDEFAULT Doc::alias("default") 98 #define COMMAND_QMLBASICTYPE Doc::alias("qmlbasictype") 98 99 #endif 99 100 … … 281 282 Tree *tree) 282 283 { 283 FILE *in = fopen(QFile::encodeName(filePath), "r");284 if (!in ) {284 QFile in(filePath); 285 if (!in.open(QIODevice::ReadOnly)) { 285 286 location.error(tr("Cannot open C++ header file '%1'").arg(filePath)); 286 287 return; … … 295 296 if (!fileTokenizer.version().isEmpty()) 296 297 tree->setVersion(fileTokenizer.version()); 297 fclose(in);298 in.close(); 298 299 299 300 if (fileLocation.fileName() == "qiterator.h") … … 312 313 Tree *tree) 313 314 { 314 FILE *in = fopen(QFile::encodeName(filePath), "r");315 if (!in ) {315 QFile in(filePath); 316 if (!in.open(QIODevice::ReadOnly)) { 316 317 location.error(tr("Cannot open C++ source file '%1' (%2)").arg(filePath).arg(strerror(errno))); 317 318 return; … … 325 326 usedNamespaces.clear(); 326 327 matchDocsAndStuff(); 327 fclose(in);328 in.close(); 328 329 } 329 330 … … 492 493 } 493 494 494 495 495 496 /* 496 497 There are several functions with the correct … … 537 538 << COMMAND_QMLATTACHEDSIGNAL 538 539 << COMMAND_QMLMETHOD 539 << COMMAND_QMLATTACHEDMETHOD; 540 << COMMAND_QMLATTACHEDMETHOD 541 << COMMAND_QMLBASICTYPE; 540 542 #else 541 543 << COMMAND_VARIABLE; … … 544 546 545 547 /*! 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. 547 549 */ 548 550 Node *CppCodeParser::processTopicCommand(const Doc& doc, … … 727 729 classNode = static_cast<const ClassNode*>(n); 728 730 } 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); 730 738 } 731 739 else if ((command == COMMAND_QMLSIGNAL) || … … 737 745 QmlClassNode* qmlClass = 0; 738 746 if (splitQmlMethodArg(doc,arg,type,element)) { 747 if (element.startsWith(QLatin1String("Qt"))) 748 element = QLatin1String("QML:") + element; 739 749 Node* n = tre->findNode(QStringList(element),Node::Fake); 740 750 if (n && n->subType() == Node::QmlClass) { … … 897 907 << COMMAND_PREVIOUSPAGE 898 908 << COMMAND_INDEXPAGE 899 #ifdef QDOC_QML 909 #ifdef QDOC_QML 900 910 << COMMAND_STARTPAGE 901 911 << COMMAND_QMLINHERITS 902 912 << COMMAND_QMLDEFAULT; 903 #else 913 #else 904 914 << COMMAND_STARTPAGE; 905 #endif 915 #endif 906 916 } 907 917 … … 1018 1028 else if (command == COMMAND_QMLINHERITS) { 1019 1029 setLink(node, Node::InheritsLink, arg); 1020 } 1030 if (node->subType() == Node::QmlClass) { 1031 QmlClassNode::addInheritedBy(arg,node); 1032 } 1033 } 1021 1034 else if (command == COMMAND_QMLDEFAULT) { 1022 1035 QmlPropGroupNode* qpgn = static_cast<QmlPropGroupNode*>(node); … … 1105 1118 else 1106 1119 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 */ 1126 bool CppCodeParser::skipTo(int target) 1127 { 1128 while ((tok != Tok_Eoi) && (tok != target)) 1129 readToken(); 1130 return (tok == target ? true : false); 1107 1131 } 1108 1132 … … 1350 1374 if (!matchDataType(&returnType)) { 1351 1375 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))) 1353 1379 returnType = CodeChunk(previousLexeme()); 1354 1380 else { … … 1633 1659 QString namespaceName = previousLexeme(); 1634 1660 NamespaceNode *namespasse = 0; 1635 if (parent) 1661 if (parent) { 1636 1662 namespasse = static_cast<NamespaceNode*>(parent->findNode(namespaceName, Node::Namespace)); 1663 } 1637 1664 if (!namespasse) { 1638 1665 namespasse = new NamespaceNode(parent, namespaceName); … … 1783 1810 bool CppCodeParser::matchProperty(InnerNode *parent) 1784 1811 { 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)) { 1788 1821 return false; 1789 if (!match(Tok_LeftParen)) 1822 } 1823 1824 if (!match(expected_tok)) 1790 1825 return false; 1791 1826 … … 1831 1866 tre->addPropertyFunction(property, value, PropertyNode::Setter); 1832 1867 property->setWritable(true); 1833 } else if (key == "STORED") 1868 } 1869 else if (key == "STORED") 1834 1870 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 } 1837 1882 else if (key == "RESET") 1838 1883 tre->addPropertyFunction(property, value, PropertyNode::Resetter); … … 1840 1885 tre->addPropertyFunction(property, value, PropertyNode::Notifier); 1841 1886 } 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(); 1843 1902 } 1844 1903 match(Tok_RightParen); … … 1912 1971 case Tok_Q_OVERRIDE: 1913 1972 case Tok_Q_PROPERTY: 1973 case Tok_Q_PRIVATE_PROPERTY: 1914 1974 case Tok_QDOC_PROPERTY: 1915 1975 matchProperty(parent); … … 2100 2160 ++a; 2101 2161 } 2102 #endif 2162 #endif 2103 2163 } 2104 2164 … … 2249 2309 { 2250 2310 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"; 2256 2312 QString userFriendlyFilePath; 2313 2257 2314 QString fullPath = Config::findFile(fake->doc().location(), 2258 2315 exampleFiles, … … 2260 2317 proFileName, 2261 2318 userFriendlyFilePath); 2262 2319 2263 2320 if (fullPath.isEmpty()) { 2264 2321 QString tmp = proFileName; … … 2271 2328 userFriendlyFilePath); 2272 2329 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 } 2276 2342 } 2277 2343 } … … 2283 2349 QString imagesPath = fullPath + "/images"; 2284 2350 QStringList imageFiles = Config::getFilesHere(imagesPath,exampleImageFilter); 2285 2286 #if 02287 qDebug() << "examplePath:" << examplePath;2288 qDebug() << " exampleFiles" << exampleFiles;2289 qDebug() << "imagesPath:" << imagesPath;2290 qDebug() << "fullPath:" << fullPath;2291 qDebug() << " imageFiles" << imageFiles;2292 #endif2293 2351 2294 2352 if (!exampleFiles.isEmpty()) { … … 2304 2362 } 2305 2363 else if (fileName.contains("/qrc_") || fileName.contains("/moc_") 2306 2364 || fileName.contains("/ui_")) 2307 2365 i.remove(); 2308 2366 } … … 2311 2369 2312 2370 // 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"); 2314 2372 } 2315 2373
Note:
See TracChangeset
for help on using the changeset viewer.