From: Eric Blake <eblake@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: qemu-devel@nongnu.org, marcandre.lureau@redhat.com,
Michael Roth <mdroth@linux.vnet.ibm.com>,
ehabkost@redhat.com
Subject: Re: [Qemu-devel] [PATCH v6 02/12] qapi: Don't use info as witness of implicit object type
Date: Fri, 2 Oct 2015 16:40:02 -0600 [thread overview]
Message-ID: <560F07C2.70300@redhat.com> (raw)
In-Reply-To: <560EB77D.6000704@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 2097 bytes --]
On 10/02/2015 10:57 AM, Eric Blake wrote:
> On 10/02/2015 10:48 AM, Markus Armbruster wrote:
>
>>>> Do it the OO-way: QAPISchemaEntity.is_implicit() returns False. Any
>>>> subclass that can have implicitly defined instances overrides it:
>>>> QAPISchemaObjectType.is_implicit() tests for ':' prefix,
>>>> QAPISchemaEnumType.is_implicit() tests for 'Kind' suffix (requires
>>>> outlawing it for user enums, if we don't do it already), and so forth.
>>>
>>> But there's still the issue of filtering by subclass. For the
>>> qapi-types visit_needed() filter, I either write:
>>>
>>> or what I want to write:
>>>
>>> if entity.is_implicit(QAPISchemaObjectType)
>>
>> I'm not even sure what that's supposed to mean :)
>
> If entity is an implicit ObjectType, return True. If it is implicit but
> not an object (such as an implicit enum), or is not implicit (regardless
> of whether it is an ObjectType), then return False.
>
> And if you don't need filtering by python type, then
> entity.is_implicit() (shorthand for entity.is_implicit(None)) then gives
> the correct answer whether entity is ObjectType or EnumType or something
> else.
>
>>
>>> while still allowing the common case of is_implicit() when I don't care
>>> which type is doing the testing. Since python doesn't allow method
>>> overloads, I'd have to repeat the:
>>>
>>> def is_implicit(self, type=None):
>>> if type and not isinstance(self, type):
>>> return False
>>>
>>> prefix in each subclass that overrides the basic version.
Or, as I just realized, split the public interface from the private
interface:
class QAPISchemaEntity...
def is_implicit(self, typ=None):
if typ and not isinstance(self, typ):
return False
return self._is_implicit()
def _is_implicit(self):
return not self.info
class QAPISchemaObjectTypeMember...
def _is_implicit(self):
return self.name[0] == ':'
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
next prev parent reply other threads:[~2015-10-02 22:40 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 ` [Qemu-devel] [PATCH v6 02/12] qapi: Don't use info as witness of implicit object type Eric Blake
2015-10-02 7:02 ` 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 [this message]
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=560F07C2.70300@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.