comparison generator/containergenerator.h @ 1:e78566595089

initial import
author mandel
date Mon, 11 May 2009 16:01:50 +0000
parents
children ae06da58ec25
comparison
equal deleted inserted replaced
0:36fb74dc547d 1:e78566595089
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 CONTAINERGENERATOR_H
43 #define CONTAINERGENERATOR_H
44
45 #include "dgenerator.h"
46 #include "metajava.h"
47 #include "prigenerator.h"
48
49 const int NUM_ARRAY_FUNCS = 3;
50
51 class ContainerGenerator : public DGenerator
52 {
53 Q_OBJECT
54
55 public:
56 enum OutputDirectoryType {
57 CppDirectory,
58 DDirectory,
59 HDirectory
60 };
61
62 typedef void (ContainerGenerator::*WriteOut)(QTextStream &s, AbstractMetaClass *cls);
63
64 ContainerGenerator();
65
66 virtual void generate();
67 virtual void write(QTextStream &s, const AbstractMetaClass *java_class);
68 void writeFile(const QString& fileName, OutputDirectoryType dirType, WriteOut writeOut);
69
70 // base functions for operating with arrays
71 void writeHeaderContent(QTextStream &s, AbstractMetaClass *cls);
72 void writeCppContent(QTextStream &s, AbstractMetaClass *cls);
73 void writeDContent(QTextStream &s, AbstractMetaClass *cls);
74
75 void buildTypeList();
76
77 void processFunction(const AbstractMetaFunction *d_function);
78 void processType(AbstractMetaType *d_type);
79 void addTypeEntry(const TypeEntry* te);
80
81 virtual QString subDirectoryForPackage(const QString &package, OutputDirectoryType type) const;
82
83 void setFilenameStub(const QString &stub) { m_filenameStub = stub; }
84 QString filenameStub() const { return m_filenameStub; }
85
86 QString headerFilename() const { return filenameStub() + ".h"; }
87 QString cppFilename() const { return filenameStub() + "_shell.cpp"; }
88 QString dFilename() const { return filenameStub() + ".d"; }
89
90 private:
91 virtual void writeArrayFunctions(QTextStream &s, const ComplexTypeEntry *centry);
92 void writeHeaderArrayFunctions(QTextStream &s, const ComplexTypeEntry *centry);
93 void writeNotice(QTextStream &s);
94
95 void setFuncNames(const QString& cls_name);
96
97 QString m_filenameStub;
98 QSet<const TypeEntry*> containerTypes;
99 // QSet< QPair<const TypeEntry*, AbstractMetaClass*> > containerTypes;
100 AbstractMetaClass* m_class;
101
102 QString all_name, ass_name, get_name;
103 };
104
105 #endif // CONTAINERGENERATOR_H