qemu-devel
[Top][All Lists]
Advanced

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

Re: [RFC v3 05/32] scripts/qapi: add QAPISchemaVisitor.visit_module_end


From: Markus Armbruster
Subject: Re: [RFC v3 05/32] scripts/qapi: add QAPISchemaVisitor.visit_module_end
Date: Wed, 08 Sep 2021 14:26:23 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)

marcandre.lureau@redhat.com writes:

> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> Used in following patches to generate code after visiting a module.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  scripts/qapi/schema.py | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py
> index 1f6301c394..6455a8f425 100644
> --- a/scripts/qapi/schema.py
> +++ b/scripts/qapi/schema.py
> @@ -128,6 +128,9 @@ def visit_end(self):
>      def visit_module(self, name):
>          pass
>  
> +    def visit_module_end(self, name) -> None:
> +        pass
> +
>      def visit_needed(self, entity):
>          # Default to visiting everything
>          return True
> @@ -207,6 +210,7 @@ def visit(self, visitor):
>          for entity in self._entity_list:
>              if visitor.visit_needed(entity):
>                  entity.visit(visitor)
> +        visitor.visit_module_end(self.name)
>  
>  
>  class QAPISchemaInclude(QAPISchemaEntity):

QAPISchema.visit(vis) now calls:

    vis.visit_begin
    for each module:
        vis.visit_module(module.name)
        for each entity in module
            entity.visit(vis)
        vis.visit_module_end(module.name)
    vis.visit_end

The .visit_module_end() isn't strictly necessary (we could do its work
in .visit_module() and .visit_end()).  But it's probably simpler this
way.

Let's rename .visit_module() to .visit_module_begin(), for symmetry with
.visit_begin(), .visit_end().




reply via email to

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