author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 06 Jul 2010 15:10:48 +0300 | |
changeset 30 | 5dc02b23752f |
parent 18 | 2f34d5167611 |
child 33 | 3e2da88830cd |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the tools applications of the Qt Toolkit. |
|
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 |
/* |
|
43 |
node.h |
|
44 |
*/ |
|
45 |
||
46 |
#ifndef NODE_H |
|
47 |
#define NODE_H |
|
48 |
||
49 |
#include <qdir.h> |
|
50 |
#include <qmap.h> |
|
51 |
#include <qpair.h> |
|
52 |
#include <qstringlist.h> |
|
53 |
||
54 |
#include "codechunk.h" |
|
55 |
#include "doc.h" |
|
56 |
#include "location.h" |
|
57 |
#include "text.h" |
|
58 |
||
59 |
QT_BEGIN_NAMESPACE |
|
60 |
||
61 |
class InnerNode; |
|
62 |
||
63 |
class Node |
|
64 |
{ |
|
65 |
public: |
|
66 |
enum Type { |
|
67 |
Namespace, |
|
68 |
Class, |
|
69 |
Fake, |
|
70 |
Enum, |
|
71 |
Typedef, |
|
72 |
Function, |
|
73 |
Property, |
|
74 |
Variable, |
|
75 |
#ifdef QDOC_QML |
|
76 |
Target, |
|
77 |
QmlProperty, |
|
78 |
QmlSignal, |
|
79 |
QmlMethod, |
|
80 |
LastType |
|
81 |
#else |
|
82 |
Target, |
|
83 |
LastType |
|
84 |
#endif |
|
85 |
}; |
|
86 |
||
87 |
enum SubType { |
|
88 |
NoSubType, |
|
89 |
Example, |
|
90 |
HeaderFile, |
|
91 |
File, |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
92 |
Image, |
0 | 93 |
Group, |
94 |
Module, |
|
95 |
Page, |
|
96 |
#ifdef QDOC_QML |
|
97 |
ExternalPage, |
|
98 |
QmlClass, |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
99 |
QmlPropertyGroup, |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
100 |
QmlBasicType |
0 | 101 |
#else |
102 |
ExternalPage |
|
103 |
#endif |
|
104 |
}; |
|
105 |
||
106 |
enum Access { Public, Protected, Private }; |
|
107 |
||
108 |
enum Status { |
|
109 |
Compat, |
|
110 |
Obsolete, |
|
111 |
Deprecated, |
|
112 |
Preliminary, |
|
113 |
Commendable, |
|
114 |
Main, |
|
115 |
Internal |
|
116 |
}; // don't reorder thisw enum |
|
117 |
||
118 |
enum ThreadSafeness { |
|
119 |
UnspecifiedSafeness, |
|
120 |
NonReentrant, |
|
121 |
Reentrant, |
|
122 |
ThreadSafe |
|
123 |
}; |
|
124 |
||
125 |
enum LinkType { |
|
126 |
StartLink, |
|
127 |
NextLink, |
|
128 |
PreviousLink, |
|
129 |
ContentsLink, |
|
130 |
IndexLink, |
|
131 |
InheritsLink /*, |
|
132 |
GlossaryLink, |
|
133 |
CopyrightLink, |
|
134 |
ChapterLink, |
|
135 |
SectionLink, |
|
136 |
SubsectionLink, |
|
137 |
AppendixLink */ |
|
138 |
}; |
|
139 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
140 |
enum PageType { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
141 |
NoPageType, |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
142 |
ApiPage, |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
143 |
ArticlePage, |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
144 |
ExamplePage |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
145 |
}; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
146 |
|
0 | 147 |
virtual ~Node(); |
148 |
||
149 |
void setAccess(Access access) { acc = access; } |
|
150 |
void setLocation(const Location& location) { loc = location; } |
|
151 |
void setDoc(const Doc& doc, bool replace = false); |
|
152 |
void setStatus(Status status) { sta = status; } |
|
153 |
void setThreadSafeness(ThreadSafeness safeness) { saf = safeness; } |
|
154 |
void setSince(const QString &since) { sinc = since; } |
|
155 |
void setRelates(InnerNode *pseudoParent); |
|
156 |
void setModuleName(const QString &module) { mod = module; } |
|
157 |
void setLink(LinkType linkType, const QString &link, const QString &desc); |
|
158 |
void setUrl(const QString &url); |
|
159 |
void setTemplateStuff(const QString &templateStuff) { tpl = templateStuff; } |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
160 |
void setPageType(PageType t) { pageTyp = t; } |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
161 |
void setPageType(const QString& t); |
0 | 162 |
|
163 |
virtual bool isInnerNode() const = 0; |
|
164 |
virtual bool isReimp() const { return false; } |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
165 |
virtual bool isFunction() const { return false; } |
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
166 |
virtual bool isQmlNode() const { return false; } |
0 | 167 |
Type type() const { return typ; } |
168 |
virtual SubType subType() const { return NoSubType; } |
|
169 |
InnerNode *parent() const { return par; } |
|
170 |
InnerNode *relates() const { return rel; } |
|
171 |
const QString& name() const { return nam; } |
|
172 |
QMap<LinkType, QPair<QString,QString> > links() const { return linkMap; } |
|
173 |
QString moduleName() const; |
|
174 |
QString url() const; |
|
175 |
virtual QString nameForLists() const { return nam; } |
|
176 |
||
177 |
Access access() const { return acc; } |
|
178 |
const Location& location() const { return loc; } |
|
179 |
const Doc& doc() const { return d; } |
|
180 |
Status status() const { return sta; } |
|
181 |
Status inheritedStatus() const; |
|
182 |
ThreadSafeness threadSafeness() const; |
|
183 |
ThreadSafeness inheritedThreadSafeness() const; |
|
184 |
QString since() const { return sinc; } |
|
185 |
QString templateStuff() const { return tpl; } |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
186 |
PageType pageType() const { return pageTyp; } |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
187 |
virtual void addPageKeywords(const QString& ) { } |
0 | 188 |
|
189 |
void clearRelated() { rel = 0; } |
|
190 |
||
191 |
virtual QString fileBase() const; |
|
192 |
||
193 |
protected: |
|
194 |
Node(Type type, InnerNode *parent, const QString& name); |
|
195 |
||
196 |
private: |
|
197 |
||
198 |
#ifdef Q_WS_WIN |
|
199 |
Type typ; |
|
200 |
Access acc; |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
201 |
ThreadSafeness saf; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
202 |
PageType pageTyp; |
0 | 203 |
Status sta; |
204 |
#else |
|
205 |
Type typ : 4; |
|
206 |
Access acc : 2; |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
207 |
ThreadSafeness saf : 2; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
208 |
PageType pageTyp : 4; |
0 | 209 |
Status sta : 3; |
210 |
#endif |
|
211 |
InnerNode *par; |
|
212 |
InnerNode *rel; |
|
213 |
QString nam; |
|
214 |
Location loc; |
|
215 |
Doc d; |
|
216 |
QMap<LinkType, QPair<QString, QString> > linkMap; |
|
217 |
QString mod; |
|
218 |
QString u; |
|
219 |
QString sinc; |
|
220 |
QString tpl; |
|
221 |
}; |
|
222 |
||
223 |
class FunctionNode; |
|
224 |
class EnumNode; |
|
225 |
||
226 |
typedef QList<Node *> NodeList; |
|
227 |
||
228 |
class InnerNode : public Node |
|
229 |
{ |
|
230 |
public: |
|
231 |
virtual ~InnerNode(); |
|
232 |
||
233 |
Node *findNode(const QString& name); |
|
234 |
Node *findNode(const QString& name, Type type); |
|
235 |
FunctionNode *findFunctionNode(const QString& name); |
|
236 |
FunctionNode *findFunctionNode(const FunctionNode *clone); |
|
237 |
void addInclude(const QString &include); |
|
238 |
void setIncludes(const QStringList &includes); |
|
239 |
void setOverload(const FunctionNode *func, bool overlode); |
|
240 |
void normalizeOverloads(); |
|
241 |
void makeUndocumentedChildrenInternal(); |
|
242 |
void deleteChildren(); |
|
243 |
void removeFromRelated(); |
|
244 |
||
245 |
virtual bool isInnerNode() const; |
|
246 |
const Node *findNode(const QString& name) const; |
|
247 |
const Node *findNode(const QString& name, Type type) const; |
|
248 |
const FunctionNode *findFunctionNode(const QString& name) const; |
|
249 |
const FunctionNode *findFunctionNode(const FunctionNode *clone) const; |
|
250 |
const EnumNode *findEnumNodeForValue(const QString &enumValue) const; |
|
251 |
const NodeList & childNodes() const { return children; } |
|
252 |
const NodeList & relatedNodes() const { return related; } |
|
253 |
int count() const { return children.size(); } |
|
254 |
int overloadNumber(const FunctionNode *func) const; |
|
255 |
int numOverloads(const QString& funcName) const; |
|
256 |
NodeList overloads(const QString &funcName) const; |
|
257 |
const QStringList& includes() const { return inc; } |
|
258 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
259 |
QStringList primaryKeys(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
260 |
QStringList secondaryKeys(); |
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
261 |
const QStringList& pageKeywords() const { return pageKeywds; } |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
262 |
virtual void addPageKeywords(const QString& t) { pageKeywds << t; } |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
263 |
|
0 | 264 |
protected: |
265 |
InnerNode(Type type, InnerNode *parent, const QString& name); |
|
266 |
||
267 |
private: |
|
268 |
friend class Node; |
|
269 |
||
270 |
static bool isSameSignature(const FunctionNode *f1, const FunctionNode *f2); |
|
271 |
void addChild(Node *child); |
|
272 |
void removeChild(Node *child); |
|
273 |
void removeRelated(Node *pseudoChild); |
|
274 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
275 |
QStringList pageKeywds; |
0 | 276 |
QStringList inc; |
277 |
NodeList children; |
|
278 |
NodeList enumChildren; |
|
279 |
NodeList related; |
|
280 |
QMap<QString, Node *> childMap; |
|
281 |
QMap<QString, Node *> primaryFunctionMap; |
|
282 |
QMap<QString, NodeList> secondaryFunctionMap; |
|
283 |
}; |
|
284 |
||
285 |
class LeafNode : public Node |
|
286 |
{ |
|
287 |
public: |
|
288 |
LeafNode(); |
|
289 |
virtual ~LeafNode() { } |
|
290 |
||
291 |
virtual bool isInnerNode() const; |
|
292 |
||
293 |
protected: |
|
294 |
LeafNode(Type type, InnerNode* parent, const QString& name); |
|
295 |
}; |
|
296 |
||
297 |
class NamespaceNode : public InnerNode |
|
298 |
{ |
|
299 |
public: |
|
300 |
NamespaceNode(InnerNode *parent, const QString& name); |
|
301 |
virtual ~NamespaceNode() { } |
|
302 |
}; |
|
303 |
||
304 |
class ClassNode; |
|
305 |
||
306 |
struct RelatedClass |
|
307 |
{ |
|
308 |
RelatedClass() { } |
|
309 |
RelatedClass(Node::Access access0, |
|
310 |
ClassNode* node0, |
|
311 |
const QString& dataTypeWithTemplateArgs0 = "") |
|
312 |
: access(access0), |
|
313 |
node(node0), |
|
314 |
dataTypeWithTemplateArgs(dataTypeWithTemplateArgs0) { } |
|
315 |
||
316 |
Node::Access access; |
|
317 |
ClassNode* node; |
|
318 |
QString dataTypeWithTemplateArgs; |
|
319 |
}; |
|
320 |
||
321 |
class ClassNode : public InnerNode |
|
322 |
{ |
|
323 |
public: |
|
324 |
ClassNode(InnerNode *parent, const QString& name); |
|
325 |
virtual ~ClassNode() { } |
|
326 |
||
327 |
void addBaseClass(Access access, |
|
328 |
ClassNode *node, |
|
329 |
const QString &dataTypeWithTemplateArgs = ""); |
|
330 |
void fixBaseClasses(); |
|
331 |
||
332 |
const QList<RelatedClass> &baseClasses() const { return bas; } |
|
333 |
const QList<RelatedClass> &derivedClasses() const { return der; } |
|
334 |
||
335 |
bool hideFromMainList() const { return hidden; } |
|
336 |
void setHideFromMainList(bool value) { hidden = value; } |
|
337 |
||
338 |
QString serviceName() const { return sname; } |
|
339 |
void setServiceName(const QString& value) { sname = value; } |
|
340 |
QString qmlElement() const { return qmlelement; } |
|
341 |
void setQmlElement(const QString& value) { qmlelement = value; } |
|
342 |
||
343 |
private: |
|
344 |
QList<RelatedClass> bas; |
|
345 |
QList<RelatedClass> der; |
|
346 |
bool hidden; |
|
347 |
QString sname; |
|
348 |
QString qmlelement; |
|
349 |
}; |
|
350 |
||
351 |
class FakeNode : public InnerNode |
|
352 |
{ |
|
353 |
public: |
|
354 |
||
355 |
FakeNode(InnerNode *parent, const QString& name, SubType subType); |
|
356 |
virtual ~FakeNode() { } |
|
357 |
||
358 |
void setTitle(const QString &title) { tle = title; } |
|
359 |
void setSubTitle(const QString &subTitle) { stle = subTitle; } |
|
360 |
void addGroupMember(Node *node) { gr.append(node); } |
|
361 |
||
362 |
SubType subType() const { return sub; } |
|
363 |
QString title() const { return tle; } |
|
364 |
QString fullTitle() const; |
|
365 |
QString subTitle() const; |
|
366 |
const NodeList &groupMembers() const { return gr; } |
|
367 |
virtual QString nameForLists() const { return title(); } |
|
368 |
||
369 |
private: |
|
370 |
SubType sub; |
|
371 |
QString tle; |
|
372 |
QString stle; |
|
373 |
NodeList gr; |
|
374 |
}; |
|
375 |
||
376 |
#ifdef QDOC_QML |
|
377 |
class QmlClassNode : public FakeNode |
|
378 |
{ |
|
379 |
public: |
|
380 |
QmlClassNode(InnerNode *parent, |
|
381 |
const QString& name, |
|
382 |
const ClassNode* cn); |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
383 |
virtual ~QmlClassNode(); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
384 |
virtual bool isQmlNode() const { return true; } |
0 | 385 |
|
386 |
const ClassNode* classNode() const { return cnode; } |
|
387 |
virtual QString fileBase() const; |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
388 |
static void addInheritedBy(const QString& base, Node* sub); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
389 |
static void subclasses(const QString& base, NodeList& subs); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
390 |
static void clear(); |
0 | 391 |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
392 |
public: |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
393 |
static bool qmlOnly; |
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
394 |
static QMultiMap<QString,Node*> inheritedBy; |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
395 |
|
0 | 396 |
private: |
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
397 |
const ClassNode* cnode; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
398 |
}; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
399 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
400 |
class QmlBasicTypeNode : public FakeNode |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
401 |
{ |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
402 |
public: |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
403 |
QmlBasicTypeNode(InnerNode *parent, |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
404 |
const QString& name); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
405 |
virtual ~QmlBasicTypeNode() { } |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
406 |
virtual bool isQmlNode() const { return true; } |
0 | 407 |
}; |
408 |
||
409 |
class QmlPropGroupNode : public FakeNode |
|
410 |
{ |
|
411 |
public: |
|
412 |
QmlPropGroupNode(QmlClassNode* parent, |
|
413 |
const QString& name, |
|
414 |
bool attached); |
|
415 |
virtual ~QmlPropGroupNode() { } |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
416 |
virtual bool isQmlNode() const { return true; } |
0 | 417 |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
418 |
const QString& element() const { return parent()->name(); } |
0 | 419 |
void setDefault() { isdefault = true; } |
420 |
bool isDefault() const { return isdefault; } |
|
421 |
bool isAttached() const { return att; } |
|
422 |
||
423 |
private: |
|
424 |
bool isdefault; |
|
425 |
bool att; |
|
426 |
}; |
|
427 |
||
428 |
class QmlPropertyNode : public LeafNode |
|
429 |
{ |
|
430 |
public: |
|
431 |
QmlPropertyNode(QmlPropGroupNode* parent, |
|
432 |
const QString& name, |
|
433 |
const QString& type, |
|
434 |
bool attached); |
|
435 |
virtual ~QmlPropertyNode() { } |
|
436 |
||
437 |
void setDataType(const QString& dataType) { dt = dataType; } |
|
438 |
void setStored(bool stored) { sto = toTrool(stored); } |
|
439 |
void setDesignable(bool designable) { des = toTrool(designable); } |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
440 |
void setWritable(bool writable) { wri = toTrool(writable); } |
0 | 441 |
|
442 |
const QString &dataType() const { return dt; } |
|
443 |
QString qualifiedDataType() const { return dt; } |
|
444 |
bool isStored() const { return fromTrool(sto,true); } |
|
445 |
bool isDesignable() const { return fromTrool(des,false); } |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
446 |
bool isWritable() const { return fromTrool(wri,true); } |
0 | 447 |
bool isAttached() const { return att; } |
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
448 |
virtual bool isQmlNode() const { return true; } |
0 | 449 |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
450 |
const QString& element() const { return static_cast<QmlPropGroupNode*>(parent())->element(); } |
0 | 451 |
|
452 |
private: |
|
453 |
enum Trool { Trool_True, Trool_False, Trool_Default }; |
|
454 |
||
455 |
static Trool toTrool(bool boolean); |
|
456 |
static bool fromTrool(Trool troolean, bool defaultValue); |
|
457 |
||
458 |
QString dt; |
|
459 |
Trool sto; |
|
460 |
Trool des; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
461 |
Trool wri; |
0 | 462 |
bool att; |
463 |
}; |
|
464 |
#endif |
|
465 |
||
466 |
class EnumItem |
|
467 |
{ |
|
468 |
public: |
|
469 |
EnumItem() { } |
|
470 |
EnumItem(const QString& name, const QString& value) |
|
471 |
: nam(name), val(value) { } |
|
472 |
EnumItem(const QString& name, const QString& value, const Text &txt) |
|
473 |
: nam(name), val(value), txt(txt) { } |
|
474 |
||
475 |
const QString& name() const { return nam; } |
|
476 |
const QString& value() const { return val; } |
|
477 |
const Text &text() const { return txt; } |
|
478 |
||
479 |
private: |
|
480 |
QString nam; |
|
481 |
QString val; |
|
482 |
Text txt; |
|
483 |
}; |
|
484 |
||
485 |
class TypedefNode; |
|
486 |
||
487 |
class EnumNode : public LeafNode |
|
488 |
{ |
|
489 |
public: |
|
490 |
EnumNode(InnerNode *parent, const QString& name); |
|
491 |
virtual ~EnumNode() { } |
|
492 |
||
493 |
void addItem(const EnumItem& item); |
|
494 |
void setFlagsType(TypedefNode *typedeff); |
|
495 |
bool hasItem(const QString &name) const { return names.contains(name); } |
|
496 |
||
497 |
const QList<EnumItem>& items() const { return itms; } |
|
498 |
Access itemAccess(const QString& name) const; |
|
499 |
const TypedefNode *flagsType() const { return ft; } |
|
500 |
QString itemValue(const QString &name) const; |
|
501 |
||
502 |
private: |
|
503 |
QList<EnumItem> itms; |
|
504 |
QSet<QString> names; |
|
505 |
const TypedefNode *ft; |
|
506 |
}; |
|
507 |
||
508 |
class TypedefNode : public LeafNode |
|
509 |
{ |
|
510 |
public: |
|
511 |
TypedefNode(InnerNode *parent, const QString& name); |
|
512 |
virtual ~TypedefNode() { } |
|
513 |
||
514 |
const EnumNode *associatedEnum() const { return ae; } |
|
515 |
||
516 |
private: |
|
517 |
void setAssociatedEnum(const EnumNode *enume); |
|
518 |
||
519 |
friend class EnumNode; |
|
520 |
||
521 |
const EnumNode *ae; |
|
522 |
}; |
|
523 |
||
524 |
inline void EnumNode::setFlagsType(TypedefNode *typedeff) |
|
525 |
{ |
|
526 |
ft = typedeff; |
|
527 |
typedeff->setAssociatedEnum(this); |
|
528 |
} |
|
529 |
||
530 |
||
531 |
class Parameter |
|
532 |
{ |
|
533 |
public: |
|
534 |
Parameter() {} |
|
535 |
Parameter(const QString& leftType, |
|
536 |
const QString& rightType = "", |
|
537 |
const QString& name = "", |
|
538 |
const QString& defaultValue = ""); |
|
539 |
Parameter(const Parameter& p); |
|
540 |
||
541 |
Parameter& operator=(const Parameter& p); |
|
542 |
||
543 |
void setName(const QString& name) { nam = name; } |
|
544 |
||
545 |
bool hasType() const { return lef.length() + rig.length() > 0; } |
|
546 |
const QString& leftType() const { return lef; } |
|
547 |
const QString& rightType() const { return rig; } |
|
548 |
const QString& name() const { return nam; } |
|
549 |
const QString& defaultValue() const { return def; } |
|
550 |
||
551 |
QString reconstruct(bool value = false) const; |
|
552 |
||
553 |
private: |
|
554 |
QString lef; |
|
555 |
QString rig; |
|
556 |
QString nam; |
|
557 |
QString def; |
|
558 |
}; |
|
559 |
||
560 |
class PropertyNode; |
|
561 |
||
562 |
class FunctionNode : public LeafNode |
|
563 |
{ |
|
564 |
public: |
|
565 |
enum Metaness { |
|
566 |
Plain, |
|
567 |
Signal, |
|
568 |
Slot, |
|
569 |
Ctor, |
|
570 |
Dtor, |
|
571 |
MacroWithParams, |
|
572 |
MacroWithoutParams, |
|
573 |
Native }; |
|
574 |
enum Virtualness { NonVirtual, ImpureVirtual, PureVirtual }; |
|
575 |
||
576 |
FunctionNode(InnerNode *parent, const QString &name); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
577 |
FunctionNode(Type type, InnerNode *parent, const QString &name, bool attached); |
0 | 578 |
virtual ~FunctionNode() { } |
579 |
||
580 |
void setReturnType(const QString& returnType) { rt = returnType; } |
|
581 |
void setParentPath(const QStringList& parentPath) { pp = parentPath; } |
|
582 |
void setMetaness(Metaness metaness) { met = metaness; } |
|
583 |
void setVirtualness(Virtualness virtualness) { vir = virtualness; } |
|
584 |
void setConst(bool conste) { con = conste; } |
|
585 |
void setStatic(bool statique) { sta = statique; } |
|
586 |
void setOverload(bool overlode); |
|
587 |
void setReimp(bool r); |
|
588 |
void addParameter(const Parameter& parameter); |
|
589 |
inline void setParameters(const QList<Parameter>& parameters); |
|
590 |
void borrowParameterNames(const FunctionNode *source); |
|
591 |
void setReimplementedFrom(FunctionNode *from); |
|
592 |
||
593 |
const QString& returnType() const { return rt; } |
|
594 |
Metaness metaness() const { return met; } |
|
595 |
bool isMacro() const { |
|
596 |
return met == MacroWithParams || met == MacroWithoutParams; |
|
597 |
} |
|
598 |
Virtualness virtualness() const { return vir; } |
|
599 |
bool isConst() const { return con; } |
|
600 |
bool isStatic() const { return sta; } |
|
601 |
bool isOverload() const { return ove; } |
|
602 |
bool isReimp() const { return reimp; } |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
603 |
bool isFunction() const { return true; } |
0 | 604 |
int overloadNumber() const; |
605 |
int numOverloads() const; |
|
606 |
const QList<Parameter>& parameters() const { return params; } |
|
607 |
QStringList parameterNames() const; |
|
608 |
const FunctionNode *reimplementedFrom() const { return rf; } |
|
609 |
const QList<FunctionNode *> &reimplementedBy() const { return rb; } |
|
610 |
const PropertyNode *associatedProperty() const { return ap; } |
|
611 |
const QStringList& parentPath() const { return pp; } |
|
612 |
||
613 |
QStringList reconstructParams(bool values = false) const; |
|
614 |
QString signature(bool values = false) const; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
615 |
const QString& element() const { return parent()->name(); } |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
616 |
bool isAttached() const { return att; } |
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
617 |
virtual bool isQmlNode() const { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
618 |
return ((type() == QmlSignal) || (type() == QmlMethod)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
619 |
} |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
620 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
621 |
void debug() const; |
0 | 622 |
|
623 |
private: |
|
624 |
void setAssociatedProperty(PropertyNode *property); |
|
625 |
||
626 |
friend class InnerNode; |
|
627 |
friend class PropertyNode; |
|
628 |
||
629 |
QString rt; |
|
630 |
QStringList pp; |
|
631 |
#ifdef Q_WS_WIN |
|
632 |
Metaness met; |
|
633 |
Virtualness vir; |
|
634 |
#else |
|
635 |
Metaness met : 4; |
|
636 |
Virtualness vir : 2; |
|
637 |
#endif |
|
638 |
bool con : 1; |
|
639 |
bool sta : 1; |
|
640 |
bool ove : 1; |
|
641 |
bool reimp: 1; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
642 |
bool att: 1; |
0 | 643 |
QList<Parameter> params; |
644 |
const FunctionNode *rf; |
|
645 |
const PropertyNode *ap; |
|
646 |
QList<FunctionNode *> rb; |
|
647 |
}; |
|
648 |
||
649 |
class PropertyNode : public LeafNode |
|
650 |
{ |
|
651 |
public: |
|
652 |
enum FunctionRole { Getter, Setter, Resetter, Notifier }; |
|
653 |
enum { NumFunctionRoles = Notifier + 1 }; |
|
654 |
||
655 |
PropertyNode(InnerNode *parent, const QString& name); |
|
656 |
virtual ~PropertyNode() { } |
|
657 |
||
658 |
void setDataType(const QString& dataType) { dt = dataType; } |
|
659 |
void addFunction(FunctionNode *function, FunctionRole role); |
|
660 |
void addSignal(FunctionNode *function, FunctionRole role); |
|
661 |
void setStored(bool stored) { sto = toTrool(stored); } |
|
662 |
void setDesignable(bool designable) { des = toTrool(designable); } |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
663 |
void setWritable(bool writable) { wri = toTrool(writable); } |
0 | 664 |
void setOverriddenFrom(const PropertyNode *baseProperty); |
665 |
||
666 |
const QString &dataType() const { return dt; } |
|
667 |
QString qualifiedDataType() const; |
|
668 |
NodeList functions() const; |
|
669 |
NodeList functions(FunctionRole role) const { return funcs[(int)role]; } |
|
670 |
NodeList getters() const { return functions(Getter); } |
|
671 |
NodeList setters() const { return functions(Setter); } |
|
672 |
NodeList resetters() const { return functions(Resetter); } |
|
673 |
NodeList notifiers() const { return functions(Notifier); } |
|
674 |
bool isStored() const { return fromTrool(sto, storedDefault()); } |
|
675 |
bool isDesignable() const { return fromTrool(des, designableDefault()); } |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
676 |
bool isWritable() const { return fromTrool(wri, writableDefault()); } |
0 | 677 |
const PropertyNode *overriddenFrom() const { return overrides; } |
678 |
||
679 |
private: |
|
680 |
enum Trool { Trool_True, Trool_False, Trool_Default }; |
|
681 |
||
682 |
static Trool toTrool(bool boolean); |
|
683 |
static bool fromTrool(Trool troolean, bool defaultValue); |
|
684 |
||
685 |
bool storedDefault() const { return true; } |
|
686 |
bool designableDefault() const { return !setters().isEmpty(); } |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
687 |
bool writableDefault() const { return !setters().isEmpty(); } |
0 | 688 |
|
689 |
QString dt; |
|
690 |
NodeList funcs[NumFunctionRoles]; |
|
691 |
Trool sto; |
|
692 |
Trool des; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
693 |
Trool wri; |
0 | 694 |
const PropertyNode *overrides; |
695 |
}; |
|
696 |
||
697 |
inline void FunctionNode::setParameters(const QList<Parameter> ¶meters) |
|
698 |
{ |
|
699 |
params = parameters; |
|
700 |
} |
|
701 |
||
702 |
inline void PropertyNode::addFunction(FunctionNode *function, FunctionRole role) |
|
703 |
{ |
|
704 |
funcs[(int)role].append(function); |
|
705 |
function->setAssociatedProperty(this); |
|
706 |
} |
|
707 |
||
708 |
inline void PropertyNode::addSignal(FunctionNode *function, FunctionRole role) |
|
709 |
{ |
|
710 |
funcs[(int)role].append(function); |
|
711 |
} |
|
712 |
||
713 |
inline NodeList PropertyNode::functions() const |
|
714 |
{ |
|
715 |
NodeList list; |
|
716 |
for (int i = 0; i < NumFunctionRoles; ++i) |
|
717 |
list += funcs[i]; |
|
718 |
return list; |
|
719 |
} |
|
720 |
||
721 |
class VariableNode : public LeafNode |
|
722 |
{ |
|
723 |
public: |
|
724 |
VariableNode(InnerNode *parent, const QString &name); |
|
725 |
virtual ~VariableNode() { } |
|
726 |
||
727 |
void setLeftType(const QString &leftType) { lt = leftType; } |
|
728 |
void setRightType(const QString &rightType) { rt = rightType; } |
|
729 |
void setStatic(bool statique) { sta = statique; } |
|
730 |
||
731 |
const QString &leftType() const { return lt; } |
|
732 |
const QString &rightType() const { return rt; } |
|
733 |
QString dataType() const { return lt + rt; } |
|
734 |
bool isStatic() const { return sta; } |
|
735 |
||
736 |
private: |
|
737 |
QString lt; |
|
738 |
QString rt; |
|
739 |
bool sta; |
|
740 |
}; |
|
741 |
||
742 |
inline VariableNode::VariableNode(InnerNode *parent, const QString &name) |
|
743 |
: LeafNode(Variable, parent, name), sta(false) |
|
744 |
{ |
|
745 |
} |
|
746 |
||
747 |
class TargetNode : public LeafNode |
|
748 |
{ |
|
749 |
public: |
|
750 |
TargetNode(InnerNode *parent, const QString& name); |
|
751 |
virtual ~TargetNode() { } |
|
752 |
||
753 |
virtual bool isInnerNode() const; |
|
754 |
}; |
|
755 |
||
756 |
QT_END_NAMESPACE |
|
757 |
||
758 |
#endif |