qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: qemu-devel@nongnu.org
Cc: Michael Roth <mdroth@linux.vnet.ibm.com>,
	marcandre.lureau@redhat.com, armbru@redhat.com,
	ehabkost@redhat.com
Subject: [Qemu-devel] [PATCH v6 02/12] qapi: Don't use info as witness of implicit object type
Date: Thu,  1 Oct 2015 22:31:42 -0600	[thread overview]
Message-ID: <1443760312-656-3-git-send-email-eblake@redhat.com> (raw)
In-Reply-To: <1443760312-656-1-git-send-email-eblake@redhat.com>

A future patch will enable error reporting from the various
QAPISchema*.check() methods.  But to report an error related
to an implicit type, we'll need to associate a location with
the type (the same location as the top-level entity that is
causing the creation of the implicit type), and once we do
that, keying off of whether foo.info exists is no longer a
viable way to determine if foo is an implicit type.

Instead, add an is_implicit() method to QAPISchemaObjectType,
and use that function where needed.  (Done at the ObjectType
level, since we already know all builtins and arrays are
implicit, no commands or events are implicit, and we don't
have any differences in generated code for regular vs.
implicit enums.)

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

---
v6: split 11/46 into pieces; don't rename _info yet; rework atop
nicer filtering mechanism, including no need to change visitor
signature
---
 scripts/qapi-types.py |  3 ++-
 scripts/qapi-visit.py |  3 ++-
 scripts/qapi.py       | 10 +++++++---
 3 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py
index c5b71b0..6bac5b3 100644
--- a/scripts/qapi-types.py
+++ b/scripts/qapi-types.py
@@ -234,7 +234,8 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor):
         self._btin = None

     def visit_predicate(self, entity):
-        return not isinstance(entity, QAPISchemaObjectType) or entity.info
+        return not (isinstance(entity, QAPISchemaObjectType) and
+                    entity.is_implicit())

     def _gen_type_cleanup(self, name):
         self.decl += gen_type_cleanup_decl(name)
diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py
index 0f47614..2957c85 100644
--- a/scripts/qapi-visit.py
+++ b/scripts/qapi-visit.py
@@ -334,7 +334,8 @@ class QAPISchemaGenVisitVisitor(QAPISchemaVisitor):
         self._btin = None

     def visit_predicate(self, entity):
-        return not isinstance(entity, QAPISchemaObjectType) or entity.info
+        return not (isinstance(entity, QAPISchemaObjectType) and
+                    entity.is_implicit())

     def visit_enum_type(self, name, info, values, prefix):
         self.decl += gen_visit_decl(name, scalar=True)
diff --git a/scripts/qapi.py b/scripts/qapi.py
index 7d359c8..8123ab3 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -970,12 +970,15 @@ class QAPISchemaObjectType(QAPISchemaType):
             self.variants.check(schema, members, seen)
         self.members = members

+    def is_implicit(self):
+        return self.name[0] == ':'
+
     def c_name(self):
-        assert self.info
+        assert not self.is_implicit()
         return QAPISchemaType.c_name(self)

     def c_type(self, is_param=False):
-        assert self.info
+        assert not self.is_implicit()
         return QAPISchemaType.c_type(self)

     def json_type(self):
@@ -1043,7 +1046,8 @@ class QAPISchemaObjectTypeVariant(QAPISchemaObjectTypeMember):
     # This function exists to support ugly simple union special cases
     # TODO get rid of them, and drop the function
     def simple_union_type(self):
-        if isinstance(self.type, QAPISchemaObjectType) and not self.type.info:
+        if isinstance(self.type,
+                      QAPISchemaObjectType) and self.type.is_implicit():
             assert len(self.type.members) == 1
             assert not self.type.variants
             return self.type.members[0].type
-- 
2.4.3

  parent reply	other threads:[~2015-10-02  4:32 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-02  4:31 [Qemu-devel] [PATCH v6 00/12] post-introspection cleanups, subset B Eric Blake
2015-10-02  4:31 ` [Qemu-devel] [PATCH v6 01/12] qapi: Use predicate callback to determine visit filtering Eric Blake
2015-10-02  6:47   ` Markus Armbruster
2015-10-02 12:16     ` Eric Blake
2015-10-02  4:31 ` Eric Blake [this message]
2015-10-02  7:02   ` [Qemu-devel] [PATCH v6 02/12] qapi: Don't use info as witness of implicit object type Markus Armbruster
2015-10-02 12:54     ` Eric Blake
2015-10-02 14:12       ` Markus Armbruster
2015-10-02 14:33         ` Eric Blake
2015-10-02 16:48           ` Markus Armbruster
2015-10-02 16:57             ` Eric Blake
2015-10-02 22:40               ` Eric Blake
2015-10-06  8:32               ` Markus Armbruster
2015-10-06 11:56                 ` Eric Blake
2015-10-06 13:31                   ` Markus Armbruster
2015-10-02  4:31 ` [Qemu-devel] [PATCH v6 03/12] qapi: Lazy creation of array types Eric Blake
2015-10-02  8:06   ` Markus Armbruster
2015-10-02 13:05     ` Eric Blake
2015-10-06  8:35       ` Markus Armbruster
2015-10-02  4:31 ` [Qemu-devel] [PATCH v6 04/12] qapi: Create simple union type member earlier Eric Blake
2015-10-02  8:34   ` Markus Armbruster
2015-10-02 13:08     ` Eric Blake
2015-10-02  4:31 ` [Qemu-devel] [PATCH v6 05/12] qapi: Track location that created an implicit type Eric Blake
2015-10-02  8:54   ` Markus Armbruster
2015-10-02 14:07     ` Eric Blake
2015-10-02 16:07       ` Markus Armbruster
2015-10-02 16:13         ` Eric Blake
2015-10-02  4:31 ` [Qemu-devel] [PATCH v6 06/12] qapi: Track owner of each object member Eric Blake
2015-10-02  9:50   ` Markus Armbruster
2015-10-02 14:48     ` Eric Blake
2015-10-02 17:05       ` Markus Armbruster
2015-10-02 22:35         ` Eric Blake
2015-10-02  4:31 ` [Qemu-devel] [PATCH v6 07/12] qapi: Detect collisions in C member names Eric Blake
2015-10-02 13:19   ` Markus Armbruster
2015-10-02 15:12     ` Eric Blake
2015-10-02 17:11       ` Markus Armbruster
2015-10-03  1:01         ` Eric Blake
2015-10-06  8:41           ` Markus Armbruster
2015-10-02  4:31 ` [Qemu-devel] [PATCH v6 08/12] qapi: Defer duplicate member checks to schema check() Eric Blake
2015-10-02 14:00   ` Markus Armbruster
2015-10-02 15:52     ` Eric Blake
2015-10-02  4:31 ` [Qemu-devel] [PATCH v6 09/12] qapi: Defer duplicate enum value " Eric Blake
2015-10-02  4:31 ` [Qemu-devel] [PATCH v6 10/12] qapi: Correct error for union branch 'kind' clash Eric Blake
2015-10-03 17:56   ` Eric Blake
2015-10-02  4:31 ` [Qemu-devel] [PATCH v6 11/12] qapi: Detect base class loops Eric Blake
2015-10-02  4:31 ` [Qemu-devel] [PATCH v6 12/12] RFC: qapi: Hide _info member Eric Blake

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1443760312-656-3-git-send-email-eblake@redhat.com \
    --to=eblake@redhat.com \
    --cc=armbru@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=mdroth@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).