Mercurial > projects > qtd
annotate generator/typesystem.h @ 366:da4235301224
Fixed VoidFunc. Updated to dmd.2.047.
author | Max Samukha <maxter@spambox.com> |
---|---|
date | Wed, 23 Jun 2010 21:34:43 +0300 |
parents | beaf4a2974d7 |
children |
rev | line source |
---|---|
1 | 1 /**************************************************************************** |
2 ** | |
3 ** Copyright (C) 1992-2008 Nokia. All rights reserved. | |
4 ** | |
5 ** This file is part of Qt Jambi. | |
6 ** | |
7 ** * Commercial Usage | |
8 * Licensees holding valid Qt Commercial licenses may use this file in | |
9 * accordance with the Qt Commercial License Agreement provided with the | |
10 * Software or, alternatively, in accordance with the terms contained in | |
11 * a written agreement between you and Nokia. | |
12 * | |
13 * | |
14 * GNU General Public License Usage | |
15 * Alternatively, this file may be used under the terms of the GNU | |
16 * General Public License versions 2.0 or 3.0 as published by the Free | |
17 * Software Foundation and appearing in the file LICENSE.GPL included in | |
18 * the packaging of this file. Please review the following information | |
19 * to ensure GNU General Public Licensing requirements will be met: | |
20 * http://www.fsf.org/licensing/licenses/info/GPLv2.html and | |
21 * http://www.gnu.org/copyleft/gpl.html. In addition, as a special | |
22 * exception, Nokia gives you certain additional rights. These rights | |
23 * are described in the Nokia Qt GPL Exception version 1.2, included in | |
24 * the file GPL_EXCEPTION.txt in this package. | |
25 * | |
26 * Qt for Windows(R) Licensees | |
27 * As a special exception, Nokia, as the sole copyright holder for Qt | |
28 * Designer, grants users of the Qt/Eclipse Integration plug-in the | |
29 * right for the Qt/Eclipse Integration to link to functionality | |
30 * provided by Qt Designer and its related libraries. | |
31 * | |
32 * | |
33 * If you are unsure which license is appropriate for your use, please | |
34 * contact the sales department at qt-sales@nokia.com. | |
35 | |
36 ** | |
37 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | |
38 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
39 ** | |
40 ****************************************************************************/ | |
41 | |
42 #ifndef TYPESYSTEM_H | |
43 #define TYPESYSTEM_H | |
44 | |
45 #include <QtCore/QHash> | |
46 #include <QtCore/QString> | |
47 #include <QtCore/QStringList> | |
48 #include <QtCore/QMap> | |
49 #include <QDebug> | |
50 | |
51 class Indentor; | |
52 | |
53 class AbstractMetaType; | |
54 class QTextStream; | |
55 | |
56 class EnumTypeEntry; | |
57 class FlagsTypeEntry; | |
58 | |
59 extern QString strings_Object; | |
60 extern QString strings_String; | |
61 extern QString strings_Thread; | |
62 extern QString strings_char; | |
63 extern QString strings_java_lang; | |
64 extern QString strings_jchar; | |
65 extern QString strings_jobject; | |
66 | |
67 struct Include | |
68 { | |
69 enum IncludeType { | |
70 IncludePath, | |
71 LocalPath, | |
72 TargetLangImport | |
73 }; | |
74 | |
75 Include() : type(IncludePath) { } | |
361
beaf4a2974d7
Autogeneration of QMetaType. First attempts at fixing qRegisterMetaType etc
Max Samukha <maxter@maxter.com>
parents:
337
diff
changeset
|
76 Include(IncludeType t, const QString prot, const QString &nam) : |
beaf4a2974d7
Autogeneration of QMetaType. First attempts at fixing qRegisterMetaType etc
Max Samukha <maxter@maxter.com>
parents:
337
diff
changeset
|
77 type(t), |
beaf4a2974d7
Autogeneration of QMetaType. First attempts at fixing qRegisterMetaType etc
Max Samukha <maxter@maxter.com>
parents:
337
diff
changeset
|
78 protection(prot), |
beaf4a2974d7
Autogeneration of QMetaType. First attempts at fixing qRegisterMetaType etc
Max Samukha <maxter@maxter.com>
parents:
337
diff
changeset
|
79 name(nam) { }; |
beaf4a2974d7
Autogeneration of QMetaType. First attempts at fixing qRegisterMetaType etc
Max Samukha <maxter@maxter.com>
parents:
337
diff
changeset
|
80 |
beaf4a2974d7
Autogeneration of QMetaType. First attempts at fixing qRegisterMetaType etc
Max Samukha <maxter@maxter.com>
parents:
337
diff
changeset
|
81 Include(IncludeType t, const QString &nam) : |
beaf4a2974d7
Autogeneration of QMetaType. First attempts at fixing qRegisterMetaType etc
Max Samukha <maxter@maxter.com>
parents:
337
diff
changeset
|
82 type(t), |
beaf4a2974d7
Autogeneration of QMetaType. First attempts at fixing qRegisterMetaType etc
Max Samukha <maxter@maxter.com>
parents:
337
diff
changeset
|
83 protection(QString()), |
beaf4a2974d7
Autogeneration of QMetaType. First attempts at fixing qRegisterMetaType etc
Max Samukha <maxter@maxter.com>
parents:
337
diff
changeset
|
84 name(nam) { }; |
1 | 85 |
86 bool isValid() { return !name.isEmpty(); } | |
87 | |
88 IncludeType type; | |
89 QString name; | |
361
beaf4a2974d7
Autogeneration of QMetaType. First attempts at fixing qRegisterMetaType etc
Max Samukha <maxter@maxter.com>
parents:
337
diff
changeset
|
90 QString protection; |
1 | 91 |
92 QString toString() const; | |
93 | |
94 bool operator<(const Include &other) const { return name < other.name; } | |
95 }; | |
96 typedef QList<Include> IncludeList; | |
97 | |
98 typedef QMap<int, QString> ArgumentMap; | |
99 | |
100 class TemplateInstance; | |
101 | |
102 namespace TypeSystem { | |
103 enum Language { | |
104 NoLanguage = 0x0000, | |
105 TargetLangCode = 0x0001, | |
106 NativeCode = 0x0002, | |
14 | 107 TargetLangFreeCode = 0x0003, |
1 | 108 ShellCode = 0x0004, |
109 ShellDeclaration = 0x0008, | |
110 PackageInitializer = 0x0010, | |
111 DestructorFunction = 0x0020, | |
112 Constructors = 0x0040, | |
113 Interface = 0x0080, | |
114 | |
115 // masks | |
116 All = TargetLangCode | |
117 | NativeCode | |
118 | ShellCode | |
119 | ShellDeclaration | |
120 | PackageInitializer | |
121 | Constructors | |
122 | Interface | |
123 | DestructorFunction, | |
124 | |
125 JavaAndNativeCode = TargetLangCode | NativeCode, | |
126 TargetLangAndNativeCode = TargetLangCode | NativeCode | |
127 }; | |
128 | |
129 enum Ownership { | |
130 InvalidOwnership, | |
131 DefaultOwnership, | |
132 TargetLangOwnership, | |
133 CppOwnership | |
134 }; | |
135 }; | |
136 | |
137 struct ReferenceCount | |
138 { | |
139 ReferenceCount() : threadSafe(false), access(Public) { } | |
140 enum Action { // 0x01 - 0xff | |
141 Invalid = 0x00, | |
142 Add = 0x01, | |
143 AddAll = 0x02, | |
144 Remove = 0x04, | |
145 Set = 0x08, | |
146 Ignore = 0x10, | |
147 | |
148 ActionsMask = 0xff, | |
149 | |
150 Padding = 0xffffffff | |
151 }; | |
152 | |
153 enum Flag { // 0x100 - 0xf00 | |
154 ThreadSafe = 0x100, | |
155 Static = 0x200, | |
156 DeclareVariable = 0x400, | |
157 | |
158 FlagsMask = 0xf00 | |
159 }; | |
160 | |
161 enum Access { // 0x1000 - 0xf000 | |
162 Private = 0x1000, | |
163 Protected = 0x2000, | |
164 Friendly = 0x3000, | |
165 Public = 0x4000, | |
166 | |
167 AccessMask = 0xf000 | |
168 }; | |
169 | |
170 Action action; | |
171 QString variableName; | |
172 QString conditional; | |
173 QString declareVariable; | |
174 | |
175 uint threadSafe : 1; | |
176 | |
177 uint access; | |
178 }; | |
179 | |
180 class CodeSnipFragment{ | |
181 private: | |
182 const QString m_code; | |
183 TemplateInstance *m_instance; | |
184 | |
185 public: | |
186 CodeSnipFragment(const QString &code) | |
187 : m_code(code), | |
188 m_instance(0) | |
189 {} | |
190 | |
191 CodeSnipFragment(TemplateInstance *instance) | |
192 : m_instance(instance) | |
193 {} | |
194 | |
195 QString code() const; | |
196 }; | |
197 | |
198 class CodeSnipAbstract{ | |
199 public: | |
200 QString code() const; | |
201 | |
202 void addCode(const QString &code){ | |
203 codeList.append(new CodeSnipFragment(code)); | |
204 } | |
205 | |
206 void addTemplateInstance(TemplateInstance *ti){ | |
207 codeList.append(new CodeSnipFragment(ti)); | |
208 } | |
209 | |
210 QList<CodeSnipFragment*> codeList; | |
211 }; | |
212 | |
213 class CustomFunction : public CodeSnipAbstract | |
214 { | |
215 public: | |
216 CustomFunction(const QString &n = QString()) : name(n) { } | |
217 | |
218 QString name; | |
219 QString param_name; | |
220 }; | |
221 | |
222 class TemplateEntry : public CodeSnipAbstract | |
223 { | |
224 public: | |
225 TemplateEntry(const QString &name) | |
226 : m_name(name) | |
227 { | |
228 }; | |
229 | |
230 QString name() const { | |
231 return m_name; | |
232 }; | |
233 | |
234 private: | |
235 QString m_name; | |
236 }; | |
237 | |
238 typedef QHash<QString, TemplateEntry *> TemplateEntryHash; | |
239 | |
240 class TemplateInstance | |
241 { | |
242 public: | |
243 TemplateInstance(const QString &name) | |
244 : m_name(name) | |
245 {} | |
246 | |
247 void addReplaceRule(const QString &name, const QString &value){ | |
248 replaceRules[name]=value; | |
249 } | |
250 | |
251 QString expandCode() const; | |
252 | |
253 QString name() const { | |
254 return m_name; | |
255 } | |
256 | |
257 private: | |
258 const QString m_name; | |
259 QHash<QString, QString> replaceRules; | |
260 }; | |
261 | |
262 | |
263 class CodeSnip : public CodeSnipAbstract | |
264 { | |
265 public: | |
266 enum Position { | |
267 Beginning, | |
268 End, | |
269 AfterThis | |
270 }; | |
271 | |
272 CodeSnip() : language(TypeSystem::TargetLangCode) { } | |
273 CodeSnip(TypeSystem::Language lang) : language(lang) { } | |
274 | |
275 // Very simple, easy to make code ugly if you try | |
276 QTextStream &formattedCode(QTextStream &s, Indentor &indentor) const; | |
277 | |
278 TypeSystem::Language language; | |
279 Position position; | |
280 ArgumentMap argumentMap; | |
281 }; | |
282 typedef QList<CodeSnip> CodeSnipList; | |
283 | |
284 struct ArgumentModification | |
285 { | |
286 ArgumentModification(int idx) : removed_default_expression(false), removed(false), no_null_pointers(false), index(idx) | |
287 {} | |
288 | |
289 // Should the default expression be removed? | |
290 uint removed_default_expression : 1; | |
291 uint removed : 1; | |
292 uint no_null_pointers : 1; | |
293 uint reset_after_use : 1; | |
294 | |
295 // The index of this argument | |
296 int index; | |
297 | |
298 // Reference count flags for this argument | |
299 QList<ReferenceCount> referenceCounts; | |
300 | |
301 // The text given for the new type of the argument | |
302 QString modified_type; | |
303 | |
304 QString replace_value; | |
305 | |
306 // The code to be used to construct a return value when no_null_pointers is true and | |
307 // the returned value is null. If no_null_pointers is true and this string is | |
308 // empty, then the base class implementation will be used (or a default construction | |
309 // if there is no implementation) | |
310 QString null_pointer_default_value; | |
311 | |
312 // The text of the new default expression of the argument | |
313 QString replaced_default_expression; | |
314 | |
315 // The new definition of ownership for a specific argument | |
316 QHash<TypeSystem::Language, TypeSystem::Ownership> ownerships; | |
317 | |
318 // Different conversion rules | |
319 CodeSnipList conversion_rules; | |
320 }; | |
321 | |
322 struct Modification { | |
323 enum Modifiers { | |
324 Private = 0x0001, | |
325 Protected = 0x0002, | |
326 Public = 0x0003, | |
327 Friendly = 0x0004, | |
328 AccessModifierMask = 0x000f, | |
329 | |
330 Final = 0x0010, | |
331 NonFinal = 0x0020, | |
332 FinalMask = Final | NonFinal, | |
333 | |
334 Readable = 0x0100, | |
335 Writable = 0x0200, | |
336 | |
337 CodeInjection = 0x1000, | |
338 Rename = 0x2000, | |
339 Deprecated = 0x4000, | |
340 ReplaceExpression = 0x8000, | |
148
ae34188ddd84
private signals of QAbstractItemModel are now accessible
eldar
parents:
42
diff
changeset
|
341 VirtualSlot = 0x10000 | NonFinal, |
ae34188ddd84
private signals of QAbstractItemModel are now accessible
eldar
parents:
42
diff
changeset
|
342 AllowAsSlot = 0x00020000, |
ae34188ddd84
private signals of QAbstractItemModel are now accessible
eldar
parents:
42
diff
changeset
|
343 PrivateSignal = 0x00040000 |
ae34188ddd84
private signals of QAbstractItemModel are now accessible
eldar
parents:
42
diff
changeset
|
344 |
1 | 345 }; |
346 | |
347 Modification() : modifiers(0) { } | |
348 | |
349 bool isAccessModifier() const { return modifiers & AccessModifierMask; } | |
350 Modifiers accessModifier() const { return Modifiers(modifiers & AccessModifierMask); } | |
351 bool isPrivate() const { return accessModifier() == Private; } | |
352 bool isProtected() const { return accessModifier() == Protected; } | |
353 bool isPublic() const { return accessModifier() == Public; } | |
354 bool isFriendly() const { return accessModifier() == Friendly; } | |
355 bool isFinal() const { return modifiers & Final; } | |
356 bool isNonFinal() const { return modifiers & NonFinal; } | |
357 bool isVirtualSlot() const { return (modifiers & VirtualSlot) == VirtualSlot; } | |
148
ae34188ddd84
private signals of QAbstractItemModel are now accessible
eldar
parents:
42
diff
changeset
|
358 bool isAllowedAsSlot() const { return (modifiers & AllowAsSlot) == AllowAsSlot; } |
ae34188ddd84
private signals of QAbstractItemModel are now accessible
eldar
parents:
42
diff
changeset
|
359 bool isPrivateSignal() const { return (modifiers & PrivateSignal) == PrivateSignal; } |
1 | 360 QString accessModifierString() const; |
361 | |
362 bool isDeprecated() const { return modifiers & Deprecated; } | |
363 | |
364 void setRenamedTo(const QString &name) { renamedToName = name; } | |
365 QString renamedTo() const { return renamedToName; } | |
366 bool isRenameModifier() const { return modifiers & Rename; } | |
367 | |
368 uint modifiers; | |
369 QString renamedToName; | |
370 }; | |
371 | |
372 struct FunctionModification: public Modification | |
373 { | |
374 FunctionModification() : removal(TypeSystem::NoLanguage), store_result(false) { } | |
375 | |
376 bool isCodeInjection() const { return modifiers & CodeInjection; } | |
377 bool isRemoveModifier() const { return removal != TypeSystem::NoLanguage; } | |
378 | |
379 QString toString() const; | |
380 | |
381 QString signature; | |
382 QString association; | |
383 CodeSnipList snips; | |
384 TypeSystem::Language removal; | |
385 bool store_result; | |
386 | |
387 QList<ArgumentModification> argument_mods; | |
388 }; | |
389 typedef QList<FunctionModification> FunctionModificationList; | |
390 | |
391 struct FieldModification: public Modification | |
392 { | |
393 bool isReadable() const { return modifiers & Readable; } | |
394 bool isWritable() const { return modifiers & Writable; } | |
395 | |
396 QString name; | |
397 }; | |
398 typedef QList<FieldModification> FieldModificationList; | |
399 | |
400 struct ExpensePolicy { | |
401 ExpensePolicy() : limit(-1) { } | |
402 int limit; | |
403 QString cost; | |
404 bool isValid() const { return limit >= 0; } | |
405 }; | |
406 | |
407 class InterfaceTypeEntry; | |
408 class ObjectTypeEntry; | |
409 | |
410 class TypeEntry | |
411 { | |
412 public: | |
413 enum Type { | |
414 PrimitiveType, | |
415 VoidType, | |
416 FlagsType, | |
417 EnumType, | |
418 TemplateArgumentType, | |
419 ThreadType, | |
420 BasicValueType, | |
421 StringType, | |
422 ContainerType, | |
423 InterfaceType, | |
424 ObjectType, | |
425 NamespaceType, | |
426 VariantType, | |
427 JObjectWrapperType, | |
428 CharType, | |
429 ArrayType, | |
430 TypeSystemType, | |
431 CustomType, | |
432 }; | |
433 | |
434 enum CodeGeneration { | |
435 GenerateTargetLang = 0x0001, | |
436 GenerateCpp = 0x0002, | |
437 GenerateForSubclass = 0x0004, | |
438 | |
439 GenerateNothing = 0, | |
440 GenerateAll = 0xffff, | |
441 GenerateCode = GenerateTargetLang | GenerateCpp | |
442 }; | |
443 | |
444 TypeEntry(const QString &name, Type t) | |
445 : m_name(name), | |
446 m_type(t), | |
447 m_code_generation(GenerateAll), | |
304 | 448 m_preferred_conversion(true), |
449 m_has_copy_constructor(false) | |
1 | 450 { |
304 | 451 } |
1 | 452 |
453 virtual ~TypeEntry() { } | |
454 | |
455 Type type() const { return m_type; } | |
456 bool isPrimitive() const { return m_type == PrimitiveType; } | |
457 bool isEnum() const { return m_type == EnumType; } | |
458 bool isFlags() const { return m_type == FlagsType; } | |
459 bool isInterface() const { return m_type == InterfaceType; } | |
460 bool isObject() const { return m_type == ObjectType; } | |
461 bool isString() const { return m_type == StringType; } | |
462 bool isChar() const { return m_type == CharType; } | |
463 bool isNamespace() const { return m_type == NamespaceType; } | |
464 bool isContainer() const { return m_type == ContainerType; } | |
465 bool isVariant() const { return m_type == VariantType; } | |
466 bool isJObjectWrapper() const { return m_type == JObjectWrapperType; } | |
467 bool isArray() const { return m_type == ArrayType; } | |
468 bool isTemplateArgument() const { return m_type == TemplateArgumentType; } | |
469 bool isVoid() const { return m_type == VoidType; } | |
470 bool isThread() const { return m_type == ThreadType; } | |
471 bool isCustom() const { return m_type == CustomType; } | |
472 bool isBasicValue() const { return m_type == BasicValueType; } | |
473 bool isTypeSystem() const { return m_type == TypeSystemType; } | |
474 | |
475 virtual bool preferredConversion() const { return m_preferred_conversion; } | |
476 virtual void setPreferredConversion(bool b) { m_preferred_conversion = b; } | |
477 | |
478 virtual QString javaQualifier() const { return QString(); } | |
479 | |
480 // The type's name in C++, fully qualified | |
481 QString name() const { return m_name; } | |
482 | |
483 uint codeGeneration() const { return m_code_generation; } | |
484 void setCodeGeneration(uint cg) { m_code_generation = cg; } | |
485 | |
486 virtual QString qualifiedCppName() const { return m_name; } | |
487 | |
488 // Its type's name in JNI | |
489 virtual QString jniName() const { return m_name; } | |
490 | |
491 // The type's name in TargetLang | |
492 virtual QString targetLangName() const { return m_name; } | |
493 | |
494 // The type to lookup when converting to TargetLang | |
495 virtual QString lookupName() const { return targetLangName(); } | |
496 | |
497 // The package | |
498 virtual QString javaPackage() const { return QString(); } | |
499 | |
500 virtual QString qualifiedTargetLangName() const { | |
501 // QString pkg = javaPackage(); | |
502 /* if (pkg.isEmpty())*/ return targetLangName(); | |
503 // return pkg + '.' + targetLangName(); | |
504 } | |
505 | |
506 virtual InterfaceTypeEntry *designatedInterface() const { return 0; } | |
507 | |
508 void setCustomConstructor(const CustomFunction &func) { m_customConstructor = func; } | |
509 CustomFunction customConstructor() const { return m_customConstructor; } | |
510 | |
511 void setCustomDestructor(const CustomFunction &func) { m_customDestructor = func; } | |
512 CustomFunction customDestructor() const { return m_customDestructor; } | |
513 | |
514 virtual bool isValue() const { return false; } | |
515 virtual bool isComplex() const { return false; } | |
516 | |
517 virtual bool isNativeIdBased() const { return false; } | |
518 | |
519 // qtd | |
520 virtual bool isStructInD() const { return false; } | |
304 | 521 bool hasPrivateCopyConstructor() const { return m_has_copy_constructor; } |
522 void setHasPrivateCopyConstructor(bool has_copy_constructor) { m_has_copy_constructor = has_copy_constructor; } | |
1 | 523 |
524 private: | |
525 QString m_name; | |
526 Type m_type; | |
527 uint m_code_generation; | |
528 CustomFunction m_customConstructor; | |
529 CustomFunction m_customDestructor; | |
530 bool m_preferred_conversion; | |
304 | 531 bool m_has_copy_constructor; |
1 | 532 }; |
533 typedef QHash<QString, QList<TypeEntry *> > TypeEntryHash; | |
534 typedef QHash<QString, TypeEntry *> SingleTypeEntryHash; | |
535 | |
536 | |
537 class TypeSystemTypeEntry : public TypeEntry | |
538 { | |
539 public: | |
540 TypeSystemTypeEntry(const QString &name) | |
541 : TypeEntry(name, TypeSystemType) | |
542 { | |
543 }; | |
544 | |
545 QList<CodeSnip> snips; | |
546 }; | |
547 | |
548 | |
549 class ThreadTypeEntry : public TypeEntry | |
550 { | |
551 public: | |
552 ThreadTypeEntry() : TypeEntry("QThread", ThreadType) { setCodeGeneration(GenerateNothing); } | |
553 | |
554 QString jniName() const { return strings_jobject; } | |
555 QString targetLangName() const { return strings_Thread; } | |
556 QString javaPackage() const { return strings_java_lang; } | |
557 }; | |
558 | |
559 class VoidTypeEntry : public TypeEntry | |
560 { | |
561 public: | |
562 VoidTypeEntry() : TypeEntry("void", VoidType) { } | |
563 }; | |
564 | |
565 class TemplateArgumentEntry : public TypeEntry | |
566 { | |
567 public: | |
568 TemplateArgumentEntry(const QString &name) | |
569 : TypeEntry(name, TemplateArgumentType), m_ordinal(0) | |
570 { | |
571 } | |
572 | |
573 int ordinal() const { return m_ordinal; } | |
574 void setOrdinal(int o) { m_ordinal = o; } | |
575 | |
576 private: | |
577 int m_ordinal; | |
578 }; | |
579 | |
580 class ArrayTypeEntry : public TypeEntry | |
581 { | |
582 public: | |
583 ArrayTypeEntry(const TypeEntry *nested_type) : TypeEntry("Array", ArrayType), m_nested_type(nested_type) | |
584 { | |
585 Q_ASSERT(m_nested_type); | |
586 } | |
587 | |
588 void setNestedTypeEntry(TypeEntry *nested) { m_nested_type = nested; } | |
589 const TypeEntry *nestedTypeEntry() const { return m_nested_type; } | |
590 | |
591 QString targetLangName() const { return m_nested_type->targetLangName() + "[]"; } | |
592 QString jniName() const | |
593 { | |
594 if (m_nested_type->isPrimitive()) | |
595 return m_nested_type->jniName() + "Array"; | |
596 else | |
597 return "jobjectArray"; | |
598 } | |
599 | |
600 private: | |
601 const TypeEntry *m_nested_type; | |
602 }; | |
603 | |
604 | |
605 class PrimitiveTypeEntry : public TypeEntry | |
606 { | |
607 public: | |
608 PrimitiveTypeEntry(const QString &name) | |
609 : TypeEntry(name, PrimitiveType), m_preferred_conversion(true), m_preferred_java_type(true) | |
610 { | |
611 } | |
612 | |
613 QString targetLangName() const { return m_java_name; } | |
614 void setTargetLangName(const QString &targetLangName) { m_java_name = targetLangName; } | |
615 | |
616 QString jniName() const { return m_jni_name; } | |
617 void setJniName(const QString &jniName) { m_jni_name = jniName; } | |
618 | |
619 QString javaObjectFullName() const { return javaObjectPackage() + "." + javaObjectName(); } | |
620 QString javaObjectName() const; | |
621 QString javaObjectPackage() const { return strings_java_lang; } | |
622 | |
623 virtual bool preferredConversion() const { return m_preferred_conversion; } | |
624 virtual void setPreferredConversion(bool b) { m_preferred_conversion = b; } | |
625 | |
626 virtual bool preferredTargetLangType() const { return m_preferred_java_type; } | |
627 virtual void setPreferredTargetLangType(bool b) { m_preferred_java_type = b; } | |
628 | |
629 private: | |
630 QString m_java_name; | |
631 QString m_jni_name; | |
632 uint m_preferred_conversion : 1; | |
633 uint m_preferred_java_type : 1; | |
634 }; | |
635 | |
636 | |
637 | |
638 | |
639 struct EnumValueRedirection | |
640 { | |
641 EnumValueRedirection(const QString &rej, const QString &us) | |
642 : rejected(rej), | |
643 used(us) | |
644 { | |
645 } | |
646 QString rejected; | |
647 QString used; | |
648 }; | |
649 | |
650 class EnumTypeEntry : public TypeEntry | |
651 { | |
652 public: | |
653 EnumTypeEntry(const QString &nspace, const QString &enumName) | |
654 : TypeEntry(nspace.isEmpty() ? enumName : nspace + QLatin1String("::") + enumName, | |
655 EnumType), | |
656 m_flags(0), | |
657 m_extensible(false) | |
658 { | |
659 m_qualifier = nspace; | |
660 m_java_name = enumName; | |
661 } | |
662 | |
663 QString javaPackage() const { return m_package_name; } | |
664 void setTargetLangPackage(const QString &package) { m_package_name = package; } | |
665 | |
666 QString targetLangName() const { return m_java_name; } | |
667 QString javaQualifier() const; | |
668 QString qualifiedTargetLangName() const { | |
337 | 669 return javaQualifier() + '.' + targetLangName(); |
670 //return targetLangName(); | |
1 | 671 } |
672 | |
673 QString jniName() const; | |
674 | |
675 QString qualifier() const { return m_qualifier; } | |
676 void setQualifier(const QString &q) { m_qualifier = q; } | |
677 | |
678 virtual bool preferredConversion() const { return false; } | |
679 | |
680 bool isBoundsChecked() const { return m_lower_bound.isEmpty() && m_upper_bound.isEmpty(); } | |
681 | |
682 QString upperBound() const { return m_upper_bound; } | |
683 void setUpperBound(const QString &bound) { m_upper_bound = bound; } | |
684 | |
685 QString lowerBound() const { return m_lower_bound; } | |
686 void setLowerBound(const QString &bound) { m_lower_bound = bound; } | |
687 | |
688 void setFlags(FlagsTypeEntry *flags) { m_flags = flags; } | |
689 FlagsTypeEntry *flags() const { return m_flags; } | |
690 | |
691 bool isExtensible() const { return m_extensible; } | |
692 void setExtensible(bool is) { m_extensible = is; } | |
693 | |
694 bool isEnumValueRejected(const QString &name) { return m_rejected_enums.contains(name); } | |
695 void addEnumValueRejection(const QString &name) { m_rejected_enums << name; } | |
696 QStringList enumValueRejections() const { return m_rejected_enums; } | |
697 | |
698 void addEnumValueRedirection(const QString &rejected, const QString &usedValue); | |
699 QString enumValueRedirection(const QString &value) const; | |
700 | |
701 bool forceInteger() const { return m_force_integer; } | |
702 void setForceInteger(bool force) { m_force_integer = force; } | |
703 | |
704 private: | |
705 QString m_package_name; | |
706 QString m_qualifier; | |
707 QString m_java_name; | |
708 | |
709 QString m_lower_bound; | |
710 QString m_upper_bound; | |
711 | |
712 QStringList m_rejected_enums; | |
713 QList<EnumValueRedirection> m_enum_redirections; | |
714 | |
715 FlagsTypeEntry *m_flags; | |
716 | |
717 bool m_extensible; | |
718 bool m_force_integer; | |
719 }; | |
720 | |
721 class FlagsTypeEntry : public TypeEntry | |
722 { | |
723 public: | |
724 FlagsTypeEntry(const QString &name) : TypeEntry(name, FlagsType), m_enum(0) | |
725 { | |
726 } | |
727 | |
728 QString qualifiedTargetLangName() const; | |
729 QString targetLangName() const { return m_java_name; } | |
730 QString jniName() const; | |
731 virtual bool preferredConversion() const { return false; } | |
732 | |
733 QString originalName() const { return m_original_name; } | |
734 void setOriginalName(const QString &s) { m_original_name = s; } | |
735 | |
736 QString flagsName() const { return m_java_name; } | |
737 void setFlagsName(const QString &name) { m_java_name = name; } | |
738 | |
739 bool forceInteger() const { return m_enum->forceInteger(); } | |
740 | |
741 EnumTypeEntry *originator() const { return m_enum; } | |
742 void setOriginator(EnumTypeEntry *e) { m_enum = e; } | |
743 | |
744 QString javaPackage() const { return m_enum->javaPackage(); } | |
745 QString javaQualifier() const { return m_enum->javaQualifier(); } | |
746 QString qualifier() const { return m_enum->qualifier(); } | |
747 | |
748 private: | |
749 QString m_original_name; | |
750 QString m_java_name; | |
751 EnumTypeEntry *m_enum; | |
752 }; | |
753 | |
754 | |
755 class ComplexTypeEntry : public TypeEntry | |
756 { | |
757 public: | |
758 enum TypeFlag { | |
759 ForceAbstract = 0x1, | |
760 DeleteInMainThread = 0x2, | |
761 Deprecated = 0x4 | |
762 }; | |
763 typedef QFlags<TypeFlag> TypeFlags; | |
764 | |
765 ComplexTypeEntry(const QString &name, Type t) | |
766 : TypeEntry(QString(name).replace("::", "_"), t), | |
767 m_qualified_cpp_name(name), | |
768 m_qobject(false), | |
769 m_polymorphic_base(false), | |
770 m_generic_class(false), | |
771 m_type_flags(0), | |
772 m_isStructInD(false), | |
773 m_isAbstract(false) | |
774 { | |
775 Include inc; | |
776 inc.name = "QVariant"; | |
777 inc.type = Include::IncludePath; | |
778 | |
779 addExtraInclude(inc); | |
780 } | |
781 | |
782 bool isComplex() const { return true; } | |
783 | |
784 IncludeList extraIncludes() const { return m_extra_includes; } | |
785 void setExtraIncludes(const IncludeList &includes) { m_extra_includes = includes; } | |
786 void addExtraInclude(const Include &include) | |
787 { | |
788 if (!m_includes_used.value(include.name, false)) { | |
789 m_extra_includes << include; | |
790 m_includes_used[include.name] = true; | |
791 } | |
792 } | |
793 | |
794 ComplexTypeEntry *copy() const | |
795 { | |
796 ComplexTypeEntry *centry = new ComplexTypeEntry(name(), type()); | |
797 centry->setInclude(include()); | |
798 centry->setExtraIncludes(extraIncludes()); | |
799 centry->setFunctionModifications(functionModifications()); | |
800 centry->setFieldModifications(fieldModifications()); | |
801 centry->setQObject(isQObject()); | |
802 centry->setDefaultSuperclass(defaultSuperclass()); | |
803 centry->setCodeSnips(codeSnips()); | |
804 centry->setTargetLangPackage(javaPackage()); | |
805 | |
806 return centry; | |
807 } | |
808 | |
809 void setLookupName(const QString &name) | |
810 { | |
811 m_lookup_name = name; | |
812 } | |
813 | |
814 virtual QString lookupName() const | |
815 { | |
816 return m_lookup_name.isEmpty() ? targetLangName() : m_lookup_name; | |
817 } | |
818 | |
819 QString jniName() const { return strings_jobject; } | |
820 | |
821 | |
822 Include include() const { return m_include; } | |
823 void setInclude(const Include &inc) { m_include = inc; } | |
824 | |
825 void setTypeFlags(TypeFlags flags) | |
826 { | |
827 m_type_flags = flags; | |
828 } | |
829 | |
830 TypeFlags typeFlags() const | |
831 { | |
832 return m_type_flags; | |
833 } | |
834 | |
835 CodeSnipList codeSnips() const { return m_code_snips; } | |
836 void setCodeSnips(const CodeSnipList &codeSnips) { m_code_snips = codeSnips; } | |
837 void addCodeSnip(const CodeSnip &codeSnip) { m_code_snips << codeSnip; } | |
838 | |
839 FunctionModificationList functionModifications() const { return m_function_mods; } | |
840 void setFunctionModifications(const FunctionModificationList &functionModifications) { | |
841 m_function_mods = functionModifications; | |
842 } | |
843 void addFunctionModification(const FunctionModification &functionModification) { | |
844 m_function_mods << functionModification; | |
845 } | |
846 FunctionModificationList functionModifications(const QString &signature) const; | |
847 | |
848 FieldModification fieldModification(const QString &name) const; | |
849 void setFieldModifications(const FieldModificationList &mods) { m_field_mods = mods; } | |
850 FieldModificationList fieldModifications() const { return m_field_mods; } | |
851 | |
852 QString javaPackage() const { return m_package; } | |
853 void setTargetLangPackage(const QString &package) { m_package = package; } | |
854 | |
855 bool isQObject() const { return m_qobject; } | |
856 void setQObject(bool qobject) { m_qobject = qobject; } | |
857 | |
858 QString defaultSuperclass() const { return m_default_superclass; } | |
859 void setDefaultSuperclass(const QString &sc) { m_default_superclass = sc; } | |
860 | |
861 virtual QString qualifiedCppName() const { return m_qualified_cpp_name; } | |
862 | |
863 | |
864 void setIsPolymorphicBase(bool on) | |
865 { | |
866 m_polymorphic_base = on; | |
867 } | |
868 bool isPolymorphicBase() const { return m_polymorphic_base; } | |
869 | |
870 void setPolymorphicIdValue(const QString &value) | |
871 { | |
872 m_polymorphic_id_value = value; | |
873 } | |
874 QString polymorphicIdValue() const { return m_polymorphic_id_value; } | |
875 | |
876 void setExpensePolicy(const ExpensePolicy &policy) { m_expense_policy = policy; } | |
877 const ExpensePolicy &expensePolicy() const { return m_expense_policy; } | |
878 | |
879 QString targetType() const { return m_target_type; } | |
880 void setTargetType(const QString &code) { m_target_type = code; } | |
881 | |
882 QString targetLangName() const { return m_java_name.isEmpty() | |
883 ? TypeEntry::targetLangName() | |
884 : m_java_name; | |
885 } | |
886 void setTargetLangName(const QString &name) { m_java_name = name; } | |
887 | |
888 bool isGenericClass() const { return m_generic_class; } | |
889 void setGenericClass(bool isGeneric) { m_generic_class = isGeneric; } | |
890 | |
891 QString injectedImports; | |
892 | |
893 // qtd | |
894 bool isStructInD() const { return m_isStructInD; } | |
895 void setStructInD(bool isStruct) { m_isStructInD = isStruct; } | |
896 | |
897 bool isAbstract() const { return m_isAbstract; } | |
898 void setAbstract(bool isAbstract) { m_isAbstract = isAbstract; } | |
899 | |
42 | 900 void setDepends(const QStringList &depends) {m_depends = depends; } |
901 const QStringList &depends() {return m_depends; } | |
902 | |
1 | 903 QString addedTo; |
904 QStringList includedClasses; | |
905 | |
906 | |
907 private: | |
908 IncludeList m_extra_includes; | |
909 Include m_include; | |
910 QHash<QString, bool> m_includes_used; | |
911 FunctionModificationList m_function_mods; | |
912 FieldModificationList m_field_mods; | |
913 CodeSnipList m_code_snips; | |
914 QString m_package; | |
915 QString m_default_superclass; | |
916 QString m_qualified_cpp_name; | |
917 QString m_java_name; | |
918 | |
919 uint m_qobject : 1; | |
920 uint m_polymorphic_base : 1; | |
921 uint m_generic_class : 1; | |
922 | |
923 QString m_polymorphic_id_value; | |
924 QString m_lookup_name; | |
925 QString m_target_type; | |
926 ExpensePolicy m_expense_policy; | |
927 TypeFlags m_type_flags; | |
928 | |
929 // qtd | |
930 bool m_isStructInD; | |
931 bool m_isAbstract; | |
42 | 932 QStringList m_depends; |
1 | 933 }; |
934 | |
935 class ContainerTypeEntry : public ComplexTypeEntry | |
936 { | |
937 public: | |
938 enum Type { | |
939 NoContainer, | |
940 ListContainer, | |
941 StringListContainer, | |
942 LinkedListContainer, | |
943 VectorContainer, | |
944 StackContainer, | |
945 QueueContainer, | |
946 SetContainer, | |
947 MapContainer, | |
948 MultiMapContainer, | |
949 HashContainer, | |
950 MultiHashContainer, | |
951 PairContainer, | |
952 }; | |
953 | |
954 ContainerTypeEntry(const QString &name, Type type) | |
955 : ComplexTypeEntry(name, ContainerType) | |
956 { | |
957 m_type = type; | |
958 setCodeGeneration(GenerateForSubclass); | |
959 } | |
960 | |
961 Type type() const { return m_type; } | |
962 QString targetLangName() const; | |
963 QString javaPackage() const; | |
964 QString qualifiedCppName() const; | |
965 | |
298
adae77fdc1ea
Native QList implementation is now used throughout QtD
eldar
parents:
148
diff
changeset
|
966 bool isQList() const { return type() == ListContainer || type() == StringListContainer; } |
adae77fdc1ea
Native QList implementation is now used throughout QtD
eldar
parents:
148
diff
changeset
|
967 |
1 | 968 private: |
969 Type m_type; | |
970 }; | |
971 | |
972 | |
973 class NamespaceTypeEntry : public ComplexTypeEntry | |
974 { | |
975 public: | |
976 NamespaceTypeEntry(const QString &name) : ComplexTypeEntry(name, NamespaceType) { } | |
977 }; | |
978 | |
979 | |
980 class ValueTypeEntry : public ComplexTypeEntry | |
981 { | |
982 public: | |
983 ValueTypeEntry(const QString &name) : ComplexTypeEntry(name, BasicValueType) { } | |
984 | |
985 bool isValue() const { return true; } | |
986 | |
987 virtual bool isNativeIdBased() const { return true; } | |
988 | |
989 protected: | |
990 ValueTypeEntry(const QString &name, Type t) : ComplexTypeEntry(name, t) { } | |
991 }; | |
992 | |
993 | |
994 class StringTypeEntry : public ValueTypeEntry | |
995 { | |
996 public: | |
997 StringTypeEntry(const QString &name) | |
998 : ValueTypeEntry(name, StringType) | |
999 { | |
1000 setCodeGeneration(GenerateNothing); | |
1001 } | |
1002 | |
1003 QString jniName() const { return strings_jobject; } | |
1004 QString targetLangName() const { return strings_String; } | |
1005 QString javaPackage() const { return strings_java_lang; } | |
1006 | |
1007 virtual bool isNativeIdBased() const { return false; } | |
1008 }; | |
1009 | |
1010 class CharTypeEntry : public ValueTypeEntry | |
1011 { | |
1012 public: | |
1013 CharTypeEntry(const QString &name) : ValueTypeEntry(name, CharType) | |
1014 { | |
1015 setCodeGeneration(GenerateNothing); | |
1016 } | |
1017 | |
1018 QString jniName() const { return strings_jchar; } | |
1019 QString targetLangName() const { return strings_char; } | |
1020 QString javaPackage() const { return QString(); } | |
1021 | |
1022 virtual bool isNativeIdBased() const { return false; } | |
1023 }; | |
1024 | |
1025 class JObjectWrapperTypeEntry: public ValueTypeEntry | |
1026 { | |
1027 public: | |
1028 JObjectWrapperTypeEntry(const QString &name) : ValueTypeEntry(name, JObjectWrapperType) { } | |
1029 | |
1030 QString jniName() const { return strings_jobject; } | |
1031 QString targetLangName() const { return strings_Object; } | |
1032 QString javaPackage() const { return strings_java_lang; } | |
1033 | |
1034 bool isNativeIdBased() const { return false; } | |
1035 }; | |
1036 | |
1037 class VariantTypeEntry: public ValueTypeEntry | |
1038 { | |
1039 public: | |
1040 VariantTypeEntry(const QString &name) : ValueTypeEntry(name, VariantType) { } | |
1041 | |
1042 QString jniName() const { return strings_jobject; } | |
1043 QString targetLangName() const { return "QVariant"; } | |
1044 QString javaPackage() const { return "qt.core"; } | |
1045 virtual bool isNativeIdBased() const { return false; } | |
1046 }; | |
1047 | |
1048 | |
1049 class InterfaceTypeEntry : public ComplexTypeEntry | |
1050 { | |
1051 public: | |
1052 InterfaceTypeEntry(const QString &name) | |
1053 : ComplexTypeEntry(name, InterfaceType) | |
1054 { | |
1055 } | |
1056 | |
1057 static QString interfaceName(const QString &name) { | |
1058 return "I" + name; | |
1059 } | |
1060 | |
1061 ObjectTypeEntry *origin() const { return m_origin; } | |
1062 void setOrigin(ObjectTypeEntry *origin) { m_origin = origin; } | |
1063 | |
1064 virtual bool isNativeIdBased() const { return true; } | |
1065 virtual QString qualifiedCppName() const { | |
1066 return ComplexTypeEntry::qualifiedCppName().right(ComplexTypeEntry::qualifiedCppName().length() - interfaceName("").length()); | |
1067 } | |
1068 | |
1069 private: | |
1070 ObjectTypeEntry *m_origin; | |
1071 }; | |
1072 | |
1073 | |
1074 class ObjectTypeEntry : public ComplexTypeEntry | |
1075 { | |
1076 public: | |
1077 ObjectTypeEntry(const QString &name) | |
1078 : ComplexTypeEntry(name, ObjectType), m_interface(0) | |
1079 { | |
1080 } | |
1081 | |
1082 InterfaceTypeEntry *designatedInterface() const { return m_interface; } | |
1083 void setDesignatedInterface(InterfaceTypeEntry *entry) { m_interface = entry; } | |
1084 | |
1085 virtual bool isNativeIdBased() const { return true; } | |
1086 | |
1087 private: | |
1088 InterfaceTypeEntry *m_interface; | |
1089 }; | |
1090 | |
1091 class CustomTypeEntry : public ComplexTypeEntry | |
1092 { | |
1093 public: | |
1094 CustomTypeEntry(const QString &name) : ComplexTypeEntry(name, CustomType) { } | |
1095 | |
1096 virtual void generateCppJavaToQt(QTextStream &s, | |
1097 const AbstractMetaType *java_type, | |
1098 const QString &env_name, | |
1099 const QString &qt_name, | |
1100 const QString &java_name) const = 0; | |
1101 | |
1102 virtual void generateCppQtToJava(QTextStream &s, | |
1103 const AbstractMetaType *java_type, | |
1104 const QString &env_name, | |
1105 const QString &qt_name, | |
1106 const QString &java_name) const = 0; | |
1107 }; | |
1108 | |
1109 struct TypeRejection | |
1110 { | |
1111 QString class_name; | |
1112 QString function_name; | |
1113 QString field_name; | |
1114 QString enum_name; | |
1115 }; | |
1116 | |
1117 class TypeDatabase | |
1118 { | |
1119 public: | |
1120 TypeDatabase(); | |
1121 | |
1122 static TypeDatabase *instance(); | |
1123 | |
1124 QList<Include> extraIncludes(const QString &className); | |
1125 | |
1126 inline PrimitiveTypeEntry *findPrimitiveType(const QString &name); | |
1127 inline ComplexTypeEntry *findComplexType(const QString &name); | |
1128 inline ObjectTypeEntry *findObjectType(const QString &name); | |
1129 inline NamespaceTypeEntry *findNamespaceType(const QString &name); | |
1130 ContainerTypeEntry *findContainerType(const QString &name); | |
1131 | |
1132 TypeEntry *findType(const QString &name) const { | |
1133 QList<TypeEntry *> entries = findTypes(name); | |
1134 foreach (TypeEntry *entry, entries) { | |
1135 if (entry != 0 && | |
1136 (!entry->isPrimitive() || static_cast<PrimitiveTypeEntry *>(entry)->preferredTargetLangType())) { | |
1137 return entry; | |
1138 } | |
1139 } | |
1140 return 0; | |
1141 } | |
1142 QList<TypeEntry *> findTypes(const QString &name) const { return m_entries.value(name); } | |
1143 TypeEntryHash allEntries() { return m_entries; } | |
1144 SingleTypeEntryHash entries() { | |
1145 TypeEntryHash entries = allEntries(); | |
1146 | |
1147 SingleTypeEntryHash returned; | |
1148 QList<QString> keys = entries.keys(); | |
1149 | |
1150 foreach(QString key, keys) { | |
1151 returned[key] = findType(key); | |
1152 } | |
1153 | |
1154 return returned; | |
1155 } | |
1156 | |
1157 PrimitiveTypeEntry *findTargetLangPrimitiveType(const QString &java_name); | |
1158 | |
1159 void addRejection(const QString &class_name, const QString &function_name, | |
1160 const QString &field_name, const QString &enum_name); | |
1161 bool isClassRejected(const QString &class_name); | |
1162 bool isFunctionRejected(const QString &class_name, const QString &function_name); | |
1163 bool isFieldRejected(const QString &class_name, const QString &field_name); | |
1164 bool isEnumRejected(const QString &class_name, const QString &enum_name); | |
1165 | |
1166 void addType(TypeEntry *e) { m_entries[e->qualifiedCppName()].append(e); } | |
1167 | |
1168 SingleTypeEntryHash flagsEntries() const { return m_flags_entries; } | |
1169 FlagsTypeEntry *findFlagsType(const QString &name) const; | |
1170 void addFlagsType(FlagsTypeEntry *fte) { m_flags_entries[fte->originalName()] = fte; } | |
1171 | |
1172 TemplateEntry *findTemplate(const QString &name) { return m_templates[name]; } | |
1173 void addTemplate(TemplateEntry *t) { m_templates[t->name()] = t; } | |
1174 | |
1175 void setIncludeEclipseWarnings(bool on) { m_includeEclipseWarnings = on; } | |
1176 bool includeEclipseWarnings() const { return m_includeEclipseWarnings; } | |
1177 | |
1178 void setSuppressWarnings(bool on) { m_suppressWarnings = on; } | |
1179 void addSuppressedWarning(const QString &s) | |
1180 { | |
1181 m_suppressedWarnings.append(s); | |
1182 } | |
1183 | |
1184 bool isSuppressedWarning(const QString &s) | |
1185 { | |
1186 if (!m_suppressWarnings) | |
1187 return false; | |
1188 | |
1189 foreach (const QString &_warning, m_suppressedWarnings) { | |
1190 QString warning(QString(_warning).replace("\\*", "&place_holder_for_asterisk;")); | |
1191 | |
1192 QStringList segs = warning.split("*", QString::SkipEmptyParts); | |
1193 if (segs.size() == 0) | |
1194 continue ; | |
1195 | |
1196 int i = 0; | |
1197 int pos = s.indexOf(QString(segs.at(i++)).replace("&place_holder_for_asterisk;", "*")); | |
1198 //qDebug() << "s == " << s << ", warning == " << segs; | |
1199 while (pos != -1) { | |
1200 if (i == segs.size()) | |
1201 return true; | |
1202 pos = s.indexOf(QString(segs.at(i++)).replace("&place_holder_for_asterisk;", "*"), pos); | |
1203 } | |
1204 } | |
1205 | |
1206 return false; | |
1207 } | |
1208 | |
1209 void setRebuildClasses(const QStringList &cls) { m_rebuild_classes = cls; } | |
1210 | |
1211 static QString globalNamespaceClassName(const TypeEntry *te); | |
1212 QString filename() const { return "typesystem.txt"; } | |
1213 | |
4 | 1214 bool parseFile(const QString &filename, const QString &work_dir, bool generate = true); |
1 | 1215 |
1216 private: | |
1217 uint m_suppressWarnings : 1; | |
1218 uint m_includeEclipseWarnings : 1; | |
1219 uint m_reserved : 30; | |
1220 | |
1221 TypeEntryHash m_entries; | |
1222 SingleTypeEntryHash m_flags_entries; | |
1223 TemplateEntryHash m_templates; | |
1224 QStringList m_suppressedWarnings; | |
1225 | |
1226 QList<TypeRejection> m_rejections; | |
1227 QStringList m_rebuild_classes; | |
1228 }; | |
1229 | |
1230 inline PrimitiveTypeEntry *TypeDatabase::findPrimitiveType(const QString &name) | |
1231 { | |
1232 QList<TypeEntry *> entries = findTypes(name); | |
1233 | |
1234 foreach (TypeEntry *entry, entries) { | |
1235 if (entry != 0 && entry->isPrimitive() && static_cast<PrimitiveTypeEntry *>(entry)->preferredTargetLangType()) | |
1236 return static_cast<PrimitiveTypeEntry *>(entry); | |
1237 } | |
1238 | |
1239 return 0; | |
1240 } | |
1241 | |
1242 inline ComplexTypeEntry *TypeDatabase::findComplexType(const QString &name) | |
1243 { | |
1244 TypeEntry *entry = findType(name); | |
1245 if (entry != 0 && entry->isComplex()) | |
1246 return static_cast<ComplexTypeEntry *>(entry); | |
1247 else | |
1248 return 0; | |
1249 } | |
1250 | |
1251 inline ObjectTypeEntry *TypeDatabase::findObjectType(const QString &name) | |
1252 { | |
1253 TypeEntry *entry = findType(name); | |
1254 if (entry != 0 && entry->isObject()) | |
1255 return static_cast<ObjectTypeEntry *>(entry); | |
1256 else | |
1257 return 0; | |
1258 } | |
1259 | |
1260 inline NamespaceTypeEntry *TypeDatabase::findNamespaceType(const QString &name) | |
1261 { | |
1262 TypeEntry *entry = findType(name); | |
1263 if (entry != 0 && entry->isNamespace()) | |
1264 return static_cast<NamespaceTypeEntry *>(entry); | |
1265 else | |
1266 return 0; | |
1267 } | |
1268 | |
1269 QString fixCppTypeName(const QString &name); | |
1270 | |
1271 #endif // TYPESYSTEM_H |