From 3e04b5112252d179ce2da745245cd57252df6dd8 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Mon, 5 Apr 2021 17:26:18 -0400 Subject: [PATCH] Walks back pretty names. Probably a bad idea. --- Processors/Z80/State/State.cpp | 12 ------------ Processors/Z80/State/State.hpp | 2 -- Reflection/Struct.cpp | 13 +++++-------- Reflection/Struct.hpp | 12 ++---------- 4 files changed, 7 insertions(+), 32 deletions(-) diff --git a/Processors/Z80/State/State.cpp b/Processors/Z80/State/State.cpp index 52b3e6022..c9b90f2de 100644 --- a/Processors/Z80/State/State.cpp +++ b/Processors/Z80/State/State.cpp @@ -195,18 +195,6 @@ State::Registers::Registers() { } } -std::unordered_map State::Registers::pretty_names() const { - return { - { "afDash", "af'" }, - { "bcDash", "bc'" }, - { "deDash", "de'" }, - { "hlDash", "hl'" }, - { "program_counter", "pc" }, - { "stack_pointer", "sp" }, - { "interrupt_mode", "im" }, - }; -} - State::ExecutionState::ExecutionState() { if(needs_declare()) { DeclareField(is_halted); diff --git a/Processors/Z80/State/State.hpp b/Processors/Z80/State/State.hpp index d62156448..f5676aa60 100644 --- a/Processors/Z80/State/State.hpp +++ b/Processors/Z80/State/State.hpp @@ -38,8 +38,6 @@ struct State: public Reflection::StructImpl { int interrupt_mode; bool iff1, iff2; - std::unordered_map pretty_names() const override; - Registers(); } registers; diff --git a/Reflection/Struct.cpp b/Reflection/Struct.cpp index 3e2a6157c..babd12744 100644 --- a/Reflection/Struct.cpp +++ b/Reflection/Struct.cpp @@ -159,7 +159,7 @@ bool Reflection::fuzzy_set(Struct &target, const std::string &name, const std::s // MARK: - Description -void Reflection::Struct::append(std::ostringstream &stream, const std::string &key, const std::type_info *const type, size_t offset, bool use_pretty_names) const { +void Reflection::Struct::append(std::ostringstream &stream, const std::string &key, const std::type_info *const type, size_t offset) const { // Output Bools as yes/no. if(*type == typeid(bool)) { stream << ::Reflection::get(*this, key, offset); @@ -198,14 +198,13 @@ void Reflection::Struct::append(std::ostringstream &stream, const std::string &k // Recurse to deal with embedded objects. if(*type == typeid(Reflection::Struct)) { const Reflection::Struct *const child = reinterpret_cast(get(key)); - stream << child->description(use_pretty_names); + stream << child->description(); return; } } -std::string Reflection::Struct::description(bool use_pretty_names) const { +std::string Reflection::Struct::description() const { std::ostringstream stream; - const auto name_map = pretty_names(); stream << "{"; @@ -214,9 +213,7 @@ std::string Reflection::Struct::description(bool use_pretty_names) const { if(!is_first) stream << ", "; is_first = false; - // Use the pretty name for this key, if defined. - const auto mapped_key = name_map.find(key); - stream << (use_pretty_names && mapped_key != name_map.end() ? mapped_key->second : key) << ": "; + stream << key << ": "; const auto count = count_of(key); const auto type = type_of(key); @@ -226,7 +223,7 @@ std::string Reflection::Struct::description(bool use_pretty_names) const { } for(size_t index = 0; index < count; ++index) { - append(stream, key, type, index, use_pretty_names); + append(stream, key, type, index); if(index != count-1) stream << ", "; } diff --git a/Reflection/Struct.hpp b/Reflection/Struct.hpp index 14026f0af..24dbd489d 100644 --- a/Reflection/Struct.hpp +++ b/Reflection/Struct.hpp @@ -27,14 +27,6 @@ namespace Reflection { #define DeclareField(Name) declare(&Name, #Name) struct Struct { - /*! - Maps from internal key names to more human-friendly ones; e.g. might contain - a mapping from afDash to af'. - */ - virtual std::unordered_map pretty_names() const { - return {}; - } - virtual std::vector all_keys() const = 0; virtual const std::type_info *type_of(const std::string &name) const = 0; virtual size_t count_of(const std::string &name) const = 0; @@ -50,7 +42,7 @@ struct Struct { @returns A string describing this struct. This string has no guaranteed layout, may not be sufficiently formed for a formal language parser, etc. */ - std::string description(bool use_pretty_names = true) const; + std::string description() const; /*! Serialises this struct in BSON format. @@ -83,7 +75,7 @@ struct Struct { virtual bool should_serialise([[maybe_unused]] const std::string &key) const { return true; } private: - void append(std::ostringstream &stream, const std::string &key, const std::type_info *type, size_t offset, bool use_pretty_names) const; + void append(std::ostringstream &stream, const std::string &key, const std::type_info *type, size_t offset) const; bool deserialise(const uint8_t *bson, size_t size); };