Make macro_reference_t store the offset of the first macro action and expose ParseMacroAction
This commit is contained in:
@@ -70,7 +70,7 @@ parser_error_t parseTextMacroAction(config_buffer_t *buffer, macro_action_t *mac
|
||||
return ParserError_Success;
|
||||
}
|
||||
|
||||
parser_error_t parseMacroAction(config_buffer_t *buffer, macro_action_t *macroAction) {
|
||||
parser_error_t ParseMacroAction(config_buffer_t *buffer, macro_action_t *macroAction) {
|
||||
uint8_t macroActionType = readUInt8(buffer);
|
||||
|
||||
switch (macroActionType) {
|
||||
@@ -91,24 +91,24 @@ parser_error_t parseMacroAction(config_buffer_t *buffer, macro_action_t *macroAc
|
||||
}
|
||||
|
||||
parser_error_t ParseMacro(config_buffer_t *buffer, uint8_t macroIdx) {
|
||||
uint16_t offset = buffer->offset;
|
||||
parser_error_t errorCode;
|
||||
uint16_t nameLen;
|
||||
bool isLooped = readBool(buffer);
|
||||
bool isPrivate = readBool(buffer);
|
||||
const char *name = readString(buffer, &nameLen);
|
||||
uint16_t macroActionsCount = readCompactLength(buffer);
|
||||
uint16_t firstMacroActionOffset = buffer->offset;
|
||||
macro_action_t dummyMacroAction;
|
||||
|
||||
(void)isLooped;
|
||||
(void)isPrivate;
|
||||
(void)name;
|
||||
if (!ParserRunDry) {
|
||||
AllMacros[macroIdx].offset = offset;
|
||||
AllMacros[macroIdx].firstMacroActionOffset = firstMacroActionOffset;
|
||||
AllMacros[macroIdx].macroActionsCount = macroActionsCount;
|
||||
}
|
||||
for (uint16_t i = 0; i < macroActionsCount; i++) {
|
||||
errorCode = parseMacroAction(buffer, &dummyMacroAction);
|
||||
errorCode = ParseMacroAction(buffer, &dummyMacroAction);
|
||||
if (errorCode != ParserError_Success) {
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
// Includes:
|
||||
|
||||
#include "parse_config.h"
|
||||
#include "macros.h"
|
||||
|
||||
// Typedefs:
|
||||
|
||||
@@ -20,6 +21,7 @@
|
||||
|
||||
// Functions:
|
||||
|
||||
parser_error_t ParseMacroAction(config_buffer_t *buffer, macro_action_t *macroAction);
|
||||
parser_error_t ParseMacro(config_buffer_t *buffer, uint8_t macroIdx);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
// Typedefs:
|
||||
|
||||
typedef struct {
|
||||
uint16_t offset;
|
||||
uint16_t firstMacroActionOffset;
|
||||
uint16_t macroActionsCount;
|
||||
} macro_reference_t;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user