[RFC 00/29] RFC: Generate object-model code based on relax-ng files

Daniel P. Berrangé berrange at redhat.com
Wed Apr 22 09:45:02 UTC 2020


On Wed, Apr 22, 2020 at 11:37:23AM +0200, Andrea Bolognani wrote:
> 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.

I think that's a double edged sword. While it gives you the full coverage
of the C language, you then have to deal with the full range of the C
language. I think the simplified parser we have for the docs build will
be easier to work with by being more constrained in what it tries to
support.

> 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.

Yes, but we can worry about that at a later date IMHO.

> 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...

I've not found anything equivalent to Golang's XML parser for C

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|




More information about the libvir-list mailing list