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;
|
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);
|
uint8_t macroActionType = readUInt8(buffer);
|
||||||
|
|
||||||
switch (macroActionType) {
|
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) {
|
parser_error_t ParseMacro(config_buffer_t *buffer, uint8_t macroIdx) {
|
||||||
uint16_t offset = buffer->offset;
|
|
||||||
parser_error_t errorCode;
|
parser_error_t errorCode;
|
||||||
uint16_t nameLen;
|
uint16_t nameLen;
|
||||||
bool isLooped = readBool(buffer);
|
bool isLooped = readBool(buffer);
|
||||||
bool isPrivate = readBool(buffer);
|
bool isPrivate = readBool(buffer);
|
||||||
const char *name = readString(buffer, &nameLen);
|
const char *name = readString(buffer, &nameLen);
|
||||||
uint16_t macroActionsCount = readCompactLength(buffer);
|
uint16_t macroActionsCount = readCompactLength(buffer);
|
||||||
|
uint16_t firstMacroActionOffset = buffer->offset;
|
||||||
macro_action_t dummyMacroAction;
|
macro_action_t dummyMacroAction;
|
||||||
|
|
||||||
(void)isLooped;
|
(void)isLooped;
|
||||||
(void)isPrivate;
|
(void)isPrivate;
|
||||||
(void)name;
|
(void)name;
|
||||||
if (!ParserRunDry) {
|
if (!ParserRunDry) {
|
||||||
AllMacros[macroIdx].offset = offset;
|
AllMacros[macroIdx].firstMacroActionOffset = firstMacroActionOffset;
|
||||||
AllMacros[macroIdx].macroActionsCount = macroActionsCount;
|
AllMacros[macroIdx].macroActionsCount = macroActionsCount;
|
||||||
}
|
}
|
||||||
for (uint16_t i = 0; i < macroActionsCount; i++) {
|
for (uint16_t i = 0; i < macroActionsCount; i++) {
|
||||||
errorCode = parseMacroAction(buffer, &dummyMacroAction);
|
errorCode = ParseMacroAction(buffer, &dummyMacroAction);
|
||||||
if (errorCode != ParserError_Success) {
|
if (errorCode != ParserError_Success) {
|
||||||
return errorCode;
|
return errorCode;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
// Includes:
|
// Includes:
|
||||||
|
|
||||||
#include "parse_config.h"
|
#include "parse_config.h"
|
||||||
|
#include "macros.h"
|
||||||
|
|
||||||
// Typedefs:
|
// Typedefs:
|
||||||
|
|
||||||
@@ -20,6 +21,7 @@
|
|||||||
|
|
||||||
// Functions:
|
// Functions:
|
||||||
|
|
||||||
|
parser_error_t ParseMacroAction(config_buffer_t *buffer, macro_action_t *macroAction);
|
||||||
parser_error_t ParseMacro(config_buffer_t *buffer, uint8_t macroIdx);
|
parser_error_t ParseMacro(config_buffer_t *buffer, uint8_t macroIdx);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
// Typedefs:
|
// Typedefs:
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint16_t offset;
|
uint16_t firstMacroActionOffset;
|
||||||
uint16_t macroActionsCount;
|
uint16_t macroActionsCount;
|
||||||
} macro_reference_t;
|
} macro_reference_t;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user