1
/****************************************************************************
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
5
** This file is part of the tools applications of the Qt Toolkit.
7
** This file may be distributed under the terms of the Q Public License
8
** as defined by Trolltech AS of Norway and appearing in the file
9
** LICENSE.QPL included in the packaging of this file.
11
** This file may be distributed and/or modified under the terms of the
12
** GNU General Public License version 2 as published by the Free Software
13
** Foundation and appearing in the file LICENSE.GPL included in the
14
** packaging of this file.
16
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
17
** information about Qt Commercial License Agreements.
18
** See http://www.trolltech.com/qpl/ for QPL licensing information.
19
** See http://www.trolltech.com/gpl/ for GPL licensing information.
21
** Contact info@trolltech.com if any conditions of this licensing are
24
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
25
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27
****************************************************************************/
33
#include <qstringlist.h>
43
QList<QByteArray> values;
48
ArgumentDef():isDefault(false){}
49
QByteArray type, rightType, normalizedType, name;
55
FunctionDef(): access(Private), isConst(false), isVirtual(false), inlineCode(false), wasCloned(false), isCompat(false), isInvokable(false), isScriptable(false) {}
56
QByteArray type, normalizedType;
60
QList<ArgumentDef> arguments;
62
enum Access { Private, Protected, Public };
69
QByteArray inPrivateClass;
77
PropertyDef():gspec(ValueSpec){}
78
QByteArray name, type, read, write, reset, designable, scriptable, editable, stored;
79
enum Specification { ValueSpec, ReferenceSpec, PointerSpec };
81
bool stdCppSet() const {
83
s += toupper(name[0]);
98
hasQObject(false), hasQGadget(false){}
100
QByteArray qualified;
101
QList<QPair<QByteArray, FunctionDef::Access> > superclassList;
105
inline explicit Interface(const QByteArray &_className)
106
: className(_className) {}
107
QByteArray className;
108
QByteArray interfaceId;
110
QList<QList<Interface> >interfaceList;
115
QList<FunctionDef> signalList, slotList, methodList, publicList;
116
QList<PropertyDef> propertyList;
117
QList<ClassInfoDef> classInfoList;
118
QMap<QByteArray, bool> enumDeclarations;
119
QList<EnumDef> enumList;
120
QMap<QByteArray, QByteArray> flagAliases;
126
struct NamespaceDef {
138
displayWarnings(true),
143
QStack<QByteArray> currentFilenames;
149
bool displayWarnings;
151
QByteArray includePath;
152
QList<QByteArray> includeFiles;
153
QList<ClassDef> classList;
154
QMap<QByteArray, QByteArray> interface2IdMap;
156
inline bool hasNext() const { return (index < symbols.size()); }
157
inline Token next() { return symbols.at(index++).token; }
160
void next(Token, const char *msg);
162
QByteArray lexemUntil(Token);
163
inline void prev() {--index;}
164
Token lookup(int k = 1);
165
inline const Symbol &symbol_lookup(int k = 1) { return symbols.at(index-1+k);}
166
inline Token token() { return symbols.at(index-1).token;}
167
inline QByteArray lexem() { return symbols.at(index-1).lexem();}
168
inline const Symbol &symbol() { return symbols.at(index-1);}
170
void error(int rollback);
171
void error(const char *msg = 0);
172
void warning(const char * = 0);
175
void generate(FILE *out);
177
bool parseClassHead(ClassDef *def);
178
inline bool inClass(const ClassDef *def) const {
179
return index > def->begin && index < def->end - 1;
182
inline bool inNamespace(const NamespaceDef *def) const {
183
return index > def->begin && index < def->end - 1;
186
QByteArray parseType();
188
bool parseEnum(EnumDef *def);
190
void parseFunction(FunctionDef *def, bool inMacro = false);
191
bool parseMaybeFunction(FunctionDef *def);
193
void parseSlots(ClassDef *def, FunctionDef::Access access);
194
void parseSignals(ClassDef *def);
195
void parseProperty(ClassDef *def);
196
void parseEnumOrFlag(ClassDef *def, bool isFlag);
197
void parseFlag(ClassDef *def);
198
void parseClassInfo(ClassDef *def);
199
void parseInterfaces(ClassDef *def);
200
void parseDeclareInterface();
201
void parseSlotInPrivate(ClassDef *def, FunctionDef::Access access);
203
void parseFunctionArguments(FunctionDef *def);
208
inline bool Moc::test(Token token)
210
if (index < symbols.size() && symbols.at(index).token == token) {
217
inline Token Moc::lookup(int k)
219
const int l = index - 1 + k;
220
return l < symbols.size() ? symbols.at(l).token : NOTOKEN;
223
inline void Moc::next(Token token)
229
inline void Moc::next(Token token, const char *msg)
235
QByteArray normalizeType(const char *s, bool fixScope = false);