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