add Command::Unit to describe similar fields between main command and motions

This commit is contained in:
josh committed 2017-10-24 22:11:57 -04:00
1 parent a07e9eb46b
commit bbc1c8d153
3 files changed
+14 -18

No files matched your search

-10
View File
@@ -1,12 +1,2 @@
#include "Command.h" #include "Command.h"
#include <string.h> #include <string.h>
Command::Command()
{
id = NOP;
count = 0u;
following_char = 0u;
motion.id = Motion::NOP;
motion.count = 0u;
motion.following_char = 0u;
}
+12 -6
View File
@@ -33,18 +33,24 @@ public:
BACK_UP_TO_CHAR, BACK_UP_TO_CHAR,
BACK_ON_TO_CHAR, BACK_ON_TO_CHAR,
}; };
uint32_t id;
uint32_t count;
uint32_t following_char;
}; };
struct Unit
{
uint32_t id; uint32_t id;
uint32_t count; uint32_t count;
uint32_t following_char; uint32_t following_char;
Motion motion;
Command(); Unit()
{
id = 0u;
count = 0u;
following_char = 0u;
}
};
Unit main;
Unit motion;
}; };
#endif #endif
+2 -2
View File
@@ -52,7 +52,7 @@ std::shared_ptr<Command> CommandMap::get_command(uint32_t * command_characters,
if (in_motion) if (in_motion)
command.motion.id = node->id; command.motion.id = node->id;
else else
command.id = node->id; command.main.id = node->id;
if (node->flags & Node::FLAG_FOLLOWING_CHAR) if (node->flags & Node::FLAG_FOLLOWING_CHAR)
{ {
if (i < (length - 1u)) if (i < (length - 1u))
@@ -60,7 +60,7 @@ std::shared_ptr<Command> CommandMap::get_command(uint32_t * command_characters,
if (in_motion) if (in_motion)
command.motion.following_char = command_characters[i + 1u]; command.motion.following_char = command_characters[i + 1u];
else else
command.following_char = command_characters[i + 1u]; command.main.following_char = command_characters[i + 1u];
return std::make_shared<Command>(command); return std::make_shared<Command>(command);
} }
} }