refactor preprocessor macros into a function

Remove the "macros" global and instead use a function to construct a
list of macros.
This commit is contained in:
Bryan Bishop 2013-08-31 10:13:17 -05:00
parent 63c2dc2f1f
commit 5815edf382
2 changed files with 23 additions and 15 deletions

View File

@ -16,20 +16,28 @@ from extras.pokemontools.crystal import (
effect_classes,
)
even_more_macros = [
Warp,
XYTrigger,
Signpost,
PeopleEvent,
DataByteWordMacro,
]
def load_pokecrystal_macros():
"""
Construct a list of macros that are needed for pokecrystal preprocessing.
"""
ourmacros = []
macros = command_classes
macros += even_more_macros
macros += [each[1] for each in text_command_classes]
macros += movement_command_classes
macros += music_classes
macros += effect_classes
even_more_macros = [
Warp,
XYTrigger,
Signpost,
PeopleEvent,
DataByteWordMacro,
]
ourmacros += command_classes
ourmacros += even_more_macros
ourmacros += [each[1] for each in text_command_classes]
ourmacros += movement_command_classes
ourmacros += music_classes
ourmacros += effect_classes
return ourmacros
# show lines before preprocessing in stdout
show_original_lines = False
@ -628,4 +636,4 @@ def preprocess(macros, lines=None):
# only run against stdin when not included as a module
if __name__ == "__main__":
preprocess(macros)
preprocess(load_pokecrystal_macros())

View File

@ -14,4 +14,4 @@ if __name__ == '__main__':
dest = os.path.splitext(source)[0] + '.tx'
sys.stdin = open(source, 'r')
sys.stdout = open(dest, 'w')
preprocessor.preprocess(preprocessor.macros)
preprocessor.preprocess(preprocessor.load_pokecrystal_macros())