Move plugins to Sol (#5622)

Co-authored-by: Nerixyz <nerixdev@outlook.de>
Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
Mm2PL
2024-10-20 11:57:05 +02:00
committed by GitHub
parent 9345050868
commit 352a4ec132
42 changed files with 2120 additions and 2208 deletions
+12 -4
View File
@@ -196,7 +196,7 @@ def write_func(path: Path, line: int, comments: list[str], out: TextIOWrapper):
if not comments[0].startswith("@"):
out.write(f"--- {comments[0]}\n---\n")
comments = comments[1:]
params = []
params: list[str] = []
for comment in comments[:-1]:
if not comment.startswith("@lua"):
panic(path, line, f"Invalid function specification - got '{comment}'")
@@ -209,7 +209,7 @@ def write_func(path: Path, line: int, comments: list[str], out: TextIOWrapper):
panic(path, line, f"Invalid function exposure - got '{comments[-1]}'")
name = comments[-1].split(" ", 1)[1]
printmsg(path, line, f"function {name}")
lua_params = ", ".join(params)
lua_params = ", ".join(p.removesuffix("?") for p in params)
out.write(f"function {name}({lua_params}) end\n\n")
@@ -242,13 +242,21 @@ def read_file(path: Path, out: TextIOWrapper):
)
name = header[0].split(" ", 1)[1]
printmsg(path, reader.line_no(), f"enum {name}")
out.write(f"---@alias {name} integer\n")
variants = reader.read_enum_variants()
vtypes = []
for variant in variants:
vtype = f'{name}.{variant}'
vtypes.append(vtype)
out.write(f'---@alias {vtype} "{vtype}"\n')
out.write(f"---@alias {name} {'|'.join(vtypes)}\n")
if header_comment:
out.write(f"--- {header_comment}\n")
out.write("---@type { ")
out.write(
", ".join(
[f"{variant}: {name}" for variant in reader.read_enum_variants()]
[f"{variant}: {typ}" for variant, typ in zip(variants,vtypes)]
)
)
out.write(" }\n")