[PATCH v3 11/34] qapi/schema: Clean up around QAPISchemaEntity.connect_doc()

Markus Armbruster posted 34 patches 5 years, 11 months ago
Maintainers: Eric Blake <eblake@redhat.com>, Michael Roth <mdroth@linux.vnet.ibm.com>, Paolo Bonzini <pbonzini@redhat.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Markus Armbruster <armbru@redhat.com>, Eduardo Habkost <ehabkost@redhat.com>, "Dr. David Alan Gilbert" <dgilbert@redhat.com>, Juan Quintela <quintela@redhat.com>
There is a newer version of this series
[PATCH v3 11/34] qapi/schema: Clean up around QAPISchemaEntity.connect_doc()
Posted by Markus Armbruster 5 years, 11 months ago
QAPISchemaEntity calls doc.connect_feature() in .check().  Improper
since commit ee1e6a1f6c8 split .connect_doc() off .check().  Move the
call.  Requires making the children call super().connect_doc() as they
should.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 scripts/qapi/schema.py | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py
index d759308b4e..2a2b495987 100644
--- a/scripts/qapi/schema.py
+++ b/scripts/qapi/schema.py
@@ -53,13 +53,13 @@ class QAPISchemaEntity:
         seen = {}
         for f in self.features:
             f.check_clash(self.info, seen)
-            if self.doc:
-                self.doc.connect_feature(f)
-
         self._checked = True
 
     def connect_doc(self, doc=None):
-        pass
+        doc = doc or self.doc
+        if doc:
+            for f in self.features:
+                doc.connect_feature(f)
 
     def check_doc(self):
         if self.doc:
@@ -250,6 +250,7 @@ class QAPISchemaEnumType(QAPISchemaType):
             m.check_clash(self.info, seen)
 
     def connect_doc(self, doc=None):
+        super().connect_doc(doc)
         doc = doc or self.doc
         if doc:
             for m in self.members:
@@ -392,6 +393,7 @@ class QAPISchemaObjectType(QAPISchemaType):
             m.check_clash(info, seen)
 
     def connect_doc(self, doc=None):
+        super().connect_doc(doc)
         doc = doc or self.doc
         if doc:
             if self.base and self.base.is_implicit():
@@ -667,6 +669,7 @@ class QAPISchemaAlternateType(QAPISchemaType):
                 types_seen[qt] = v.name
 
     def connect_doc(self, doc=None):
+        super().connect_doc(doc)
         doc = doc or self.doc
         if doc:
             for v in self.variants.variants:
@@ -733,6 +736,7 @@ class QAPISchemaCommand(QAPISchemaEntity):
                         % self.ret_type.describe())
 
     def connect_doc(self, doc=None):
+        super().connect_doc(doc)
         doc = doc or self.doc
         if doc:
             if self.arg_type and self.arg_type.is_implicit():
@@ -775,6 +779,7 @@ class QAPISchemaEvent(QAPISchemaEntity):
                     % self.arg_type.describe())
 
     def connect_doc(self, doc=None):
+        super().connect_doc(doc)
         doc = doc or self.doc
         if doc:
             if self.arg_type and self.arg_type.is_implicit():
-- 
2.21.1


Re: [PATCH v3 11/34] qapi/schema: Clean up around QAPISchemaEntity.connect_doc()
Posted by Marc-André Lureau 5 years, 10 months ago
On Sun, Mar 15, 2020 at 4:23 PM Markus Armbruster <armbru@redhat.com> wrote:
>
> QAPISchemaEntity calls doc.connect_feature() in .check().  Improper
> since commit ee1e6a1f6c8 split .connect_doc() off .check().  Move the
> call.  Requires making the children call super().connect_doc() as they
> should.
>
> Signed-off-by: Markus Armbruster <armbru@redhat.com>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>


> ---
>  scripts/qapi/schema.py | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py
> index d759308b4e..2a2b495987 100644
> --- a/scripts/qapi/schema.py
> +++ b/scripts/qapi/schema.py
> @@ -53,13 +53,13 @@ class QAPISchemaEntity:
>          seen = {}
>          for f in self.features:
>              f.check_clash(self.info, seen)
> -            if self.doc:
> -                self.doc.connect_feature(f)
> -
>          self._checked = True
>
>      def connect_doc(self, doc=None):
> -        pass
> +        doc = doc or self.doc
> +        if doc:
> +            for f in self.features:
> +                doc.connect_feature(f)
>
>      def check_doc(self):
>          if self.doc:
> @@ -250,6 +250,7 @@ class QAPISchemaEnumType(QAPISchemaType):
>              m.check_clash(self.info, seen)
>
>      def connect_doc(self, doc=None):
> +        super().connect_doc(doc)
>          doc = doc or self.doc
>          if doc:
>              for m in self.members:
> @@ -392,6 +393,7 @@ class QAPISchemaObjectType(QAPISchemaType):
>              m.check_clash(info, seen)
>
>      def connect_doc(self, doc=None):
> +        super().connect_doc(doc)
>          doc = doc or self.doc
>          if doc:
>              if self.base and self.base.is_implicit():
> @@ -667,6 +669,7 @@ class QAPISchemaAlternateType(QAPISchemaType):
>                  types_seen[qt] = v.name
>
>      def connect_doc(self, doc=None):
> +        super().connect_doc(doc)
>          doc = doc or self.doc
>          if doc:
>              for v in self.variants.variants:
> @@ -733,6 +736,7 @@ class QAPISchemaCommand(QAPISchemaEntity):
>                          % self.ret_type.describe())
>
>      def connect_doc(self, doc=None):
> +        super().connect_doc(doc)
>          doc = doc or self.doc
>          if doc:
>              if self.arg_type and self.arg_type.is_implicit():
> @@ -775,6 +779,7 @@ class QAPISchemaEvent(QAPISchemaEntity):
>                      % self.arg_type.describe())
>
>      def connect_doc(self, doc=None):
> +        super().connect_doc(doc)
>          doc = doc or self.doc
>          if doc:
>              if self.arg_type and self.arg_type.is_implicit():
> --
> 2.21.1
>
>


-- 
Marc-André Lureau

Re: [PATCH v3 11/34] qapi/schema: Clean up around QAPISchemaEntity.connect_doc()
Posted by Eric Blake 5 years, 10 months ago
On 3/15/20 9:46 AM, Markus Armbruster wrote:
> QAPISchemaEntity calls doc.connect_feature() in .check().  Improper
> since commit ee1e6a1f6c8 split .connect_doc() off .check().  Move the
> call.  Requires making the children call super().connect_doc() as they
> should.
> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>   scripts/qapi/schema.py | 13 +++++++++----
>   1 file changed, 9 insertions(+), 4 deletions(-)
> 

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org