qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2 2/2] qapi: Add a primitive to include other f


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH v2 2/2] qapi: Add a primitive to include other files from a QAPI schema file
Date: Mon, 10 Feb 2014 13:30:04 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0

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 <address@hidden>
> ---
>  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

[Prev in Thread] Current Thread [Next in Thread]