Mercurial > projects > qtd
annotate generator/dgenerator.h @ 127:6027ff37f8ca
bind QLibraryInfo
author | mandel |
---|---|
date | Fri, 05 Jun 2009 15:28:04 +0000 |
parents | 136c9ee83ee5 |
children | ae06da58ec25 |
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" | |
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); | |
105
3aa118a9ae71
each QObject now has associated child QObject for handling signals. fixes #15
eldar
parents:
1
diff
changeset
|
157 void writeQObjectFunctions(QTextStream &s, const AbstractMetaClass *d_class); |
110 | 158 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
|
159 |
1 | 160 // void writeMarshallFunction(QTextStream &s, const AbstractMetaClass *d_class); |
161 | |
162 int m_recursive; | |
163 bool m_isRecursive; | |
164 QSet<const TypeEntry*> typeEntries; // imports | |
165 QSet<const TypeEntry*> typeEntriesEnums; // imports for enums | |
166 QSet<QString> excludedTypes2; | |
167 | |
168 protected: | |
169 void writeImportString(QTextStream &s, const TypeEntry* typeEntry); | |
170 | |
171 QSet<QString> excludedTypes; | |
172 QString m_package_name; | |
173 QString m_doc_directory; | |
174 DocParser *m_doc_parser; | |
175 bool m_docs_enabled; | |
176 bool m_native_jump_table; | |
177 QList<const AbstractMetaFunction *> m_nativepointer_functions; | |
178 QList<const AbstractMetaFunction *> m_resettable_object_functions; | |
179 QList<const AbstractMetaFunction *> m_reference_count_candidate_functions; | |
180 }; | |
181 | |
182 class ClassFromEntry : Generator | |
183 { | |
184 Q_OBJECT | |
185 | |
186 private: | |
187 ClassFromEntry(); | |
110 | 188 void buildHash(); |
1 | 189 QHash<const TypeEntry *, AbstractMetaClass *> classFromEntry; |
190 static ClassFromEntry* m_instance; | |
191 | |
192 public: | |
193 static AbstractMetaClass* get(const TypeEntry *te); | |
110 | 194 static void print(QTextStream &s); |
195 static void construct(const AbstractMetaClassList &classes); | |
196 | |
1 | 197 }; |
198 #endif // DGENERATOR_H |