Genex: Remove use of TransitiveWhitelistCompare

Replace with generic solution based on cmArray* for better
readability.
This commit is contained in:
Stephen Kelly 2013-10-22 01:12:24 +02:00
parent 73d7705416
commit 86d5d808c8
1 changed files with 9 additions and 21 deletions

View File

@ -703,17 +703,6 @@ std::string getLinkedTargetsContent(const std::vector<std::string> &libraries,
return linkedTargetsContent; return linkedTargetsContent;
} }
//----------------------------------------------------------------------------
struct TransitiveWhitelistCompare
{
explicit TransitiveWhitelistCompare(const std::string &needle)
: Needle(needle) {}
bool operator() (const char *item)
{ return strcmp(item, this->Needle.c_str()) == 0; }
private:
std::string Needle;
};
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
static const struct TargetPropertyNode : public cmGeneratorExpressionNode static const struct TargetPropertyNode : public cmGeneratorExpressionNode
{ {
@ -864,8 +853,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
return std::string(); return std::string();
case cmGeneratorExpressionDAGChecker::ALREADY_SEEN: case cmGeneratorExpressionDAGChecker::ALREADY_SEEN:
for (size_t i = 1; for (size_t i = 1;
i < (sizeof(targetPropertyTransitiveWhitelist) / i < cmArraySize(targetPropertyTransitiveWhitelist);
sizeof(*targetPropertyTransitiveWhitelist));
++i) ++i)
{ {
if (targetPropertyTransitiveWhitelist[i] == propertyName) if (targetPropertyTransitiveWhitelist[i] == propertyName)
@ -928,12 +916,13 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
cmTarget *headTarget = context->HeadTarget ? context->HeadTarget : target; cmTarget *headTarget = context->HeadTarget ? context->HeadTarget : target;
const char **transBegin = targetPropertyTransitiveWhitelist + 1; const char * const *transBegin =
const char **transEnd = targetPropertyTransitiveWhitelist cmArrayBegin(targetPropertyTransitiveWhitelist) + 1;
+ (sizeof(targetPropertyTransitiveWhitelist) / const char * const *transEnd =
sizeof(*targetPropertyTransitiveWhitelist)); cmArrayEnd(targetPropertyTransitiveWhitelist);
if (std::find_if(transBegin, transEnd, if (std::find_if(transBegin, transEnd,
TransitiveWhitelistCompare(propertyName)) != transEnd) cmStrCmp(propertyName)) != transEnd)
{ {
std::vector<std::string> libs; std::vector<std::string> libs;
@ -949,7 +938,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
} }
} }
else if (std::find_if(transBegin, transEnd, else if (std::find_if(transBegin, transEnd,
TransitiveWhitelistCompare(interfacePropertyName)) != transEnd) cmStrCmp(interfacePropertyName)) != transEnd)
{ {
const cmTarget::LinkImplementation *impl = target->GetLinkImplementation( const cmTarget::LinkImplementation *impl = target->GetLinkImplementation(
context->Config, context->Config,
@ -996,8 +985,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
} }
for (size_t i = 1; for (size_t i = 1;
i < (sizeof(targetPropertyTransitiveWhitelist) / i < cmArraySize(targetPropertyTransitiveWhitelist);
sizeof(*targetPropertyTransitiveWhitelist));
++i) ++i)
{ {
if (targetPropertyTransitiveWhitelist[i] == interfacePropertyName) if (targetPropertyTransitiveWhitelist[i] == interfacePropertyName)