From c619e353bd16a20981e62da04581c2aaac958529 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Thu, 18 Jan 2024 11:36:30 -0500 Subject: [PATCH] Remove one further macro. --- Analyser/Static/StaticAnalyser.cpp | 55 ++++++++++++++++-------------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/Analyser/Static/StaticAnalyser.cpp b/Analyser/Static/StaticAnalyser.cpp index d202ff6a2..32b5cfe38 100644 --- a/Analyser/Static/StaticAnalyser.cpp +++ b/Analyser/Static/StaticAnalyser.cpp @@ -303,10 +303,12 @@ Media Analyser::Static::GetMedia(const std::string &file_name) { } TargetList Analyser::Static::GetTargets(const std::string &file_name) { - TargetList targets; const std::string extension = get_extension(file_name); + TargetList targets; // Check whether the file directly identifies a target; if so then just return that. + + #define Format(ext, class) \ if(extension == ext) { \ try { \ @@ -333,30 +335,33 @@ TargetList Analyser::Static::GetTargets(const std::string &file_name) { // Hand off to platform-specific determination of whether these // things are actually compatible and, if so, how to load them. -#define Append(x) if(potential_platforms & TargetPlatform::x) {\ - auto new_targets = x::GetTargets(media, file_name, potential_platforms);\ - std::move(new_targets.begin(), new_targets.end(), std::back_inserter(targets));\ -} - Append(Acorn); - Append(AmstradCPC); - Append(AppleII); - Append(AppleIIgs); - Append(Amiga); - Append(Atari2600); - Append(AtariST); - Append(Coleco); - Append(Commodore); - Append(DiskII); - Append(Enterprise); - Append(FAT12); - Append(Macintosh); - Append(MSX); - Append(Oric); - Append(PCCompatible); - Append(Sega); - Append(ZX8081); - Append(ZXSpectrum); -#undef Append + const auto append = [&](TargetPlatform::IntType platform, auto evaluator) { + if(!(potential_platforms & platform)) { + return; + } + auto new_targets = evaluator(media, file_name, potential_platforms); + std::move(new_targets.begin(), new_targets.end(), std::back_inserter(targets)); + }; + + append(TargetPlatform::Acorn, Acorn::GetTargets); + append(TargetPlatform::AmstradCPC, AmstradCPC::GetTargets); + append(TargetPlatform::AppleII, AppleII::GetTargets); + append(TargetPlatform::AppleIIgs, AppleIIgs::GetTargets); + append(TargetPlatform::Amiga, Amiga::GetTargets); + append(TargetPlatform::Atari2600, Atari2600::GetTargets); + append(TargetPlatform::AtariST, AtariST::GetTargets); + append(TargetPlatform::Coleco, Coleco::GetTargets); + append(TargetPlatform::Commodore, Commodore::GetTargets); + append(TargetPlatform::DiskII, DiskII::GetTargets); + append(TargetPlatform::Enterprise, Enterprise::GetTargets); + append(TargetPlatform::FAT12, FAT12::GetTargets); + append(TargetPlatform::Macintosh, Macintosh::GetTargets); + append(TargetPlatform::MSX, MSX::GetTargets); + append(TargetPlatform::Oric, Oric::GetTargets); + append(TargetPlatform::PCCompatible, PCCompatible::GetTargets); + append(TargetPlatform::Sega, Sega::GetTargets); + append(TargetPlatform::ZX8081, ZX8081::GetTargets); + append(TargetPlatform::ZXSpectrum, ZXSpectrum::GetTargets); // Reset any tapes to their initial position. for(const auto &target : targets) {