Mercurial > projects > qtd
annotate generator/parser/codemodel.h @ 354:18bd68f586c6
removed superfluous destructors
author | Max Samukha <maxter@spambox.com> |
---|---|
date | Mon, 24 May 2010 23:43:30 +0300 |
parents | 09a0f1d048f2 |
children |
rev | line source |
---|---|
1 | 1 /**************************************************************************** |
2 ** | |
52
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
3 ** Copyright (C) 1992-2009 Nokia. All rights reserved. |
1 | 4 ** Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org> |
5 ** | |
6 ** This file is part of Qt Jambi. | |
7 ** | |
52
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
8 ** Commercial Usage |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
9 Licensees holding valid Qt Commercial licenses may use this file in |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
10 accordance with the Qt Commercial License Agreement provided with the |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
11 Software or, alternatively, in accordance with the terms contained in |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
12 a written agreement between you and Nokia. |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
13 |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
14 GNU Lesser General Public License Usage |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
15 Alternatively, this file may be used under the terms of the GNU Lesser |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
16 General Public License version 2.1 as published by the Free Software |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
17 Foundation and appearing in the file LICENSE.LGPL included in the |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
18 packaging of this file. Please review the following information to |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
19 ensure the GNU Lesser General Public License version 2.1 requirements |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
20 will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
21 |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
22 In addition, as a special exception, Nokia gives you certain |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
23 additional rights. These rights are described in the Nokia Qt LGPL |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
24 Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
25 package. |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
26 |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
27 GNU General Public License Usage |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
28 Alternatively, this file may be used under the terms of the GNU |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
29 General Public License version 3.0 as published by the Free Software |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
30 Foundation and appearing in the file LICENSE.GPL included in the |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
31 packaging of this file. Please review the following information to |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
32 ensure the GNU General Public License version 3.0 requirements will be |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
33 met: http://www.gnu.org/copyleft/gpl.html. |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
34 |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
35 If you are unsure which license is appropriate for your use, please |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
36 contact the sales department at qt-sales@nokia.com. |
1 | 37 |
38 ** | |
39 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | |
40 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
41 ** | |
42 ****************************************************************************/ | |
43 | |
44 | |
45 #ifndef CODEMODEL_H | |
46 #define CODEMODEL_H | |
47 | |
48 #include "codemodel_fwd.h" | |
49 #include <codemodel_pointer.h> | |
50 | |
51 #include <QtCore/QHash> | |
52 #include <QtCore/QList> | |
53 #include <QtCore/QString> | |
54 #include <QtCore/QStringList> | |
55 #include <QtCore/QVector> | |
56 | |
57 #define DECLARE_MODEL_NODE(k) \ | |
58 enum { __node_kind = Kind_##k }; \ | |
59 typedef CodeModelPointer<k##ModelItem> Pointer; | |
60 | |
61 template <class _Target, class _Source> | |
62 _Target model_static_cast(_Source item) | |
63 { | |
64 typedef typename _Target::Type * _Target_pointer; | |
65 | |
66 _Target ptr (static_cast<_Target_pointer>(item.data())); | |
67 return ptr; | |
68 } | |
69 | |
70 class CodeModel | |
71 { | |
72 public: | |
73 enum AccessPolicy | |
74 { | |
75 Public, | |
76 Protected, | |
77 Private | |
78 }; | |
79 | |
80 enum FunctionType | |
81 { | |
82 Normal, | |
83 Signal, | |
84 Slot | |
85 }; | |
86 | |
87 enum ClassType | |
88 { | |
89 Class, | |
90 Struct, | |
91 Union | |
92 }; | |
93 | |
94 public: | |
95 CodeModel(); | |
96 virtual ~CodeModel(); | |
97 | |
98 template <class _Target> _Target create() | |
99 { | |
100 typedef typename _Target::Type _Target_type; | |
101 | |
102 _Target result = _Target_type::create(this); | |
103 result->setCreationId(_M_creation_id++); | |
104 return result; | |
105 } | |
106 | |
107 FileList files() const; | |
108 NamespaceModelItem globalNamespace() const; | |
109 | |
110 void addFile(FileModelItem item); | |
111 void removeFile(FileModelItem item); | |
112 FileModelItem findFile(const QString &name) const; | |
113 QHash<QString, FileModelItem> fileMap() const; | |
114 | |
115 CodeModelItem findItem(const QStringList &qualifiedName, CodeModelItem scope) const; | |
116 | |
117 void wipeout(); | |
118 | |
119 private: | |
120 QHash<QString, FileModelItem> _M_files; | |
121 NamespaceModelItem _M_globalNamespace; | |
122 std::size_t _M_creation_id; | |
123 | |
124 private: | |
125 CodeModel(const CodeModel &other); | |
126 void operator = (const CodeModel &other); | |
127 }; | |
128 | |
129 class TypeInfo | |
130 { | |
131 public: | |
132 TypeInfo(const TypeInfo &other) | |
133 : flags(other.flags), | |
134 m_qualifiedName(other.m_qualifiedName), | |
135 m_arrayElements(other.m_arrayElements), | |
136 m_arguments(other.m_arguments) | |
137 { | |
138 } | |
139 | |
140 TypeInfo(): | |
141 flags (0) {} | |
142 | |
143 QStringList qualifiedName() const { return m_qualifiedName; } | |
144 void setQualifiedName(const QStringList &qualified_name) { m_qualifiedName = qualified_name; } | |
145 | |
146 bool isConstant() const { return m_constant; } | |
147 void setConstant(bool is) { m_constant = is; } | |
148 | |
149 bool isVolatile() const { return m_volatile; } | |
150 void setVolatile(bool is) { m_volatile = is; } | |
151 | |
152 bool isReference() const { return m_reference; } | |
153 void setReference(bool is) { m_reference = is; } | |
154 | |
155 int indirections() const { return m_indirections; } | |
156 void setIndirections(int indirections) { m_indirections = indirections; } | |
157 | |
158 bool isFunctionPointer() const { return m_functionPointer; } | |
159 void setFunctionPointer(bool is) { m_functionPointer = is; } | |
160 | |
161 QStringList arrayElements() const { return m_arrayElements; } | |
162 void setArrayElements(const QStringList &arrayElements) { m_arrayElements = arrayElements; } | |
163 | |
164 QList<TypeInfo> arguments() const { return m_arguments; } | |
165 void setArguments(const QList<TypeInfo> &arguments); | |
166 void addArgument(const TypeInfo &arg) { m_arguments.append(arg); } | |
167 | |
168 bool operator==(const TypeInfo &other); | |
169 bool operator!=(const TypeInfo &other) { return !(*this==other); } | |
170 | |
171 // ### arrays and templates?? | |
172 | |
173 QString toString() const; | |
174 | |
175 static TypeInfo combine (const TypeInfo &__lhs, const TypeInfo &__rhs); | |
176 static TypeInfo resolveType (TypeInfo const &__type, CodeModelItem __scope); | |
177 | |
178 private: | |
179 union | |
180 { | |
181 uint flags; | |
182 | |
183 struct | |
184 { | |
185 uint m_constant: 1; | |
186 uint m_volatile: 1; | |
187 uint m_reference: 1; | |
188 uint m_functionPointer: 1; | |
189 uint m_indirections: 6; | |
190 uint m_padding: 22; | |
191 }; | |
192 }; | |
193 | |
194 QStringList m_qualifiedName; | |
195 QStringList m_arrayElements; | |
196 QList<TypeInfo> m_arguments; | |
197 }; | |
198 | |
199 class _CodeModelItem: public QSharedData | |
200 { | |
201 public: | |
202 enum Kind | |
203 { | |
204 /* These are bit-flags resembling inheritance */ | |
205 Kind_Scope = 0x1, | |
206 Kind_Namespace = 0x2 | Kind_Scope, | |
207 Kind_Member = 0x4, | |
208 Kind_Function = 0x8 | Kind_Member, | |
209 KindMask = 0xf, | |
210 | |
211 /* These are for classes that are not inherited from */ | |
212 FirstKind = 0x8, | |
213 Kind_Argument = 1 << FirstKind, | |
214 Kind_Class = 2 << FirstKind | Kind_Scope, | |
215 Kind_Enum = 3 << FirstKind, | |
216 Kind_Enumerator = 4 << FirstKind, | |
217 Kind_File = 5 << FirstKind | Kind_Namespace, | |
218 Kind_FunctionDefinition = 6 << FirstKind | Kind_Function, | |
219 Kind_TemplateParameter = 7 << FirstKind, | |
220 Kind_TypeAlias = 8 << FirstKind, | |
221 Kind_Variable = 9 << FirstKind | Kind_Member | |
222 }; | |
223 | |
224 public: | |
225 virtual ~_CodeModelItem(); | |
226 | |
227 int kind() const; | |
228 | |
229 QStringList qualifiedName() const; | |
230 | |
231 QString name() const; | |
232 void setName(const QString &name); | |
233 | |
234 QStringList scope() const; | |
235 void setScope(const QStringList &scope); | |
236 | |
237 QString fileName() const; | |
238 void setFileName(const QString &fileName); | |
239 | |
240 FileModelItem file() const; | |
241 | |
242 void getStartPosition(int *line, int *column); | |
243 void setStartPosition(int line, int column); | |
244 | |
245 void getEndPosition(int *line, int *column); | |
246 void setEndPosition(int line, int column); | |
247 | |
248 inline std::size_t creationId() const { return _M_creation_id; } | |
249 inline void setCreationId(std::size_t creation_id) { _M_creation_id = creation_id; } | |
250 | |
251 inline CodeModel *model() const { return _M_model; } | |
252 | |
253 CodeModelItem toItem() const; | |
254 | |
255 protected: | |
256 _CodeModelItem(CodeModel *model, int kind); | |
257 void setKind(int kind); | |
258 | |
259 private: | |
260 CodeModel *_M_model; | |
261 int _M_kind; | |
262 int _M_startLine; | |
263 int _M_startColumn; | |
264 int _M_endLine; | |
265 int _M_endColumn; | |
266 std::size_t _M_creation_id; | |
267 QString _M_name; | |
268 QString _M_fileName; | |
269 QStringList _M_scope; | |
270 | |
271 private: | |
272 _CodeModelItem(const _CodeModelItem &other); | |
273 void operator = (const _CodeModelItem &other); | |
274 }; | |
275 | |
276 class _ScopeModelItem: public _CodeModelItem | |
277 { | |
278 public: | |
279 DECLARE_MODEL_NODE(Scope) | |
280 | |
281 static ScopeModelItem create(CodeModel *model); | |
282 | |
283 public: | |
284 ClassList classes() const; | |
285 EnumList enums() const; | |
286 FunctionDefinitionList functionDefinitions() const; | |
287 FunctionList functions() const; | |
288 TypeAliasList typeAliases() const; | |
289 VariableList variables() const; | |
290 | |
291 void addClass(ClassModelItem item); | |
292 void addEnum(EnumModelItem item); | |
293 void addFunction(FunctionModelItem item); | |
294 void addFunctionDefinition(FunctionDefinitionModelItem item); | |
295 void addTypeAlias(TypeAliasModelItem item); | |
296 void addVariable(VariableModelItem item); | |
297 | |
298 void removeClass(ClassModelItem item); | |
299 void removeEnum(EnumModelItem item); | |
300 void removeFunction(FunctionModelItem item); | |
301 void removeFunctionDefinition(FunctionDefinitionModelItem item); | |
302 void removeTypeAlias(TypeAliasModelItem item); | |
303 void removeVariable(VariableModelItem item); | |
304 | |
305 ClassModelItem findClass(const QString &name) const; | |
306 EnumModelItem findEnum(const QString &name) const; | |
307 FunctionDefinitionList findFunctionDefinitions(const QString &name) const; | |
308 FunctionList findFunctions(const QString &name) const; | |
309 TypeAliasModelItem findTypeAlias(const QString &name) const; | |
310 VariableModelItem findVariable(const QString &name) const; | |
311 | |
312 void addEnumsDeclaration(const QString &enumsDeclaration); | |
313 QStringList enumsDeclarations() const { return _M_enumsDeclarations; } | |
314 | |
315 inline QHash<QString, ClassModelItem> classMap() const { return _M_classes; } | |
316 inline QHash<QString, EnumModelItem> enumMap() const { return _M_enums; } | |
317 inline QHash<QString, TypeAliasModelItem> typeAliasMap() const { return _M_typeAliases; } | |
318 inline QHash<QString, VariableModelItem> variableMap() const { return _M_variables; } | |
319 inline QMultiHash<QString, FunctionDefinitionModelItem> functionDefinitionMap() const { return _M_functionDefinitions; } | |
320 inline QMultiHash<QString, FunctionModelItem> functionMap() const { return _M_functions; } | |
321 | |
322 FunctionModelItem declaredFunction(FunctionModelItem item); | |
323 | |
324 protected: | |
325 _ScopeModelItem(CodeModel *model, int kind = __node_kind) | |
326 : _CodeModelItem(model, kind) {} | |
327 | |
328 private: | |
329 QHash<QString, ClassModelItem> _M_classes; | |
330 QHash<QString, EnumModelItem> _M_enums; | |
331 QHash<QString, TypeAliasModelItem> _M_typeAliases; | |
332 QHash<QString, VariableModelItem> _M_variables; | |
333 QMultiHash<QString, FunctionDefinitionModelItem> _M_functionDefinitions; | |
334 QMultiHash<QString, FunctionModelItem> _M_functions; | |
335 | |
336 private: | |
337 _ScopeModelItem(const _ScopeModelItem &other); | |
338 void operator = (const _ScopeModelItem &other); | |
339 | |
340 QStringList _M_enumsDeclarations; | |
341 }; | |
342 | |
343 class _ClassModelItem: public _ScopeModelItem | |
344 { | |
345 public: | |
346 DECLARE_MODEL_NODE(Class) | |
347 | |
348 static ClassModelItem create(CodeModel *model); | |
349 | |
350 public: | |
351 QStringList baseClasses() const; | |
352 | |
353 void setBaseClasses(const QStringList &baseClasses); | |
354 void addBaseClass(const QString &baseClass); | |
355 void removeBaseClass(const QString &baseClass); | |
356 | |
357 TemplateParameterList templateParameters() const; | |
358 void setTemplateParameters(const TemplateParameterList &templateParameters); | |
359 | |
360 bool extendsClass(const QString &name) const; | |
361 | |
362 void setClassType(CodeModel::ClassType type); | |
363 CodeModel::ClassType classType() const; | |
364 | |
365 void addPropertyDeclaration(const QString &propertyDeclaration); | |
366 QStringList propertyDeclarations() const { return _M_propertyDeclarations; } | |
367 | |
368 protected: | |
369 _ClassModelItem(CodeModel *model, int kind = __node_kind) | |
370 : _ScopeModelItem(model, kind), _M_classType(CodeModel::Class) {} | |
371 | |
372 private: | |
373 QStringList _M_baseClasses; | |
374 TemplateParameterList _M_templateParameters; | |
375 CodeModel::ClassType _M_classType; | |
376 | |
377 QStringList _M_propertyDeclarations; | |
378 | |
379 private: | |
380 _ClassModelItem(const _ClassModelItem &other); | |
381 void operator = (const _ClassModelItem &other); | |
382 }; | |
383 | |
384 class _NamespaceModelItem: public _ScopeModelItem | |
385 { | |
386 public: | |
387 DECLARE_MODEL_NODE(Namespace) | |
388 | |
389 static NamespaceModelItem create(CodeModel *model); | |
390 | |
391 public: | |
392 NamespaceList namespaces() const; | |
393 | |
394 void addNamespace(NamespaceModelItem item); | |
395 void removeNamespace(NamespaceModelItem item); | |
396 | |
397 NamespaceModelItem findNamespace(const QString &name) const; | |
398 | |
399 inline QHash<QString, NamespaceModelItem> namespaceMap() const { return _M_namespaces; }; | |
400 | |
401 protected: | |
402 _NamespaceModelItem(CodeModel *model, int kind = __node_kind) | |
403 : _ScopeModelItem(model, kind) {} | |
404 | |
405 private: | |
406 QHash<QString, NamespaceModelItem> _M_namespaces; | |
407 | |
408 private: | |
409 _NamespaceModelItem(const _NamespaceModelItem &other); | |
410 void operator = (const _NamespaceModelItem &other); | |
411 }; | |
412 | |
413 class _FileModelItem: public _NamespaceModelItem | |
414 { | |
415 public: | |
416 DECLARE_MODEL_NODE(File) | |
417 | |
418 static FileModelItem create(CodeModel *model); | |
419 | |
420 protected: | |
421 _FileModelItem(CodeModel *model, int kind = __node_kind) | |
422 : _NamespaceModelItem(model, kind) {} | |
423 | |
424 private: | |
425 _FileModelItem(const _FileModelItem &other); | |
426 void operator = (const _FileModelItem &other); | |
427 }; | |
428 | |
429 class _ArgumentModelItem: public _CodeModelItem | |
430 { | |
431 public: | |
432 DECLARE_MODEL_NODE(Argument) | |
433 | |
434 static ArgumentModelItem create(CodeModel *model); | |
435 | |
436 public: | |
437 TypeInfo type() const; | |
438 void setType(const TypeInfo &type); | |
439 | |
440 bool defaultValue() const; | |
441 void setDefaultValue(bool defaultValue); | |
442 | |
443 QString defaultValueExpression() const { return _M_defaultValueExpression; } | |
444 void setDefaultValueExpression(const QString &expr) { _M_defaultValueExpression = expr; } | |
445 | |
446 protected: | |
447 _ArgumentModelItem(CodeModel *model, int kind = __node_kind) | |
448 : _CodeModelItem(model, kind), _M_defaultValue(false) {} | |
449 | |
450 private: | |
451 TypeInfo _M_type; | |
452 QString _M_defaultValueExpression; | |
453 bool _M_defaultValue; | |
454 | |
455 private: | |
456 _ArgumentModelItem(const _ArgumentModelItem &other); | |
457 void operator = (const _ArgumentModelItem &other); | |
458 }; | |
459 | |
460 class _MemberModelItem: public _CodeModelItem | |
461 { | |
462 public: | |
463 DECLARE_MODEL_NODE(Member) | |
464 | |
465 bool isConstant() const; | |
466 void setConstant(bool isConstant); | |
467 | |
468 bool isVolatile() const; | |
469 void setVolatile(bool isVolatile); | |
470 | |
471 bool isStatic() const; | |
472 void setStatic(bool isStatic); | |
473 | |
474 bool isAuto() const; | |
475 void setAuto(bool isAuto); | |
476 | |
477 bool isFriend() const; | |
478 void setFriend(bool isFriend); | |
479 | |
480 bool isRegister() const; | |
481 void setRegister(bool isRegister); | |
482 | |
483 bool isExtern() const; | |
484 void setExtern(bool isExtern); | |
485 | |
486 bool isMutable() const; | |
487 void setMutable(bool isMutable); | |
488 | |
489 CodeModel::AccessPolicy accessPolicy() const; | |
490 void setAccessPolicy(CodeModel::AccessPolicy accessPolicy); | |
491 | |
492 TemplateParameterList templateParameters() const | |
493 { return _M_templateParameters; } | |
494 | |
495 void setTemplateParameters(const TemplateParameterList &templateParameters) | |
496 { _M_templateParameters = templateParameters; } | |
497 | |
498 TypeInfo type() const; | |
499 void setType(const TypeInfo &type); | |
500 | |
501 protected: | |
502 _MemberModelItem(CodeModel *model, int kind) | |
503 : _CodeModelItem(model, kind), | |
504 _M_accessPolicy(CodeModel::Public), | |
505 _M_flags(0) | |
506 {} | |
507 | |
508 private: | |
509 TemplateParameterList _M_templateParameters; | |
510 TypeInfo _M_type; | |
511 CodeModel::AccessPolicy _M_accessPolicy; | |
512 union | |
513 { | |
514 struct | |
515 { | |
516 uint _M_isConstant: 1; | |
517 uint _M_isVolatile: 1; | |
518 uint _M_isStatic: 1; | |
519 uint _M_isAuto: 1; | |
520 uint _M_isFriend: 1; | |
521 uint _M_isRegister: 1; | |
522 uint _M_isExtern: 1; | |
523 uint _M_isMutable: 1; | |
524 }; | |
525 uint _M_flags; | |
526 }; | |
527 | |
528 }; | |
529 | |
530 class _FunctionModelItem: public _MemberModelItem | |
531 { | |
532 public: | |
533 DECLARE_MODEL_NODE(Function) | |
534 | |
535 static FunctionModelItem create(CodeModel *model); | |
536 | |
537 public: | |
538 ArgumentList arguments() const; | |
539 | |
540 void addArgument(ArgumentModelItem item); | |
541 void removeArgument(ArgumentModelItem item); | |
542 | |
543 CodeModel::FunctionType functionType() const; | |
544 void setFunctionType(CodeModel::FunctionType functionType); | |
545 | |
546 bool isVirtual() const; | |
547 void setVirtual(bool isVirtual); | |
548 | |
549 bool isInline() const; | |
550 void setInline(bool isInline); | |
551 | |
552 bool isExplicit() const; | |
553 void setExplicit(bool isExplicit); | |
554 | |
555 bool isInvokable() const; // Qt | |
556 void setInvokable(bool isInvokable); // Qt | |
557 | |
558 bool isAbstract() const; | |
559 void setAbstract(bool isAbstract); | |
560 | |
561 bool isVariadics() const; | |
562 void setVariadics(bool isVariadics); | |
563 | |
564 bool isSimilar(FunctionModelItem other) const; | |
565 | |
566 protected: | |
567 _FunctionModelItem(CodeModel *model, int kind = __node_kind) | |
568 : _MemberModelItem(model, kind), | |
569 _M_functionType(CodeModel::Normal), | |
570 _M_flags(0) | |
571 {} | |
572 | |
573 private: | |
574 ArgumentList _M_arguments; | |
575 CodeModel::FunctionType _M_functionType; | |
576 union | |
577 { | |
578 struct | |
579 { | |
580 uint _M_isVirtual: 1; | |
581 uint _M_isInline: 1; | |
582 uint _M_isAbstract: 1; | |
583 uint _M_isExplicit: 1; | |
584 uint _M_isVariadics: 1; | |
585 uint _M_isInvokable : 1; // Qt | |
586 }; | |
587 uint _M_flags; | |
588 }; | |
589 | |
590 private: | |
591 _FunctionModelItem(const _FunctionModelItem &other); | |
592 void operator = (const _FunctionModelItem &other); | |
593 }; | |
594 | |
595 class _FunctionDefinitionModelItem: public _FunctionModelItem | |
596 { | |
597 public: | |
598 DECLARE_MODEL_NODE(FunctionDefinition) | |
599 | |
600 static FunctionDefinitionModelItem create(CodeModel *model); | |
601 | |
602 protected: | |
603 _FunctionDefinitionModelItem(CodeModel *model, int kind = __node_kind) | |
604 : _FunctionModelItem(model, kind) {} | |
605 | |
606 private: | |
607 _FunctionDefinitionModelItem(const _FunctionDefinitionModelItem &other); | |
608 void operator = (const _FunctionDefinitionModelItem &other); | |
609 }; | |
610 | |
611 class _VariableModelItem: public _MemberModelItem | |
612 { | |
613 public: | |
614 DECLARE_MODEL_NODE(Variable) | |
615 | |
616 static VariableModelItem create(CodeModel *model); | |
617 | |
618 protected: | |
619 _VariableModelItem(CodeModel *model, int kind = __node_kind) | |
620 : _MemberModelItem(model, kind) | |
621 {} | |
622 | |
623 private: | |
624 _VariableModelItem(const _VariableModelItem &other); | |
625 void operator = (const _VariableModelItem &other); | |
626 }; | |
627 | |
628 class _TypeAliasModelItem: public _CodeModelItem | |
629 { | |
630 public: | |
631 DECLARE_MODEL_NODE(TypeAlias) | |
632 | |
633 static TypeAliasModelItem create(CodeModel *model); | |
634 | |
635 public: | |
636 TypeInfo type() const; | |
637 void setType(const TypeInfo &type); | |
638 | |
639 protected: | |
640 _TypeAliasModelItem(CodeModel *model, int kind = __node_kind) | |
641 : _CodeModelItem(model, kind) {} | |
642 | |
643 private: | |
644 TypeInfo _M_type; | |
645 | |
646 private: | |
647 _TypeAliasModelItem(const _TypeAliasModelItem &other); | |
648 void operator = (const _TypeAliasModelItem &other); | |
649 }; | |
650 | |
651 class _EnumModelItem: public _CodeModelItem | |
652 { | |
653 public: | |
654 DECLARE_MODEL_NODE(Enum) | |
655 | |
656 static EnumModelItem create(CodeModel *model); | |
657 | |
658 public: | |
659 CodeModel::AccessPolicy accessPolicy() const; | |
660 void setAccessPolicy(CodeModel::AccessPolicy accessPolicy); | |
661 | |
662 EnumeratorList enumerators() const; | |
663 void addEnumerator(EnumeratorModelItem item); | |
664 void removeEnumerator(EnumeratorModelItem item); | |
665 | |
666 protected: | |
667 _EnumModelItem(CodeModel *model, int kind = __node_kind) | |
668 : _CodeModelItem(model, kind), | |
669 _M_accessPolicy(CodeModel::Public) | |
670 {} | |
671 | |
672 private: | |
673 CodeModel::AccessPolicy _M_accessPolicy; | |
674 EnumeratorList _M_enumerators; | |
675 | |
676 private: | |
677 _EnumModelItem(const _EnumModelItem &other); | |
678 void operator = (const _EnumModelItem &other); | |
679 }; | |
680 | |
681 class _EnumeratorModelItem: public _CodeModelItem | |
682 { | |
683 public: | |
684 DECLARE_MODEL_NODE(Enumerator) | |
685 | |
686 static EnumeratorModelItem create(CodeModel *model); | |
687 | |
688 public: | |
689 QString value() const; | |
690 void setValue(const QString &value); | |
691 | |
692 protected: | |
693 _EnumeratorModelItem(CodeModel *model, int kind = __node_kind) | |
694 : _CodeModelItem(model, kind) {} | |
695 | |
696 private: | |
697 QString _M_value; | |
698 | |
699 private: | |
700 _EnumeratorModelItem(const _EnumeratorModelItem &other); | |
701 void operator = (const _EnumeratorModelItem &other); | |
702 }; | |
703 | |
704 class _TemplateParameterModelItem: public _CodeModelItem | |
705 { | |
706 public: | |
707 DECLARE_MODEL_NODE(TemplateParameter) | |
708 | |
709 static TemplateParameterModelItem create(CodeModel *model); | |
710 | |
711 public: | |
712 TypeInfo type() const; | |
713 void setType(const TypeInfo &type); | |
714 | |
715 bool defaultValue() const; | |
716 void setDefaultValue(bool defaultValue); | |
717 | |
718 protected: | |
719 _TemplateParameterModelItem(CodeModel *model, int kind = __node_kind) | |
720 : _CodeModelItem(model, kind), _M_defaultValue(false) {} | |
721 | |
722 private: | |
723 TypeInfo _M_type; | |
724 bool _M_defaultValue; | |
725 | |
726 private: | |
727 _TemplateParameterModelItem(const _TemplateParameterModelItem &other); | |
728 void operator = (const _TemplateParameterModelItem &other); | |
729 }; | |
730 | |
731 template <class _Target, class _Source> | |
732 _Target model_safe_cast(_Source item) | |
733 { | |
734 typedef typename _Target::Type * _Target_pointer; | |
735 typedef typename _Source::Type * _Source_pointer; | |
736 | |
737 _Source_pointer source = item.data(); | |
738 if (source && source->kind() == _Target_pointer(0)->__node_kind) | |
739 { | |
740 _Target ptr(static_cast<_Target_pointer>(source)); | |
741 return ptr; | |
742 } | |
743 | |
744 return _Target(); | |
745 } | |
746 | |
747 template <typename _Target, typename _Source> | |
748 _Target model_dynamic_cast(_Source item) | |
749 { | |
750 typedef typename _Target::Type * _Target_pointer; | |
751 typedef typename _Source::Type * _Source_pointer; | |
752 | |
753 _Source_pointer source = item.data(); | |
754 if (source && (source->kind() == _Target_pointer(0)->__node_kind | |
755 || (int(_Target_pointer(0)->__node_kind) <= int(_CodeModelItem::KindMask) | |
756 && ((source->kind() & _Target_pointer(0)->__node_kind) | |
757 == _Target_pointer(0)->__node_kind)))) | |
758 { | |
759 _Target ptr(static_cast<_Target_pointer>(source)); | |
760 return ptr; | |
761 } | |
762 | |
763 return _Target(); | |
764 } | |
765 #endif // CODEMODEL_H | |
766 | |
767 // kate: space-indent on; indent-width 2; replace-tabs on; |