Mercurial > projects > qtd
annotate generator/generator.h @ 238:1349940724eb
Generate a classes list for cmake.
author | SokoL_SD |
---|---|
date | Mon, 20 Jul 2009 06:04:17 +0000 |
parents | ae06da58ec25 |
children | 073b9153ed8a |
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 extern bool cpp_shared; | |
54 extern bool dPhobos; | |
55 extern int dVersion; | |
56 | |
57 class Generator : public QObject | |
58 { | |
59 Q_OBJECT | |
60 | |
61 Q_PROPERTY(QString outputDirectory READ outputDirectory WRITE setOutputDirectory); | |
62 | |
63 public: | |
64 enum Option { | |
65 NoOption = 0x00000000, | |
66 BoxedPrimitive = 0x00000001, | |
67 ExcludeConst = 0x00000002, | |
68 ExcludeReference = 0x00000004, | |
69 UseNativeIds = 0x00000008, | |
70 | |
71 EnumAsInts = 0x00000010, | |
72 SkipName = 0x00000020, | |
73 NoCasts = 0x00000040, | |
74 SkipReturnType = 0x00000080, | |
75 OriginalName = 0x00000100, | |
76 ShowStatic = 0x00000200, | |
77 UnderscoreSpaces = 0x00000400, | |
78 ForceEnumCast = 0x00000800, | |
79 ArrayAsPointer = 0x00001000, | |
80 VirtualCall = 0x00002000, | |
81 SkipTemplateParameters = 0x00004000, | |
82 SkipAttributes = 0x00008000, | |
83 OriginalTypeDescription = 0x00010000, | |
84 SkipRemovedArguments = 0x00020000, | |
85 IncludeDefaultExpression = 0x00040000, | |
86 NoReturnStatement = 0x00080000, | |
87 NoBlockedSlot = 0x00100000, | |
88 NormalizeAndFixTypeSignature = 0x00200000, | |
89 SuperCall = 0x00400000, | |
90 GlobalRefJObject = 0x00800000, | |
91 ExternC = 0x01000000, | |
92 VirtualDispatch = 0x02000000, | |
93 ForcePointer = 0x10000000, | |
94 | |
95 ForceValueType = ExcludeReference | ExcludeConst | |
96 }; | |
97 | |
98 Generator(); | |
99 | |
100 void setClasses(const AbstractMetaClassList &classes) { m_classes = classes; } | |
101 AbstractMetaClassList classes() const { return m_classes; } | |
102 | |
103 QString outputDirectory() const { return m_out_dir; } | |
104 void setOutputDirectory(const QString &outDir) { m_out_dir = outDir; } | |
105 virtual void generate(); | |
106 void printClasses(); | |
107 | |
108 int numGenerated() { return m_num_generated; } | |
109 int numGeneratedAndWritten() { return m_num_generated_written; } | |
110 | |
111 virtual bool shouldGenerate(const AbstractMetaClass *) const { return true; } | |
112 virtual QString subDirectoryForClass(const AbstractMetaClass *java_class) const; | |
113 virtual QString fileNameForClass(const AbstractMetaClass *java_class) const; | |
114 virtual void write(QTextStream &s, const AbstractMetaClass *java_class); | |
115 | |
116 bool hasDefaultConstructor(const AbstractMetaType *type); | |
117 | |
118 protected: | |
119 void verifyDirectoryFor(const QFile &file); | |
120 | |
121 AbstractMetaClassList m_classes; | |
122 int m_num_generated; | |
123 int m_num_generated_written; | |
124 QString m_out_dir; | |
125 }; | |
126 | |
127 class Indentor { | |
128 public: | |
129 Indentor(): | |
130 indent(0) | |
131 {} | |
132 int indent; | |
133 }; | |
134 | |
135 class Indentation { | |
136 public: | |
137 Indentation(Indentor &indentor): | |
138 indentor(indentor) | |
139 { | |
140 indentor.indent++; | |
141 } | |
142 ~Indentation() | |
143 { | |
144 indentor.indent--; | |
145 } | |
146 | |
147 private: | |
148 Indentor &indentor; | |
149 }; | |
150 | |
151 inline QTextStream &operator <<(QTextStream &s, const Indentor &indentor) | |
152 { | |
153 for (int i=0; i<indentor.indent; ++i) | |
154 s << " "; | |
155 return s; | |
156 } | |
157 | |
158 inline QString signalExternName(const AbstractMetaClass *cls, const AbstractMetaFunction* signal) | |
159 { | |
160 return "qtd_" + cls->name() + "_" + signal->name(); | |
161 } | |
162 | |
167
ae06da58ec25
fixed hacky conversion of arguments when emmitting a signal
eldar
parents:
1
diff
changeset
|
163 inline QString fromCppContainerName(const AbstractMetaClass *cls, const AbstractMetaType *type) |
ae06da58ec25
fixed hacky conversion of arguments when emmitting a signal
eldar
parents:
1
diff
changeset
|
164 { |
ae06da58ec25
fixed hacky conversion of arguments when emmitting a signal
eldar
parents:
1
diff
changeset
|
165 QString package = cls->package().replace(".", "_"); |
ae06da58ec25
fixed hacky conversion of arguments when emmitting a signal
eldar
parents:
1
diff
changeset
|
166 const TypeEntry *te = type->instantiations().first()->typeEntry(); |
ae06da58ec25
fixed hacky conversion of arguments when emmitting a signal
eldar
parents:
1
diff
changeset
|
167 |
ae06da58ec25
fixed hacky conversion of arguments when emmitting a signal
eldar
parents:
1
diff
changeset
|
168 return "qtd_" + package + "_" + te->targetLangName() + "_from_" + type->typeEntry()->qualifiedCppName(); |
ae06da58ec25
fixed hacky conversion of arguments when emmitting a signal
eldar
parents:
1
diff
changeset
|
169 } |
ae06da58ec25
fixed hacky conversion of arguments when emmitting a signal
eldar
parents:
1
diff
changeset
|
170 |
1 | 171 bool notWrappedYet(const AbstractMetaFunction *java_function); |
172 bool isLinearContainer(const ContainerTypeEntry *type); | |
173 AbstractMetaFunctionList signalFunctions(const AbstractMetaClass *cls); | |
174 | |
175 #endif // GENERATOR_H |