diff options
author | Kitware Robot <kwrobot@kitware.com> | 2016-05-16 14:34:04 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-05-16 20:05:19 (GMT) |
commit | d9fd2f5402eeaa345691313658e02b51038f570b (patch) | |
tree | dca71b9a7e267f4c6300da3eb770415381726785 /Source/cmScriptGenerator.cxx | |
parent | 82df6deaafb36cbbfd450202bb20b320f637751a (diff) | |
download | CMake-d9fd2f5402eeaa345691313658e02b51038f570b.zip CMake-d9fd2f5402eeaa345691313658e02b51038f570b.tar.gz CMake-d9fd2f5402eeaa345691313658e02b51038f570b.tar.bz2 |
Revise C++ coding style using clang-format
Run the `Utilities/Scripts/clang-format.bash` script to update
all our C++ code to a new style defined by `.clang-format`.
Use `clang-format` version 3.8.
* If you reached this commit for a line in `git blame`, re-run the blame
operation starting at the parent of this commit to see older history
for the content.
* See the parent commit for instructions to rebase a change across this
style transition commit.
Diffstat (limited to 'Source/cmScriptGenerator.cxx')
-rw-r--r-- | Source/cmScriptGenerator.cxx | 132 |
1 files changed, 52 insertions, 80 deletions
diff --git a/Source/cmScriptGenerator.cxx b/Source/cmScriptGenerator.cxx index 3b8a20e..5fed107 100644 --- a/Source/cmScriptGenerator.cxx +++ b/Source/cmScriptGenerator.cxx @@ -13,26 +13,24 @@ #include "cmSystemTools.h" -cmScriptGenerator -::cmScriptGenerator(const std::string& config_var, - std::vector<std::string> const& configurations): - RuntimeConfigVariable(config_var), - Configurations(configurations), - ConfigurationName(""), - ConfigurationTypes(0), - ActionsPerConfig(false) +cmScriptGenerator::cmScriptGenerator( + const std::string& config_var, + std::vector<std::string> const& configurations) + : RuntimeConfigVariable(config_var) + , Configurations(configurations) + , ConfigurationName("") + , ConfigurationTypes(0) + , ActionsPerConfig(false) { } -cmScriptGenerator -::~cmScriptGenerator() +cmScriptGenerator::~cmScriptGenerator() { } -void -cmScriptGenerator -::Generate(std::ostream& os, const std::string& config, - std::vector<std::string> const& configurationTypes) +void cmScriptGenerator::Generate( + std::ostream& os, const std::string& config, + std::vector<std::string> const& configurationTypes) { this->ConfigurationName = config; this->ConfigurationTypes = &configurationTypes; @@ -44,57 +42,48 @@ cmScriptGenerator static void cmScriptGeneratorEncodeConfig(const std::string& config, std::string& result) { - for(const char* c = config.c_str(); *c; ++c) - { - if(*c >= 'a' && *c <= 'z') - { + for (const char* c = config.c_str(); *c; ++c) { + if (*c >= 'a' && *c <= 'z') { result += "["; result += static_cast<char>(*c + 'A' - 'a'); result += *c; result += "]"; - } - else if(*c >= 'A' && *c <= 'Z') - { + } else if (*c >= 'A' && *c <= 'Z') { result += "["; result += *c; result += static_cast<char>(*c + 'a' - 'A'); result += "]"; - } - else - { + } else { result += *c; - } } + } } -std::string -cmScriptGenerator::CreateConfigTest(const std::string& config) +std::string cmScriptGenerator::CreateConfigTest(const std::string& config) { std::string result = "\"${"; result += this->RuntimeConfigVariable; result += "}\" MATCHES \"^("; - if(!config.empty()) - { + if (!config.empty()) { cmScriptGeneratorEncodeConfig(config, result); - } + } result += ")$\""; return result; } -std::string -cmScriptGenerator::CreateConfigTest(std::vector<std::string> const& configs) +std::string cmScriptGenerator::CreateConfigTest( + std::vector<std::string> const& configs) { std::string result = "\"${"; result += this->RuntimeConfigVariable; result += "}\" MATCHES \"^("; const char* sep = ""; - for(std::vector<std::string>::const_iterator ci = configs.begin(); - ci != configs.end(); ++ci) - { + for (std::vector<std::string>::const_iterator ci = configs.begin(); + ci != configs.end(); ++ci) { result += sep; sep = "|"; cmScriptGeneratorEncodeConfig(*ci, result); - } + } result += ")$\""; return result; } @@ -111,25 +100,21 @@ void cmScriptGenerator::GenerateScript(std::ostream& os) void cmScriptGenerator::GenerateScriptConfigs(std::ostream& os, Indent const& indent) { - if(this->ActionsPerConfig) - { + if (this->ActionsPerConfig) { this->GenerateScriptActionsPerConfig(os, indent); - } - else - { + } else { this->GenerateScriptActionsOnce(os, indent); - } + } } void cmScriptGenerator::GenerateScriptActions(std::ostream& os, Indent const& indent) { - if(this->ActionsPerConfig) - { + if (this->ActionsPerConfig) { // This is reached for single-configuration build generators in a // per-config script generator. this->GenerateScriptForConfig(os, this->ConfigurationName, indent); - } + } } void cmScriptGenerator::GenerateScriptForConfig(std::ostream&, @@ -142,84 +127,71 @@ void cmScriptGenerator::GenerateScriptForConfig(std::ostream&, bool cmScriptGenerator::GeneratesForConfig(const std::string& config) { // If this is not a configuration-specific rule then we install. - if(this->Configurations.empty()) - { + if (this->Configurations.empty()) { return true; - } + } // This is a configuration-specific rule. Check if the config // matches this rule. std::string config_upper = cmSystemTools::UpperCase(config); - for(std::vector<std::string>::const_iterator i = - this->Configurations.begin(); - i != this->Configurations.end(); ++i) - { - if(cmSystemTools::UpperCase(*i) == config_upper) - { + for (std::vector<std::string>::const_iterator i = + this->Configurations.begin(); + i != this->Configurations.end(); ++i) { + if (cmSystemTools::UpperCase(*i) == config_upper) { return true; - } } + } return false; } void cmScriptGenerator::GenerateScriptActionsOnce(std::ostream& os, Indent const& indent) { - if(this->Configurations.empty()) - { + if (this->Configurations.empty()) { // This rule is for all configurations. this->GenerateScriptActions(os, indent); - } - else - { + } else { // Generate a per-configuration block. std::string config_test = this->CreateConfigTest(this->Configurations); os << indent << "if(" << config_test << ")\n"; this->GenerateScriptActions(os, indent.Next()); os << indent << "endif(" << config_test << ")\n"; - } + } } void cmScriptGenerator::GenerateScriptActionsPerConfig(std::ostream& os, Indent const& indent) { - if(this->ConfigurationTypes->empty()) - { + if (this->ConfigurationTypes->empty()) { // In a single-configuration generator there is only one action // and it applies if the runtime-requested configuration is among // the rule's allowed configurations. The configuration built in // the tree does not matter for this decision but will be used to // generate proper target file names into the code. this->GenerateScriptActionsOnce(os, indent); - } - else - { + } else { // In a multi-configuration generator we produce a separate rule // in a block for each configuration that is built. We restrict // the list of configurations to those to which this rule applies. bool first = true; - for(std::vector<std::string>::const_iterator i = - this->ConfigurationTypes->begin(); - i != this->ConfigurationTypes->end(); ++i) - { + for (std::vector<std::string>::const_iterator i = + this->ConfigurationTypes->begin(); + i != this->ConfigurationTypes->end(); ++i) { const char* config = i->c_str(); - if(this->GeneratesForConfig(config)) - { + if (this->GeneratesForConfig(config)) { // Generate a per-configuration block. std::string config_test = this->CreateConfigTest(config); - os << indent << (first? "if(" : "elseif(") << config_test << ")\n"; + os << indent << (first ? "if(" : "elseif(") << config_test << ")\n"; this->GenerateScriptForConfig(os, config, indent.Next()); first = false; - } } - if(!first) - { - if(this->NeedsScriptNoConfig()) - { + } + if (!first) { + if (this->NeedsScriptNoConfig()) { os << indent << "else()\n"; this->GenerateScriptNoConfig(os, indent.Next()); - } - os << indent << "endif()\n"; } + os << indent << "endif()\n"; } + } } |