我有 C 代码:
int func4b(float *x, int (*fp)(int *hello, float *goodbye));
int hello(int *x, float *y) {
return 0;
}
void callerb() {
float x=6.0;
func4b(&x, &hello); // This is line 28
}
clang-12 -cc1 -ast-dump t2_calls.c
provides:
...
...
`-CallExpr 0x55ee03be4d68 <line:28:3, col:20> 'int'
|-ImplicitCastExpr 0x55ee03be4d50 <col:3> 'int (*)(float *, int (*)(int *, float *))' <FunctionToPointerDecay>
使用 clang 的 python 绑定,我在第 28 行获得了这个函数调用:
CursorKind.CALL_EXPR func4b line=28 col=3
CursorKind.UNEXPOSED_EXPR func4b line=28 col=3
在我的python代码中,我有兴趣知道这两个
- 这是节点类型“ImplicitCastExpr”和
- 该functionCall的参数签名是'int(*)(float ,int()(int *,float *))'
这是否可以通过几个小时的工作来实现?我一直在阅读:
https://eli.thegreenplace.net/2011/07/03/parsing-c-in-python-with-clang 但那已经有 9 年历史了,我希望 python 绑定现在更完整。