Mercurial > projects > qtd
annotate generator/dgenerator.h @ 351:59d847a814e3
added meta subdir
author | Max Samukha <maxter@spambox.com> |
---|---|
date | Thu, 20 May 2010 15:54:06 +0300 |
parents | 4920ef9206fe |
children | 08c1ca7975ab |
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 DGENERATOR_H | |
43 #define DGENERATOR_H | |
44 | |
45 #include "generator.h" | |
46 #include "metajava.h" | |
167
ae06da58ec25
fixed hacky conversion of arguments when emmitting a signal
eldar
parents:
110
diff
changeset
|
47 #include "cppimplgenerator.h" |
1 | 48 |
49 #include <QTextStream> | |
341
4920ef9206fe
moved enums into interfaces
Max Samukha <maxter@spambox.com>
parents:
298
diff
changeset
|
50 #include <QStack> |
1 | 51 |
52 class DocParser; | |
53 | |
54 class DGenerator : public Generator | |
55 { | |
56 Q_OBJECT | |
57 | |
58 public: | |
59 DGenerator(); | |
60 | |
61 static QString translateType(const AbstractMetaType *d_type, const AbstractMetaClass *context, Option option = NoOption); | |
62 | |
63 void writeInjectedCode(QTextStream &s, | |
64 const AbstractMetaFunction *d_function, | |
65 CodeSnip::Position position); | |
66 static void writeArgument(QTextStream &s, | |
67 const AbstractMetaFunction *d_function, | |
68 const AbstractMetaArgument *d_argument, | |
69 uint options = 0); | |
70 static QString argumentString(const AbstractMetaFunction *d_function, | |
71 const AbstractMetaArgument *d_argument, | |
72 uint options = 0); | |
341
4920ef9206fe
moved enums into interfaces
Max Samukha <maxter@spambox.com>
parents:
298
diff
changeset
|
73 void writeEnum(QTextStream &s, const AbstractMetaEnum *d_enum, bool withAliases = false); |
1 | 74 void writeIntegerEnum(QTextStream &s, const AbstractMetaEnum *d_enum); |
75 void writeSignal(QTextStream &s, const AbstractMetaFunction *d_function); | |
76 void writeFunction(QTextStream &s, const AbstractMetaFunction *d_function, | |
77 uint included_attributes = 0, uint excluded_attributes = 0); | |
78 void writeFieldAccessors(QTextStream &s, const AbstractMetaField *field); | |
79 void writeNativeField(QTextStream &s, const AbstractMetaField *field); | |
80 | |
81 void write(QTextStream &s, const AbstractMetaClass *d_class); | |
82 | |
83 void writeFunctionOverloads(QTextStream &s, const AbstractMetaFunction *d_function, | |
84 uint included_attributes, uint excluded_attributes); | |
85 void writeEnumOverload(QTextStream &s, const AbstractMetaFunction *d_function, | |
86 uint include_attributes, uint exclude_attributes); | |
87 void writeExtraFunctions(QTextStream &s, const AbstractMetaClass *d_class); | |
88 void writeToStringFunction(QTextStream &s, const AbstractMetaClass *d_class); | |
89 void writeCloneFunction(QTextStream &s, const AbstractMetaClass *d_class); | |
90 void writeFunctionAttributes(QTextStream &s, const AbstractMetaFunction *d_function, | |
91 uint included_attributes = 0, uint excluded_attributes = 0, | |
92 uint options = 0); | |
93 void writeConstructorContents(QTextStream &s, const AbstractMetaFunction *d_function); | |
94 void writeFunctionArguments(QTextStream &s, const AbstractMetaFunction *d_function, | |
95 int count = -1, uint options = 0); | |
96 void writeJavaCallThroughContents(QTextStream &s, const AbstractMetaFunction *d_function, uint attributes = 0); | |
97 void writeOwnershipForContainer(QTextStream &s, TypeSystem::Ownership ownership, AbstractMetaArgument *arg); | |
98 void writeOwnershipForContainer(QTextStream &s, TypeSystem::Ownership ownership, AbstractMetaType *type, | |
99 const QString &arg_name); | |
100 void writePrivateNativeFunction(QTextStream &s, const AbstractMetaFunction *d_function); | |
101 void writeJavaLangObjectOverrideFunctions(QTextStream &s, const AbstractMetaClass *cls); | |
298
adae77fdc1ea
Native QList implementation is now used throughout QtD
eldar
parents:
292
diff
changeset
|
102 void writeReferenceCount(QTextStream &s, const ReferenceCount &refCount, const QString &argumentName, AbstractMetaType *argumentType = 0); |
1 | 103 void retrieveModifications(const AbstractMetaFunction *f, const AbstractMetaClass *d_class, |
104 uint *exclude_attributes, uint *include_attributes) const; | |
105 QString functionSignature(const AbstractMetaFunction *d_function, | |
106 uint included_attributes, | |
107 uint excluded_attributes, | |
108 Option option = NoOption, | |
109 int arg_count = -1); | |
110 void setupForFunction(const AbstractMetaFunction *d_function, | |
111 uint *included_attributes, uint *excluded_attributes) const; | |
112 | |
113 virtual QString subDirectoryForClass(const AbstractMetaClass *d_class) const | |
114 { return subDirectoryForPackage(d_class->package()); } | |
115 | |
116 virtual QString fileNameForClass(const AbstractMetaClass *d_class) const; | |
117 | |
118 bool isComparable(const AbstractMetaClass *cls) const; | |
119 | |
120 #if 0 | |
121 void write1_dot_5_enum(QTextStream &s, const AbstractMetaEnum *d_enum); | |
122 #endif | |
123 | |
124 bool shouldGenerate(const AbstractMetaClass *d_class) const { | |
125 return !d_class->typeEntry()->isContainer() && !d_class->typeEntry()->isVariant() | |
126 && (d_class->typeEntry()->codeGeneration() & TypeEntry::GenerateTargetLang); | |
127 } | |
128 | |
129 QString documentationDirectory() const { return m_doc_directory; } | |
130 void setDocumentationDirectory(const QString &docDir) { m_doc_directory = docDir; } | |
131 | |
132 bool documentationEnabled() const { return m_docs_enabled; } | |
133 void setDocumentationEnabled(bool e) { m_docs_enabled = e; } | |
134 void generate(); | |
135 | |
136 inline bool nativeJumpTable() const { return m_native_jump_table; } | |
137 inline void setNativeJumpTable(bool n) { m_native_jump_table = n; } | |
138 | |
139 void writeShellVirtualFunction(QTextStream &s, const AbstractMetaFunction *function, | |
140 const AbstractMetaClass *implementor, int id); | |
141 void marshallFromCppToD(QTextStream &s, const ComplexTypeEntry* ctype); | |
142 | |
143 private: | |
144 QString subDirectoryForPackage(const QString &package) const { return QString(package).replace(".", "/"); } | |
145 void writeInstantiatedType(QTextStream &s, const AbstractMetaType *abstractMetaType) const; | |
146 | |
147 // qtd | |
148 void addTypeEntry(const AbstractMetaClass *d_class, const AbstractMetaFunction *function, QSet<const TypeEntry*> &typeEntries); | |
149 void fillRequiredImports(const AbstractMetaClass *d_class); | |
150 void addInstantiations(const AbstractMetaType* d_type); | |
151 void writeRequiredImports(QTextStream &s, const AbstractMetaClass *d_class); | |
152 const TypeEntry* fixedTypeEntry(const TypeEntry *type); | |
288 | 153 AbstractMetaFunctionList generatedClassFunctions(const AbstractMetaClass *d_class); |
1 | 154 |
155 void writeDestructor(QTextStream &s, const AbstractMetaClass *d_class); | |
253 | 156 void writeFlagsSetter(QTextStream &s, const AbstractMetaClass *d_class); |
1 | 157 void writeSignalHandlers(QTextStream &s, const AbstractMetaClass *d_class); |
341
4920ef9206fe
moved enums into interfaces
Max Samukha <maxter@spambox.com>
parents:
298
diff
changeset
|
158 void writeEnumAliases(QTextStream &s, const AbstractMetaEnum *d_enum); |
253 | 159 void writeSignalSignatures(QTextStream &s, const AbstractMetaClass *d_class, AbstractMetaFunctionList signal_funcs); |
288 | 160 void writeMetaMethodArguments(QTextStream &s, const AbstractMetaFunction *d_function, int reduce = -1); |
105
3aa118a9ae71
each QObject now has associated child QObject for handling signals. fixes #15
eldar
parents:
1
diff
changeset
|
161 void writeQObjectFunctions(QTextStream &s, const AbstractMetaClass *d_class); |
288 | 162 void writeQObjectFreeFunctions(QTextStream &s, const AbstractMetaClass *d_class); |
110 | 163 void writeConversionFunction(QTextStream &s, const AbstractMetaClass *d_class); |
292 | 164 void writeValueFreeFunctions(QTextStream &s, const AbstractMetaClass *d_class); |
165 void writeValueFunctions(QTextStream &s, const AbstractMetaClass *d_class); | |
105
3aa118a9ae71
each QObject now has associated child QObject for handling signals. fixes #15
eldar
parents:
1
diff
changeset
|
166 |
1 | 167 // void writeMarshallFunction(QTextStream &s, const AbstractMetaClass *d_class); |
168 | |
169 int m_recursive; | |
170 bool m_isRecursive; | |
341
4920ef9206fe
moved enums into interfaces
Max Samukha <maxter@spambox.com>
parents:
298
diff
changeset
|
171 QStack<const AbstractMetaClass*> m_recursionStack; |
1 | 172 QSet<const TypeEntry*> typeEntries; // imports |
173 QSet<const TypeEntry*> typeEntriesEnums; // imports for enums | |
174 QSet<QString> excludedTypes2; | |
175 | |
176 protected: | |
177 void writeImportString(QTextStream &s, const TypeEntry* typeEntry); | |
178 | |
179 QSet<QString> excludedTypes; | |
180 QString m_package_name; | |
181 QString m_doc_directory; | |
182 DocParser *m_doc_parser; | |
183 bool m_docs_enabled; | |
184 bool m_native_jump_table; | |
185 QList<const AbstractMetaFunction *> m_nativepointer_functions; | |
186 QList<const AbstractMetaFunction *> m_resettable_object_functions; | |
187 QList<const AbstractMetaFunction *> m_reference_count_candidate_functions; | |
188 }; | |
189 | |
190 class ClassFromEntry : Generator | |
191 { | |
192 Q_OBJECT | |
193 | |
194 private: | |
195 ClassFromEntry(); | |
110 | 196 void buildHash(); |
1 | 197 QHash<const TypeEntry *, AbstractMetaClass *> classFromEntry; |
198 static ClassFromEntry* m_instance; | |
199 | |
200 public: | |
201 static AbstractMetaClass* get(const TypeEntry *te); | |
110 | 202 static void print(QTextStream &s); |
203 static void construct(const AbstractMetaClassList &classes); | |
204 | |
1 | 205 }; |
206 #endif // DGENERATOR_H |