summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStephen Kelly <stephen.kelly@kdab.com>2012-03-08 21:34:14 +0100
committerQt by Nokia <qt-info@nokia.com>2012-03-14 19:59:53 +0100
commitb05139b2dc1f52690fb30f0734ef38716a87303d (patch)
treedb8d80956cf3cacd73215b44cfe79f079c2a5bad /src
parent08c1cb5c5a7da849dbd8a1f5020da69e8ebc7c70 (diff)
Add an overload to Moc to allow reading from a QIODevice.
This allows external code to provide the input data, such as a bootstrapped version of qdbuscpp2xml. Change-Id: I163062efc6495b3ab92573f94523967a67601191 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'src')
-rw-r--r--src/tools/moc/preprocessor.cpp9
-rw-r--r--src/tools/moc/preprocessor.h2
2 files changed, 9 insertions, 2 deletions
diff --git a/src/tools/moc/preprocessor.cpp b/src/tools/moc/preprocessor.cpp
index 07986a71e6..696b32c728 100644
--- a/src/tools/moc/preprocessor.cpp
+++ b/src/tools/moc/preprocessor.cpp
@@ -937,10 +937,15 @@ Symbols Preprocessor::preprocessed(const QByteArray &filename, FILE *file)
{
QFile qfile;
qfile.open(file, QFile::ReadOnly);
- QByteArray input = qfile.readAll();
+ return preprocessed(filename, &qfile);
+}
+
+Symbols Preprocessor::preprocessed(const QByteArray &filename, QIODevice *file)
+{
+ QByteArray input = file->readAll();
if (input.isEmpty())
return symbols;
-
+
// phase 1: get rid of backslash-newlines
input = cleaned(input);
diff --git a/src/tools/moc/preprocessor.h b/src/tools/moc/preprocessor.h
index e0707da4ee..4e0bd6343d 100644
--- a/src/tools/moc/preprocessor.h
+++ b/src/tools/moc/preprocessor.h
@@ -62,6 +62,7 @@ typedef SubArray MacroName;
typedef QHash<MacroName, Macro> Macros;
typedef QVector<MacroName> MacroSafeSet;
+class QIODevice;
class Preprocessor : public Parser
{
@@ -80,6 +81,7 @@ public:
QSet<QByteArray> preprocessedIncludes;
Macros macros;
Symbols preprocessed(const QByteArray &filename, FILE *file);
+ Symbols preprocessed(const QByteArray &filename, QIODevice *device);
void skipUntilEndif();