Mercurial > projects > qtd
annotate generator/cppimplgenerator.h @ 176:16b67e2b5adc
--
author | SokoL_SD |
---|---|
date | Wed, 01 Jul 2009 18:14:46 +0000 |
parents | 3aa118a9ae71 |
children | 7664de4a55e5 |
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 CPPIMPLGENERATOR_H | |
43 #define CPPIMPLGENERATOR_H | |
44 | |
45 #include "cppgenerator.h" | |
46 #include "metajava.h" | |
47 | |
48 enum JNISignatureFormat { | |
49 Underscores, // Used in the jni exported function names | |
50 SlashesAndStuff // Used for looking up functions through jni | |
51 }; | |
52 | |
53 QString jni_signature(const QString &full_name, JNISignatureFormat format); | |
54 QString jni_signature(const AbstractMetaType *java_type, JNISignatureFormat format = Underscores); | |
55 | |
56 class CppImplGenerator : public CppGenerator | |
57 { | |
58 Q_OBJECT | |
59 | |
60 public: | |
61 enum JNISignatureMode { | |
62 JNIExport = 0x0001, | |
63 ReturnType = 0x0002, | |
64 ExternC = 0x0004, | |
65 | |
66 StandardJNISignature = JNIExport | ReturnType | ExternC | |
67 }; | |
68 | |
69 CppImplGenerator(PriGenerator *pri) | |
70 : m_native_jump_table(false) | |
71 { | |
72 priGenerator = pri; | |
73 } | |
74 | |
75 virtual QString fileNameForClass(const AbstractMetaClass *cls) const; | |
76 | |
77 void write(QTextStream &s, const AbstractMetaClass *java_class); | |
78 | |
79 static void writeExtraIncludes(QTextStream &s, const AbstractMetaClass *java_class); | |
80 | |
81 void writeAssignment(QTextStream &s, const QString &destName, const QString &srcName, | |
82 const AbstractMetaType *java_type); | |
83 void writeSignalInitialization(QTextStream &s, const AbstractMetaClass *java_class); | |
84 void writeCodeInjections(QTextStream &s, const AbstractMetaFunction *java_function, | |
85 const AbstractMetaClass *implementor, CodeSnip::Position position, TypeSystem::Language language); | |
86 void writeExtraFunctions(QTextStream &s, const AbstractMetaClass *java_class); | |
87 void writeToStringFunction(QTextStream &s, const AbstractMetaClass *java_class); | |
88 void writeCloneFunction(QTextStream &s, const AbstractMetaClass *java_class); | |
89 void writeShellSignatures(QTextStream &s, const AbstractMetaClass *java_class); | |
90 void writeShellConstructor(QTextStream &s, const AbstractMetaFunction *java_function); | |
91 void writeShellDestructor(QTextStream &s, const AbstractMetaClass *java_class); | |
92 void writeSignalFunction(QTextStream &s, const AbstractMetaFunction *java_function, | |
93 const AbstractMetaClass *implementor, int pos); | |
94 void writeShellFunction(QTextStream &s, const AbstractMetaFunction *java_function, | |
95 const AbstractMetaClass *implementor, int pos); | |
96 void writeShellVirtualFunction(QTextStream &s, const AbstractMetaFunction *java_function, | |
97 const AbstractMetaClass *implementor, int pos); | |
98 void writePublicFunctionOverride(QTextStream &s, | |
99 const AbstractMetaFunction *java_function, | |
100 const AbstractMetaClass *java_class); | |
101 void writeVirtualFunctionOverride(QTextStream &s, | |
102 const AbstractMetaFunction *java_function, | |
103 const AbstractMetaClass *java_class); | |
104 void writeBaseClassFunctionCall(QTextStream &s, | |
105 const AbstractMetaFunction *java_function, | |
106 const AbstractMetaClass *java_class, | |
107 Option options = NoOption); | |
108 void writeFinalDestructor(QTextStream &s, const AbstractMetaClass *cls); | |
109 void writeFinalConstructor(QTextStream &s, | |
110 const AbstractMetaFunction *java_function, | |
111 const QString &qt_object_name, | |
112 const QString &java_object_name); | |
113 void writeQObjectFunctions(QTextStream &s, const AbstractMetaClass *java_class); | |
114 void writeFunctionCall(QTextStream &s, | |
115 const QString &variable_name, | |
116 const AbstractMetaFunction *java_function, | |
117 const QString &prefix = QString(), | |
118 Option option = NoOption, | |
119 const QStringList &extraParameters = QStringList()); | |
120 void writeFunctionCallArguments(QTextStream &s, const AbstractMetaFunction *java_function, | |
121 const QString &prefix = QString(), Option option = NoOption); | |
122 static void writeFunctionName(QTextStream &s, | |
123 const AbstractMetaFunction *java_function, | |
124 const AbstractMetaClass *java_class = 0, | |
125 uint options = StandardJNISignature); | |
126 | |
127 void writeJavaToQt(QTextStream &s, | |
128 const AbstractMetaClass *java_class, | |
129 const AbstractMetaType *function_return_type, | |
130 const QString &qt_name, | |
131 const QString &java_name, | |
132 const AbstractMetaFunction *java_function, | |
133 int argument_index); | |
134 void writeJavaToQt(QTextStream &s, | |
135 const AbstractMetaType *java_type, | |
136 const QString &qt_name, | |
137 const QString &java_name, | |
138 const AbstractMetaFunction *java_function, | |
139 int argument_index, | |
140 Option option = OriginalName); | |
141 | |
142 void writeFinalFunction(QTextStream &s, | |
143 const AbstractMetaFunction *java_function, | |
144 const AbstractMetaClass *java_class); | |
145 static void writeFinalFunctionArguments(QTextStream &s, | |
146 const AbstractMetaFunction *java_function, bool d_export = false); | |
147 static void writeVirtualDispatchArguments(QTextStream &s, | |
148 const AbstractMetaFunction *java_function, bool d_export = false); | |
149 void writeFinalFunctionSetup(QTextStream &s, | |
150 const AbstractMetaFunction *java_function, | |
151 const QString &qt_object_name, | |
152 const AbstractMetaClass *java_class); | |
153 void writeOwnership(QTextStream &s, | |
154 const AbstractMetaFunction *java_function, | |
155 const QString &var_name, | |
156 int var_index, | |
157 const AbstractMetaClass *implementor); | |
158 void writeQtToJava(QTextStream &s, | |
159 const AbstractMetaType *java_type, | |
160 const QString &qt_name, | |
161 const QString &java_name, | |
162 const AbstractMetaFunction *java_function, | |
163 int argument_index, | |
164 Option option = NoOption); | |
165 | |
166 bool writeConversionRule(QTextStream &s, | |
167 TypeSystem::Language target_language, | |
168 const AbstractMetaFunction *java_function, | |
169 int argument_index, | |
170 const QString &qt_name, | |
171 const QString &java_name); | |
172 | |
173 void writeFieldAccessors(QTextStream &s, const AbstractMetaField *java_field); | |
174 | |
175 void writeOriginalMetaObjectFunction(QTextStream &s, const AbstractMetaClass *java_class); | |
176 void writeFromNativeFunction(QTextStream &s, | |
177 const AbstractMetaClass *java_class); | |
178 void writeFromArrayFunction(QTextStream &s, const AbstractMetaClass *java_class); | |
179 void writeJavaLangObjectOverrideFunctions(QTextStream &s, const AbstractMetaClass *cls); | |
180 | |
181 void writeInterfaceCastFunction(QTextStream &s, | |
182 const AbstractMetaClass *java_class, | |
183 const AbstractMetaClass *interface); | |
184 | |
185 void writeQtToJavaContainer(QTextStream &s, | |
186 const AbstractMetaType *java_type, | |
187 const QString &qt_name, | |
188 const QString &java_name, | |
189 const AbstractMetaFunction *java_function, | |
190 int argument_index); | |
191 void writeJavaToQtContainer(QTextStream &s, | |
192 const AbstractMetaType *java_type, | |
193 const QString &qt_name, | |
194 const QString &java_name, | |
195 const AbstractMetaFunction *java_function, | |
196 int argument_index); | |
197 | |
198 void writeDefaultConstructedValues(QTextStream &s, const AbstractMetaClass *java_class); | |
199 | |
200 bool hasCustomDestructor(const AbstractMetaClass *java_class) const; | |
201 | |
202 static QString translateType(const AbstractMetaType *java_type, Option option = NoOption, bool d_export = false); | |
203 | |
204 inline bool nativeJumpTable() const { return m_native_jump_table; } | |
205 inline void setNativeJumpTable(bool n) { m_native_jump_table = n; } | |
206 | |
207 static QString jniReturnName(const AbstractMetaFunction *java_function, uint options = StandardJNISignature, bool d_export = false); | |
208 static void writeVirtualFunctionDispatchName(QTextStream &s, const AbstractMetaFunction *function, bool d_export = false); | |
209 static void writeVirtualDispatchFunction(QTextStream &s, const AbstractMetaFunction *function, bool d_export = false); | |
210 static void writeInterfaceCasts(QTextStream &s, const AbstractMetaClass *java_class); | |
211 void writeSignalsHandling(QTextStream &s, const AbstractMetaClass *java_class); | |
105
3aa118a9ae71
each QObject now has associated child QObject for handling signals. fixes #15
eldar
parents:
33
diff
changeset
|
212 void writeQObjectLink(QTextStream &s, const AbstractMetaClass *java_class); |
1 | 213 void writeSignalHandler(QTextStream &s, const AbstractMetaClass *java_class, AbstractMetaFunction *signal); |
214 static void writeInitCallbacks(QTextStream &s, const AbstractMetaClass *java_class); | |
33
cf8a415f3f32
gui package is fully wrapped now. lots of fixes in the generator
eldar
parents:
1
diff
changeset
|
215 void writeRefArguments(QTextStream &s, const AbstractMetaFunction *java_function); |
1 | 216 |
217 private: | |
218 void writeDefaultConstructedValues_helper(QSet<QString> &values, | |
219 const AbstractMetaFunction *function); | |
220 QString fromObject(const TypeEntry *centry, const QString &var_name); | |
221 | |
222 //qtd | |
223 QString jniReturnType(const AbstractMetaType *f_type, uint options = StandardJNISignature); | |
224 QString getTypeName(const TypeEntry *entry, Option option); | |
225 | |
226 bool m_native_jump_table; | |
227 }; | |
228 | |
229 #endif // CPPIMPLGENERATOR_H |