From bbc1c8d153144e7850601f3254160bdc3d99cc7b Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Tue, 24 Oct 2017 22:11:57 -0400 Subject: [PATCH] add Command::Unit to describe similar fields between main command and motions --- src/core/Command.cc | 10 ---------- src/core/Command.h | 18 ++++++++++++------ src/core/CommandMap.cc | 4 ++-- 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/core/Command.cc b/src/core/Command.cc index 41dcb06..4b93d48 100644 --- a/src/core/Command.cc +++ b/src/core/Command.cc @@ -1,12 +1,2 @@ #include "Command.h" #include - -Command::Command() -{ - id = NOP; - count = 0u; - following_char = 0u; - motion.id = Motion::NOP; - motion.count = 0u; - motion.following_char = 0u; -} diff --git a/src/core/Command.h b/src/core/Command.h index 72ab446..2297016 100644 --- a/src/core/Command.h +++ b/src/core/Command.h @@ -33,18 +33,24 @@ public: BACK_UP_TO_CHAR, BACK_ON_TO_CHAR, }; + }; + struct Unit + { uint32_t id; uint32_t count; uint32_t following_char; + + Unit() + { + id = 0u; + count = 0u; + following_char = 0u; + } }; - uint32_t id; - uint32_t count; - uint32_t following_char; - Motion motion; - - Command(); + Unit main; + Unit motion; }; #endif diff --git a/src/core/CommandMap.cc b/src/core/CommandMap.cc index 1fee683..12a3549 100644 --- a/src/core/CommandMap.cc +++ b/src/core/CommandMap.cc @@ -52,7 +52,7 @@ std::shared_ptr CommandMap::get_command(uint32_t * command_characters, if (in_motion) command.motion.id = node->id; else - command.id = node->id; + command.main.id = node->id; if (node->flags & Node::FLAG_FOLLOWING_CHAR) { if (i < (length - 1u)) @@ -60,7 +60,7 @@ std::shared_ptr CommandMap::get_command(uint32_t * command_characters, if (in_motion) command.motion.following_char = command_characters[i + 1u]; else - command.following_char = command_characters[i + 1u]; + command.main.following_char = command_characters[i + 1u]; return std::make_shared(command); } }