Mercurial > projects > qtd
annotate generator/generator.h @ 389:d37abad3def9
Added missing ?const? to qt.core.QModelIndex.object.
Previously, QModelIndex.internalPointer was const, while QModelIndex.object was not, even if they in fact do the same thing.
author | David Nadlinger <code@klickverbot.at> |
---|---|
date | Fri, 27 Aug 2010 14:44:09 +0200 |
parents | d2f48c4cb3e3 |
children |
rev | line source |
---|---|
1 | 1 /**************************************************************************** |
2 ** | |
3 ** Copyright (C) 1992-2008 Nokia. All rights reserved. | |
4 ** | |
5 ** This file is part of Qt Jambi. | |
6 ** | |
7 ** * Commercial Usage | |
8 * Licensees holding valid Qt Commercial licenses may use this file in | |
9 * accordance with the Qt Commercial License Agreement provided with the | |
10 * Software or, alternatively, in accordance with the terms contained in | |
11 * a written agreement between you and Nokia. | |
12 * | |
13 * | |
14 * GNU General Public License Usage | |
15 * Alternatively, this file may be used under the terms of the GNU | |
16 * General Public License versions 2.0 or 3.0 as published by the Free | |
17 * Software Foundation and appearing in the file LICENSE.GPL included in | |
18 * the packaging of this file. Please review the following information | |
19 * to ensure GNU General Public Licensing requirements will be met: | |
20 * http://www.fsf.org/licensing/licenses/info/GPLv2.html and | |
21 * http://www.gnu.org/copyleft/gpl.html. In addition, as a special | |
22 * exception, Nokia gives you certain additional rights. These rights | |
23 * are described in the Nokia Qt GPL Exception version 1.2, included in | |
24 * the file GPL_EXCEPTION.txt in this package. | |
25 * | |
26 * Qt for Windows(R) Licensees | |
27 * As a special exception, Nokia, as the sole copyright holder for Qt | |
28 * Designer, grants users of the Qt/Eclipse Integration plug-in the | |
29 * right for the Qt/Eclipse Integration to link to functionality | |
30 * provided by Qt Designer and its related libraries. | |
31 * | |
32 * | |
33 * If you are unsure which license is appropriate for your use, please | |
34 * contact the sales department at qt-sales@nokia.com. | |
35 | |
36 ** | |
37 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | |
38 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
39 ** | |
40 ****************************************************************************/ | |
41 | |
42 #ifndef GENERATOR_H | |
43 #define GENERATOR_H | |
44 | |
45 #include "metajava.h" | |
46 #include "typesystem.h" | |
47 | |
48 #include "codemodel.h" | |
49 | |
50 #include <QObject> | |
51 #include <QFile> | |
52 | |
53 class Generator : public QObject | |
54 { | |
55 Q_OBJECT | |
56 | |
57 Q_PROPERTY(QString outputDirectory READ outputDirectory WRITE setOutputDirectory); | |
58 | |
59 public: | |
60 enum Option { | |
61 NoOption = 0x00000000, | |
62 BoxedPrimitive = 0x00000001, | |
63 ExcludeConst = 0x00000002, | |
64 ExcludeReference = 0x00000004, | |
65 UseNativeIds = 0x00000008, | |
66 | |
67 EnumAsInts = 0x00000010, | |
68 SkipName = 0x00000020, | |
69 NoCasts = 0x00000040, | |
70 SkipReturnType = 0x00000080, | |
71 OriginalName = 0x00000100, | |
72 ShowStatic = 0x00000200, | |
73 UnderscoreSpaces = 0x00000400, | |
74 ForceEnumCast = 0x00000800, | |
75 ArrayAsPointer = 0x00001000, | |
76 VirtualCall = 0x00002000, | |
77 SkipTemplateParameters = 0x00004000, | |
78 SkipAttributes = 0x00008000, | |
79 OriginalTypeDescription = 0x00010000, | |
80 SkipRemovedArguments = 0x00020000, | |
81 IncludeDefaultExpression = 0x00040000, | |
82 NoReturnStatement = 0x00080000, | |
83 NoBlockedSlot = 0x00100000, | |
84 NormalizeAndFixTypeSignature = 0x00200000, | |
85 SuperCall = 0x00400000, | |
86 GlobalRefJObject = 0x00800000, | |
87 ExternC = 0x01000000, | |
88 VirtualDispatch = 0x02000000, | |
89 ForcePointer = 0x10000000, | |
90 | |
91 ForceValueType = ExcludeReference | ExcludeConst | |
92 }; | |
93 | |
357
9784459f0750
An attempt (failed due to optlink) to improve locality of declarations exported from QtD executables
Max Samukha <maxter@spambox.com>
parents:
270
diff
changeset
|
94 enum ModuleNameType |
9784459f0750
An attempt (failed due to optlink) to improve locality of declarations exported from QtD executables
Max Samukha <maxter@spambox.com>
parents:
270
diff
changeset
|
95 { |
9784459f0750
An attempt (failed due to optlink) to improve locality of declarations exported from QtD executables
Max Samukha <maxter@spambox.com>
parents:
270
diff
changeset
|
96 ShortUpper, |
9784459f0750
An attempt (failed due to optlink) to improve locality of declarations exported from QtD executables
Max Samukha <maxter@spambox.com>
parents:
270
diff
changeset
|
97 LongCamel |
9784459f0750
An attempt (failed due to optlink) to improve locality of declarations exported from QtD executables
Max Samukha <maxter@spambox.com>
parents:
270
diff
changeset
|
98 }; |
9784459f0750
An attempt (failed due to optlink) to improve locality of declarations exported from QtD executables
Max Samukha <maxter@spambox.com>
parents:
270
diff
changeset
|
99 |
1 | 100 Generator(); |
101 | |
102 void setClasses(const AbstractMetaClassList &classes) { m_classes = classes; } | |
103 AbstractMetaClassList classes() const { return m_classes; } | |
104 | |
105 QString outputDirectory() const { return m_out_dir; } | |
106 void setOutputDirectory(const QString &outDir) { m_out_dir = outDir; } | |
107 virtual void generate(); | |
108 void printClasses(); | |
109 | |
110 int numGenerated() { return m_num_generated; } | |
111 int numGeneratedAndWritten() { return m_num_generated_written; } | |
112 | |
113 virtual bool shouldGenerate(const AbstractMetaClass *) const { return true; } | |
114 virtual QString subDirectoryForClass(const AbstractMetaClass *java_class) const; | |
115 virtual QString fileNameForClass(const AbstractMetaClass *java_class) const; | |
116 virtual void write(QTextStream &s, const AbstractMetaClass *java_class); | |
117 | |
118 bool hasDefaultConstructor(const AbstractMetaType *type); | |
119 | |
357
9784459f0750
An attempt (failed due to optlink) to improve locality of declarations exported from QtD executables
Max Samukha <maxter@spambox.com>
parents:
270
diff
changeset
|
120 // TODO: this should be a property of the generator set, not inferred from java package. |
9784459f0750
An attempt (failed due to optlink) to improve locality of declarations exported from QtD executables
Max Samukha <maxter@spambox.com>
parents:
270
diff
changeset
|
121 static QString packageToQtModule(QString package, ModuleNameType nameType = ShortUpper); |
9784459f0750
An attempt (failed due to optlink) to improve locality of declarations exported from QtD executables
Max Samukha <maxter@spambox.com>
parents:
270
diff
changeset
|
122 |
1 | 123 protected: |
124 void verifyDirectoryFor(const QFile &file); | |
125 | |
126 AbstractMetaClassList m_classes; | |
127 int m_num_generated; | |
128 int m_num_generated_written; | |
129 QString m_out_dir; | |
130 }; | |
131 | |
132 class Indentor { | |
133 public: | |
134 Indentor(): | |
135 indent(0) | |
136 {} | |
137 int indent; | |
138 }; | |
139 | |
140 class Indentation { | |
141 public: | |
142 Indentation(Indentor &indentor): | |
143 indentor(indentor) | |
144 { | |
145 indentor.indent++; | |
146 } | |
147 ~Indentation() | |
148 { | |
149 indentor.indent--; | |
150 } | |
151 | |
152 private: | |
153 Indentor &indentor; | |
154 }; | |
155 | |
156 inline QTextStream &operator <<(QTextStream &s, const Indentor &indentor) | |
157 { | |
158 for (int i=0; i<indentor.indent; ++i) | |
159 s << " "; | |
160 return s; | |
161 } | |
162 | |
163 inline QString signalExternName(const AbstractMetaClass *cls, const AbstractMetaFunction* signal) | |
164 { | |
165 return "qtd_" + cls->name() + "_" + signal->name(); | |
166 } | |
167 | |
270 | 168 enum ConversionFunction |
169 { | |
170 FromCpp, | |
171 ToCpp | |
172 }; | |
173 | |
174 inline QString cppContainerConversionName(const AbstractMetaClass *cls, const AbstractMetaType *type, ConversionFunction func) | |
167
ae06da58ec25
fixed hacky conversion of arguments when emmitting a signal
eldar
parents:
1
diff
changeset
|
175 { |
ae06da58ec25
fixed hacky conversion of arguments when emmitting a signal
eldar
parents:
1
diff
changeset
|
176 QString package = cls->package().replace(".", "_"); |
ae06da58ec25
fixed hacky conversion of arguments when emmitting a signal
eldar
parents:
1
diff
changeset
|
177 const TypeEntry *te = type->instantiations().first()->typeEntry(); |
ae06da58ec25
fixed hacky conversion of arguments when emmitting a signal
eldar
parents:
1
diff
changeset
|
178 |
270 | 179 QString word; |
180 if (func == FromCpp) | |
181 word = "_fromcpp_"; | |
182 else | |
183 word = "_tocpp_"; | |
184 | |
185 return "qtd_" + package + "_" + te->targetLangName() + word + type->typeEntry()->qualifiedCppName(); | |
167
ae06da58ec25
fixed hacky conversion of arguments when emmitting a signal
eldar
parents:
1
diff
changeset
|
186 } |
ae06da58ec25
fixed hacky conversion of arguments when emmitting a signal
eldar
parents:
1
diff
changeset
|
187 |
1 | 188 bool notWrappedYet(const AbstractMetaFunction *java_function); |
189 bool isLinearContainer(const ContainerTypeEntry *type); | |
253 | 190 AbstractMetaFunctionList signalFunctions(const AbstractMetaClass *cls, bool includeBase = true); |
1 | 191 |
192 #endif // GENERATOR_H |