From 81d70ee325a62d25c6187434af8285cc13e2dbc7 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sat, 9 May 2020 23:49:37 -0400 Subject: [PATCH] Adds in a few further `const`s. --- Analyser/Static/Macintosh/StaticAnalyser.cpp | 2 +- Analyser/Static/ZX8081/StaticAnalyser.cpp | 2 +- Inputs/Keyboard.cpp | 4 ++-- Inputs/QuadratureMouse/QuadratureMouse.hpp | 2 +- Machines/KeyboardMachine.cpp | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Analyser/Static/Macintosh/StaticAnalyser.cpp b/Analyser/Static/Macintosh/StaticAnalyser.cpp index d14a69554..658ce2897 100644 --- a/Analyser/Static/Macintosh/StaticAnalyser.cpp +++ b/Analyser/Static/Macintosh/StaticAnalyser.cpp @@ -17,7 +17,7 @@ Analyser::Static::TargetList Analyser::Static::Macintosh::GetTargets(const Media Analyser::Static::TargetList targets; using Target = Analyser::Static::Macintosh::Target; - auto *target = new Target; + auto *const target = new Target; target->media = media; targets.push_back(std::unique_ptr(target)); diff --git a/Analyser/Static/ZX8081/StaticAnalyser.cpp b/Analyser/Static/ZX8081/StaticAnalyser.cpp index 466d5cea4..2f9681325 100644 --- a/Analyser/Static/ZX8081/StaticAnalyser.cpp +++ b/Analyser/Static/ZX8081/StaticAnalyser.cpp @@ -34,7 +34,7 @@ Analyser::Static::TargetList Analyser::Static::ZX8081::GetTargets(const Media &m std::vector files = GetFiles(media.tapes.front()); media.tapes.front()->reset(); if(!files.empty()) { - Target *target = new Target; + Target *const target = new Target; destination.push_back(std::unique_ptr<::Analyser::Static::Target>(target)); target->machine = Machine::ZX8081; diff --git a/Inputs/Keyboard.cpp b/Inputs/Keyboard.cpp index dbd6ab223..16c342f71 100644 --- a/Inputs/Keyboard.cpp +++ b/Inputs/Keyboard.cpp @@ -20,7 +20,7 @@ Keyboard::Keyboard(const std::set &observed_keys, const std::set &esse observed_keys_(observed_keys), essential_modifiers_(essential_modifiers), is_exclusive_(false) {} bool Keyboard::set_key_pressed(Key key, char value, bool is_pressed) { - std::size_t key_offset = size_t(key); + const size_t key_offset = size_t(key); if(key_offset >= key_states_.size()) { key_states_.resize(key_offset+1, false); } @@ -44,7 +44,7 @@ void Keyboard::set_delegate(Delegate *delegate) { } bool Keyboard::get_key_state(Key key) { - std::size_t key_offset = size_t(key); + const size_t key_offset = size_t(key); if(key_offset >= key_states_.size()) return false; return key_states_[key_offset]; } diff --git a/Inputs/QuadratureMouse/QuadratureMouse.hpp b/Inputs/QuadratureMouse/QuadratureMouse.hpp index 3edf8197b..e3ba34d6b 100644 --- a/Inputs/QuadratureMouse/QuadratureMouse.hpp +++ b/Inputs/QuadratureMouse/QuadratureMouse.hpp @@ -110,7 +110,7 @@ class QuadratureMouse: public Mouse { } private: - int number_of_buttons_ = 0; + const int number_of_buttons_ = 0; std::atomic button_flags_; std::atomic axes_[2]; diff --git a/Machines/KeyboardMachine.cpp b/Machines/KeyboardMachine.cpp index 8c08dbddb..6b4846318 100644 --- a/Machines/KeyboardMachine.cpp +++ b/Machines/KeyboardMachine.cpp @@ -15,7 +15,7 @@ MachineTypes::MappedKeyboardMachine::MappedKeyboardMachine(const std::setmapped_key_for_key(key); + const uint16_t mapped_key = get_keyboard_mapper()->mapped_key_for_key(key); if(mapped_key == KeyNotMapped) return false; set_key_state(mapped_key, is_pressed); return true;