rpav / c2ffi

Clang-based FFI wrapper generator
GNU Lesser General Public License v2.1
234 stars 39 forks source link

doc: please clarify how it relates to clang ast-dump #112

Open attila-lendvai opened 1 year ago

attila-lendvai commented 1 year ago

apparently there's something called clang ast-dump, that can dump the AST in json format (as mentioned at https://github.com/libsdl-org/SDL/issues/6337#issuecomment-1278569855).

it would be nice if the readme clarified how c2ffi relates to clang ast-dump, and what justifies the creation of a custom tool.

attila-lendvai commented 8 months ago

https://clang.llvm.org/docs/IntroductionToTheClangAST.html#examining-the-ast

apparently there's clang -ast-dump=json, but i haven't tried it.

and there's a Rust project that uses it:

https://github.com/dtolnay/clang-ast

maybe it entirely subersedes c2ffi?

@rpav, any word on this?

rpav commented 8 months ago

I'll have to look at it again but I recall it not producing anything particularly easy to work with... I'll have to check the JSON output.

Note there's more than simple AST that's very commonly useful... notably constant evaluation/values and the #define hack c2ffi does, which can pull useful values from things like #define SOME_SIZE sizeof(Foo)+1 or the like.

If clang-ast does this it might be pretty ideal, but I haven't checked in awhile.