summaryrefslogtreecommitdiffstats
path: root/Source/cmQtAutomoc.cxx
diff options
context:
space:
mode:
authorAlex Neundorf <neundorf@kde.org>2011-11-22 20:35:08 (GMT)
committerAlex Neundorf <neundorf@kde.org>2011-11-22 20:35:08 (GMT)
commit74ab0f6aa409a9d3e90c91b1b1c7a6e4b865ed62 (patch)
treee589e8c6c5e7599073982d76f6f6beb872f557c7 /Source/cmQtAutomoc.cxx
parentbc7560e6e56d1f6fa65745cf5c1206192fb77b04 (diff)
downloadCMake-74ab0f6aa409a9d3e90c91b1b1c7a6e4b865ed62.zip
CMake-74ab0f6aa409a9d3e90c91b1b1c7a6e4b865ed62.tar.gz
CMake-74ab0f6aa409a9d3e90c91b1b1c7a6e4b865ed62.tar.bz2
automoc: move some code from the big parsing loop into separate functions
Alex
Diffstat (limited to 'Source/cmQtAutomoc.cxx')
-rw-r--r--Source/cmQtAutomoc.cxx77
1 files changed, 47 insertions, 30 deletions
diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx
index ad11668..931cc5d 100644
--- a/Source/cmQtAutomoc.cxx
+++ b/Source/cmQtAutomoc.cxx
@@ -37,6 +37,50 @@ static bool containsQ_OBJECT(const std::string& text)
}
+static std::string findMatchingHeader(const std::string& absPath,
+ const std::string& mocSubDir,
+ const std::string& basename,
+ const std::list<std::string>& headerExtensions)
+{
+ std::string header;
+ for(std::list<std::string>::const_iterator ext = headerExtensions.begin();
+ ext != headerExtensions.end();
+ ++ext)
+ {
+ std::string sourceFilePath = absPath + basename + (*ext);
+ if (cmsys::SystemTools::FileExists(sourceFilePath.c_str()))
+ {
+ header = sourceFilePath;
+ break;
+ }
+ if (!mocSubDir.empty())
+ {
+ sourceFilePath = mocSubDir + basename + (*ext);
+ if (cmsys::SystemTools::FileExists(sourceFilePath.c_str()))
+ {
+ header = sourceFilePath;
+ break;
+ }
+ }
+ }
+
+ return header;
+}
+
+
+static std::string extractSubDir(const std::string& absPath,
+ const std::string& currentMoc)
+{
+ std::string subDir;
+ if (currentMoc.find_first_of('/') != std::string::npos)
+ {
+ subDir = absPath
+ + cmsys::SystemTools::GetFilenamePath(currentMoc) + '/';
+ }
+ return subDir;
+}
+
+
cmQtAutomoc::cmQtAutomoc()
:Verbose(cmsys::SystemTools::GetEnv("VERBOSE") != 0)
,ColorOutput(true)
@@ -569,36 +613,9 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename,
// basename should be the part of the moc filename used for
// finding the correct header, so we need to remove the moc_ part
basename = basename.substr(4);
-
- std::string mocSubDir;
- if (currentMoc.find_first_of('/') != std::string::npos)
- {
- mocSubDir = absPath
- + cmsys::SystemTools::GetFilenamePath(currentMoc) + '/';
- }
-
- std::string headerToMoc;
- for(std::list<std::string>::const_iterator ext =
- headerExtensions.begin();
- ext != headerExtensions.end();
- ++ext)
- {
- std::string sourceFilePath = absPath + basename + (*ext);
- if (cmsys::SystemTools::FileExists(sourceFilePath.c_str()))
- {
- headerToMoc = sourceFilePath;
- break;
- }
- if (!mocSubDir.empty())
- {
- sourceFilePath = mocSubDir + basename + (*ext);
- if (cmsys::SystemTools::FileExists(sourceFilePath.c_str()))
- {
- headerToMoc = sourceFilePath;
- break;
- }
- }
- }
+ std::string mocSubDir = extractSubDir(absPath, currentMoc);
+ std::string headerToMoc = findMatchingHeader(
+ absPath, mocSubDir, basename, headerExtensions);
if (!headerToMoc.empty())
{