From b1fb5f62c13b28f0141f94ed8ff56dce6c16de46 Mon Sep 17 00:00:00 2001 From: Eric Tang Date: Wed, 9 Aug 2017 13:13:50 -0700 Subject: [PATCH] Make macro_reference_t store the offset of the first macro action and expose ParseMacroAction --- right/src/config_parser/parse_macro.c | 8 ++++---- right/src/config_parser/parse_macro.h | 2 ++ right/src/macros.h | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/right/src/config_parser/parse_macro.c b/right/src/config_parser/parse_macro.c index fb35cfb..6e4b328 100644 --- a/right/src/config_parser/parse_macro.c +++ b/right/src/config_parser/parse_macro.c @@ -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; } diff --git a/right/src/config_parser/parse_macro.h b/right/src/config_parser/parse_macro.h index 3f99a1f..0dba439 100644 --- a/right/src/config_parser/parse_macro.h +++ b/right/src/config_parser/parse_macro.h @@ -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 diff --git a/right/src/macros.h b/right/src/macros.h index d577e1f..e85ea39 100644 --- a/right/src/macros.h +++ b/right/src/macros.h @@ -13,7 +13,7 @@ // Typedefs: typedef struct { - uint16_t offset; + uint16_t firstMacroActionOffset; uint16_t macroActionsCount; } macro_reference_t;