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 METAINFOGENERATOR_H
|
|
43 #define METAINFOGENERATOR_H
|
|
44
|
|
45 #include "generator.h"
|
|
46 #include "dgenerator.h"
|
|
47 #include "cppgenerator.h"
|
|
48
|
|
49 class MetaInfoGenerator : public DGenerator
|
|
50 {
|
|
51 public:
|
|
52 MetaInfoGenerator(PriGenerator *pri);
|
|
53
|
|
54 enum GenerationFlags {
|
|
55 GeneratedJavaClasses = 0x1,
|
|
56 GeneratedMetaInfo = 0x2
|
|
57 };
|
|
58
|
|
59 enum OutputDirectoryType {
|
|
60 CppDirectory,
|
|
61 JavaDirectory
|
|
62 };
|
|
63
|
|
64 MetaInfoGenerator();
|
|
65
|
|
66 virtual void generate();
|
|
67 virtual QString fileNameForClass(const AbstractMetaClass *java_class) const;
|
|
68 virtual void write(QTextStream &s, const AbstractMetaClass *java_class);
|
|
69
|
|
70 void setFilenameStub(const QString &stub) { m_filenameStub = stub; }
|
|
71 QString filenameStub() const { return m_filenameStub; }
|
|
72
|
|
73 QString headerFilename() const { return filenameStub() + ".h"; }
|
|
74 QString cppFilename() const { return filenameStub() + ".cpp"; }
|
|
75
|
|
76 virtual QString subDirectoryForClass(const AbstractMetaClass *, OutputDirectoryType type) const;
|
|
77 virtual QString subDirectoryForPackage(const QString &package, OutputDirectoryType type) const;
|
|
78 virtual bool shouldGenerate(const AbstractMetaClass *) const;
|
|
79
|
|
80 bool generated(const AbstractMetaClass *cls) const;
|
|
81 bool generatedJavaClasses(const QString &package) const;
|
|
82 bool generatedMetaInfo(const QString &package) const;
|
|
83
|
|
84 private:
|
|
85 void writeCppFile();
|
|
86 void writeHeaderFile();
|
|
87 void writeLibraryInitializers();
|
|
88 void writeInclude(QTextStream &s, const Include &inc);
|
|
89 void writeIncludeStatements(QTextStream &s, const AbstractMetaClassList &classList, const QString &package);
|
|
90 void writeInitializationFunctionName(QTextStream &s, const QString &package, bool fullSignature);
|
|
91 void writeInitialization(QTextStream &s, const TypeEntry *entry, const AbstractMetaClass *cls, bool registerMetaType = true);
|
|
92 void writeCustomStructors(QTextStream &s, const TypeEntry *entry);
|
|
93 void writeDestructors(QTextStream &s, const AbstractMetaClass *cls);
|
|
94 void writeCodeBlock(QTextStream &s, const QString &code);
|
|
95 void writeSignalsAndSlots(QTextStream &s, const QString &package);
|
|
96 void writeEnums(QTextStream &s, const QString &package);
|
|
97 void writeRegisterSignalsAndSlots(QTextStream &s);
|
|
98 void writeRegisterEnums(QTextStream &s);
|
|
99 QStringList writePolymorphicHandler(QTextStream &s, const QString &package, const AbstractMetaClassList &clss);
|
|
100 bool shouldGenerate(const TypeEntry *entry) const;
|
|
101 void buildSkipList();
|
|
102
|
|
103 #if defined(QTJAMBI_DEBUG_TOOLS)
|
|
104 void writeNameLiteral(QTextStream &, const TypeEntry *, const QString &fileName);
|
|
105 #endif
|
|
106
|
|
107 QHash<QString, int> m_skip_list;
|
|
108 QString m_filenameStub;
|
|
109
|
|
110 QHash<OutputDirectoryType, QString> m_out_dir;
|
|
111
|
|
112 const AbstractMetaClass* lookupClassWithPublicDestructor(const AbstractMetaClass *cls);
|
|
113
|
|
114 PriGenerator *priGenerator;
|
|
115 };
|
|
116
|
|
117 #endif // METAINFOGENERATOR_H
|