Mercurial > projects > qtd
annotate generator/parser/codemodel.cpp @ 409:4a943393a167
Added wrapper for QImage::save.
It has been private back from QtJambi because the format argument is a plain char pointer instead of a QString, but unlike QPixmap, wrappers were missing.
author | David Nadlinger <code@klickverbot.at> |
---|---|
date | Sun, 20 Mar 2011 20:39:44 +0100 |
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 #include "codemodel.h" | |
46 | |
47 // --------------------------------------------------------------------------- | |
48 CodeModel::CodeModel() | |
49 : _M_creation_id(0) | |
50 { | |
51 _M_globalNamespace = create<NamespaceModelItem>(); | |
52 } | |
53 | |
54 CodeModel::~CodeModel() | |
55 { | |
56 } | |
57 | |
58 void CodeModel::wipeout() | |
59 { | |
60 _M_globalNamespace = create<NamespaceModelItem>(); | |
61 _M_files.clear(); | |
62 } | |
63 | |
64 FileList CodeModel::files() const | |
65 { | |
66 return _M_files.values(); | |
67 } | |
68 | |
69 NamespaceModelItem CodeModel::globalNamespace() const | |
70 { | |
71 return _M_globalNamespace; | |
72 } | |
73 | |
74 void CodeModel::addFile(FileModelItem item) | |
75 { | |
76 _M_creation_id = 0; // reset the creation id | |
77 _M_files.insert(item->name(), item); | |
78 } | |
79 | |
80 void CodeModel::removeFile(FileModelItem item) | |
81 { | |
82 QHash<QString, FileModelItem>::Iterator it = _M_files.find(item->name()); | |
83 | |
84 if (it != _M_files.end() && it.value() == item) | |
85 _M_files.erase(it); | |
86 } | |
87 | |
88 FileModelItem CodeModel::findFile(const QString &name) const | |
89 { | |
90 return _M_files.value(name); | |
91 } | |
92 | |
93 QHash<QString, FileModelItem> CodeModel::fileMap() const | |
94 { | |
95 return _M_files; | |
96 } | |
97 | |
98 CodeModelItem CodeModel::findItem(const QStringList &qualifiedName, CodeModelItem scope) const | |
99 { | |
100 for (int i=0; i<qualifiedName.size(); ++i) { | |
101 // ### Extend to look for members etc too. | |
102 const QString &name = qualifiedName.at(i); | |
103 | |
104 if (NamespaceModelItem ns = model_dynamic_cast<NamespaceModelItem>(scope)) | |
105 { | |
106 if (NamespaceModelItem tmp_ns = ns->findNamespace(name)) { | |
107 scope = tmp_ns; | |
108 continue; | |
109 } | |
110 } | |
111 | |
112 if (ScopeModelItem ss = model_dynamic_cast<ScopeModelItem>(scope)) | |
113 { | |
114 if (ClassModelItem cs = ss->findClass(name)) | |
115 { | |
116 scope = cs; | |
117 } | |
118 else if (EnumModelItem es = ss->findEnum(name)) | |
119 { | |
120 if (i == qualifiedName.size () - 1) | |
121 return es->toItem(); | |
122 } | |
123 else if (TypeAliasModelItem tp = ss->findTypeAlias(name)) | |
124 { | |
125 if (i == qualifiedName.size () - 1) | |
126 return tp->toItem (); | |
127 } | |
128 else | |
129 { | |
130 // If we don't find the name in the scope chain we | |
131 // need to return an empty item to indicate failure... | |
132 return CodeModelItem(); | |
133 } | |
134 } | |
135 } | |
136 | |
137 return scope; | |
138 } | |
139 | |
140 | |
141 // --------------------------------------------------------------------------- | |
142 TypeInfo TypeInfo::combine (const TypeInfo &__lhs, const TypeInfo &__rhs) | |
143 { | |
144 TypeInfo __result = __lhs; | |
145 | |
146 __result.setConstant (__result.isConstant () || __rhs.isConstant ()); | |
147 __result.setVolatile (__result.isVolatile () || __rhs.isVolatile ()); | |
148 __result.setReference (__result.isReference () || __rhs.isReference ()); | |
149 __result.setIndirections (__result.indirections () + __rhs.indirections ()); | |
150 __result.setArrayElements (__result.arrayElements () + __rhs.arrayElements ()); | |
151 | |
152 return __result; | |
153 } | |
154 | |
155 TypeInfo TypeInfo::resolveType (TypeInfo const &__type, CodeModelItem __scope) | |
156 { | |
157 CodeModel *__model = __scope->model (); | |
158 Q_ASSERT (__model != 0); | |
159 | |
160 CodeModelItem __item = __model->findItem (__type.qualifiedName (), __scope); | |
161 | |
162 // Copy the type and replace with the proper qualified name. This | |
163 // only makes sence to do if we're actually getting a resolved | |
164 // type with a namespace. We only get this if the returned type | |
165 // has more than 2 entries in the qualified name... This test | |
166 // could be improved by returning if the type was found or not. | |
167 TypeInfo otherType(__type); | |
168 if (__item && __item->qualifiedName().size() > 1) { | |
169 otherType.setQualifiedName(__item->qualifiedName()); | |
170 } | |
171 | |
172 if (TypeAliasModelItem __alias = model_dynamic_cast<TypeAliasModelItem> (__item)) | |
173 return resolveType (TypeInfo::combine (__alias->type (), otherType), __scope); | |
174 | |
175 return otherType; | |
176 } | |
177 | |
178 QString TypeInfo::toString() const | |
179 { | |
180 QString tmp; | |
181 | |
182 tmp += m_qualifiedName.join("::"); | |
183 if (isConstant()) | |
184 tmp += QLatin1String(" const"); | |
185 | |
186 if (isVolatile()) | |
187 tmp += QLatin1String(" volatile"); | |
188 | |
189 if (indirections()) | |
190 tmp += QString(indirections(), QLatin1Char('*')); | |
191 | |
192 if (isReference()) | |
193 tmp += QLatin1Char('&'); | |
194 | |
195 if (isFunctionPointer()) | |
196 { | |
197 tmp += QLatin1String(" (*)("); | |
198 for (int i=0; i<m_arguments.count(); ++i) | |
199 { | |
200 if (i != 0) | |
201 tmp += QLatin1String(", "); | |
202 | |
203 tmp += m_arguments.at(i).toString(); | |
204 } | |
205 tmp += QLatin1String(")"); | |
206 } | |
207 | |
208 foreach (QString elt, arrayElements ()) | |
209 { | |
210 tmp += QLatin1String ("["); | |
211 tmp += elt; | |
212 tmp += QLatin1String ("]"); | |
213 } | |
214 | |
215 return tmp; | |
216 } | |
217 | |
218 bool TypeInfo::operator==(const TypeInfo &other) | |
219 { | |
220 if (arrayElements().count() != other.arguments().count()) | |
221 return false; | |
222 | |
223 #if defined (RXX_CHECK_ARRAY_ELEMENTS) // ### it'll break | |
224 for (int i=0; i<arrayElements().count(); ++i) | |
225 { | |
226 QString elt1 = arrayElements ().at (i).trimmed (); | |
227 QString elt2 = other.arrayElements ().at (i).trimmed (); | |
228 | |
229 if (elt1 != elt2) | |
230 return false; | |
231 } | |
232 #endif | |
233 | |
234 return flags == other.flags | |
235 && m_qualifiedName == other.m_qualifiedName | |
236 && (!m_functionPointer || m_arguments == other.m_arguments); | |
237 } | |
238 | |
239 // --------------------------------------------------------------------------- | |
240 _CodeModelItem::_CodeModelItem(CodeModel *model, int kind) | |
241 : _M_model(model), | |
242 _M_kind(kind), | |
243 _M_startLine(0), | |
244 _M_startColumn(0), | |
245 _M_endLine(0), | |
246 _M_endColumn(0), | |
247 _M_creation_id(0) | |
248 { | |
249 } | |
250 | |
251 _CodeModelItem::~_CodeModelItem() | |
252 { | |
253 } | |
254 | |
255 CodeModelItem _CodeModelItem::toItem() const | |
256 { | |
257 return CodeModelItem(const_cast<_CodeModelItem*>(this)); | |
258 } | |
259 | |
260 int _CodeModelItem::kind() const | |
261 { | |
262 return _M_kind; | |
263 } | |
264 | |
265 void _CodeModelItem::setKind(int kind) | |
266 { | |
267 _M_kind = kind; | |
268 } | |
269 | |
270 QStringList _CodeModelItem::qualifiedName() const | |
271 { | |
272 QStringList q = scope(); | |
273 | |
274 if (!name().isEmpty()) | |
275 q += name(); | |
276 | |
277 return q; | |
278 } | |
279 | |
280 QString _CodeModelItem::name() const | |
281 { | |
282 return _M_name; | |
283 } | |
284 | |
285 void _CodeModelItem::setName(const QString &name) | |
286 { | |
287 _M_name = name; | |
288 } | |
289 | |
290 QStringList _CodeModelItem::scope() const | |
291 { | |
292 return _M_scope; | |
293 } | |
294 | |
295 void _CodeModelItem::setScope(const QStringList &scope) | |
296 { | |
297 _M_scope = scope; | |
298 } | |
299 | |
300 QString _CodeModelItem::fileName() const | |
301 { | |
302 return _M_fileName; | |
303 } | |
304 | |
305 void _CodeModelItem::setFileName(const QString &fileName) | |
306 { | |
307 _M_fileName = fileName; | |
308 } | |
309 | |
310 FileModelItem _CodeModelItem::file() const | |
311 { | |
312 return model()->findFile(fileName()); | |
313 } | |
314 | |
315 void _CodeModelItem::getStartPosition(int *line, int *column) | |
316 { | |
317 *line = _M_startLine; | |
318 *column = _M_startColumn; | |
319 } | |
320 | |
321 void _CodeModelItem::setStartPosition(int line, int column) | |
322 { | |
323 _M_startLine = line; | |
324 _M_startColumn = column; | |
325 } | |
326 | |
327 void _CodeModelItem::getEndPosition(int *line, int *column) | |
328 { | |
329 *line = _M_endLine; | |
330 *column = _M_endColumn; | |
331 } | |
332 | |
333 void _CodeModelItem::setEndPosition(int line, int column) | |
334 { | |
335 _M_endLine = line; | |
336 _M_endColumn = column; | |
337 } | |
338 | |
339 // --------------------------------------------------------------------------- | |
340 QStringList _ClassModelItem::baseClasses() const | |
341 { | |
342 return _M_baseClasses; | |
343 } | |
344 | |
345 void _ClassModelItem::setBaseClasses(const QStringList &baseClasses) | |
346 { | |
347 _M_baseClasses = baseClasses; | |
348 } | |
349 | |
350 TemplateParameterList _ClassModelItem::templateParameters() const | |
351 { | |
352 return _M_templateParameters; | |
353 } | |
354 | |
355 void _ClassModelItem::setTemplateParameters(const TemplateParameterList &templateParameters) | |
356 { | |
357 _M_templateParameters = templateParameters; | |
358 } | |
359 | |
360 void _ClassModelItem::addBaseClass(const QString &baseClass) | |
361 { | |
362 _M_baseClasses.append(baseClass); | |
363 } | |
364 | |
365 void _ClassModelItem::removeBaseClass(const QString &baseClass) | |
366 { | |
367 _M_baseClasses.removeAt(_M_baseClasses.indexOf(baseClass)); | |
368 } | |
369 | |
370 bool _ClassModelItem::extendsClass(const QString &name) const | |
371 { | |
372 return _M_baseClasses.contains(name); | |
373 } | |
374 | |
375 void _ClassModelItem::setClassType(CodeModel::ClassType type) | |
376 { | |
377 _M_classType = type; | |
378 } | |
379 | |
380 CodeModel::ClassType _ClassModelItem::classType() const | |
381 { | |
382 return _M_classType; | |
383 } | |
384 | |
385 void _ClassModelItem::addPropertyDeclaration(const QString &propertyDeclaration) | |
386 { | |
387 _M_propertyDeclarations << propertyDeclaration; | |
388 } | |
389 | |
390 | |
391 // --------------------------------------------------------------------------- | |
392 FunctionModelItem _ScopeModelItem::declaredFunction(FunctionModelItem item) | |
393 { | |
394 FunctionList function_list = findFunctions(item->name()); | |
395 | |
396 foreach (FunctionModelItem fun, function_list) | |
397 { | |
398 if (fun->isSimilar(item)) | |
399 return fun; | |
400 } | |
401 | |
402 return FunctionModelItem(); | |
403 } | |
404 | |
405 ClassList _ScopeModelItem::classes() const | |
406 { | |
407 return _M_classes.values(); | |
408 } | |
409 | |
410 TypeAliasList _ScopeModelItem::typeAliases() const | |
411 { | |
412 return _M_typeAliases.values(); | |
413 } | |
414 | |
415 VariableList _ScopeModelItem::variables() const | |
416 { | |
417 return _M_variables.values(); | |
418 } | |
419 | |
420 FunctionList _ScopeModelItem::functions() const | |
421 { | |
422 return _M_functions.values(); | |
423 } | |
424 | |
425 void _ScopeModelItem::addEnumsDeclaration(const QString &enumsDeclaration) | |
426 { | |
427 _M_enumsDeclarations << enumsDeclaration; | |
428 } | |
429 | |
430 FunctionDefinitionList _ScopeModelItem::functionDefinitions() const | |
431 { | |
432 return _M_functionDefinitions.values(); | |
433 } | |
434 | |
435 EnumList _ScopeModelItem::enums() const | |
436 { | |
437 return _M_enums.values(); | |
438 } | |
439 | |
440 void _ScopeModelItem::addClass(ClassModelItem item) | |
441 { | |
442 QString name = item->name(); | |
443 int idx = name.indexOf("<"); | |
444 if (idx > 0) | |
445 _M_classes.insert(name.left(idx), item); | |
446 _M_classes.insert(name, item); | |
447 } | |
448 | |
449 void _ScopeModelItem::addFunction(FunctionModelItem item) | |
450 { | |
451 _M_functions.insert(item->name(), item); | |
452 } | |
453 | |
454 void _ScopeModelItem::addFunctionDefinition(FunctionDefinitionModelItem item) | |
455 { | |
456 _M_functionDefinitions.insert(item->name(), item); | |
457 } | |
458 | |
459 void _ScopeModelItem::addVariable(VariableModelItem item) | |
460 { | |
461 _M_variables.insert(item->name(), item); | |
462 } | |
463 | |
464 void _ScopeModelItem::addTypeAlias(TypeAliasModelItem item) | |
465 { | |
466 _M_typeAliases.insert(item->name(), item); | |
467 } | |
468 | |
469 void _ScopeModelItem::addEnum(EnumModelItem item) | |
470 { | |
471 _M_enums.insert(item->name(), item); | |
472 } | |
473 | |
474 void _ScopeModelItem::removeClass(ClassModelItem item) | |
475 { | |
476 QHash<QString, ClassModelItem>::Iterator it = _M_classes.find(item->name()); | |
477 | |
478 if (it != _M_classes.end() && it.value() == item) | |
479 _M_classes.erase(it); | |
480 } | |
481 | |
482 void _ScopeModelItem::removeFunction(FunctionModelItem item) | |
483 { | |
484 QMultiHash<QString, FunctionModelItem>::Iterator it = _M_functions.find(item->name()); | |
485 | |
486 while (it != _M_functions.end() && it.key() == item->name() | |
487 && it.value() != item) | |
488 { | |
489 ++it; | |
490 } | |
491 | |
492 if (it != _M_functions.end() && it.value() == item) | |
493 { | |
494 _M_functions.erase(it); | |
495 } | |
496 } | |
497 | |
498 void _ScopeModelItem::removeFunctionDefinition(FunctionDefinitionModelItem item) | |
499 { | |
500 QMultiHash<QString, FunctionDefinitionModelItem>::Iterator it = _M_functionDefinitions.find(item->name()); | |
501 | |
502 while (it != _M_functionDefinitions.end() && it.key() == item->name() | |
503 && it.value() != item) | |
504 { | |
505 ++it; | |
506 } | |
507 | |
508 if (it != _M_functionDefinitions.end() && it.value() == item) | |
509 { | |
510 _M_functionDefinitions.erase(it); | |
511 } | |
512 } | |
513 | |
514 void _ScopeModelItem::removeVariable(VariableModelItem item) | |
515 { | |
516 QHash<QString, VariableModelItem>::Iterator it = _M_variables.find(item->name()); | |
517 | |
518 if (it != _M_variables.end() && it.value() == item) | |
519 _M_variables.erase(it); | |
520 } | |
521 | |
522 void _ScopeModelItem::removeTypeAlias(TypeAliasModelItem item) | |
523 { | |
524 QHash<QString, TypeAliasModelItem>::Iterator it = _M_typeAliases.find(item->name()); | |
525 | |
526 if (it != _M_typeAliases.end() && it.value() == item) | |
527 _M_typeAliases.erase(it); | |
528 } | |
529 | |
530 void _ScopeModelItem::removeEnum(EnumModelItem item) | |
531 { | |
532 QHash<QString, EnumModelItem>::Iterator it = _M_enums.find(item->name()); | |
533 | |
534 if (it != _M_enums.end() && it.value() == item) | |
535 _M_enums.erase(it); | |
536 } | |
537 | |
538 ClassModelItem _ScopeModelItem::findClass(const QString &name) const | |
539 { | |
540 return _M_classes.value(name); | |
541 } | |
542 | |
543 VariableModelItem _ScopeModelItem::findVariable(const QString &name) const | |
544 { | |
545 return _M_variables.value(name); | |
546 } | |
547 | |
548 TypeAliasModelItem _ScopeModelItem::findTypeAlias(const QString &name) const | |
549 { | |
550 return _M_typeAliases.value(name); | |
551 } | |
552 | |
553 EnumModelItem _ScopeModelItem::findEnum(const QString &name) const | |
554 { | |
555 return _M_enums.value(name); | |
556 } | |
557 | |
558 FunctionList _ScopeModelItem::findFunctions(const QString &name) const | |
559 { | |
560 return _M_functions.values(name); | |
561 } | |
562 | |
563 FunctionDefinitionList _ScopeModelItem::findFunctionDefinitions(const QString &name) const | |
564 { | |
565 return _M_functionDefinitions.values(name); | |
566 } | |
567 | |
568 // --------------------------------------------------------------------------- | |
569 NamespaceList _NamespaceModelItem::namespaces() const | |
570 { | |
571 return _M_namespaces.values(); | |
572 } | |
573 void _NamespaceModelItem::addNamespace(NamespaceModelItem item) | |
574 { | |
575 _M_namespaces.insert(item->name(), item); | |
576 } | |
577 void _NamespaceModelItem::removeNamespace(NamespaceModelItem item) | |
578 { | |
579 QHash<QString, NamespaceModelItem>::Iterator it = _M_namespaces.find(item->name()); | |
580 | |
581 if (it != _M_namespaces.end() && it.value() == item) | |
582 _M_namespaces.erase(it); | |
583 } | |
584 | |
585 NamespaceModelItem _NamespaceModelItem::findNamespace(const QString &name) const | |
586 { | |
587 return _M_namespaces.value(name); | |
588 } | |
589 | |
590 // --------------------------------------------------------------------------- | |
591 TypeInfo _ArgumentModelItem::type() const | |
592 { | |
593 return _M_type; | |
594 } | |
595 | |
596 void _ArgumentModelItem::setType(const TypeInfo &type) | |
597 { | |
598 _M_type = type; | |
599 } | |
600 | |
601 bool _ArgumentModelItem::defaultValue() const | |
602 { | |
603 return _M_defaultValue; | |
604 } | |
605 | |
606 void _ArgumentModelItem::setDefaultValue(bool defaultValue) | |
607 { | |
608 _M_defaultValue = defaultValue; | |
609 } | |
610 | |
611 // --------------------------------------------------------------------------- | |
612 bool _FunctionModelItem::isSimilar(FunctionModelItem other) const | |
613 { | |
614 if (name() != other->name()) | |
615 return false; | |
616 | |
617 if (isConstant() != other->isConstant()) | |
618 return false; | |
619 | |
620 if (isVariadics() != other->isVariadics()) | |
621 return false; | |
622 | |
623 if (arguments().count() != other->arguments().count()) | |
624 return false; | |
625 | |
626 // ### check the template parameters | |
627 | |
628 for (int i=0; i<arguments().count(); ++i) | |
629 { | |
630 ArgumentModelItem arg1 = arguments().at(i); | |
631 ArgumentModelItem arg2 = other->arguments().at(i); | |
632 | |
633 if (arg1->type() != arg2->type()) | |
634 return false; | |
635 } | |
636 | |
637 return true; | |
638 } | |
639 | |
640 ArgumentList _FunctionModelItem::arguments() const | |
641 { | |
642 return _M_arguments; | |
643 } | |
644 | |
645 void _FunctionModelItem::addArgument(ArgumentModelItem item) | |
646 { | |
647 _M_arguments.append(item); | |
648 } | |
649 | |
650 void _FunctionModelItem::removeArgument(ArgumentModelItem item) | |
651 { | |
652 _M_arguments.removeAt(_M_arguments.indexOf(item)); | |
653 } | |
654 | |
655 CodeModel::FunctionType _FunctionModelItem::functionType() const | |
656 { | |
657 return _M_functionType; | |
658 } | |
659 | |
660 void _FunctionModelItem::setFunctionType(CodeModel::FunctionType functionType) | |
661 { | |
662 _M_functionType = functionType; | |
663 } | |
664 | |
665 bool _FunctionModelItem::isVariadics() const | |
666 { | |
667 return _M_isVariadics; | |
668 } | |
669 | |
670 void _FunctionModelItem::setVariadics(bool isVariadics) | |
671 { | |
672 _M_isVariadics = isVariadics; | |
673 } | |
674 | |
675 bool _FunctionModelItem::isVirtual() const | |
676 { | |
677 return _M_isVirtual; | |
678 } | |
679 | |
680 void _FunctionModelItem::setVirtual(bool isVirtual) | |
681 { | |
682 _M_isVirtual = isVirtual; | |
683 } | |
684 | |
685 bool _FunctionModelItem::isInline() const | |
686 { | |
687 return _M_isInline; | |
688 } | |
689 | |
690 void _FunctionModelItem::setInline(bool isInline) | |
691 { | |
692 _M_isInline = isInline; | |
693 } | |
694 | |
695 bool _FunctionModelItem::isExplicit() const | |
696 { | |
697 return _M_isExplicit; | |
698 } | |
699 | |
700 void _FunctionModelItem::setExplicit(bool isExplicit) | |
701 { | |
702 _M_isExplicit = isExplicit; | |
703 } | |
704 | |
705 bool _FunctionModelItem::isAbstract() const | |
706 { | |
707 return _M_isAbstract; | |
708 } | |
709 | |
710 void _FunctionModelItem::setAbstract(bool isAbstract) | |
711 { | |
712 _M_isAbstract = isAbstract; | |
713 } | |
714 | |
715 // Qt | |
716 bool _FunctionModelItem::isInvokable() const | |
717 { | |
718 return _M_isInvokable; | |
719 } | |
720 | |
721 void _FunctionModelItem::setInvokable(bool isInvokable) | |
722 { | |
723 _M_isInvokable = isInvokable; | |
724 } | |
725 | |
726 // --------------------------------------------------------------------------- | |
727 TypeInfo _TypeAliasModelItem::type() const | |
728 { | |
729 return _M_type; | |
730 } | |
731 | |
732 void _TypeAliasModelItem::setType(const TypeInfo &type) | |
733 { | |
734 _M_type = type; | |
735 } | |
736 | |
737 // --------------------------------------------------------------------------- | |
738 CodeModel::AccessPolicy _EnumModelItem::accessPolicy() const | |
739 { | |
740 return _M_accessPolicy; | |
741 } | |
742 | |
743 void _EnumModelItem::setAccessPolicy(CodeModel::AccessPolicy accessPolicy) | |
744 { | |
745 _M_accessPolicy = accessPolicy; | |
746 } | |
747 | |
748 EnumeratorList _EnumModelItem::enumerators() const | |
749 { | |
750 return _M_enumerators; | |
751 } | |
752 | |
753 void _EnumModelItem::addEnumerator(EnumeratorModelItem item) | |
754 { | |
755 _M_enumerators.append(item); | |
756 } | |
757 | |
758 void _EnumModelItem::removeEnumerator(EnumeratorModelItem item) | |
759 { | |
760 _M_enumerators.removeAt(_M_enumerators.indexOf(item)); | |
761 } | |
762 | |
763 // --------------------------------------------------------------------------- | |
764 QString _EnumeratorModelItem::value() const | |
765 { | |
766 return _M_value; | |
767 } | |
768 | |
769 void _EnumeratorModelItem::setValue(const QString &value) | |
770 { | |
771 _M_value = value; | |
772 } | |
773 | |
774 // --------------------------------------------------------------------------- | |
775 TypeInfo _TemplateParameterModelItem::type() const | |
776 { | |
777 return _M_type; | |
778 } | |
779 | |
780 void _TemplateParameterModelItem::setType(const TypeInfo &type) | |
781 { | |
782 _M_type = type; | |
783 } | |
784 | |
785 bool _TemplateParameterModelItem::defaultValue() const | |
786 { | |
787 return _M_defaultValue; | |
788 } | |
789 | |
790 void _TemplateParameterModelItem::setDefaultValue(bool defaultValue) | |
791 { | |
792 _M_defaultValue = defaultValue; | |
793 } | |
794 | |
795 // --------------------------------------------------------------------------- | |
796 ScopeModelItem _ScopeModelItem::create(CodeModel *model) | |
797 { | |
798 ScopeModelItem item(new _ScopeModelItem(model)); | |
799 return item; | |
800 } | |
801 | |
802 ClassModelItem _ClassModelItem::create(CodeModel *model) | |
803 { | |
804 ClassModelItem item(new _ClassModelItem(model)); | |
805 return item; | |
806 } | |
807 | |
808 NamespaceModelItem _NamespaceModelItem::create(CodeModel *model) | |
809 { | |
810 NamespaceModelItem item(new _NamespaceModelItem(model)); | |
811 return item; | |
812 } | |
813 | |
814 FileModelItem _FileModelItem::create(CodeModel *model) | |
815 { | |
816 FileModelItem item(new _FileModelItem(model)); | |
817 return item; | |
818 } | |
819 | |
820 ArgumentModelItem _ArgumentModelItem::create(CodeModel *model) | |
821 { | |
822 ArgumentModelItem item(new _ArgumentModelItem(model)); | |
823 return item; | |
824 } | |
825 | |
826 FunctionModelItem _FunctionModelItem::create(CodeModel *model) | |
827 { | |
828 FunctionModelItem item(new _FunctionModelItem(model)); | |
829 return item; | |
830 } | |
831 | |
832 FunctionDefinitionModelItem _FunctionDefinitionModelItem::create(CodeModel *model) | |
833 { | |
834 FunctionDefinitionModelItem item(new _FunctionDefinitionModelItem(model)); | |
835 return item; | |
836 } | |
837 | |
838 VariableModelItem _VariableModelItem::create(CodeModel *model) | |
839 { | |
840 VariableModelItem item(new _VariableModelItem(model)); | |
841 return item; | |
842 } | |
843 | |
844 TypeAliasModelItem _TypeAliasModelItem::create(CodeModel *model) | |
845 { | |
846 TypeAliasModelItem item(new _TypeAliasModelItem(model)); | |
847 return item; | |
848 } | |
849 | |
850 EnumModelItem _EnumModelItem::create(CodeModel *model) | |
851 { | |
852 EnumModelItem item(new _EnumModelItem(model)); | |
853 return item; | |
854 } | |
855 | |
856 EnumeratorModelItem _EnumeratorModelItem::create(CodeModel *model) | |
857 { | |
858 EnumeratorModelItem item(new _EnumeratorModelItem(model)); | |
859 return item; | |
860 } | |
861 | |
862 TemplateParameterModelItem _TemplateParameterModelItem::create(CodeModel *model) | |
863 { | |
864 TemplateParameterModelItem item(new _TemplateParameterModelItem(model)); | |
865 return item; | |
866 } | |
867 | |
868 // --------------------------------------------------------------------------- | |
869 TypeInfo _MemberModelItem::type() const | |
870 { | |
871 return _M_type; | |
872 } | |
873 | |
874 void _MemberModelItem::setType(const TypeInfo &type) | |
875 { | |
876 _M_type = type; | |
877 } | |
878 | |
879 CodeModel::AccessPolicy _MemberModelItem::accessPolicy() const | |
880 { | |
881 return _M_accessPolicy; | |
882 } | |
883 | |
884 void _MemberModelItem::setAccessPolicy(CodeModel::AccessPolicy accessPolicy) | |
885 { | |
886 _M_accessPolicy = accessPolicy; | |
887 } | |
888 | |
889 bool _MemberModelItem::isStatic() const | |
890 { | |
891 return _M_isStatic; | |
892 } | |
893 | |
894 void _MemberModelItem::setStatic(bool isStatic) | |
895 { | |
896 _M_isStatic = isStatic; | |
897 } | |
898 | |
899 bool _MemberModelItem::isConstant() const | |
900 { | |
901 return _M_isConstant; | |
902 } | |
903 | |
904 void _MemberModelItem::setConstant(bool isConstant) | |
905 { | |
906 _M_isConstant = isConstant; | |
907 } | |
908 | |
909 bool _MemberModelItem::isVolatile() const | |
910 { | |
911 return _M_isVolatile; | |
912 } | |
913 | |
914 void _MemberModelItem::setVolatile(bool isVolatile) | |
915 { | |
916 _M_isVolatile = isVolatile; | |
917 } | |
918 | |
919 bool _MemberModelItem::isAuto() const | |
920 { | |
921 return _M_isAuto; | |
922 } | |
923 | |
924 void _MemberModelItem::setAuto(bool isAuto) | |
925 { | |
926 _M_isAuto = isAuto; | |
927 } | |
928 | |
929 bool _MemberModelItem::isFriend() const | |
930 { | |
931 return _M_isFriend; | |
932 } | |
933 | |
934 void _MemberModelItem::setFriend(bool isFriend) | |
935 { | |
936 _M_isFriend = isFriend; | |
937 } | |
938 | |
939 bool _MemberModelItem::isRegister() const | |
940 { | |
941 return _M_isRegister; | |
942 } | |
943 | |
944 void _MemberModelItem::setRegister(bool isRegister) | |
945 { | |
946 _M_isRegister = isRegister; | |
947 } | |
948 | |
949 bool _MemberModelItem::isExtern() const | |
950 { | |
951 return _M_isExtern; | |
952 } | |
953 | |
954 void _MemberModelItem::setExtern(bool isExtern) | |
955 { | |
956 _M_isExtern = isExtern; | |
957 } | |
958 | |
959 bool _MemberModelItem::isMutable() const | |
960 { | |
961 return _M_isMutable; | |
962 } | |
963 | |
964 void _MemberModelItem::setMutable(bool isMutable) | |
965 { | |
966 _M_isMutable = isMutable; | |
967 } | |
968 | |
969 // kate: space-indent on; indent-width 2; replace-tabs on; | |
970 |