From 5eedbe1225967f2b324a4565b5b4ad6e60f0e3ea Mon Sep 17 00:00:00 2001 From: Adrian Conlon Date: Sat, 2 May 2020 11:36:43 +0100 Subject: [PATCH] Make better use of modern c++ Signed-off-by: Adrian Conlon --- inc/BigEndianProcessor.h | 2 +- inc/Chip.h | 4 ++-- inc/ClockedChip.h | 2 +- inc/Device.h | 4 ++-- inc/InputOutput.h | 2 -- inc/IntelHexFile.h | 2 +- inc/IntelProcessor.h | 2 +- inc/LittleEndianProcessor.h | 2 +- inc/MemoryMapping.h | 2 +- inc/Processor.h | 2 +- src/Chip.cpp | 6 ------ src/EightBit.vcxproj | 1 - src/EightBit.vcxproj.filters | 3 --- 13 files changed, 11 insertions(+), 23 deletions(-) delete mode 100644 src/Chip.cpp diff --git a/inc/BigEndianProcessor.h b/inc/BigEndianProcessor.h index 05abf39..be58b6a 100644 --- a/inc/BigEndianProcessor.h +++ b/inc/BigEndianProcessor.h @@ -8,7 +8,7 @@ namespace EightBit { class BigEndianProcessor : public Processor { public: - ~BigEndianProcessor() = default; + virtual ~BigEndianProcessor() = default; register16_t peekWord(register16_t address) final; void pokeWord(register16_t address, register16_t value) final; diff --git a/inc/Chip.h b/inc/Chip.h index 64ffc7b..2be0b7a 100644 --- a/inc/Chip.h +++ b/inc/Chip.h @@ -66,9 +66,9 @@ namespace EightBit { [[nodiscard]] static constexpr auto promoteNibble(const int value) { return value << 4; } [[nodiscard]] static constexpr auto demoteNibble(const int value) { return highNibble(value); } - virtual ~Chip(); + virtual ~Chip() = default; protected: - Chip(); + Chip() = default; }; } diff --git a/inc/ClockedChip.h b/inc/ClockedChip.h index 3f2b828..d2f24f3 100644 --- a/inc/ClockedChip.h +++ b/inc/ClockedChip.h @@ -7,7 +7,7 @@ namespace EightBit { class ClockedChip : public Chip { public: - ~ClockedChip() {}; + virtual ~ClockedChip() = default; Signal Ticked; diff --git a/inc/Device.h b/inc/Device.h index 770615c..5154056 100644 --- a/inc/Device.h +++ b/inc/Device.h @@ -72,13 +72,13 @@ namespace EightBit { static void match(PinLevel& line, bool condition) noexcept { condition ? raise(line) : lower(line); } static void match(PinLevel& out, PinLevel in) noexcept { out = in; } - virtual ~Device() {}; + virtual ~Device() = default; [[nodiscard]] bool powered() noexcept { return raised(POWER()); } DECLARE_PIN_INPUT(POWER) protected: - Device() noexcept {}; + Device() noexcept = default; }; } diff --git a/inc/InputOutput.h b/inc/InputOutput.h index f238278..91290aa 100644 --- a/inc/InputOutput.h +++ b/inc/InputOutput.h @@ -11,8 +11,6 @@ namespace EightBit { public: enum class AccessType { Unknown, Reading, Writing }; - InputOutput() = default; - [[nodiscard]] size_t size() const noexcept override; [[nodiscard]] uint8_t peek(uint16_t address) const override; diff --git a/inc/IntelHexFile.h b/inc/IntelHexFile.h index 8765d4d..510547f 100644 --- a/inc/IntelHexFile.h +++ b/inc/IntelHexFile.h @@ -9,7 +9,7 @@ #include namespace EightBit { - class IntelHexFile { + class IntelHexFile final { public: IntelHexFile(std::string path); diff --git a/inc/IntelProcessor.h b/inc/IntelProcessor.h index 4a71974..300591e 100644 --- a/inc/IntelProcessor.h +++ b/inc/IntelProcessor.h @@ -34,7 +34,7 @@ namespace EightBit { } }; - ~IntelProcessor() = default; + virtual ~IntelProcessor() = default; [[nodiscard]] const auto& getDecodedOpcode(const size_t i) const noexcept { return m_decodedOpcodes.at(i); diff --git a/inc/LittleEndianProcessor.h b/inc/LittleEndianProcessor.h index 73d432f..15e8d0e 100644 --- a/inc/LittleEndianProcessor.h +++ b/inc/LittleEndianProcessor.h @@ -8,7 +8,7 @@ namespace EightBit { class LittleEndianProcessor : public Processor { public: - ~LittleEndianProcessor() = default; + virtual ~LittleEndianProcessor() = default; register16_t peekWord(register16_t address) final; void pokeWord(register16_t address, register16_t value) final; diff --git a/inc/MemoryMapping.h b/inc/MemoryMapping.h index 59f727b..b702a72 100644 --- a/inc/MemoryMapping.h +++ b/inc/MemoryMapping.h @@ -7,7 +7,7 @@ namespace EightBit { class Memory; - struct MemoryMapping { + struct MemoryMapping final { enum class AccessLevel { Unknown, ReadOnly, WriteOnly, ReadWrite }; diff --git a/inc/Processor.h b/inc/Processor.h index 5026c52..18890f6 100644 --- a/inc/Processor.h +++ b/inc/Processor.h @@ -15,7 +15,7 @@ namespace EightBit { // x: sign extend this b-bit number to r [[nodiscard]] static int8_t signExtend(int b, uint8_t x) noexcept; - ~Processor() = default; + virtual ~Processor() = default; [[nodiscard]] auto& PC() noexcept { return m_pc; } diff --git a/src/Chip.cpp b/src/Chip.cpp deleted file mode 100644 index d0c7201..0000000 --- a/src/Chip.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "stdafx.h" -#include "Chip.h" - -EightBit::Chip::Chip() {} - -EightBit::Chip::~Chip() {} diff --git a/src/EightBit.vcxproj b/src/EightBit.vcxproj index 83d7a59..1c06082 100644 --- a/src/EightBit.vcxproj +++ b/src/EightBit.vcxproj @@ -178,7 +178,6 @@ - diff --git a/src/EightBit.vcxproj.filters b/src/EightBit.vcxproj.filters index f685ed9..d831fb2 100644 --- a/src/EightBit.vcxproj.filters +++ b/src/EightBit.vcxproj.filters @@ -103,9 +103,6 @@ Source Files - - Source Files - Source Files