marcandre.lur...@redhat.com writes:

> From: Marc-André Lureau <marcandre.lur...@redhat.com>
>
> Used in following patches to generate code after visiting a module.
>
> Signed-off-by: Marc-André Lureau <marcandre.lur...@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