Path: blob/master/SonicMania/funcheader.py
338 views
import os, sys, hashlib1import re2from typing import IO, BinaryIO, Dict, Iterable, Iterator, List, Tuple3from pathlib import Path45if len(sys.argv) < 2:6print(f"No Objects path specified... Exiting...")7exit(1)89events = ("Update", "LateUpdate", "StaticUpdate", "Draw", "Create", "StageLoad", "EditorLoad", "EditorDraw", "Serialize")1011print("void InitPublicFunctions()\n{")12for path in Path(sys.argv[1]).rglob("*.h"):13done = False14prepros = ""15hasPrepos = False16f = open(path, "r")17while (line := f.readline()) != "":18if (line != line.lstrip() or line.startswith("//")):19continue20line = line.rstrip()21if (match := re.fullmatch(r"([a-zA-Z0-9]* ?\**) *([^(]*)\((.*)(,|\);)(\s*\/\/.*)?", line)) != None:22ret, name, args, end, comment = match.groups()23if name[len(path.stem) + 1:] in events:24continue25if (not done):26print(f" // {path.parent.name}/{path.stem}")27done = True28if (prepros == "#endif"):29prepros = ""30hasPrepos = False31if prepros and (prepros != "#endif"):32print(prepros)33prepros = ""34hasPrepos = True35if (prepros == "#endif" and hasPrepos == True):36print(prepros)37prepros = ""38hasPrepos = False39print(f" ADD_PUBLIC_FUNC({name});")40if (prepros == "#endif"):41print(prepros)42prepros = ""43hasPrepos = False44elif line.startswith("#"):45prepros = line46else:47prepros = ""48if (hasPrepos):49print("#endif")50if (done):51print()52print("}")535455