OSDN Git Service

qapi: Track enum values by QAPISchemaMember, not string
authorEric Blake <eblake@redhat.com>
Wed, 2 Dec 2015 05:20:55 +0000 (22:20 -0700)
committerMarkus Armbruster <armbru@redhat.com>
Thu, 17 Dec 2015 07:21:29 +0000 (08:21 +0100)
commit93bda4dd461358b4fc05dfd8e2d6419cdd574789
tree759dc42b2c7a640688204dceb07ba4236da65254
parentd44f9ac80c43e34b1522cde8829f0ab371f086ca
qapi: Track enum values by QAPISchemaMember, not string

Rather than using just an array of strings, make enum.values be
an array of the new QAPISchemaMember type, and add a helper
member_names() method to get back at the original list of names.
Likewise, creating an enum requires wrapping strings, via a new
QAPISchema._make_enum_members() method.  The benefit of wrapping
enum members in a QAPISchemaMember Python object is that we now
share the existing code for C name clash detection (although the
code is not yet active until a later commit removes the earlier
ad hoc parser checks).

In a related change, the QAPISchemaMember._pretty_owner() method
needs to learn about one more implicit type name: the generated
enum associated with a simple union.

In the interest of keeping the changes of this patch local to one
file, the visitor interface still passes just a list of names
rather than the full list of QAPISchemaMember instances.  We may
want to revisit this in the future, if the consistency with
visit_object_type() is worth it.

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1449033659-25497-12-git-send-email-eblake@redhat.com>
[Eric's simplifying followup squashed in]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
scripts/qapi.py