diff options
author | Brad King <brad.king@kitware.com> | 2015-05-01 17:16:16 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2015-05-01 17:16:16 (GMT) |
commit | 514640411a928c55509343017799df4a10a75d6d (patch) | |
tree | 03fed14217cba3907b1e4d9471d972fffa4f39fa /Source | |
parent | 5d6a7a1164188a0c28e3f5a37d0e33e952e0c8e4 (diff) | |
parent | e8ae46e5e228cc3008e64766e6c8da48b1835545 (diff) | |
download | CMake-514640411a928c55509343017799df4a10a75d6d.zip CMake-514640411a928c55509343017799df4a10a75d6d.tar.gz CMake-514640411a928c55509343017799df4a10a75d6d.tar.bz2 |
Merge topic 'refactor-RaiseScope'
e8ae46e5 cmMakefile: Implement RaiseScope without relying on Parent.
30a021cc cmMakefile: Implement RaiseScope in terms of local Get method.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmMakefile.cxx | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index bd42f4e..5686b1b 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -117,34 +117,38 @@ public: bool RaiseScope(std::string const& var, const char* varDef, cmMakefile* mf) { - cmDefinitions& cur = this->VarStack.back(); - if(cmDefinitions* up = cur.GetParent()) - { - // First localize the definition in the current scope. - cur.Get(var); + assert(this->VarStack.size() > 0); - // Now update the definition in the parent scope. - up->Set(var, varDef); - } - else if(cmLocalGenerator* plg = mf->GetLocalGenerator()->GetParent()) + std::list<cmDefinitions>::reverse_iterator it = this->VarStack.rbegin(); + ++it; + if(it == this->VarStack.rend()) { - // Update the definition in the parent directory top scope. This - // directory's scope was initialized by the closure of the parent - // scope, so we do not need to localize the definition first. - cmMakefile* parent = plg->GetMakefile(); - if (varDef) + if(cmLocalGenerator* plg = mf->GetLocalGenerator()->GetParent()) { - parent->AddDefinition(var, varDef); + // Update the definition in the parent directory top scope. This + // directory's scope was initialized by the closure of the parent + // scope, so we do not need to localize the definition first. + cmMakefile* parent = plg->GetMakefile(); + if (varDef) + { + parent->AddDefinition(var, varDef); + } + else + { + parent->RemoveDefinition(var); + } + return true; } else { - parent->RemoveDefinition(var); + return false; } } - else - { - return false; - } + // First localize the definition in the current scope. + this->GetDefinition(var); + + // Now update the definition in the parent scope. + it->Set(var, varDef); return true; } }; |