summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/corelib/kernel/qobjectdefs.h12
-rw-r--r--src/tools/moc/main.cpp2
-rw-r--r--src/tools/moc/moc.cpp109
-rw-r--r--src/tools/moc/moc.h13
-rw-r--r--src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp3
5 files changed, 12 insertions, 127 deletions
diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h
index 306728d77c..e840706021 100644
--- a/src/corelib/kernel/qobjectdefs.h
+++ b/src/corelib/kernel/qobjectdefs.h
@@ -213,16 +213,16 @@ Q_CORE_EXPORT const char *qFlagLocation(const char *method);
#ifndef QT_NO_DEBUG
# define QLOCATION "\0" __FILE__ ":" QTOSTRING(__LINE__)
# ifndef QT_NO_KEYWORDS
-# define METHOD(a) qFlagLocation("0" QTOSTRING(a) QLOCATION)
+# define METHOD(a) qFlagLocation("0"#a QLOCATION)
# endif
-# define SLOT(a) qFlagLocation("1" QTOSTRING(a) QLOCATION)
-# define SIGNAL(a) qFlagLocation("2" QTOSTRING(a) QLOCATION)
+# define SLOT(a) qFlagLocation("1"#a QLOCATION)
+# define SIGNAL(a) qFlagLocation("2"#a QLOCATION)
#else
# ifndef QT_NO_KEYWORDS
-# define METHOD(a) "0" QTOSTRING(a)
+# define METHOD(a) "0"#a
# endif
-# define SLOT(a) "1" QTOSTRING(a)
-# define SIGNAL(a) "2" QTOSTRING(a)
+# define SLOT(a) "1"#a
+# define SIGNAL(a) "2"#a
#endif
#define QMETHOD_CODE 0 // member type codes
diff --git a/src/tools/moc/main.cpp b/src/tools/moc/main.cpp
index 7db8737975..905eed1c5d 100644
--- a/src/tools/moc/main.cpp
+++ b/src/tools/moc/main.cpp
@@ -167,7 +167,7 @@ int runMoc(int _argc, char **_argv)
bool autoInclude = true;
bool defaultInclude = true;
Preprocessor pp;
- Moc moc(pp);
+ Moc moc;
pp.macros["Q_MOC_RUN"];
pp.macros["__cplusplus"];
QByteArray filename;
diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp
index aaaf701ea5..c35f27deaf 100644
--- a/src/tools/moc/moc.cpp
+++ b/src/tools/moc/moc.cpp
@@ -302,9 +302,7 @@ void Moc::parseFunctionArguments(FunctionDef *def)
arg.rightType += lexem();
}
arg.normalizedType = normalizeType(QByteArray(arg.type.name + ' ' + arg.rightType));
- arg.normalizedType = getTypeSubstitution(arg.normalizedType);
arg.typeNameForCast = normalizeType(QByteArray(noRef(arg.type.name) + "(*)" + arg.rightType));
- arg.typeNameForCast = getTypeSubstitution(arg.typeNameForCast);
if (test(EQ))
arg.isDefault = true;
def->arguments += arg;
@@ -414,7 +412,6 @@ bool Moc::parseFunction(FunctionDef *def, bool inMacro)
}
def->normalizedType = normalizeType(def->type.name);
- def->normalizedType = getTypeSubstitution(def->normalizedType);
if (!test(RPAREN)) {
parseFunctionArguments(def);
@@ -513,7 +510,6 @@ bool Moc::parseMaybeFunction(const ClassDef *cdef, FunctionDef *def)
}
def->normalizedType = normalizeType(def->type.name);
- def->normalizedType = getTypeSubstitution(def->normalizedType);
if (!test(RPAREN)) {
parseFunctionArguments(def);
@@ -970,7 +966,6 @@ void Moc::createPropertyDef(PropertyDef &propDef)
QVariant.
*/
type = normalizeType(type);
- type = getTypeSubstitution(type);
if (type == "QMap")
type = "QMap<QString,QVariant>";
else if (type == "QValueList")
@@ -1244,8 +1239,7 @@ void Moc::parseInterfaces(ClassDef *def)
}
// resolve from classnames to interface ids
for (int i = 0; i < iface.count(); ++i) {
- QByteArray className = getTypeSubstitution(iface.at(i).className);
- QByteArray iid = interface2IdMap.value(className);
+ const QByteArray iid = interface2IdMap.value(iface.at(i).className);
if (iid.isEmpty())
error("Undefined interface");
@@ -1503,107 +1497,6 @@ void Moc::checkProperties(ClassDef *cdef)
}
}
-QByteArray Moc::getSubstitution(const QByteArray &token) const
-{
- Macros::ConstIterator it = preprocessor.macros.find(token);
- if (it != preprocessor.macros.end() && it->symbols.count() == 1) {
- // We can only handle substitutions that result in a single symbol
- return it->symbols.at(0).lexem();
- }
-
- return QByteArray();
-}
-
-QByteArray Moc::getTokenSubstitution(const QByteArray &token) const
-{
- QByteArray result = token;
-
- QSet<QByteArray> used;
-
- // Process substitution chain until no replacement exists
- QByteArray substitution = getSubstitution(result);
- while (!substitution.isEmpty()) {
- used.insert(result);
- result = substitution;
-
- if (used.contains(result)) {
- break;
- }
-
- substitution = getSubstitution(result);
- }
-
- return result;
-}
-
-QByteArray Moc::getWordSubstitution(const QByteArray &word) const
-{
- QByteArray result;
-
- // A word can contain multiple components separated by '*'
- int startIndex = 0;
- do {
- int index = word.indexOf('*', startIndex);
- if (index == -1) {
- result.append(getTokenSubstitution(word.mid(startIndex)));
- } else {
- result.append(getTokenSubstitution(word.mid(startIndex, (index - startIndex))));
- result.append('*');
- }
-
- startIndex = index + 1;
- } while (startIndex != 0);
-
- return result;
-}
-
-QByteArray Moc::getNameSubstitution(const QByteArray &name) const
-{
- QByteArray result;
-
- // Parse multiple tokens in this name independently
- int startIndex = 0;
- do {
- int index = name.indexOf(' ', startIndex);
- if (index == -1) {
- result.append(getWordSubstitution(name.mid(startIndex)));
- } else {
- result.append(getWordSubstitution(name.mid(startIndex, (index - startIndex))));
- result.append(' ');
- }
-
- startIndex = index + 1;
- } while (startIndex != 0);
-
- return result;
-}
-
-QByteArray Moc::getTypeSubstitution(const QByteArray &typeName) const
-{
- int index = typeName.indexOf('<');
- if (index != -1) {
- QByteArray templateName = typeName.left(index);
-
- int lastIndex = typeName.lastIndexOf('>');
- if (lastIndex > index) {
- QByteArray result = getNameSubstitution(templateName);
-
- // Parse the interior type independently
- QByteArray parameter = typeName.mid(index + 1, (lastIndex - index - 1));
- QByteArray interior = getTypeSubstitution(parameter);
- if (interior.endsWith('>')) {
- interior.append(' ');
- }
- result.append('<').append(interior).append(typeName.mid(lastIndex));
- return result;
- } else {
- // Something is broken; return the input unmodified
- return typeName;
- }
- }
-
- return getNameSubstitution(typeName);
-}
QT_END_NAMESPACE
diff --git a/src/tools/moc/moc.h b/src/tools/moc/moc.h
index b12ec492ff..e20e29acb8 100644
--- a/src/tools/moc/moc.h
+++ b/src/tools/moc/moc.h
@@ -43,7 +43,6 @@
#define MOC_H
#include "parser.h"
-#include "preprocessor.h"
#include <QStringList>
#include <QMap>
#include <QPair>
@@ -198,14 +197,12 @@ struct NamespaceDef {
class Moc : public Parser
{
public:
- Moc(Preprocessor &p)
- : preprocessor(p), noInclude(false), generatedCode(false),
- mustIncludeQPluginH(false)
+ Moc()
+ : noInclude(false), generatedCode(false), mustIncludeQPluginH(false)
{}
QByteArray filename;
- Preprocessor &preprocessor;
bool noInclude;
bool generatedCode;
bool mustIncludeQPluginH;
@@ -262,12 +259,6 @@ public:
void checkSuperClasses(ClassDef *def);
void checkProperties(ClassDef* cdef);
-
- QByteArray getSubstitution(const QByteArray &token) const;
- QByteArray getTokenSubstitution(const QByteArray &token) const;
- QByteArray getWordSubstitution(const QByteArray &word) const;
- QByteArray getNameSubstitution(const QByteArray &name) const;
- QByteArray getTypeSubstitution(const QByteArray &typeName) const;
};
inline QByteArray noRef(const QByteArray &type)
diff --git a/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp b/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp
index 41756de5bc..87a7692333 100644
--- a/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp
+++ b/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp
@@ -71,6 +71,7 @@ static const char docTypeHeader[] =
#include "moc.h"
#include "generator.h"
+#include "preprocessor.h"
#define PROGRAMNAME "qdbuscpp2xml"
#define PROGRAMVERSION "0.2"
@@ -414,7 +415,7 @@ int main(int argc, char **argv)
}
Preprocessor pp;
- Moc moc(pp);
+ Moc moc;
pp.macros["Q_MOC_RUN"];
pp.macros["__cplusplus"];