qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v3 08/49] qapi: add #if/#endif helpers


From: Markus Armbruster
Subject: Re: [Qemu-devel] [PATCH v3 08/49] qapi: add #if/#endif helpers
Date: Thu, 21 Jun 2018 09:06:24 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)

Marc-André Lureau <address@hidden> writes:

> Add helpers to wrap generated code with #if/#endif lines.
>
> Add QAPIGenCSnippet class to write C snippet code, make QAPIGenC
> inherit from it, for full C files with copyright headers etc.
>
> Add a 'with' statement context manager that will be used to wrap
> generator visitor methods.  The manager will check if code was
> generated before adding #if/#endif lines on QAPIGenCSnippet
> objects. Used in the following patches.
>
> Signed-off-by: Marc-André Lureau <address@hidden>
> ---
>  scripts/qapi/common.py | 82 +++++++++++++++++++++++++++++++++++++++---
>  1 file changed, 78 insertions(+), 4 deletions(-)
>
> diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py
> index 47efe79758..60c1d0a783 100644
> --- a/scripts/qapi/common.py
> +++ b/scripts/qapi/common.py
[...]
> @@ -2061,6 +2097,23 @@ class QAPIGen(object):
>      def add(self, text):
>          self._body += text
>  
> +    def start_if(self, ifcond):
> +        self._ifcond = ifcond
> +        self._start_if_body = self._body
> +        self._start_if_preamble = self._preamble

pylint gripes:

+W:2102, 8: Attribute '_start_if_body' defined outside __init__ 
(attribute-defined-outside-init)
+W:2103, 8: Attribute '_start_if_preamble' defined outside __init__ 
(attribute-defined-outside-init)

We generally define in .__init__(), except when we want to catch
premature use, such as in PATCH 05.  Let's define these two in
.__init__().

[...]



reply via email to

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