summaryrefslogtreecommitdiffstats
path: root/Source/cmGeneratorExpressionParser.cxx
diff options
context:
space:
mode:
authorKitware Robot <kwrobot@kitware.com>2016-05-16 14:34:04 (GMT)
committerBrad King <brad.king@kitware.com>2016-05-16 20:05:19 (GMT)
commitd9fd2f5402eeaa345691313658e02b51038f570b (patch)
treedca71b9a7e267f4c6300da3eb770415381726785 /Source/cmGeneratorExpressionParser.cxx
parent82df6deaafb36cbbfd450202bb20b320f637751a (diff)
downloadCMake-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/cmGeneratorExpressionParser.cxx')
-rw-r--r--Source/cmGeneratorExpressionParser.cxx235
1 files changed, 100 insertions, 135 deletions
diff --git a/Source/cmGeneratorExpressionParser.cxx b/Source/cmGeneratorExpressionParser.cxx
index f59405c..f853f8d 100644
--- a/Source/cmGeneratorExpressionParser.cxx
+++ b/Source/cmGeneratorExpressionParser.cxx
@@ -17,51 +17,48 @@
#include "assert.h"
cmGeneratorExpressionParser::cmGeneratorExpressionParser(
- const std::vector<cmGeneratorExpressionToken> &tokens)
- : Tokens(tokens), NestingLevel(0)
+ const std::vector<cmGeneratorExpressionToken>& tokens)
+ : Tokens(tokens)
+ , NestingLevel(0)
{
}
void cmGeneratorExpressionParser::Parse(
- std::vector<cmGeneratorExpressionEvaluator*> &result)
+ std::vector<cmGeneratorExpressionEvaluator*>& result)
{
it = this->Tokens.begin();
- while (this->it != this->Tokens.end())
- {
+ while (this->it != this->Tokens.end()) {
this->ParseContent(result);
- }
+ }
}
-static void extendText(std::vector<cmGeneratorExpressionEvaluator*> &result,
- std::vector<cmGeneratorExpressionToken>::const_iterator it)
+static void extendText(
+ std::vector<cmGeneratorExpressionEvaluator*>& result,
+ std::vector<cmGeneratorExpressionToken>::const_iterator it)
{
- if (!result.empty()
- && (*(result.end() - 1))->GetType()
- == cmGeneratorExpressionEvaluator::Text)
- {
- TextContent *textContent = static_cast<TextContent*>(*(result.end() - 1));
+ if (!result.empty() &&
+ (*(result.end() - 1))->GetType() ==
+ cmGeneratorExpressionEvaluator::Text) {
+ TextContent* textContent = static_cast<TextContent*>(*(result.end() - 1));
textContent->Extend(it->Length);
- }
- else
- {
- TextContent *textContent = new TextContent(it->Content, it->Length);
+ } else {
+ TextContent* textContent = new TextContent(it->Content, it->Length);
result.push_back(textContent);
- }
+ }
}
-static void extendResult(std::vector<cmGeneratorExpressionEvaluator*> &result,
- const std::vector<cmGeneratorExpressionEvaluator*> &contents)
+static void extendResult(
+ std::vector<cmGeneratorExpressionEvaluator*>& result,
+ const std::vector<cmGeneratorExpressionEvaluator*>& contents)
{
- if (!result.empty()
- && (*(result.end() - 1))->GetType()
- == cmGeneratorExpressionEvaluator::Text
- && (*contents.begin())->GetType()
- == cmGeneratorExpressionEvaluator::Text)
- {
- TextContent *textContent = static_cast<TextContent*>(*(result.end() - 1));
+ if (!result.empty() &&
+ (*(result.end() - 1))->GetType() ==
+ cmGeneratorExpressionEvaluator::Text &&
+ (*contents.begin())->GetType() == cmGeneratorExpressionEvaluator::Text) {
+ TextContent* textContent = static_cast<TextContent*>(*(result.end() - 1));
textContent->Extend(
- static_cast<TextContent*>(*contents.begin())->GetLength());
+ static_cast<TextContent*>(*contents.begin())->GetLength());
delete *contents.begin();
result.insert(result.end(), contents.begin() + 1, contents.end());
} else {
@@ -70,207 +67,178 @@ static void extendResult(std::vector<cmGeneratorExpressionEvaluator*> &result,
}
void cmGeneratorExpressionParser::ParseGeneratorExpression(
- std::vector<cmGeneratorExpressionEvaluator*> &result)
+ std::vector<cmGeneratorExpressionEvaluator*>& result)
{
assert(this->it != this->Tokens.end());
unsigned int nestedLevel = this->NestingLevel;
++this->NestingLevel;
- std::vector<cmGeneratorExpressionToken>::const_iterator startToken
- = this->it - 1;
+ std::vector<cmGeneratorExpressionToken>::const_iterator startToken =
+ this->it - 1;
std::vector<cmGeneratorExpressionEvaluator*> identifier;
- while(this->it->TokenType != cmGeneratorExpressionToken::EndExpression
- && this->it->TokenType != cmGeneratorExpressionToken::ColonSeparator)
- {
- if (this->it->TokenType == cmGeneratorExpressionToken::CommaSeparator)
- {
+ while (this->it->TokenType != cmGeneratorExpressionToken::EndExpression &&
+ this->it->TokenType != cmGeneratorExpressionToken::ColonSeparator) {
+ if (this->it->TokenType == cmGeneratorExpressionToken::CommaSeparator) {
extendText(identifier, this->it);
++this->it;
- }
- else
- {
+ } else {
this->ParseContent(identifier);
- }
- if (this->it == this->Tokens.end())
- {
+ }
+ if (this->it == this->Tokens.end()) {
break;
- }
}
- if (identifier.empty())
- {
+ }
+ if (identifier.empty()) {
// ERROR
- }
+ }
if (this->it != this->Tokens.end() &&
- this->it->TokenType == cmGeneratorExpressionToken::EndExpression)
- {
- GeneratorExpressionContent *content = new GeneratorExpressionContent(
- startToken->Content, this->it->Content
- - startToken->Content
- + this->it->Length);
+ this->it->TokenType == cmGeneratorExpressionToken::EndExpression) {
+ GeneratorExpressionContent* content =
+ new GeneratorExpressionContent(startToken->Content, this->it->Content -
+ startToken->Content + this->it->Length);
assert(this->it != this->Tokens.end());
++this->it;
--this->NestingLevel;
content->SetIdentifier(identifier);
result.push_back(content);
return;
- }
+ }
std::vector<std::vector<cmGeneratorExpressionEvaluator*> > parameters;
std::vector<std::vector<cmGeneratorExpressionToken>::const_iterator>
- commaTokens;
+ commaTokens;
std::vector<cmGeneratorExpressionToken>::const_iterator colonToken;
bool emptyParamTermination = false;
if (this->it != this->Tokens.end() &&
- this->it->TokenType == cmGeneratorExpressionToken::ColonSeparator)
- {
+ this->it->TokenType == cmGeneratorExpressionToken::ColonSeparator) {
colonToken = this->it;
parameters.resize(parameters.size() + 1);
assert(this->it != this->Tokens.end());
++this->it;
- if(this->it == this->Tokens.end())
- {
+ if (this->it == this->Tokens.end()) {
emptyParamTermination = true;
- }
+ }
while (this->it != this->Tokens.end() &&
- this->it->TokenType == cmGeneratorExpressionToken::CommaSeparator)
- {
+ this->it->TokenType == cmGeneratorExpressionToken::CommaSeparator) {
commaTokens.push_back(this->it);
parameters.resize(parameters.size() + 1);
assert(this->it != this->Tokens.end());
++this->it;
- if(this->it == this->Tokens.end())
- {
+ if (this->it == this->Tokens.end()) {
emptyParamTermination = true;
- }
}
+ }
while (this->it != this->Tokens.end() &&
- this->it->TokenType == cmGeneratorExpressionToken::ColonSeparator)
- {
+ this->it->TokenType == cmGeneratorExpressionToken::ColonSeparator) {
extendText(*(parameters.end() - 1), this->it);
assert(this->it != this->Tokens.end());
++this->it;
- }
+ }
while (this->it != this->Tokens.end() &&
- this->it->TokenType != cmGeneratorExpressionToken::EndExpression)
- {
+ this->it->TokenType != cmGeneratorExpressionToken::EndExpression) {
this->ParseContent(*(parameters.end() - 1));
- if (this->it == this->Tokens.end())
- {
+ if (this->it == this->Tokens.end()) {
break;
- }
+ }
while (this->it != this->Tokens.end() &&
- this->it->TokenType == cmGeneratorExpressionToken::CommaSeparator)
- {
+ this->it->TokenType ==
+ cmGeneratorExpressionToken::CommaSeparator) {
commaTokens.push_back(this->it);
parameters.resize(parameters.size() + 1);
assert(this->it != this->Tokens.end());
++this->it;
- if(this->it == this->Tokens.end())
- {
+ if (this->it == this->Tokens.end()) {
emptyParamTermination = true;
- }
}
+ }
while (this->it != this->Tokens.end() &&
- this->it->TokenType == cmGeneratorExpressionToken::ColonSeparator)
- {
+ this->it->TokenType ==
+ cmGeneratorExpressionToken::ColonSeparator) {
extendText(*(parameters.end() - 1), this->it);
assert(this->it != this->Tokens.end());
++this->it;
- }
}
- if(this->it != this->Tokens.end()
- && this->it->TokenType == cmGeneratorExpressionToken::EndExpression)
- {
- --this->NestingLevel;
- assert(this->it != this->Tokens.end());
- ++this->it;
- }
}
+ if (this->it != this->Tokens.end() &&
+ this->it->TokenType == cmGeneratorExpressionToken::EndExpression) {
+ --this->NestingLevel;
+ assert(this->it != this->Tokens.end());
+ ++this->it;
+ }
+ }
- if (nestedLevel != this->NestingLevel)
- {
+ if (nestedLevel != this->NestingLevel) {
// There was a '$<' in the text, but no corresponding '>'. Rebuild to
// treat the '$<' as having been plain text, along with the
// corresponding : and , tokens that might have been found.
extendText(result, startToken);
extendResult(result, identifier);
- if (!parameters.empty())
- {
+ if (!parameters.empty()) {
extendText(result, colonToken);
typedef std::vector<cmGeneratorExpressionEvaluator*> EvaluatorVector;
typedef std::vector<cmGeneratorExpressionToken> TokenVector;
std::vector<EvaluatorVector>::const_iterator pit = parameters.begin();
const std::vector<EvaluatorVector>::const_iterator pend =
- parameters.end();
+ parameters.end();
std::vector<TokenVector::const_iterator>::const_iterator commaIt =
- commaTokens.begin();
+ commaTokens.begin();
assert(parameters.size() > commaTokens.size());
- for ( ; pit != pend; ++pit, ++commaIt)
- {
- if (!pit->empty() && !emptyParamTermination)
- {
+ for (; pit != pend; ++pit, ++commaIt) {
+ if (!pit->empty() && !emptyParamTermination) {
extendResult(result, *pit);
- }
- if (commaIt != commaTokens.end())
- {
+ }
+ if (commaIt != commaTokens.end()) {
extendText(result, *commaIt);
- }
- else
- {
+ } else {
break;
- }
}
}
+ }
return;
}
- size_t contentLength = ((this->it - 1)->Content
- - startToken->Content)
- + (this->it - 1)->Length;
- GeneratorExpressionContent *content = new GeneratorExpressionContent(
- startToken->Content, contentLength);
+ size_t contentLength =
+ ((this->it - 1)->Content - startToken->Content) + (this->it - 1)->Length;
+ GeneratorExpressionContent* content =
+ new GeneratorExpressionContent(startToken->Content, contentLength);
content->SetIdentifier(identifier);
content->SetParameters(parameters);
result.push_back(content);
}
void cmGeneratorExpressionParser::ParseContent(
- std::vector<cmGeneratorExpressionEvaluator*> &result)
+ std::vector<cmGeneratorExpressionEvaluator*>& result)
{
assert(this->it != this->Tokens.end());
- switch(this->it->TokenType)
- {
- case cmGeneratorExpressionToken::Text:
- {
- if (this->NestingLevel == 0)
- {
- if (!result.empty()
- && (*(result.end() - 1))->GetType()
- == cmGeneratorExpressionEvaluator::Text)
- {
+ switch (this->it->TokenType) {
+ case cmGeneratorExpressionToken::Text: {
+ if (this->NestingLevel == 0) {
+ if (!result.empty() &&
+ (*(result.end() - 1))->GetType() ==
+ cmGeneratorExpressionEvaluator::Text) {
// A comma in 'plain text' could have split text that should
// otherwise be continuous. Extend the last text content instead of
// creating a new one.
- TextContent *textContent =
- static_cast<TextContent*>(*(result.end() - 1));
+ TextContent* textContent =
+ static_cast<TextContent*>(*(result.end() - 1));
textContent->Extend(this->it->Length);
assert(this->it != this->Tokens.end());
++this->it;
return;
- }
}
- cmGeneratorExpressionEvaluator* n = new TextContent(this->it->Content,
- this->it->Length);
+ }
+ cmGeneratorExpressionEvaluator* n =
+ new TextContent(this->it->Content, this->it->Length);
result.push_back(n);
assert(this->it != this->Tokens.end());
++this->it;
- return ;
+ return;
}
case cmGeneratorExpressionToken::BeginExpression:
assert(this->it != this->Tokens.end());
@@ -280,17 +248,14 @@ void cmGeneratorExpressionParser::ParseContent(
case cmGeneratorExpressionToken::EndExpression:
case cmGeneratorExpressionToken::ColonSeparator:
case cmGeneratorExpressionToken::CommaSeparator:
- if (this->NestingLevel == 0)
- {
+ if (this->NestingLevel == 0) {
extendText(result, this->it);
- }
- else
- {
- assert(0 && "Got unexpected syntax token.");
- }
+ } else {
+ assert(0 && "Got unexpected syntax token.");
+ }
assert(this->it != this->Tokens.end());
++this->it;
return;
- }
- assert(0 && "Unhandled token in generator expression.");
+ }
+ assert(0 && "Unhandled token in generator expression.");
}