MCPcopy Create free account
hub / github.com/WarmUpTill/SceneSwitcher / getParentMacro

Function getParentMacro

lib/utils/temp-variable.cpp:259–305  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

257}
258
259static Macro *getParentMacro(const Macro *targetMacro,
260 const std::vector<Macro *> &macros)
261{
262 if (!targetMacro) {
263 return nullptr;
264 }
265
266 if (macros.empty()) {
267 return nullptr;
268 }
269
270 std::vector<Macro *> newMacros;
271 for (const auto &macro : macros) {
272 for (const auto &action : macro->Actions()) {
273 const auto nestedMacroAction =
274 dynamic_cast<MacroActionMacro *>(action.get());
275 if (!nestedMacroAction) {
276 continue;
277 }
278
279 if (nestedMacroAction->_nestedMacro.get() ==
280 targetMacro) {
281 return nestedMacroAction->GetMacro();
282 }
283
284 newMacros.emplace_back(
285 nestedMacroAction->_nestedMacro.get());
286 }
287 for (const auto &action : macro->ElseActions()) {
288 const auto nestedMacroAction =
289 dynamic_cast<MacroActionMacro *>(action.get());
290 if (!nestedMacroAction) {
291 continue;
292 }
293
294 if (nestedMacroAction->_nestedMacro.get() ==
295 targetMacro) {
296 return nestedMacroAction->GetMacro();
297 }
298
299 newMacros.emplace_back(
300 nestedMacroAction->_nestedMacro.get());
301 }
302 }
303
304 return getParentMacro(targetMacro, newMacros);
305}
306
307static Macro *getParentMacro(const Macro *macro)
308{

Callers 3

getDepthFunction · 0.85
PostLoadMethod · 0.85
PopulateSelectionMethod · 0.85

Calls 4

sizeMethod · 0.80
emptyMethod · 0.45
getMethod · 0.45
GetMacroMethod · 0.45

Tested by

no test coverage detected