avoid duplicate events in translation file
This commit is contained in:
parent
8829f3face
commit
8a2caf120d
@ -302,13 +302,15 @@ def write_translation_source_file(
|
|||||||
):
|
):
|
||||||
outputfile = open(filename, "w")
|
outputfile = open(filename, "w")
|
||||||
definitions = ""
|
definitions = ""
|
||||||
|
# Look up table to avoid duplicate events
|
||||||
|
lut = dict()
|
||||||
function = (
|
function = (
|
||||||
"const char *translateEvents(Event event) {\n switch ((event & 0xFFFF)) {\n"
|
"const char *translateEvents(Event event) {\n switch ((event & 0xFFFF)) {\n"
|
||||||
)
|
)
|
||||||
for entry in event_list:
|
for entry in event_list:
|
||||||
event_id = entry[0]
|
event_id = entry[0]
|
||||||
event_value = entry[1]
|
event_value = entry[1]
|
||||||
|
if event_value[EVENT_ENTRY_NAME_IDX] not in lut:
|
||||||
definitions += (
|
definitions += (
|
||||||
f"const char *{event_value[EVENT_ENTRY_NAME_IDX]}_STRING "
|
f"const char *{event_value[EVENT_ENTRY_NAME_IDX]}_STRING "
|
||||||
f'= "{event_value[EVENT_ENTRY_NAME_IDX]}";\n'
|
f'= "{event_value[EVENT_ENTRY_NAME_IDX]}";\n'
|
||||||
@ -317,6 +319,7 @@ def write_translation_source_file(
|
|||||||
f" case ({event_id}):\n "
|
f" case ({event_id}):\n "
|
||||||
f"return {event_value[EVENT_ENTRY_NAME_IDX]}_STRING;\n"
|
f"return {event_value[EVENT_ENTRY_NAME_IDX]}_STRING;\n"
|
||||||
)
|
)
|
||||||
|
lut.update({event_value[EVENT_ENTRY_NAME_IDX] : event_value})
|
||||||
function += ' default:\n return "UNKNOWN_EVENT";\n'
|
function += ' default:\n return "UNKNOWN_EVENT";\n'
|
||||||
outputfile.write(
|
outputfile.write(
|
||||||
f"/**\n * @brief Auto-generated event translation file. "
|
f"/**\n * @brief Auto-generated event translation file. "
|
||||||
|
Loading…
Reference in New Issue
Block a user