Mercurial > projects > qtd
comparison generator/abstractmetabuilder.h @ 1:e78566595089
initial import
author | mandel |
---|---|
date | Mon, 11 May 2009 16:01:50 +0000 |
parents | |
children |
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 ABSTRACTMETABUILDER_H | |
43 #define ABSTRACTMETABUILDER_H | |
44 | |
45 #include "codemodel.h" | |
46 #include "abstractmetalang.h" | |
47 #include "typesystem.h" | |
48 #include "typeparser.h" | |
49 | |
50 #include <QtCore/QSet> | |
51 | |
52 class AbstractMetaBuilder | |
53 { | |
54 public: | |
55 enum RejectReason { | |
56 NotInTypeSystem, | |
57 GenerationDisabled, | |
58 RedefinedToNotClass, | |
59 UnmatchedArgumentType, | |
60 UnmatchedReturnType, | |
61 NoReason | |
62 }; | |
63 | |
64 AbstractMetaBuilder(); | |
65 virtual ~AbstractMetaBuilder() {}; | |
66 | |
67 AbstractMetaClassList classes() const { return m_meta_classes; } | |
68 AbstractMetaClassList classesTopologicalSorted() const; | |
69 | |
70 FileModelItem model() const { return m_dom; } | |
71 void setModel(FileModelItem item) { m_dom = item; } | |
72 | |
73 | |
74 ScopeModelItem popScope() { return m_scopes.takeLast(); } | |
75 void pushScope(ScopeModelItem item) { m_scopes << item; } | |
76 ScopeModelItem currentScope() const { return m_scopes.last(); } | |
77 | |
78 QString fileName() const { return m_file_name; } | |
79 void setFileName(const QString &fileName) { m_file_name = fileName; } | |
80 | |
81 void dumpLog(); | |
82 | |
83 bool build(); | |
84 | |
85 void figureOutEnumValuesForClass(AbstractMetaClass *meta_class, QSet<AbstractMetaClass *> *classes); | |
86 int figureOutEnumValue(const QString &name, int value, AbstractMetaEnum *meta_enum, AbstractMetaFunction *meta_function = 0); | |
87 void figureOutEnumValues(); | |
88 void figureOutDefaultEnumArguments(); | |
89 | |
90 void addAbstractMetaClass(AbstractMetaClass *cls); | |
91 AbstractMetaClass *traverseTypeAlias(TypeAliasModelItem item); | |
92 AbstractMetaClass *traverseClass(ClassModelItem item); | |
93 bool setupInheritance(AbstractMetaClass *meta_class); | |
94 AbstractMetaClass *traverseNamespace(NamespaceModelItem item); | |
95 AbstractMetaEnum *traverseEnum(EnumModelItem item, AbstractMetaClass *enclosing, const QSet<QString> &enumsDeclarations); | |
96 void traverseEnums(ScopeModelItem item, AbstractMetaClass *parent, const QStringList &enumsDeclarations); | |
97 void traverseFunctions(ScopeModelItem item, AbstractMetaClass *parent); | |
98 void traverseFields(ScopeModelItem item, AbstractMetaClass *parent); | |
99 void traverseStreamOperator(FunctionModelItem function_item); | |
100 void traverseCompareOperator(FunctionModelItem item); | |
101 AbstractMetaFunction *traverseFunction(FunctionModelItem function); | |
102 AbstractMetaField *traverseField(VariableModelItem field, const AbstractMetaClass *cls); | |
103 void checkFunctionModifications(); | |
104 void registerHashFunction(FunctionModelItem function_item); | |
105 void registerToStringCapability(FunctionModelItem function_item); | |
106 | |
107 void parseQ_Property(AbstractMetaClass *meta_class, const QStringList &declarations); | |
108 void setupEquals(AbstractMetaClass *meta_class); | |
109 void setupComparable(AbstractMetaClass *meta_class); | |
110 void setupClonable(AbstractMetaClass *cls); | |
111 void setupFunctionDefaults(AbstractMetaFunction *meta_function, AbstractMetaClass *meta_class); | |
112 | |
113 QString translateDefaultValue(ArgumentModelItem item, AbstractMetaType *type, | |
114 AbstractMetaFunction *fnc, AbstractMetaClass *, | |
115 int argument_index); | |
116 AbstractMetaType *translateType(const TypeInfo &type, bool *ok, bool resolveType = true, bool resolveScope = true); | |
117 | |
118 void decideUsagePattern(AbstractMetaType *type); | |
119 | |
120 bool inheritTemplate(AbstractMetaClass *subclass, | |
121 const AbstractMetaClass *template_class, | |
122 const TypeParser::Info &info); | |
123 AbstractMetaType *inheritTemplateType(const QList<AbstractMetaType *> &template_types, AbstractMetaType *meta_type, bool *ok = 0); | |
124 | |
125 bool isQObject(const QString &qualified_name); | |
126 bool isEnum(const QStringList &qualified_name); | |
127 | |
128 void fixQObjectForScope (TypeDatabase *types, | |
129 NamespaceModelItem item); | |
130 protected: | |
131 AbstractMetaClass *argumentToClass(ArgumentModelItem); | |
132 | |
133 virtual AbstractMetaClass *createMetaClass() = 0; | |
134 virtual AbstractMetaEnum *createMetaEnum() = 0; | |
135 virtual AbstractMetaEnumValue *createMetaEnumValue() = 0; | |
136 virtual AbstractMetaField *createMetaField() = 0; | |
137 virtual AbstractMetaFunction *createMetaFunction() = 0; | |
138 virtual AbstractMetaArgument *createMetaArgument() = 0; | |
139 virtual AbstractMetaType *createMetaType() = 0; | |
140 | |
141 private: | |
142 void sortLists(); | |
143 | |
144 QString m_file_name; | |
145 | |
146 AbstractMetaClassList m_meta_classes; | |
147 AbstractMetaClassList m_templates; | |
148 FileModelItem m_dom; | |
149 | |
150 QSet<const TypeEntry *> m_used_types; | |
151 | |
152 QMap<QString, RejectReason> m_rejected_classes; | |
153 QMap<QString, RejectReason> m_rejected_enums; | |
154 QMap<QString, RejectReason> m_rejected_functions; | |
155 QMap<QString, RejectReason> m_rejected_fields; | |
156 | |
157 QList<AbstractMetaEnum *> m_enums; | |
158 | |
159 QList<QPair<AbstractMetaArgument *, AbstractMetaFunction *> > m_enum_default_arguments; | |
160 | |
161 QHash<QString, AbstractMetaEnumValue *> m_enum_values; | |
162 | |
163 AbstractMetaClass *m_current_class; | |
164 QList<ScopeModelItem> m_scopes; | |
165 QString m_namespace_prefix; | |
166 | |
167 QSet<AbstractMetaClass *> m_setup_inheritance_done; | |
168 }; | |
169 | |
170 #endif // ABSTRACTMETBUILDER_H |