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