On 02/10/2014 12:58 PM, Lluís Vilanova wrote:
> Adds the "include(...)" primitive to the syntax of QAPI schema files.
> 
> Signed-off-by: Lluís Vilanova <vilan...@ac.upc.edu>
> ---
>  scripts/qapi.py |   24 ++++++++++++++++++++++--
>  1 file changed, 22 insertions(+), 2 deletions(-)
> 

> +            elif self.tok == 'i':
> +                include_src = self.src[self.cursor-1:]
> +                include_match = include_cre.match(include_src)
> +                if include_match is not None:
> +                    include_path = os.path.join(self.input_dir,
> +                                                include_match.group(1))
> +                    if not os.path.isfile(include_path):
> +                        raise QAPISchemaError(
> +                            self,
> +                            'Non-existing included file "%s"' % include_path)

Should you also check against loops, and gracefully fail if a file tries
to include itself, or if file A includes B while B includes A?

This changes the code generator, but not the documentation.  For this
patch to be complete, you need to edit somewhere in the docs tree,
probably docs/qapi-code-gen.txt, to describe how to use includes.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to