我正在编写一个简单的工具来帮助重构应用程序的源代码。我想解析基于WxWIDGoS库的C++代码,它定义了GUI并生成了与Qt一起使用的XML ^ {
目前,我正在使用Python绑定到Clang,使用下面的示例代码可以得到标记及其种类和位置,但是游标种类总是CursorKind.INVALID_FILE
。
import sys
import clang.cindex
def find_typerefs(node):
""" Find all references to the type named 'typename'
"""
for t in node.get_tokens():
if not node.location.file != sys.argv[1]:
continue
if t.kind.value != 0 and t.kind.value != 1 and t.kind.value != 4:
print t.spelling
print t.location
print t.cursor.kind
print t.kind
print "\n"
index = clang.cindex.Index.create()
tu = index.parse(sys.argv[1])
print 'Translation unit:', tu.spelling
find_typerefs(tu.cursor)
确定光标类型的正确方法是什么?
我找不到任何文档,除了一些博客文章,但他们是过时的或没有涵盖这个主题。我也不能从叮当的例子中找出答案。
目前没有回答
相关问题 更多 >
编程相关推荐