On Wed, 2020-04-22 at 09:48 +0100, Daniel P. Berrangé wrote:
On Wed, Apr 22, 2020 at 01:51:10PM +0800, Shi Lei wrote:
> As you suggested, parsing C-structs plus some magic comments may be a good starting
point.
> But parsing C is much more difficult than parsing xml or json. I think this job
should base on
> some present tools or other basis. We can first refer to Clang or other light
compiler front-end.
> Maybe we can utilize some output of the middle stage of these compilers.
FWIW, we already have a tool in libvirt that parsers C header files. The
scripts/apibuild.py file extracts info about our enums, structs, APIs and
uses it to build the public API documentation.
I wonder if we can refactor that tool to extract the code for parsing into
a module, so that we can more reasily re-use it for both the API docs and
for a new XML generator
Or we could replace that C parsing code with something based on
libclang.
Either way, if this ever becomes usable I think it should not live
in the libvirt repository but be a standalone tool instead, as I can
see many projects potentially benefiting from it.
Which begs the question: are we absolutely certain something like
this doesn't exist already? We should make sure that's really the
case before we invest time on it...
--
Andrea Bolognani / Red Hat / Virtualization