1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
16 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights. These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
32 **************************************************************************/
37 ** The ParseManager parses and compares to different header files
38 ** of its metadata. This can be used for checking if an Interface
39 ** is implemented complete.
43 ** //Parse the interface header
44 ** ParseManager* iParseManager = new ParseManager();
45 ** iParseManager->setIncludePath(iIncludepathlist);
46 ** iParseManager->parse(iFilelist);
48 ** //Parse the header that needs to be compared against the interface header
49 ** ParseManager* chParseManager = new ParseManager();
50 ** chIncludepathlist << getQTIncludePath();
51 * chParseManager->setIncludePath(chIncludepathlist);
52 ** chParseManager->parse(chFilelist);
54 ** if(!chParseManager->checkAllMetadatas(iParseManager)){
55 ** cout << "Following interface items are missing:" << endl;
56 ** QStringList errorlist = chParseManager->getErrorMsg();
57 ** foreach(QString msg, errorlist){
58 ** cout << (const char *)msg.toLatin1() << endl;
63 ** cout << "Interface is full defined.";
66 #ifndef PARSEMANAGER_H
67 #define PARSEMANAGER_H
69 #include "cplusplus/CppDocument.h"
71 #include "FullySpecifiedType.h"
76 #include <QStringList>
81 class CppPreprocessor;
89 CPlusPlus::TranslationUnit* trlUnit;
90 ClassSpecifierAST* classspec;
95 CLASSLISTITEM* highestlevelclass;
96 QList<CLASSLISTITEM*> classlist;
101 const CLASSLISTITEM* highestlevelclass;
102 CPlusPlus::TranslationUnit* trlUnit;
103 ClassSpecifierAST* classAst;
104 QStringList classWichIsNotFound;
105 CPlusPlus::Function* function;
107 bool isEqualTo(FUNCTIONITEM* cpfct, bool ignoreName = true);
111 highestlevelclass = 0;
120 const CLASSLISTITEM* highestlevelclass;
121 QStringList classWichIsNotFound;
122 QtPropertyDeclarationAST *ast;
123 CPlusPlus::TranslationUnit* trlUnit;
124 FullySpecifiedType type;
125 ExpressionAST *readAst;
126 FUNCTIONITEM *readFct;
127 ExpressionAST *writeAst;
128 FUNCTIONITEM *writeFct;
129 ExpressionAST *resetAst;
130 FUNCTIONITEM *resetFct;
131 ExpressionAST *notifyAst;
132 FUNCTIONITEM *notifyFct;
133 bool foundalldefinedfct;
135 bool isEqualTo(PROPERTYITEM* cpppt);
138 highestlevelclass = 0;
149 foundalldefinedfct = false;
152 static PROPERTYITEM *create(QtPropertyDeclarationAST *ast, const CLASSLISTITEM *clazz);
158 const CLASSLISTITEM* highestlevelclass;
159 QStringList classWichIsNotFound;
161 //an item in this list will be shown like:
162 //EnumName.EnumItemName.Value
163 //ConnectionState.disconnected.0
167 bool isEqualTo(QENUMITEM *cpenum);
170 highestlevelclass = 0;
172 foundallenums = true;
179 const CLASSLISTITEM* highestlevelclass;
180 CPlusPlus::TranslationUnit* trlUnit;
181 QStringList classWichIsNotFound;
182 EnumSpecifierAST* ast;
186 highestlevelclass = 0;
195 const CLASSLISTITEM* highestlevelclass;
197 QStringList classWichIsNotFound;
198 QStringList enumvalues;
201 bool isEqualTo(QFLAGITEM *cpflag);
204 highestlevelclass = 0;
206 foundallenums = true;
210 class QDECLAREFLAGSITEM
213 const CLASSLISTITEM* highestlevelclass;
214 CPlusPlus::TranslationUnit* trlUnit;
215 QStringList classWichIsNotFound;
216 QtFlagsDeclarationAST* ast;
220 highestlevelclass = 0;
226 static QFile* m_resultFile = 0;
227 class ParseManager : public QObject
232 virtual ~ParseManager();
233 void setIncludePath(const QStringList &includePath);
234 void parse(const QStringList &sourceFiles);
235 bool checkAllMetadatas(ParseManager* pInterfaceParserManager, QString resultfile);
236 CppTools::Internal::CppPreprocessor *getPreProcessor() { return pCppPreprocessor; }
237 QList<CLASSTREE*> CreateClassLists(bool isInterfaceHeader);
238 QStringList getErrorMsg() { return m_errormsgs; }
241 void parse(CppTools::Internal::CppPreprocessor *preproc, const QStringList &files);
242 void Trace(QString value);
243 inline QString getTraceFuntionString(const FUNCTIONITEM* fctitem, const QString& classname);
244 void getBaseClasses(const CLASSLISTITEM* pclass
245 , QList<CLASSLISTITEM*> &baseclasslist
246 , const QList<CLASSLISTITEM*> &allclasslist
248 , bool isInterfaceHeader);
249 void getElements(QList<FUNCTIONITEM*> &functionlist
250 , QList<PROPERTYITEM*> &propertylist
251 , QList<QENUMITEM*> &qenumlist
252 , QList<ENUMITEM*> &enumlist
253 , QList<QFLAGITEM*> &qflaglist
254 , QList<QDECLAREFLAGSITEM*> &qdeclareflaglist
255 , const QList<CLASSLISTITEM*> classitems
256 , const CLASSLISTITEM* highestlevelclass);
258 //<--- for Metadata functions checks
259 QList<FUNCTIONITEM*> checkMetadataFunctions(const QList<QList<FUNCTIONITEM*> > &classfctlist, const QList<QList<FUNCTIONITEM*> > &iclassfctlist);
260 bool isMetaObjFunction(FUNCTIONITEM* fct);
261 QList<FUNCTIONITEM*> containsAllMetadataFunction(const QList<FUNCTIONITEM*> &classfctlist, const QList<FUNCTIONITEM*> &iclassfctlist);
262 QStringList getErrorMessage(FUNCTIONITEM* fct);
265 //<--- for Q_PROPERTY functions checks
266 QList<PROPERTYITEM*> checkMetadataProperties(const QList<QList<PROPERTYITEM*> > &classproplist
267 , const QList<QList<FUNCTIONITEM*> > &classfctlist
268 , const QList<QList<PROPERTYITEM*> > &iclassproplist
269 , const QList<QList<FUNCTIONITEM*> > &iclassfctlist);
270 void assignPropertyFunctions(PROPERTYITEM* prop, const QList<QList<FUNCTIONITEM*> > &fctlookuplist);
271 QList<PROPERTYITEM*> containsAllPropertyFunction(const QList<PROPERTYITEM*> &classproplist, const QList<PROPERTYITEM*> &iclassproplist);
272 QStringList getErrorMessage(PROPERTYITEM* ppt);
275 //<--- for Q_ENUMS checks
276 QList<QENUMITEM*> checkMetadataEnums(const QList<QList<QENUMITEM*> > &classqenumlist
277 , const QList<QList<ENUMITEM*> > &classenumlist
278 , const QList<QList<QENUMITEM*> > &iclassqenumlist
279 , const QList<QList<ENUMITEM*> > &iclassenumlist);
280 QStringList getEnumValueStringList(ENUMITEM *penum, QString mappedenumname = "");
281 void assignEnumValues(QENUMITEM* qenum, const QList<QList<ENUMITEM*> > &enumlookuplist);
282 QList<QENUMITEM*> containsAllEnums(const QList<QENUMITEM*> &classqenumlist, const QList<QENUMITEM*> &iclassqenumlist);
283 QStringList getErrorMessage(QENUMITEM* qenum);
286 //<--- for QFlags checks --->
287 QList<QFLAGITEM*> checkMetadataFlags(const QList<QList<QFLAGITEM*> > &classqflaglist
288 , const QList<QList<QDECLAREFLAGSITEM*> > &classqdeclareflaglist
289 , const QList<QList<ENUMITEM*> > &classenumlist
290 , const QList<QList<QFLAGITEM*> > &iclassqflaglist
291 , const QList<QList<QDECLAREFLAGSITEM*> > &iclassqdeclareflaglist
292 , const QList<QList<ENUMITEM*> > &iclassenumlist);
293 void assignFlagValues(QFLAGITEM* qflags, const QList<QList<QDECLAREFLAGSITEM*> > &qdeclareflagslookuplist, const QList<QList<ENUMITEM*> > &enumlookuplist);
294 QList<QFLAGITEM*> containsAllFlags(const QList<QFLAGITEM*> &classqflaglist, const QList<QFLAGITEM*> &iclassqflaglist);
295 QStringList getErrorMessage(QFLAGITEM* pfg);
300 QStringList m_includePaths;
301 QStringList m_frameworkPaths;
302 QByteArray m_definedMacros;
303 CppTools::Internal::CppPreprocessor* pCppPreprocessor;
304 QString m_strHeaderFile;
305 QStringList m_errormsgs;
308 #endif // PARSEMANAGER_H