|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the Qt Mobility Components. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
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 |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #ifndef PARSEMANAGER_H |
|
43 #define PARSEMANAGER_H |
|
44 |
|
45 #include <QObject> |
|
46 #include <QList> |
|
47 #include <QFuture> |
|
48 #include <QStringList> |
|
49 #include "cplusplus/CppDocument.h" |
|
50 #include <QFile> |
|
51 |
|
52 namespace CppTools{ |
|
53 namespace Internal{ |
|
54 class CppPreprocessor; |
|
55 } |
|
56 } |
|
57 |
|
58 namespace CPlusPlus { |
|
59 class TranslationUnit; |
|
60 class AST; |
|
61 class ClassSpecifierAST; |
|
62 class QPropertyDeclarationAST; |
|
63 class QDeclareFlagsDeclarationAST; |
|
64 class EnumSpecifierAST; |
|
65 class Function; |
|
66 class EnumeratorAST; |
|
67 |
|
68 class CLASSLISTITEM |
|
69 { |
|
70 public: |
|
71 CPlusPlus::TranslationUnit* trlUnit; |
|
72 ClassSpecifierAST* classspec; |
|
73 }; |
|
74 class CLASSTREE |
|
75 { |
|
76 public: |
|
77 CLASSLISTITEM* highestlevelclass; |
|
78 QList<CLASSLISTITEM*> classlist; |
|
79 }; |
|
80 class FUNCTIONITEM |
|
81 { |
|
82 public: |
|
83 const CLASSLISTITEM* highestlevelclass; |
|
84 CPlusPlus::TranslationUnit* trlUnit; |
|
85 ClassSpecifierAST* classAst; |
|
86 QStringList classWichIsNotFound; |
|
87 CPlusPlus::Function* function; |
|
88 |
|
89 bool isEqualTo(FUNCTIONITEM* cpfct, bool ignoreName = true); |
|
90 FUNCTIONITEM() |
|
91 { |
|
92 highestlevelclass = 0; |
|
93 trlUnit = 0; |
|
94 classAst = 0; |
|
95 function = 0; |
|
96 } |
|
97 }; |
|
98 class PROPERTYITEM |
|
99 { |
|
100 public: |
|
101 const CLASSLISTITEM* highestlevelclass; |
|
102 QStringList classWichIsNotFound; |
|
103 QPropertyDeclarationAST *ast; |
|
104 CPlusPlus::TranslationUnit* trlUnit; |
|
105 bool readdefined; |
|
106 FUNCTIONITEM *readFct; |
|
107 bool writedefined; |
|
108 FUNCTIONITEM *writeFct; |
|
109 bool resetdefined; |
|
110 FUNCTIONITEM *resetFct; |
|
111 bool notifydefined; |
|
112 FUNCTIONITEM *notifyFct; |
|
113 bool foundalldefinedfct; |
|
114 |
|
115 bool isEqualTo(PROPERTYITEM* cpppt); |
|
116 PROPERTYITEM() |
|
117 { |
|
118 highestlevelclass = 0; |
|
119 ast = 0; |
|
120 trlUnit = 0; |
|
121 readdefined = false; |
|
122 readFct = 0; |
|
123 writedefined = false; |
|
124 writeFct = 0; |
|
125 resetdefined = false; |
|
126 resetFct = 0; |
|
127 notifydefined = false; |
|
128 notifyFct = 0; |
|
129 foundalldefinedfct = false; |
|
130 } |
|
131 }; |
|
132 |
|
133 class QENUMITEM |
|
134 { |
|
135 public: |
|
136 const CLASSLISTITEM* highestlevelclass; |
|
137 CPlusPlus::TranslationUnit* trlUnit; |
|
138 QStringList classWichIsNotFound; |
|
139 EnumeratorAST* ast; |
|
140 //an item in this list will be shown like: |
|
141 //EnumName.EnumItemName.Value |
|
142 //ConnectionState.disconnected.0 |
|
143 QStringList values; |
|
144 bool foundallenums; |
|
145 |
|
146 bool isEqualTo(QENUMITEM *cpenum); |
|
147 QENUMITEM() |
|
148 { |
|
149 highestlevelclass = 0; |
|
150 trlUnit = 0; |
|
151 ast = 0; |
|
152 values.clear(); |
|
153 foundallenums = true; |
|
154 } |
|
155 }; |
|
156 |
|
157 class ENUMITEM |
|
158 { |
|
159 public: |
|
160 const CLASSLISTITEM* highestlevelclass; |
|
161 CPlusPlus::TranslationUnit* trlUnit; |
|
162 QStringList classWichIsNotFound; |
|
163 EnumSpecifierAST* ast; |
|
164 |
|
165 ENUMITEM() |
|
166 { |
|
167 highestlevelclass = 0; |
|
168 trlUnit = 0; |
|
169 ast = 0; |
|
170 } |
|
171 }; |
|
172 |
|
173 class QFLAGITEM |
|
174 { |
|
175 public: |
|
176 const CLASSLISTITEM* highestlevelclass; |
|
177 CPlusPlus::TranslationUnit* trlUnit; |
|
178 QStringList classWichIsNotFound; |
|
179 EnumeratorAST* ast; |
|
180 QStringList enumvalues; |
|
181 bool foundallenums; |
|
182 |
|
183 bool isEqualTo(QFLAGITEM *cpflag); |
|
184 QFLAGITEM() |
|
185 { |
|
186 highestlevelclass = 0; |
|
187 trlUnit = 0; |
|
188 ast = 0; |
|
189 enumvalues.clear(); |
|
190 foundallenums = true; |
|
191 } |
|
192 }; |
|
193 |
|
194 class QDECLAREFLAGSITEM |
|
195 { |
|
196 public: |
|
197 const CLASSLISTITEM* highestlevelclass; |
|
198 CPlusPlus::TranslationUnit* trlUnit; |
|
199 QStringList classWichIsNotFound; |
|
200 QDeclareFlagsDeclarationAST* ast; |
|
201 |
|
202 QDECLAREFLAGSITEM() |
|
203 { |
|
204 highestlevelclass = 0; |
|
205 trlUnit = 0; |
|
206 ast = 0; |
|
207 } |
|
208 }; |
|
209 |
|
210 static QFile* m_resultFile = 0; |
|
211 class ParseManager : public QObject |
|
212 { |
|
213 Q_OBJECT |
|
214 public: |
|
215 ParseManager(); |
|
216 virtual ~ParseManager(); |
|
217 void setIncludePath(const QStringList &includePath); |
|
218 void parse(const QStringList &sourceFiles); |
|
219 bool checkAllMetadatas(ParseManager* pInterfaceParserManager, QString resultfile); |
|
220 CppTools::Internal::CppPreprocessor *getPreProcessor() { return pCppPreprocessor; } |
|
221 QList<CLASSTREE*> CreateClassLists(bool isInterfaceHeader); |
|
222 QStringList getErrorMsg() { return m_errormsgs; } |
|
223 |
|
224 private: |
|
225 void parse(CppTools::Internal::CppPreprocessor *preproc, const QStringList &files); |
|
226 void Trace(QString value); |
|
227 inline QString getTraceFuntionString(const FUNCTIONITEM* fctitem, const QString& classname); |
|
228 void getBaseClasses(const CLASSLISTITEM* pclass |
|
229 , QList<CLASSLISTITEM*> &baseclasslist |
|
230 , const QList<CLASSLISTITEM*> &allclasslist |
|
231 , int level |
|
232 , bool isInterfaceHeader); |
|
233 void getElements(QList<FUNCTIONITEM*> &functionlist |
|
234 , QList<PROPERTYITEM*> &propertylist |
|
235 , QList<QENUMITEM*> &qenumlist |
|
236 , QList<ENUMITEM*> &enumlist |
|
237 , QList<QFLAGITEM*> &qflaglist |
|
238 , QList<QDECLAREFLAGSITEM*> &qdeclareflaglist |
|
239 , const QList<CLASSLISTITEM*> classitems |
|
240 , const CLASSLISTITEM* highestlevelclass); |
|
241 |
|
242 //<--- for Metadata functions checks |
|
243 QList<FUNCTIONITEM*> checkMetadataFunctions(const QList<QList<FUNCTIONITEM*> > &classfctlist, const QList<QList<FUNCTIONITEM*> > &iclassfctlist); |
|
244 bool isMetaObjFunction(FUNCTIONITEM* fct); |
|
245 QList<FUNCTIONITEM*> containsAllMetadataFunction(const QList<FUNCTIONITEM*> &classfctlist, const QList<FUNCTIONITEM*> &iclassfctlist); |
|
246 QStringList getErrorMessage(FUNCTIONITEM* fct); |
|
247 //---> |
|
248 |
|
249 //<--- for Q_PROPERTY functions checks |
|
250 QList<PROPERTYITEM*> checkMetadataProperties(const QList<QList<PROPERTYITEM*> > &classproplist |
|
251 , const QList<QList<FUNCTIONITEM*> > &classfctlist |
|
252 , const QList<QList<PROPERTYITEM*> > &iclassproplist |
|
253 , const QList<QList<FUNCTIONITEM*> > &iclassfctlist); |
|
254 void assignPropertyFunctions(PROPERTYITEM* prop, const QList<QList<FUNCTIONITEM*> > &fctlookuplist); |
|
255 QList<PROPERTYITEM*> containsAllPropertyFunction(const QList<PROPERTYITEM*> &classproplist, const QList<PROPERTYITEM*> &iclassproplist); |
|
256 QStringList getErrorMessage(PROPERTYITEM* ppt); |
|
257 //---> |
|
258 |
|
259 //<--- for Q_ENUMS checks |
|
260 QList<QENUMITEM*> checkMetadataEnums(const QList<QList<QENUMITEM*> > &classqenumlist |
|
261 , const QList<QList<ENUMITEM*> > &classenumlist |
|
262 , const QList<QList<QENUMITEM*> > &iclassqenumlist |
|
263 , const QList<QList<ENUMITEM*> > &iclassenumlist); |
|
264 QStringList getEnumValueStringList(ENUMITEM *penum, QString mappedenumname = ""); |
|
265 void assignEnumValues(QENUMITEM* qenum, const QList<QList<ENUMITEM*> > &enumlookuplist); |
|
266 QList<QENUMITEM*> containsAllEnums(const QList<QENUMITEM*> &classqenumlist, const QList<QENUMITEM*> &iclassqenumlist); |
|
267 QStringList getErrorMessage(QENUMITEM* qenum); |
|
268 //---> |
|
269 |
|
270 //<--- for QFlags checks ---> |
|
271 QList<QFLAGITEM*> checkMetadataFlags(const QList<QList<QFLAGITEM*> > &classqflaglist |
|
272 , const QList<QList<QDECLAREFLAGSITEM*> > &classqdeclareflaglist |
|
273 , const QList<QList<ENUMITEM*> > &classenumlist |
|
274 , const QList<QList<QFLAGITEM*> > &iclassqflaglist |
|
275 , const QList<QList<QDECLAREFLAGSITEM*> > &iclassqdeclareflaglist |
|
276 , const QList<QList<ENUMITEM*> > &iclassenumlist); |
|
277 void assignFlagValues(QFLAGITEM* qflags, const QList<QList<QDECLAREFLAGSITEM*> > &qdeclareflagslookuplist, const QList<QList<ENUMITEM*> > &enumlookuplist); |
|
278 QList<QFLAGITEM*> containsAllFlags(const QList<QFLAGITEM*> &classqflaglist, const QList<QFLAGITEM*> &iclassqflaglist); |
|
279 QStringList getErrorMessage(QFLAGITEM* pfg); |
|
280 //---> |
|
281 |
|
282 private: |
|
283 // cache |
|
284 QStringList m_includePaths; |
|
285 QStringList m_frameworkPaths; |
|
286 QByteArray m_definedMacros; |
|
287 CppTools::Internal::CppPreprocessor* pCppPreprocessor; |
|
288 QString m_strHeaderFile; |
|
289 QStringList m_errormsgs; |
|
290 }; |
|
291 } |
|
292 #endif // PARSEMANAGER_H |