feat(script/gen_constants_cpp): generate snake_case C++ function names
This commit is contained in:
parent
beda5f5f43
commit
ef85657c90
1 changed files with 8 additions and 1 deletions
|
|
@ -20,13 +20,20 @@ def error(msg):
|
|||
|
||||
def to_c_const(s):
|
||||
out = ""
|
||||
first = True
|
||||
for c in s:
|
||||
if c == '.' or c == '_':
|
||||
out += '_'
|
||||
elif c.isalpha() or c.isdigit():
|
||||
out += c
|
||||
if c.isupper():
|
||||
if not first:
|
||||
out += "_"
|
||||
out += c.lower()
|
||||
else:
|
||||
out += c
|
||||
else:
|
||||
error("unsupported character in constant: %s" % s)
|
||||
first = False
|
||||
return out
|
||||
|
||||
def main(argv=None):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue