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

Function HandlePopBackCommand

Source/cmListCommand.cxx:197–244  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

195}
196
197bool HandlePopBackCommand(std::vector<std::string> const& args,
198 cmExecutionStatus& status)
199{
200 assert(args.size() >= 2);
201
202 cmMakefile& makefile = status.GetMakefile();
203 auto ai = args.cbegin();
204 ++ai; // Skip subcommand name
205 std::string const& listName = *ai++;
206 auto list = GetList(listName, makefile);
207
208 if (!list) {
209 // Can't get the list definition... undefine any vars given after.
210 for (; ai != args.cend(); ++ai) {
211 makefile.RemoveDefinition(*ai);
212 }
213 return true;
214 }
215
216 if (!list->empty()) {
217 if (ai == args.cend()) {
218 // No variables are given... Just remove one element.
219 list->pop_back();
220 } else {
221 // Ok, assign elements to be removed to the given variables
222 for (; !list->empty() && ai != args.cend(); ++ai) {
223 assert(!ai->empty());
224 makefile.AddDefinition(*ai, list->back());
225 list->pop_back();
226 }
227 // Undefine the rest variables if the list gets empty earlier...
228 for (; ai != args.cend(); ++ai) {
229 makefile.RemoveDefinition(*ai);
230 }
231 }
232
233 makefile.AddDefinition(listName, list->to_string());
234
235 } else if (ai !=
236 args.cend()) { // The list is empty, but some args were given
237 // Need to *undefine* 'em all, cuz there are no items to assign...
238 for (; ai != args.cend(); ++ai) {
239 makefile.RemoveDefinition(*ai);
240 }
241 }
242
243 return true;
244}
245
246bool HandlePopFrontCommand(std::vector<std::string> const& args,
247 cmExecutionStatus& status)

Callers

nothing calls this directly

Calls 11

cbeginMethod · 0.80
cendMethod · 0.80
pop_backMethod · 0.80
to_stringMethod · 0.80
GetListFunction · 0.70
sizeMethod · 0.45
GetMakefileMethod · 0.45
RemoveDefinitionMethod · 0.45
emptyMethod · 0.45
AddDefinitionMethod · 0.45
backMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…