Skip to content

Commit

Permalink
remove redundant replace_fun
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-Auto committed Oct 15, 2023
1 parent e48d68c commit 56f5734
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 16 deletions.
6 changes: 2 additions & 4 deletions docs/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
"object ": "any ",
}


def replace_all(text):
for repl, wth in replace_table.items():
pos = text.find(repl)
Expand All @@ -59,7 +58,6 @@ def replace_all(text):
text = text.replace(repl, wth)
return text


ps.configure_parse(replace_all, "slate.pickle")
ps.run_parse()

Expand Down Expand Up @@ -126,11 +124,11 @@ def include_example(name):


def format_af(lf, af):
ret = replace_all(af["return"]) or "nil"
ret = af["return"] or "nil"
ret = ret.replace("<", "&lt;").replace(">", "&gt;")
ret = link_custom_type(ret)
name = lf["name"]
param = replace_all(af["param"]).replace("vector<", "array<")
param = af["param"].replace("vector<", "array<")
param = link_custom_type(param)
fun = f"{ret} {name}({param})".strip()
return fun
Expand Down
10 changes: 4 additions & 6 deletions docs/parse_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,9 +516,7 @@ def run_parse():
index = literal_eval(index.strip())
if binds := re.search(r"BackBinder<([^>]*)>", signature_and_binder):
binds = binds.group(1)
binds = replace_fun(
"{} {}".format(binds, camel_case_to_snake_case(binds))
)
binds = "{} {}".format(binds, camel_case_to_snake_case(binds))
else:
binds = None
signature = re.sub(
Expand All @@ -527,9 +525,9 @@ def run_parse():
signature = re.search(
r"([_a-zA-Z][_a-zA-Z0-9]*.*)\((.*)\)", signature
)
ret = replace_fun(signature.group(1))
ret = signature.group(1)
args = [
replace_fun(t) for t in signature.group(2).split(",")
t for t in signature.group(2).split(",")
]
vtable_entries[name] = {
"name": name,
Expand Down Expand Up @@ -650,7 +648,7 @@ def run_parse():

if var[0].startswith("sol::constructors"):
for fun in underlying_cpp_type["member_funs"][cpp_type]:
param = replace_fun(fun["param"])
param = fun["param"]

if cpp_type not in constructors:
constructors[cpp_type] = []
Expand Down
12 changes: 6 additions & 6 deletions docs/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ def replace_all(text):
"variadic_args",
"MAX_PLAYERS",
"any",
"IMAGE",
"IMAGE"
"VTABLE_OFFSET",
]

unknown_types = []
Expand Down Expand Up @@ -100,10 +101,9 @@ def check_types(ret):
ret = "nil"
param = ""
if m:
ret = replace_all(m.group(2)).strip() or "nil"
ret = m.group(2) or "nil"
if m or m2:
param = (m or m2).group(1)
param = replace_all(param).strip()

check_types(ret)
check_types(param)
Expand Down Expand Up @@ -135,11 +135,11 @@ def check_types(ret):

if n:
if n.group(2):
param = replace_all(n.group(2).strip())
param = n.group(2)
elif m:
ret = replace_all(m.group(1)) or "nil"
ret = m.group(1) or "nil"
if m.group(3):
param = replace_all(m.group(3).strip())
param = m.group(3)

if(param):
check_types(param)
Expand Down

0 comments on commit 56f5734

Please sign in to comment.