MCPcopy Create free account
hub / github.com/Kitware/CMake / ReplayItems

Method ReplayItems

Source/cmForEachCommand.cxx:110–150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

108}
109
110bool cmForEachFunctionBlocker::ReplayItems(
111 std::vector<cmListFileFunction> const& functions,
112 cmExecutionStatus& inStatus)
113{
114 assert("Unexpected number of iteration variables" &&
115 this->IterationVarsCount == 1);
116
117 auto& mf = inStatus.GetMakefile();
118
119 // At end of for each execute recorded commands
120 // store the old value
121 cm::optional<std::string> oldDef;
122 if (mf.GetPolicyStatus(cmPolicies::CMP0124) != cmPolicies::NEW) {
123 oldDef = mf.GetSafeDefinition(this->Args.front());
124 } else if (mf.IsNormalDefinitionSet(this->Args.front())) {
125 oldDef = *mf.GetDefinition(this->Args.front());
126 }
127
128 auto restore = false;
129 for (std::string const& arg : cmMakeRange(this->Args).advance(1)) {
130 // Set the variable to the loop value
131 mf.AddDefinition(this->Args.front(), arg);
132 // Invoke all the functions that were collected in the block.
133 auto r = this->invoke(functions, inStatus, mf);
134 restore = r.Restore;
135 if (r.Break) {
136 break;
137 }
138 }
139
140 if (restore) {
141 if (oldDef) {
142 // restore the variable to its prior value
143 mf.AddDefinition(this->Args.front(), *oldDef);
144 } else {
145 mf.RemoveDefinition(this->Args.front());
146 }
147 }
148
149 return true;
150}
151
152bool cmForEachFunctionBlocker::ReplayZipLists(
153 std::vector<cmListFileFunction> const& functions,

Callers 1

ReplayMethod · 0.95

Calls 10

invokeMethod · 0.95
cmMakeRangeFunction · 0.85
IsNormalDefinitionSetMethod · 0.80
GetMakefileMethod · 0.45
GetPolicyStatusMethod · 0.45
frontMethod · 0.45
GetDefinitionMethod · 0.45
advanceMethod · 0.45
AddDefinitionMethod · 0.45
RemoveDefinitionMethod · 0.45

Tested by

no test coverage detected