annotate generator/typesystem.h @ 361:beaf4a2974d7

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