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