Add macro group helper functions

This commit is contained in:
WarmUpTill
2025-12-09 18:54:14 +01:00
committed by WarmUpTill
parent 266e470509
commit 21c34356ed
4 changed files with 35 additions and 30 deletions

View File

@@ -117,6 +117,34 @@ GetMacroConditions(Macro *macro)
return macro->Conditions();
}
bool IsGroupMacro(Macro *macro)
{
return macro && macro->IsGroup();
}
std::vector<std::shared_ptr<Macro>> GetGroupMacroEntries(Macro *macro)
{
if (!macro || !macro->IsGroup()) {
return {};
}
std::vector<std::shared_ptr<Macro>> entries;
entries.reserve(macro->GroupSize());
const auto &macros = GetTopLevelMacros();
for (auto it = macros.begin(); it < macros.end(); it++) {
if ((*it)->Name() != macro->Name()) {
continue;
}
for (uint32_t i = 1; i <= macro->GroupSize(); i++) {
entries.emplace_back(*std::next(it, i));
}
break;
}
return entries;
}
std::condition_variable &GetMacroWaitCV()
{
static std::condition_variable cv;