mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-18 14:42:33 +00:00
tool/btstack_parser: enable lower_underscore_style commands and params
This commit is contained in:
parent
b292911501
commit
3ddaf9c7ca
@ -103,7 +103,7 @@ def parse_events():
|
|||||||
|
|
||||||
return (events, subvents, event_types)
|
return (events, subvents, event_types)
|
||||||
|
|
||||||
def my_parse_commands(infile):
|
def my_parse_commands(infile, camel_case):
|
||||||
commands = []
|
commands = []
|
||||||
with open (infile, 'rt') as fin:
|
with open (infile, 'rt') as fin:
|
||||||
|
|
||||||
@ -113,14 +113,23 @@ def my_parse_commands(infile):
|
|||||||
parts = re.match('.*@param\s*(\w*)\s*', line)
|
parts = re.match('.*@param\s*(\w*)\s*', line)
|
||||||
if parts and len(parts.groups()) == 1:
|
if parts and len(parts.groups()) == 1:
|
||||||
param = parts.groups()[0]
|
param = parts.groups()[0]
|
||||||
params.append(camel_case_var(param))
|
if camel_case:
|
||||||
|
param = camel_case_var(param)
|
||||||
|
else:
|
||||||
|
param = param.lower()
|
||||||
|
params.append(param)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
declaration = re.match('const\s+hci_cmd_t\s+(\w+)[\s=]+', line)
|
declaration = re.match('const\s+hci_cmd_t\s+(\w+)[\s=]+', line)
|
||||||
if declaration:
|
if declaration:
|
||||||
command_name = camel_case(declaration.groups()[0])
|
command_name = declaration.groups()[0]
|
||||||
if command_name.endswith('Cmd'):
|
# drop _cmd suffix for daemon commands
|
||||||
command_name = command_name[:-len('Cmd')]
|
if command_name.endswith('_cmd'):
|
||||||
|
command_name = command_name[:-len('_cmd')]
|
||||||
|
if camel_case:
|
||||||
|
command_name = camel_case(command_name)
|
||||||
|
else:
|
||||||
|
command_name = command_name.lower()
|
||||||
continue
|
continue
|
||||||
|
|
||||||
definition = re.match('\s*OPCODE\\(\s*(\w+)\s*,\s+(\w+)\s*\\)\s*,\s\\"(\w*)\\".*', line)
|
definition = re.match('\s*OPCODE\\(\s*(\w+)\s*,\s+(\w+)\s*\\)\s*,\s\\"(\w*)\\".*', line)
|
||||||
@ -138,9 +147,9 @@ def my_parse_commands(infile):
|
|||||||
continue
|
continue
|
||||||
return commands
|
return commands
|
||||||
|
|
||||||
def parse_commands():
|
def parse_commands(camel_case=True):
|
||||||
global btstack_root
|
global btstack_root
|
||||||
commands = []
|
commands = []
|
||||||
commands = commands = my_parse_commands(btstack_root + '/' + hci_cmds_c_path)
|
commands = commands = my_parse_commands(btstack_root + '/' + hci_cmds_c_path, camel_case)
|
||||||
commands = commands = my_parse_commands(btstack_root + '/' + daemon_cmds_c_path)
|
commands = commands = my_parse_commands(btstack_root + '/' + daemon_cmds_c_path, camel_case)
|
||||||
return commands
|
return commands
|
Loading…
x
Reference in New Issue
Block a user