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 CPPGENERATOR_H
|
|
43 #define CPPGENERATOR_H
|
|
44
|
|
45 #include "generator.h"
|
|
46 #include "metajava.h"
|
|
47 #include "prigenerator.h"
|
|
48
|
|
49 class CppGenerator : public Generator
|
|
50 {
|
|
51 Q_OBJECT
|
|
52
|
|
53 public:
|
|
54 static inline QString subDirectoryForPackage(const QString &package) {
|
|
55 return QLatin1String("cpp/") + QString(package).replace(".", "_");
|
|
56 }
|
|
57
|
|
58 virtual QString subDirectoryForClass(const AbstractMetaClass *cls) const
|
|
59 {
|
|
60 return subDirectoryForPackage(cls->package()) + "/";
|
|
61 }
|
|
62
|
|
63 static QString fixNormalizedSignatureForQt(const QString &signature);
|
|
64 static void writeTypeInfo(QTextStream &s, const AbstractMetaType *type, Option option = NoOption);
|
|
65 static void writeFunctionSignature(QTextStream &s, const AbstractMetaFunction *java_function,
|
|
66 const AbstractMetaClass *implementor = 0,
|
|
67 const QString &name_prefix = QString(),
|
|
68 Option option = NoOption,
|
|
69 const QString &classname_prefix = QString(),
|
|
70 const QStringList &extra_arguments = QStringList(),
|
|
71 int numArguments = -1);
|
|
72 static void writeFunctionArguments(QTextStream &s, const AbstractMetaArgumentList &arguments,
|
|
73 Option option = NoOption,
|
|
74 int numArguments = -1);
|
|
75
|
|
76 QString signalWrapperPrefix() const { return "__qt_signalwrapper_"; }
|
|
77
|
|
78 bool shouldGenerate(const AbstractMetaClass *java_class) const {
|
|
79 return (!java_class->isNamespace() || java_class->functionsInTargetLang().size() > 0) && !java_class->isInterface()
|
|
80 && !java_class->typeEntry()->isVariant()
|
|
81 && (java_class->typeEntry()->codeGeneration() & TypeEntry::GenerateCpp)
|
|
82 && !(java_class->attributes() & AbstractMetaAttributes::Fake);
|
|
83 }
|
|
84
|
|
85 static QString shellClassName(const AbstractMetaClass *java_class) {
|
|
86 return java_class->generateShellClass()
|
|
87 ? java_class->name() + "_QtDShell"
|
|
88 : java_class->qualifiedCppName();
|
|
89 }
|
|
90
|
|
91 protected:
|
|
92 PriGenerator *priGenerator;
|
|
93
|
|
94 };
|
|
95
|
|
96 #endif // CPPGENERATOR_H
|