prog
Some checks failed
Build Dusk / run-tests (push) Failing after 1m58s
Build Dusk / build-linux (push) Failing after 1m26s
Build Dusk / build-psp (push) Failing after 1m41s

This commit is contained in:
2026-01-26 18:27:12 -06:00
parent 9544d15a18
commit d1b03c4cb3
7 changed files with 126 additions and 104 deletions

44
tools/util/type.py Normal file
View File

@@ -0,0 +1,44 @@
def detectType(value: str) -> str:
val = value.strip()
# Boolean check
if val.lower() in {'true', 'false'}:
return 'Boolean'
# Int check
try:
int(val)
return 'Int'
except ValueError:
pass
# Float check
try:
float(val)
return 'Float'
except ValueError:
pass
# Default to String
return 'String'
def typeToCType(valType: str) -> str:
if valType == 'Int':
return 'int'
elif valType == 'Float':
return 'float'
elif valType == 'Boolean':
return 'bool'
else:
return 'char_t*'
def stringToCType(value: str) -> str:
valType = detectType(value)
if valType == 'Int':
return str(int(value))
elif valType == 'Float':
return str(float(value))
elif valType == 'Boolean':
return 'true' if value.lower() == 'true' else 'false'
else:
escaped = value.replace('\\', '\\\\').replace('"', '\\"')
return f'"{escaped}"'