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 DGENERATOR_H
|
|
43 #define DGENERATOR_H
|
|
44
|
|
45 #include "generator.h"
|
|
46 #include "metajava.h"
|
|
47
|
|
48 #include <QTextStream>
|
|
49
|
|
50 class DocParser;
|
|
51
|
|
52 class DGenerator : public Generator
|
|
53 {
|
|
54 Q_OBJECT
|
|
55
|
|
56 public:
|
|
57 DGenerator();
|
|
58
|
|
59 static QString translateType(const AbstractMetaType *d_type, const AbstractMetaClass *context, Option option = NoOption);
|
|
60
|
|
61 void writeInjectedCode(QTextStream &s,
|
|
62 const AbstractMetaFunction *d_function,
|
|
63 CodeSnip::Position position);
|
|
64 static void writeArgument(QTextStream &s,
|
|
65 const AbstractMetaFunction *d_function,
|
|
66 const AbstractMetaArgument *d_argument,
|
|
67 uint options = 0);
|
|
68 static QString argumentString(const AbstractMetaFunction *d_function,
|
|
69 const AbstractMetaArgument *d_argument,
|
|
70 uint options = 0);
|
|
71 void writeEnum(QTextStream &s, const AbstractMetaEnum *d_enum);
|
|
72 void writeIntegerEnum(QTextStream &s, const AbstractMetaEnum *d_enum);
|
|
73 void writeSignal(QTextStream &s, const AbstractMetaFunction *d_function);
|
|
74 void writeFunction(QTextStream &s, const AbstractMetaFunction *d_function,
|
|
75 uint included_attributes = 0, uint excluded_attributes = 0);
|
|
76 void writeFieldAccessors(QTextStream &s, const AbstractMetaField *field);
|
|
77 void writeNativeField(QTextStream &s, const AbstractMetaField *field);
|
|
78
|
|
79 void write(QTextStream &s, const AbstractMetaClass *d_class);
|
|
80
|
|
81 void writeFunctionOverloads(QTextStream &s, const AbstractMetaFunction *d_function,
|
|
82 uint included_attributes, uint excluded_attributes);
|
|
83 void writeEnumOverload(QTextStream &s, const AbstractMetaFunction *d_function,
|
|
84 uint include_attributes, uint exclude_attributes);
|
|
85 void writeExtraFunctions(QTextStream &s, const AbstractMetaClass *d_class);
|
|
86 void writeToStringFunction(QTextStream &s, const AbstractMetaClass *d_class);
|
|
87 void writeCloneFunction(QTextStream &s, const AbstractMetaClass *d_class);
|
|
88 void writeFunctionAttributes(QTextStream &s, const AbstractMetaFunction *d_function,
|
|
89 uint included_attributes = 0, uint excluded_attributes = 0,
|
|
90 uint options = 0);
|
|
91 void writeConstructorContents(QTextStream &s, const AbstractMetaFunction *d_function);
|
|
92 void writeFunctionArguments(QTextStream &s, const AbstractMetaFunction *d_function,
|
|
93 int count = -1, uint options = 0);
|
|
94 void writeJavaCallThroughContents(QTextStream &s, const AbstractMetaFunction *d_function, uint attributes = 0);
|
|
95 void writeOwnershipForContainer(QTextStream &s, TypeSystem::Ownership ownership, AbstractMetaArgument *arg);
|
|
96 void writeOwnershipForContainer(QTextStream &s, TypeSystem::Ownership ownership, AbstractMetaType *type,
|
|
97 const QString &arg_name);
|
|
98 void writePrivateNativeFunction(QTextStream &s, const AbstractMetaFunction *d_function);
|
|
99 void writeJavaLangObjectOverrideFunctions(QTextStream &s, const AbstractMetaClass *cls);
|
|
100 void writeReferenceCount(QTextStream &s, const ReferenceCount &refCount, const QString &argumentName);
|
|
101 void retrieveModifications(const AbstractMetaFunction *f, const AbstractMetaClass *d_class,
|
|
102 uint *exclude_attributes, uint *include_attributes) const;
|
|
103 QString functionSignature(const AbstractMetaFunction *d_function,
|
|
104 uint included_attributes,
|
|
105 uint excluded_attributes,
|
|
106 Option option = NoOption,
|
|
107 int arg_count = -1);
|
|
108 void setupForFunction(const AbstractMetaFunction *d_function,
|
|
109 uint *included_attributes, uint *excluded_attributes) const;
|
|
110
|
|
111 virtual QString subDirectoryForClass(const AbstractMetaClass *d_class) const
|
|
112 { return subDirectoryForPackage(d_class->package()); }
|
|
113
|
|
114 virtual QString fileNameForClass(const AbstractMetaClass *d_class) const;
|
|
115
|
|
116 bool isComparable(const AbstractMetaClass *cls) const;
|
|
117
|
|
118 #if 0
|
|
119 void write1_dot_5_enum(QTextStream &s, const AbstractMetaEnum *d_enum);
|
|
120 #endif
|
|
121
|
|
122 bool shouldGenerate(const AbstractMetaClass *d_class) const {
|
|
123 return !d_class->typeEntry()->isContainer() && !d_class->typeEntry()->isVariant()
|
|
124 && (d_class->typeEntry()->codeGeneration() & TypeEntry::GenerateTargetLang);
|
|
125 }
|
|
126
|
|
127 QString documentationDirectory() const { return m_doc_directory; }
|
|
128 void setDocumentationDirectory(const QString &docDir) { m_doc_directory = docDir; }
|
|
129
|
|
130 bool documentationEnabled() const { return m_docs_enabled; }
|
|
131 void setDocumentationEnabled(bool e) { m_docs_enabled = e; }
|
|
132 void generate();
|
|
133
|
|
134 inline bool nativeJumpTable() const { return m_native_jump_table; }
|
|
135 inline void setNativeJumpTable(bool n) { m_native_jump_table = n; }
|
|
136
|
|
137 void writeShellVirtualFunction(QTextStream &s, const AbstractMetaFunction *function,
|
|
138 const AbstractMetaClass *implementor, int id);
|
|
139 void marshallFromCppToD(QTextStream &s, const ComplexTypeEntry* ctype);
|
|
140
|
|
141 private:
|
|
142 QString subDirectoryForPackage(const QString &package) const { return QString(package).replace(".", "/"); }
|
|
143 void writeInstantiatedType(QTextStream &s, const AbstractMetaType *abstractMetaType) const;
|
|
144
|
|
145 // qtd
|
|
146 void addTypeEntry(const AbstractMetaClass *d_class, const AbstractMetaFunction *function, QSet<const TypeEntry*> &typeEntries);
|
|
147 void fillRequiredImports(const AbstractMetaClass *d_class);
|
|
148 void addInstantiations(const AbstractMetaType* d_type);
|
|
149 void writeRequiredImports(QTextStream &s, const AbstractMetaClass *d_class);
|
|
150 const TypeEntry* fixedTypeEntry(const TypeEntry *type);
|
|
151
|
|
152 void writeDestructor(QTextStream &s, const AbstractMetaClass *d_class);
|
|
153 void writeOwnershipMethods(QTextStream &s, const AbstractMetaClass *d_class);
|
|
154 void writeSignalHandlers(QTextStream &s, const AbstractMetaClass *d_class);
|
|
155 void writeEnumAlias(QTextStream &s, const AbstractMetaEnum *d_enum);
|
|
156 void writeSignalConnectors(QTextStream &s, const AbstractMetaClass *d_class, AbstractMetaFunctionList signal_funcs);
|
|
157 // void writeMarshallFunction(QTextStream &s, const AbstractMetaClass *d_class);
|
|
158
|
|
159 int m_recursive;
|
|
160 bool m_isRecursive;
|
|
161 QSet<const TypeEntry*> typeEntries; // imports
|
|
162 QSet<const TypeEntry*> typeEntriesEnums; // imports for enums
|
|
163 QSet<QString> excludedTypes2;
|
|
164
|
|
165 protected:
|
|
166 void writeImportString(QTextStream &s, const TypeEntry* typeEntry);
|
|
167
|
|
168 QSet<QString> excludedTypes;
|
|
169 QString m_package_name;
|
|
170 QString m_doc_directory;
|
|
171 DocParser *m_doc_parser;
|
|
172 bool m_docs_enabled;
|
|
173 bool m_native_jump_table;
|
|
174 QList<const AbstractMetaFunction *> m_nativepointer_functions;
|
|
175 QList<const AbstractMetaFunction *> m_resettable_object_functions;
|
|
176 QList<const AbstractMetaFunction *> m_reference_count_candidate_functions;
|
|
177 };
|
|
178
|
|
179 class ClassFromEntry : Generator
|
|
180 {
|
|
181 Q_OBJECT
|
|
182
|
|
183 private:
|
|
184 ClassFromEntry();
|
|
185 QHash<const TypeEntry *, AbstractMetaClass *> classFromEntry;
|
|
186 static ClassFromEntry* m_instance;
|
|
187
|
|
188 public:
|
|
189 static AbstractMetaClass* get(const TypeEntry *te);
|
|
190 };
|
|
191 #endif // DGENERATOR_H
|