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