diff options
author | Sebastian Holtermann <sebholt@xwmw.org> | 2016-12-28 09:25:16 (GMT) |
---|---|---|
committer | Sebastian Holtermann <sebholt@xwmw.org> | 2017-01-10 11:49:14 (GMT) |
commit | 6ae19bf32e232beb59a0c427d82c0761e8248ab8 (patch) | |
tree | 2ac5182066ad2150d05e3aa6b332d9255e7fac89 /Source/cmQtAutoGenerators.cxx | |
parent | 9986da4f0f2f49c0d7d260f9d21deaa906708376 (diff) | |
download | CMake-6ae19bf32e232beb59a0c427d82c0761e8248ab8.zip CMake-6ae19bf32e232beb59a0c427d82c0761e8248ab8.tar.gz CMake-6ae19bf32e232beb59a0c427d82c0761e8248ab8.tar.bz2 |
AUTOGEN: Generators: Add dedicated method for moc content parsing
Diffstat (limited to 'Source/cmQtAutoGenerators.cxx')
-rw-r--r-- | Source/cmQtAutoGenerators.cxx | 136 |
1 files changed, 74 insertions, 62 deletions
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 33550b0..5877619 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -580,19 +580,90 @@ bool cmQtAutoGenerators::ParseSourceFile( std::map<std::string, std::string>& includedMocs, std::map<std::string, std::vector<std::string> >& includedUis, bool relaxed) { + bool success = true; const std::string contentsString = ReadAll(absFilename); if (contentsString.empty()) { std::ostringstream err; err << "AUTOGEN: warning: " << absFilename << "\n" << "The file is empty\n"; this->LogWarning(err.str()); - return true; + } else { + // Parse source contents for UIC + this->ParseContentForUic(absFilename, contentsString, includedUis); + // Parse source contents for MOC + success = this->ParseContentForMoc( + absFilename, contentsString, headerExtensions, includedMocs, relaxed); + } + return success; +} + +bool cmQtAutoGenerators::requiresMocing(const std::string& text, + std::string& macroName) +{ + // Run a simple check before an expensive regular expression check + if (strstr(text.c_str(), "Q_OBJECT") != CM_NULLPTR) { + if (this->RegExpQObject.find(text)) { + macroName = "Q_OBJECT"; + return true; + } + } + if (strstr(text.c_str(), "Q_GADGET") != CM_NULLPTR) { + if (this->RegExpQGadget.find(text)) { + macroName = "Q_GADGET"; + return true; + } } + return false; +} - // Parse source contents for UIC +void cmQtAutoGenerators::ParseForUic( + const std::string& absFilename, + std::map<std::string, std::vector<std::string> >& includedUis) +{ + if (this->UicExecutable.empty()) { + return; + } + const std::string contentsString = ReadAll(absFilename); + if (contentsString.empty()) { + std::ostringstream err; + err << "AUTOGEN: warning: " << absFilename << ": file is empty\n" + << std::endl; + this->LogWarning(err.str()); + return; + } this->ParseContentForUic(absFilename, contentsString, includedUis); +} - // Continue with moc parsing on demand +void cmQtAutoGenerators::ParseContentForUic( + const std::string& absFilename, const std::string& contentsString, + std::map<std::string, std::vector<std::string> >& includedUis) +{ + if (this->UicExecutable.empty()) { + return; + } + const std::string realName = cmsys::SystemTools::GetRealPath(absFilename); + const char* contentChars = contentsString.c_str(); + if (strstr(contentChars, "ui_") != CM_NULLPTR) { + while (this->RegExpUicInclude.find(contentChars)) { + const std::string currentUi = this->RegExpUicInclude.match(1); + const std::string basename = + cmsys::SystemTools::GetFilenameWithoutLastExtension(currentUi); + // basename should be the part of the ui filename used for + // finding the correct header, so we need to remove the ui_ part + includedUis[realName].push_back(basename.substr(3)); + contentChars += this->RegExpUicInclude.end(); + } + } +} + +/** + * @return True on success + */ +bool cmQtAutoGenerators::ParseContentForMoc( + const std::string& absFilename, const std::string& contentsString, + const std::vector<std::string>& headerExtensions, + std::map<std::string, std::string>& includedMocs, bool relaxed) +{ if (this->MocExecutable.empty()) { return true; } @@ -775,65 +846,6 @@ bool cmQtAutoGenerators::ParseSourceFile( return true; } -bool cmQtAutoGenerators::requiresMocing(const std::string& text, - std::string& macroName) -{ - // Run a simple check before an expensive regular expression check - if (strstr(text.c_str(), "Q_OBJECT") != CM_NULLPTR) { - if (this->RegExpQObject.find(text)) { - macroName = "Q_OBJECT"; - return true; - } - } - if (strstr(text.c_str(), "Q_GADGET") != CM_NULLPTR) { - if (this->RegExpQGadget.find(text)) { - macroName = "Q_GADGET"; - return true; - } - } - return false; -} - -void cmQtAutoGenerators::ParseForUic( - const std::string& absFilename, - std::map<std::string, std::vector<std::string> >& includedUis) -{ - if (this->UicExecutable.empty()) { - return; - } - const std::string contentsString = ReadAll(absFilename); - if (contentsString.empty()) { - std::ostringstream err; - err << "AUTOGEN: warning: " << absFilename << ": file is empty\n" - << std::endl; - this->LogWarning(err.str()); - return; - } - this->ParseContentForUic(absFilename, contentsString, includedUis); -} - -void cmQtAutoGenerators::ParseContentForUic( - const std::string& absFilename, const std::string& contentsString, - std::map<std::string, std::vector<std::string> >& includedUis) -{ - if (this->UicExecutable.empty()) { - return; - } - const std::string realName = cmsys::SystemTools::GetRealPath(absFilename); - const char* contentChars = contentsString.c_str(); - if (strstr(contentChars, "ui_") != CM_NULLPTR) { - while (this->RegExpUicInclude.find(contentChars)) { - const std::string currentUi = this->RegExpUicInclude.match(1); - const std::string basename = - cmsys::SystemTools::GetFilenameWithoutLastExtension(currentUi); - // basename should be the part of the ui filename used for - // finding the correct header, so we need to remove the ui_ part - includedUis[realName].push_back(basename.substr(3)); - contentChars += this->RegExpUicInclude.end(); - } - } -} - void cmQtAutoGenerators::SearchHeadersForCppFile( const std::string& absFilename, const std::vector<std::string>& headerExtensions, |