Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-Mania-Decompilation
Path: blob/master/SonicMania/funcheader.py
338 views
1
import os, sys, hashlib
2
import re
3
from typing import IO, BinaryIO, Dict, Iterable, Iterator, List, Tuple
4
from pathlib import Path
5
6
if len(sys.argv) < 2:
7
print(f"No Objects path specified... Exiting...")
8
exit(1)
9
10
events = ("Update", "LateUpdate", "StaticUpdate", "Draw", "Create", "StageLoad", "EditorLoad", "EditorDraw", "Serialize")
11
12
print("void InitPublicFunctions()\n{")
13
for path in Path(sys.argv[1]).rglob("*.h"):
14
done = False
15
prepros = ""
16
hasPrepos = False
17
f = open(path, "r")
18
while (line := f.readline()) != "":
19
if (line != line.lstrip() or line.startswith("//")):
20
continue
21
line = line.rstrip()
22
if (match := re.fullmatch(r"([a-zA-Z0-9]* ?\**) *([^(]*)\((.*)(,|\);)(\s*\/\/.*)?", line)) != None:
23
ret, name, args, end, comment = match.groups()
24
if name[len(path.stem) + 1:] in events:
25
continue
26
if (not done):
27
print(f" // {path.parent.name}/{path.stem}")
28
done = True
29
if (prepros == "#endif"):
30
prepros = ""
31
hasPrepos = False
32
if prepros and (prepros != "#endif"):
33
print(prepros)
34
prepros = ""
35
hasPrepos = True
36
if (prepros == "#endif" and hasPrepos == True):
37
print(prepros)
38
prepros = ""
39
hasPrepos = False
40
print(f" ADD_PUBLIC_FUNC({name});")
41
if (prepros == "#endif"):
42
print(prepros)
43
prepros = ""
44
hasPrepos = False
45
elif line.startswith("#"):
46
prepros = line
47
else:
48
prepros = ""
49
if (hasPrepos):
50
print("#endif")
51
if (done):
52
print()
53
print("}")
54
55