mirror of
https://github.com/TomHarte/CLK.git
synced 2025-01-12 15:31:09 +00:00
Walks back pretty names. Probably a bad idea.
This commit is contained in:
parent
76f2aba51a
commit
3e04b51122
@ -195,18 +195,6 @@ State::Registers::Registers() {
|
||||
}
|
||||
}
|
||||
|
||||
std::unordered_map<std::string, std::string> 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);
|
||||
|
@ -38,8 +38,6 @@ struct State: public Reflection::StructImpl<State> {
|
||||
int interrupt_mode;
|
||||
bool iff1, iff2;
|
||||
|
||||
std::unordered_map<std::string, std::string> pretty_names() const override;
|
||||
|
||||
Registers();
|
||||
} registers;
|
||||
|
||||
|
@ -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<bool>(*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<const Reflection::Struct *>(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 << ", ";
|
||||
}
|
||||
|
||||
|
@ -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<std::string, std::string> pretty_names() const {
|
||||
return {};
|
||||
}
|
||||
|
||||
virtual std::vector<std::string> 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);
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user