From d360b2c62dd45cacc251cc16c9e783abd38f05c3 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Tue, 23 Jan 2018 22:18:16 -0500 Subject: [PATCH] Standardises the static analyser on std::vector and slightly widens passageway to a machine. The SDL target would now be fooled by a hypothetical multi-target, the Mac not yet. --- Machines/Utility/MachineForTarget.cpp | 7 ++++--- Machines/Utility/MachineForTarget.hpp | 7 ++++--- .../Mac/Clock Signal.xcodeproj/project.pbxproj | 6 ++++-- .../Machine/StaticAnalyser/CSStaticAnalyser.mm | 15 +++++++-------- OSBindings/SDL/main.cpp | 4 ++-- StaticAnalyser/Acorn/Disk.cpp | 6 ++---- StaticAnalyser/Acorn/Disk.hpp | 2 +- StaticAnalyser/Acorn/File.hpp | 3 +-- StaticAnalyser/Acorn/StaticAnalyser.cpp | 10 +++++----- StaticAnalyser/Acorn/StaticAnalyser.hpp | 2 +- StaticAnalyser/Acorn/Tape.cpp | 4 ++-- StaticAnalyser/Acorn/Tape.hpp | 2 +- StaticAnalyser/AmstradCPC/StaticAnalyser.cpp | 2 +- StaticAnalyser/AmstradCPC/StaticAnalyser.hpp | 2 +- StaticAnalyser/Atari/StaticAnalyser.cpp | 2 +- StaticAnalyser/Atari/StaticAnalyser.hpp | 2 +- StaticAnalyser/Commodore/Disk.cpp | 4 ++-- StaticAnalyser/Commodore/Disk.hpp | 4 ++-- StaticAnalyser/Commodore/StaticAnalyser.cpp | 18 +++++++++--------- StaticAnalyser/Commodore/StaticAnalyser.hpp | 2 +- StaticAnalyser/Commodore/Tape.cpp | 4 ++-- StaticAnalyser/Commodore/Tape.hpp | 2 +- StaticAnalyser/MSX/StaticAnalyser.cpp | 8 ++++---- StaticAnalyser/MSX/StaticAnalyser.hpp | 2 +- StaticAnalyser/Oric/StaticAnalyser.cpp | 4 ++-- StaticAnalyser/Oric/StaticAnalyser.hpp | 2 +- StaticAnalyser/Oric/Tape.cpp | 4 ++-- StaticAnalyser/Oric/Tape.hpp | 2 +- StaticAnalyser/StaticAnalyser.cpp | 4 ++-- StaticAnalyser/StaticAnalyser.hpp | 9 ++++----- StaticAnalyser/ZX8081/StaticAnalyser.cpp | 2 +- StaticAnalyser/ZX8081/StaticAnalyser.hpp | 2 +- 32 files changed, 74 insertions(+), 75 deletions(-) diff --git a/Machines/Utility/MachineForTarget.cpp b/Machines/Utility/MachineForTarget.cpp index 730284163..ef96f1d15 100644 --- a/Machines/Utility/MachineForTarget.cpp +++ b/Machines/Utility/MachineForTarget.cpp @@ -18,15 +18,16 @@ #include "TypedDynamicMachine.hpp" -::Machine::DynamicMachine *::Machine::MachineForTarget(const StaticAnalyser::Target &target) { - switch(target.machine) { +::Machine::DynamicMachine *::Machine::MachineForTargets(const std::vector &targets) { + // TODO: deal with target lists containing more than one machine. + switch(targets.front().machine) { case StaticAnalyser::Target::AmstradCPC: return new TypedDynamicMachine(AmstradCPC::Machine::AmstradCPC()); case StaticAnalyser::Target::Atari2600: return new TypedDynamicMachine(Atari2600::Machine::Atari2600()); case StaticAnalyser::Target::Electron: return new TypedDynamicMachine(Electron::Machine::Electron()); case StaticAnalyser::Target::MSX: return new TypedDynamicMachine(MSX::Machine::MSX()); case StaticAnalyser::Target::Oric: return new TypedDynamicMachine(Oric::Machine::Oric()); case StaticAnalyser::Target::Vic20: return new TypedDynamicMachine(Commodore::Vic20::Machine::Vic20()); - case StaticAnalyser::Target::ZX8081: return new TypedDynamicMachine(ZX8081::Machine::ZX8081(target)); + case StaticAnalyser::Target::ZX8081: return new TypedDynamicMachine(ZX8081::Machine::ZX8081(targets.front())); default: return nullptr; } diff --git a/Machines/Utility/MachineForTarget.hpp b/Machines/Utility/MachineForTarget.hpp index 01f2c326a..95f0ef035 100644 --- a/Machines/Utility/MachineForTarget.hpp +++ b/Machines/Utility/MachineForTarget.hpp @@ -20,6 +20,7 @@ #include #include +#include namespace Machine { @@ -38,10 +39,10 @@ struct DynamicMachine { /*! Allocates an instance of DynamicMachine holding a machine that can - receive the supplied target. The machine has been allocated on the heap. - It is the caller's responsibility to delete the class when finished. + receive the supplied static analyser result. The machine has been allocated + on the heap. It is the caller's responsibility to delete the class when finished. */ -DynamicMachine *MachineForTarget(const StaticAnalyser::Target &target); +DynamicMachine *MachineForTargets(const std::vector &target); /*! Returns a short string name for the machine identified by the target, diff --git a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj index 42dd15821..cc7a17244 100644 --- a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj +++ b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj @@ -166,6 +166,7 @@ 4B2C45421E3C3896002A2389 /* cartridge.png in Resources */ = {isa = PBXBuildFile; fileRef = 4B2C45411E3C3896002A2389 /* cartridge.png */; }; 4B2E2D9A1C3A06EC00138695 /* Atari2600.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B2E2D971C3A06EC00138695 /* Atari2600.cpp */; }; 4B2E2D9D1C3A070400138695 /* Electron.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B2E2D9B1C3A070400138695 /* Electron.cpp */; }; + 4B2F67F12018312F00251FB5 /* Z80.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B9C9D731FF81CC00030A129 /* Z80.cpp */; }; 4B30512D1D989E2200B4FED8 /* Drive.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B30512B1D989E2200B4FED8 /* Drive.cpp */; }; 4B3051301D98ACC600B4FED8 /* Plus3.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B30512E1D98ACC600B4FED8 /* Plus3.cpp */; }; 4B322E011F5A2990004EB04C /* Z80AllRAM.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B322DFD1F5A2981004EB04C /* Z80AllRAM.cpp */; }; @@ -2848,13 +2849,13 @@ 4BF1354A1D6D2C300054B2EA /* StaticAnalyser.cpp */, 4BF1354B1D6D2C300054B2EA /* StaticAnalyser.hpp */, 4BD14B121D7462810088EAD6 /* Acorn */, + 4B38F3451F2EB41800D9235D /* AmstradCPC */, 4BA799961D8B65730045123D /* Atari */, 4BC830D21D6E7C6D0000A26F /* Commodore */, 4B5A12581DD55873007A2231 /* Disassembler */, + 4B0E04F01FC9E89100F43484 /* MSX */, 4BCF1FAC1DADD41F0039D2E7 /* Oric */, 4B14978C1EE4AC6200CE2596 /* ZX80/81 */, - 4B38F3451F2EB41800D9235D /* AmstradCPC */, - 4B0E04F01FC9E89100F43484 /* MSX */, ); name = StaticAnalyser; sourceTree = ""; @@ -3380,6 +3381,7 @@ 4B055A881FAE85530060FFFF /* 6502.cpp in Sources */, 4B055AED1FAE9BA20060FFFF /* Z80Storage.cpp in Sources */, 4B055AD11FAE9B030060FFFF /* Video.cpp in Sources */, + 4B2F67F12018312F00251FB5 /* Z80.cpp in Sources */, 4B055AA21FAE85DA0060FFFF /* SSD.cpp in Sources */, 4BEBFB4E2002C4BF000708CC /* MSXDSK.cpp in Sources */, 4B055ADD1FAE9B460060FFFF /* i8272.cpp in Sources */, diff --git a/OSBindings/Mac/Clock Signal/Machine/StaticAnalyser/CSStaticAnalyser.mm b/OSBindings/Mac/Clock Signal/Machine/StaticAnalyser/CSStaticAnalyser.mm index 8dcd7d18a..dd8661fcc 100644 --- a/OSBindings/Mac/Clock Signal/Machine/StaticAnalyser/CSStaticAnalyser.mm +++ b/OSBindings/Mac/Clock Signal/Machine/StaticAnalyser/CSStaticAnalyser.mm @@ -25,15 +25,14 @@ #import "Clock_Signal-Swift.h" @implementation CSStaticAnalyser { - StaticAnalyser::Target _target; + std::vector _targets; } - (instancetype)initWithFileAtURL:(NSURL *)url { self = [super init]; if(self) { - std::list targets = StaticAnalyser::GetTargets([url fileSystemRepresentation]); - if(!targets.size()) return nil; - _target = targets.front(); + _targets = StaticAnalyser::GetTargets([url fileSystemRepresentation]); + if(!_targets.size()) return nil; // TODO: can this better be supplied by the analyser? _displayName = [[url pathComponents] lastObject]; @@ -42,7 +41,7 @@ } - (NSString *)optionsPanelNibName { - switch(_target.machine) { + switch(_targets.front().machine) { case StaticAnalyser::Target::AmstradCPC: return nil; case StaticAnalyser::Target::Atari2600: return @"Atari2600Options"; case StaticAnalyser::Target::Electron: return @"QuickLoadCompositeOptions"; @@ -55,20 +54,20 @@ } - (CSMachine *)newMachine { - switch(_target.machine) { + switch(_targets.front().machine) { case StaticAnalyser::Target::AmstradCPC: return [[CSAmstradCPC alloc] init]; case StaticAnalyser::Target::Atari2600: return [[CSAtari2600 alloc] init]; case StaticAnalyser::Target::Electron: return [[CSElectron alloc] init]; case StaticAnalyser::Target::MSX: return [[CSMSX alloc] init]; case StaticAnalyser::Target::Oric: return [[CSOric alloc] init]; case StaticAnalyser::Target::Vic20: return [[CSVic20 alloc] init]; - case StaticAnalyser::Target::ZX8081: return [[CSZX8081 alloc] initWithIntendedTarget:_target]; + case StaticAnalyser::Target::ZX8081: return [[CSZX8081 alloc] initWithIntendedTarget:_targets.front()]; default: return nil; } } - (void)applyToMachine:(CSMachine *)machine { - [machine applyTarget:_target]; + [machine applyTarget:_targets.front()]; } @end diff --git a/OSBindings/SDL/main.cpp b/OSBindings/SDL/main.cpp index abcb46e77..d9faf5067 100644 --- a/OSBindings/SDL/main.cpp +++ b/OSBindings/SDL/main.cpp @@ -250,7 +250,7 @@ int main(int argc, char *argv[]) { } // Determine the machine for the supplied file. - std::list targets = StaticAnalyser::GetTargets(arguments.file_name.c_str()); + std::vector targets = StaticAnalyser::GetTargets(arguments.file_name.c_str()); if(targets.empty()) { std::cerr << "Cannot open " << arguments.file_name << std::endl; return -1; @@ -262,7 +262,7 @@ int main(int argc, char *argv[]) { SpeakerDelegate speaker_delegate; // Create and configure a machine. - std::unique_ptr<::Machine::DynamicMachine> machine(::Machine::MachineForTarget(targets.front())); + std::unique_ptr<::Machine::DynamicMachine> machine(::Machine::MachineForTargets(targets)); updater.set_clock_rate(machine->crt_machine()->get_clock_rate()); crt_delegate.best_effort_updater = &updater; diff --git a/StaticAnalyser/Acorn/Disk.cpp b/StaticAnalyser/Acorn/Disk.cpp index 228e5e9bc..1249cca36 100644 --- a/StaticAnalyser/Acorn/Disk.cpp +++ b/StaticAnalyser/Acorn/Disk.cpp @@ -41,9 +41,7 @@ std::unique_ptr StaticAnalyser::Acorn::GetDFSCatalogue(const std::sha case 3: catalogue->bootOption = Catalogue::BootOption::ExecBOOT; break; } - // DFS files are stored contiguously, and listed in descending order of distance from track 0. - // So iterating backwards implies the least amount of seeking. - for(std::size_t file_offset = final_file_offset - 8; file_offset > 0; file_offset -= 8) { + for(std::size_t file_offset = 8; file_offset < final_file_offset; file_offset += 8) { File new_file; char name[10]; snprintf(name, 10, "%c.%.7s", names->samples[0][file_offset + 7] & 0x7f, &names->samples[0][file_offset]); @@ -69,7 +67,7 @@ std::unique_ptr StaticAnalyser::Acorn::GetDFSCatalogue(const std::sha new_file.data.insert(new_file.data.end(), next_sector->samples[0].begin(), next_sector->samples[0].begin() + length_from_sector); data_length -= length_from_sector; } - if(!data_length) catalogue->files.push_front(new_file); + if(!data_length) catalogue->files.push_back(new_file); } return catalogue; diff --git a/StaticAnalyser/Acorn/Disk.hpp b/StaticAnalyser/Acorn/Disk.hpp index 43e6810c0..2bf33bcb8 100644 --- a/StaticAnalyser/Acorn/Disk.hpp +++ b/StaticAnalyser/Acorn/Disk.hpp @@ -18,7 +18,7 @@ namespace Acorn { /// Describes a DFS- or ADFS-format catalogue(/directory) — the list of files available and the catalogue's boot option. struct Catalogue { std::string name; - std::list files; + std::vector files; enum class BootOption { None, LoadBOOT, diff --git a/StaticAnalyser/Acorn/File.hpp b/StaticAnalyser/Acorn/File.hpp index 375137eff..d2cfeb59b 100644 --- a/StaticAnalyser/Acorn/File.hpp +++ b/StaticAnalyser/Acorn/File.hpp @@ -9,7 +9,6 @@ #ifndef StaticAnalyser_Acorn_File_hpp #define StaticAnalyser_Acorn_File_hpp -#include #include #include #include @@ -38,7 +37,7 @@ struct File { std::vector data; }; - std::list chunks; + std::vector chunks; }; } diff --git a/StaticAnalyser/Acorn/StaticAnalyser.cpp b/StaticAnalyser/Acorn/StaticAnalyser.cpp index ddcc86be4..b7ab067ca 100644 --- a/StaticAnalyser/Acorn/StaticAnalyser.cpp +++ b/StaticAnalyser/Acorn/StaticAnalyser.cpp @@ -13,9 +13,9 @@ using namespace StaticAnalyser::Acorn; -static std::list> - AcornCartridgesFrom(const std::list> &cartridges) { - std::list> acorn_cartridges; +static std::vector> + AcornCartridgesFrom(const std::vector> &cartridges) { + std::vector> acorn_cartridges; for(const auto &cartridge : cartridges) { const auto &segments = cartridge->get_segments(); @@ -56,7 +56,7 @@ static std::list> return acorn_cartridges; } -void StaticAnalyser::Acorn::AddTargets(const Media &media, std::list &destination) { +void StaticAnalyser::Acorn::AddTargets(const Media &media, std::vector &destination) { Target target; target.machine = Target::Electron; target.probability = 1.0; // TODO: a proper estimation @@ -70,7 +70,7 @@ void StaticAnalyser::Acorn::AddTargets(const Media &media, std::list &de // if there are any tapes, attempt to get data from the first if(media.tapes.size() > 0) { std::shared_ptr tape = media.tapes.front(); - std::list files = GetFiles(tape); + std::vector files = GetFiles(tape); tape->reset(); // continue if there are any files diff --git a/StaticAnalyser/Acorn/StaticAnalyser.hpp b/StaticAnalyser/Acorn/StaticAnalyser.hpp index c7ebbbf52..c578321b3 100644 --- a/StaticAnalyser/Acorn/StaticAnalyser.hpp +++ b/StaticAnalyser/Acorn/StaticAnalyser.hpp @@ -14,7 +14,7 @@ namespace StaticAnalyser { namespace Acorn { -void AddTargets(const Media &media, std::list &destination); +void AddTargets(const Media &media, std::vector &destination); } } diff --git a/StaticAnalyser/Acorn/Tape.cpp b/StaticAnalyser/Acorn/Tape.cpp index 5ef66673b..60cb030d5 100644 --- a/StaticAnalyser/Acorn/Tape.cpp +++ b/StaticAnalyser/Acorn/Tape.cpp @@ -118,7 +118,7 @@ static std::unique_ptr GetNextFile(std::deque &chunks) { return file; } -std::list StaticAnalyser::Acorn::GetFiles(const std::shared_ptr &tape) { +std::vector StaticAnalyser::Acorn::GetFiles(const std::shared_ptr &tape) { Storage::Tape::Acorn::Parser parser; // populate chunk list @@ -131,7 +131,7 @@ std::list StaticAnalyser::Acorn::GetFiles(const std::shared_ptr file_list; + std::vector file_list; while(chunk_list.size()) { std::unique_ptr next_file = GetNextFile(chunk_list); diff --git a/StaticAnalyser/Acorn/Tape.hpp b/StaticAnalyser/Acorn/Tape.hpp index ac13b6ab3..3f16aad1d 100644 --- a/StaticAnalyser/Acorn/Tape.hpp +++ b/StaticAnalyser/Acorn/Tape.hpp @@ -17,7 +17,7 @@ namespace StaticAnalyser { namespace Acorn { -std::list GetFiles(const std::shared_ptr &tape); +std::vector GetFiles(const std::shared_ptr &tape); } } diff --git a/StaticAnalyser/AmstradCPC/StaticAnalyser.cpp b/StaticAnalyser/AmstradCPC/StaticAnalyser.cpp index ea2f5c1fd..5fa6bc977 100644 --- a/StaticAnalyser/AmstradCPC/StaticAnalyser.cpp +++ b/StaticAnalyser/AmstradCPC/StaticAnalyser.cpp @@ -177,7 +177,7 @@ static bool CheckBootSector(const std::shared_ptr &disk, St return false; } -void StaticAnalyser::AmstradCPC::AddTargets(const Media &media, std::list &destination) { +void StaticAnalyser::AmstradCPC::AddTargets(const Media &media, std::vector &destination) { Target target; target.machine = Target::AmstradCPC; target.probability = 1.0; diff --git a/StaticAnalyser/AmstradCPC/StaticAnalyser.hpp b/StaticAnalyser/AmstradCPC/StaticAnalyser.hpp index 03811a376..1f91e58bb 100644 --- a/StaticAnalyser/AmstradCPC/StaticAnalyser.hpp +++ b/StaticAnalyser/AmstradCPC/StaticAnalyser.hpp @@ -14,7 +14,7 @@ namespace StaticAnalyser { namespace AmstradCPC { -void AddTargets(const Media &media, std::list &destination); +void AddTargets(const Media &media, std::vector &destination); } } diff --git a/StaticAnalyser/Atari/StaticAnalyser.cpp b/StaticAnalyser/Atari/StaticAnalyser.cpp index 7490c7861..fb36d427f 100644 --- a/StaticAnalyser/Atari/StaticAnalyser.cpp +++ b/StaticAnalyser/Atari/StaticAnalyser.cpp @@ -178,7 +178,7 @@ static void DeterminePagingForCartridge(StaticAnalyser::Target &target, const St } } -void StaticAnalyser::Atari::AddTargets(const Media &media, std::list &destination) { +void StaticAnalyser::Atari::AddTargets(const Media &media, std::vector &destination) { // TODO: sanity checking; is this image really for an Atari 2600. Target target; target.machine = Target::Atari2600; diff --git a/StaticAnalyser/Atari/StaticAnalyser.hpp b/StaticAnalyser/Atari/StaticAnalyser.hpp index 6276583c0..866e4bead 100644 --- a/StaticAnalyser/Atari/StaticAnalyser.hpp +++ b/StaticAnalyser/Atari/StaticAnalyser.hpp @@ -14,7 +14,7 @@ namespace StaticAnalyser { namespace Atari { -void AddTargets(const Media &media, std::list &destination); +void AddTargets(const Media &media, std::vector &destination); } } diff --git a/StaticAnalyser/Commodore/Disk.cpp b/StaticAnalyser/Commodore/Disk.cpp index bef7e6e9e..1af2fedb2 100644 --- a/StaticAnalyser/Commodore/Disk.cpp +++ b/StaticAnalyser/Commodore/Disk.cpp @@ -165,8 +165,8 @@ class CommodoreGCRParser: public Storage::Disk::Controller { } }; -std::list StaticAnalyser::Commodore::GetFiles(const std::shared_ptr &disk) { - std::list files; +std::vector StaticAnalyser::Commodore::GetFiles(const std::shared_ptr &disk) { + std::vector files; CommodoreGCRParser parser; parser.drive->set_disk(disk); diff --git a/StaticAnalyser/Commodore/Disk.hpp b/StaticAnalyser/Commodore/Disk.hpp index 373d00124..ab1d8a0a2 100644 --- a/StaticAnalyser/Commodore/Disk.hpp +++ b/StaticAnalyser/Commodore/Disk.hpp @@ -11,12 +11,12 @@ #include "../../Storage/Disk/Disk.hpp" #include "File.hpp" -#include +#include namespace StaticAnalyser { namespace Commodore { -std::list GetFiles(const std::shared_ptr &disk); +std::vector GetFiles(const std::shared_ptr &disk); } } diff --git a/StaticAnalyser/Commodore/StaticAnalyser.cpp b/StaticAnalyser/Commodore/StaticAnalyser.cpp index 921b399b1..9f98b4c7c 100644 --- a/StaticAnalyser/Commodore/StaticAnalyser.cpp +++ b/StaticAnalyser/Commodore/StaticAnalyser.cpp @@ -17,9 +17,9 @@ using namespace StaticAnalyser::Commodore; -static std::list> - Vic20CartridgesFrom(const std::list> &cartridges) { - std::list> vic20_cartridges; +static std::vector> + Vic20CartridgesFrom(const std::vector> &cartridges) { + std::vector> vic20_cartridges; for(const auto &cartridge : cartridges) { const auto &segments = cartridge->get_segments(); @@ -38,13 +38,13 @@ static std::list> return vic20_cartridges; } -void StaticAnalyser::Commodore::AddTargets(const Media &media, std::list &destination) { +void StaticAnalyser::Commodore::AddTargets(const Media &media, std::vector &destination) { Target target; target.machine = Target::Vic20; // TODO: machine estimation target.probability = 1.0; // TODO: a proper estimation int device = 0; - std::list files; + std::vector files; bool is_disk = false; // strip out inappropriate cartridges @@ -52,10 +52,10 @@ void StaticAnalyser::Commodore::AddTargets(const Media &media, std::list // check disks for(auto &disk : media.disks) { - std::list disk_files = GetFiles(disk); + std::vector disk_files = GetFiles(disk); if(!disk_files.empty()) { is_disk = true; - files.splice(files.end(), disk_files); + files.insert(files.end(), disk_files.begin(), disk_files.end()); target.media.disks.push_back(disk); if(!device) device = 8; } @@ -63,10 +63,10 @@ void StaticAnalyser::Commodore::AddTargets(const Media &media, std::list // check tapes for(auto &tape : media.tapes) { - std::list tape_files = GetFiles(tape); + std::vector tape_files = GetFiles(tape); tape->reset(); if(!tape_files.empty()) { - files.splice(files.end(), tape_files); + files.insert(files.end(), tape_files.begin(), tape_files.end()); target.media.tapes.push_back(tape); if(!device) device = 1; } diff --git a/StaticAnalyser/Commodore/StaticAnalyser.hpp b/StaticAnalyser/Commodore/StaticAnalyser.hpp index df845c972..536560f7f 100644 --- a/StaticAnalyser/Commodore/StaticAnalyser.hpp +++ b/StaticAnalyser/Commodore/StaticAnalyser.hpp @@ -14,7 +14,7 @@ namespace StaticAnalyser { namespace Commodore { -void AddTargets(const Media &media, std::list &destination); +void AddTargets(const Media &media, std::vector &destination); } } diff --git a/StaticAnalyser/Commodore/Tape.cpp b/StaticAnalyser/Commodore/Tape.cpp index 9f667bf76..9e20774c1 100644 --- a/StaticAnalyser/Commodore/Tape.cpp +++ b/StaticAnalyser/Commodore/Tape.cpp @@ -12,9 +12,9 @@ using namespace StaticAnalyser::Commodore; -std::list StaticAnalyser::Commodore::GetFiles(const std::shared_ptr &tape) { +std::vector StaticAnalyser::Commodore::GetFiles(const std::shared_ptr &tape) { Storage::Tape::Commodore::Parser parser; - std::list file_list; + std::vector file_list; std::unique_ptr header = parser.get_next_header(tape); diff --git a/StaticAnalyser/Commodore/Tape.hpp b/StaticAnalyser/Commodore/Tape.hpp index 8318b0837..fef2130b0 100644 --- a/StaticAnalyser/Commodore/Tape.hpp +++ b/StaticAnalyser/Commodore/Tape.hpp @@ -16,7 +16,7 @@ namespace StaticAnalyser { namespace Commodore { -std::list GetFiles(const std::shared_ptr &tape); +std::vector GetFiles(const std::shared_ptr &tape); } } diff --git a/StaticAnalyser/MSX/StaticAnalyser.cpp b/StaticAnalyser/MSX/StaticAnalyser.cpp index 3de0bcfc4..7946a1c15 100644 --- a/StaticAnalyser/MSX/StaticAnalyser.cpp +++ b/StaticAnalyser/MSX/StaticAnalyser.cpp @@ -24,9 +24,9 @@ DEFW basic ; pointer to the start of a tokenized basicprogram, 0 if no basicprogram DEFS 6,0 ; room reserved for future extensions */ -static std::list> - MSXCartridgesFrom(const std::list> &cartridges, StaticAnalyser::Target &target) { - std::list> msx_cartridges; +static std::vector> + MSXCartridgesFrom(const std::vector> &cartridges, StaticAnalyser::Target &target) { + std::vector> msx_cartridges; for(const auto &cartridge : cartridges) { const auto &segments = cartridge->get_segments(); @@ -200,7 +200,7 @@ static std::list> return msx_cartridges; } -void StaticAnalyser::MSX::AddTargets(const Media &media, std::list &destination) { +void StaticAnalyser::MSX::AddTargets(const Media &media, std::vector &destination) { Target target; // Obtain only those cartridges which it looks like an MSX would understand. diff --git a/StaticAnalyser/MSX/StaticAnalyser.hpp b/StaticAnalyser/MSX/StaticAnalyser.hpp index 354fd2d7c..22bed2c79 100644 --- a/StaticAnalyser/MSX/StaticAnalyser.hpp +++ b/StaticAnalyser/MSX/StaticAnalyser.hpp @@ -14,7 +14,7 @@ namespace StaticAnalyser { namespace MSX { -void AddTargets(const Media &media, std::list &destination); +void AddTargets(const Media &media, std::vector &destination); } } diff --git a/StaticAnalyser/Oric/StaticAnalyser.cpp b/StaticAnalyser/Oric/StaticAnalyser.cpp index 09ec12734..1aea8e986 100644 --- a/StaticAnalyser/Oric/StaticAnalyser.cpp +++ b/StaticAnalyser/Oric/StaticAnalyser.cpp @@ -73,7 +73,7 @@ static int Basic11Score(const StaticAnalyser::MOS6502::Disassembly &disassembly) return Score(disassembly, rom_functions, variable_locations); } -void StaticAnalyser::Oric::AddTargets(const Media &media, std::list &destination) { +void StaticAnalyser::Oric::AddTargets(const Media &media, std::vector &destination) { Target target; target.machine = Target::Oric; target.probability = 1.0; @@ -82,7 +82,7 @@ void StaticAnalyser::Oric::AddTargets(const Media &media, std::list &des int basic11_votes = 0; for(auto &tape : media.tapes) { - std::list tape_files = GetFiles(tape); + std::vector tape_files = GetFiles(tape); tape->reset(); if(tape_files.size()) { for(auto file : tape_files) { diff --git a/StaticAnalyser/Oric/StaticAnalyser.hpp b/StaticAnalyser/Oric/StaticAnalyser.hpp index 3b660367f..53a1f6085 100644 --- a/StaticAnalyser/Oric/StaticAnalyser.hpp +++ b/StaticAnalyser/Oric/StaticAnalyser.hpp @@ -14,7 +14,7 @@ namespace StaticAnalyser { namespace Oric { -void AddTargets(const Media &media, std::list &destination); +void AddTargets(const Media &media, std::vector &destination); } } diff --git a/StaticAnalyser/Oric/Tape.cpp b/StaticAnalyser/Oric/Tape.cpp index 7a45d029f..7e1aeefd6 100644 --- a/StaticAnalyser/Oric/Tape.cpp +++ b/StaticAnalyser/Oric/Tape.cpp @@ -11,8 +11,8 @@ using namespace StaticAnalyser::Oric; -std::list StaticAnalyser::Oric::GetFiles(const std::shared_ptr &tape) { - std::list files; +std::vector StaticAnalyser::Oric::GetFiles(const std::shared_ptr &tape) { + std::vector files; Storage::Tape::Oric::Parser parser; while(!tape->is_at_end()) { diff --git a/StaticAnalyser/Oric/Tape.hpp b/StaticAnalyser/Oric/Tape.hpp index b8d0f39db..00073df6d 100644 --- a/StaticAnalyser/Oric/Tape.hpp +++ b/StaticAnalyser/Oric/Tape.hpp @@ -30,7 +30,7 @@ struct File { std::vector data; }; -std::list GetFiles(const std::shared_ptr &tape); +std::vector GetFiles(const std::shared_ptr &tape); } } diff --git a/StaticAnalyser/StaticAnalyser.cpp b/StaticAnalyser/StaticAnalyser.cpp index ce9214b9d..eb63f3b7b 100644 --- a/StaticAnalyser/StaticAnalyser.cpp +++ b/StaticAnalyser/StaticAnalyser.cpp @@ -139,8 +139,8 @@ Media StaticAnalyser::GetMedia(const char *file_name) { return GetMediaAndPlatforms(file_name, throwaway); } -std::list StaticAnalyser::GetTargets(const char *file_name) { - std::list targets; +std::vector StaticAnalyser::GetTargets(const char *file_name) { + std::vector targets; // Collect all disks, tapes and ROMs as can be extrapolated from this file, forming the // union of all platforms this file might be a target for. diff --git a/StaticAnalyser/StaticAnalyser.hpp b/StaticAnalyser/StaticAnalyser.hpp index b4bcee655..3b44864ba 100644 --- a/StaticAnalyser/StaticAnalyser.hpp +++ b/StaticAnalyser/StaticAnalyser.hpp @@ -14,7 +14,6 @@ #include "../Storage/Cartridge/Cartridge.hpp" #include -#include #include namespace StaticAnalyser { @@ -65,9 +64,9 @@ enum class AmstradCPCModel { A list of disks, tapes and cartridges. */ struct Media { - std::list> disks; - std::list> tapes; - std::list> cartridges; + std::vector> disks; + std::vector> tapes; + std::vector> cartridges; bool empty() const { return disks.empty() && tapes.empty() && cartridges.empty(); @@ -137,7 +136,7 @@ struct Target { @returns The list of potential targets, sorted from most to least probable. */ -std::list GetTargets(const char *file_name); +std::vector GetTargets(const char *file_name); /*! Inspects the supplied file and determines the media included. diff --git a/StaticAnalyser/ZX8081/StaticAnalyser.cpp b/StaticAnalyser/ZX8081/StaticAnalyser.cpp index 02fe4c37f..464bc6041 100644 --- a/StaticAnalyser/ZX8081/StaticAnalyser.cpp +++ b/StaticAnalyser/ZX8081/StaticAnalyser.cpp @@ -27,7 +27,7 @@ static std::vector GetFiles(const std::shared_ptr &destination, TargetPlatform::IntType potential_platforms) { +void StaticAnalyser::ZX8081::AddTargets(const Media &media, std::vector &destination, TargetPlatform::IntType potential_platforms) { if(!media.tapes.empty()) { std::vector files = GetFiles(media.tapes.front()); media.tapes.front()->reset(); diff --git a/StaticAnalyser/ZX8081/StaticAnalyser.hpp b/StaticAnalyser/ZX8081/StaticAnalyser.hpp index 3212f4c53..4cc381c46 100644 --- a/StaticAnalyser/ZX8081/StaticAnalyser.hpp +++ b/StaticAnalyser/ZX8081/StaticAnalyser.hpp @@ -15,7 +15,7 @@ namespace StaticAnalyser { namespace ZX8081 { -void AddTargets(const Media &media, std::list &destination, TargetPlatform::IntType potential_platforms); +void AddTargets(const Media &media, std::vector &destination, TargetPlatform::IntType potential_platforms); } }