代码拉取完成,页面将自动刷新
import clang.cindex
index = clang.cindex.Index.create()
tu = index.parse("framework/include/bt_device.h", args=['-std=c99'])
for node in tu.cursor.walk_preorder():
if node.kind == clang.cindex.CursorKind.FUNCTION_DECL:
print('struct ' + node.spelling + '_s')
print('{')
if node.result_type.spelling == 'void *':
print(' ' + node.result_type.spelling + ' __ret;')
elif node.result_type.spelling != 'void':
print(' ' + node.result_type.spelling.replace("*","") + ' __ret;')
for arg in node.get_arguments():
print(' ' + arg.type.spelling.replace("*","") + ' ' + arg.spelling + ';')
print('};\n')
print(arg.type.spelling + ' ' + node.spelling + '(', end="")
first = True
for arg in node.get_arguments():
if first != True:
print(', ', end="")
first = False
print(arg.type.spelling + ' ' + arg.spelling, end="")
print(')')
print('{')
print('}\n')
for node in tu.cursor.walk_preorder():
if node.kind == clang.cindex.CursorKind.FUNCTION_DECL:
print(node.spelling.upper() + ',')
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。