When parsing a macro, store its offset and number of actions
This commit is contained in:
@@ -38,7 +38,7 @@ parser_error_t ParseConfig(config_buffer_t *buffer)
|
|||||||
}
|
}
|
||||||
macroCount = readCompactLength(buffer);
|
macroCount = readCompactLength(buffer);
|
||||||
for (uint16_t macroIdx = 0; macroIdx < macroCount; macroIdx++) {
|
for (uint16_t macroIdx = 0; macroIdx < macroCount; macroIdx++) {
|
||||||
errorCode = ParseMacro(buffer);
|
errorCode = ParseMacro(buffer, macroIdx);
|
||||||
if (errorCode != ParserError_Success) {
|
if (errorCode != ParserError_Success) {
|
||||||
return errorCode;
|
return errorCode;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
#include "parse_macro.h"
|
#include "parse_macro.h"
|
||||||
|
#include "config_globals.h"
|
||||||
|
#include "macros.h"
|
||||||
|
|
||||||
parser_error_t parseKeyMacroAction(config_buffer_t *buffer, serialized_macro_action_type_t macroActionType) {
|
parser_error_t parseKeyMacroAction(config_buffer_t *buffer, serialized_macro_action_type_t macroActionType) {
|
||||||
uint8_t keyMacroType = macroActionType - SerializedMacroActionType_KeyMacroAction;
|
uint8_t keyMacroType = macroActionType - SerializedMacroActionType_KeyMacroAction;
|
||||||
@@ -85,7 +87,8 @@ parser_error_t parseMacroAction(config_buffer_t *buffer) {
|
|||||||
return ParserError_InvalidSerializedMacroActionType;
|
return ParserError_InvalidSerializedMacroActionType;
|
||||||
}
|
}
|
||||||
|
|
||||||
parser_error_t ParseMacro(config_buffer_t *buffer) {
|
parser_error_t ParseMacro(config_buffer_t *buffer, uint16_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);
|
||||||
@@ -96,6 +99,10 @@ parser_error_t ParseMacro(config_buffer_t *buffer) {
|
|||||||
(void)isLooped;
|
(void)isLooped;
|
||||||
(void)isPrivate;
|
(void)isPrivate;
|
||||||
(void)name;
|
(void)name;
|
||||||
|
if (!ParserRunDry) {
|
||||||
|
AllMacros[macroIdx].offset = offset;
|
||||||
|
AllMacros[macroIdx].macroActionsCount = macroActionsCount;
|
||||||
|
}
|
||||||
for (uint16_t i = 0; i < macroActionsCount; i++) {
|
for (uint16_t i = 0; i < macroActionsCount; i++) {
|
||||||
errorCode = parseMacroAction(buffer);
|
errorCode = parseMacroAction(buffer);
|
||||||
if (errorCode != ParserError_Success) {
|
if (errorCode != ParserError_Success) {
|
||||||
|
|||||||
@@ -20,6 +20,6 @@
|
|||||||
|
|
||||||
// Functions:
|
// Functions:
|
||||||
|
|
||||||
parser_error_t ParseMacro(config_buffer_t *buffer);
|
parser_error_t ParseMacro(config_buffer_t *buffer, uint16_t macroIdx);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
3
right/src/macros.c
Normal file
3
right/src/macros.c
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
#include "macros.h"
|
||||||
|
|
||||||
|
macro_reference_t AllMacros[MAX_MACRO_NUM];
|
||||||
23
right/src/macros.h
Normal file
23
right/src/macros.h
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
#ifndef __MACROS_H__
|
||||||
|
#define __MACROS_H__
|
||||||
|
|
||||||
|
// Includes:
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
// Macros:
|
||||||
|
|
||||||
|
#define MAX_MACRO_NUM 1024
|
||||||
|
|
||||||
|
// Typedefs:
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint16_t offset;
|
||||||
|
uint16_t macroActionsCount;
|
||||||
|
} macro_reference_t;
|
||||||
|
|
||||||
|
// Variables:
|
||||||
|
|
||||||
|
extern macro_reference_t AllMacros[MAX_MACRO_NUM];
|
||||||
|
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user