[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v6 02/12] qapi: Don't use info as witness of imp
From: |
Eric Blake |
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 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 |
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
signature.asc
Description: OpenPGP digital signature
- [Qemu-devel] [PATCH v6 02/12] qapi: Don't use info as witness of implicit object type, (continued)
- [Qemu-devel] [PATCH v6 02/12] qapi: Don't use info as witness of implicit object type, Eric Blake, 2015/10/08
- Re: [Qemu-devel] [PATCH v6 02/12] qapi: Don't use info as witness of implicit object type, Markus Armbruster, 2015/10/08
- Re: [Qemu-devel] [PATCH v6 02/12] qapi: Don't use info as witness of implicit object type, Eric Blake, 2015/10/08
- Re: [Qemu-devel] [PATCH v6 02/12] qapi: Don't use info as witness of implicit object type, Markus Armbruster, 2015/10/08
- Re: [Qemu-devel] [PATCH v6 02/12] qapi: Don't use info as witness of implicit object type, Eric Blake, 2015/10/08
- Re: [Qemu-devel] [PATCH v6 02/12] qapi: Don't use info as witness of implicit object type, Markus Armbruster, 2015/10/08
- Re: [Qemu-devel] [PATCH v6 02/12] qapi: Don't use info as witness of implicit object type, Eric Blake, 2015/10/08
- Re: [Qemu-devel] [PATCH v6 02/12] qapi: Don't use info as witness of implicit object type, Markus Armbruster, 2015/10/08
- Re: [Qemu-devel] [PATCH v6 02/12] qapi: Don't use info as witness of implicit object type, Eric Blake, 2015/10/08
- Re: [Qemu-devel] [PATCH v6 02/12] qapi: Don't use info as witness of implicit object type, Markus Armbruster, 2015/10/08
- Re: [Qemu-devel] [PATCH v6 02/12] qapi: Don't use info as witness of implicit object type,
Eric Blake <=
[Qemu-devel] [PATCH v6 05/12] qapi: Track location that created an implicit type, Eric Blake, 2015/10/08
[Qemu-devel] [PATCH v6 08/12] qapi: Defer duplicate member checks to schema check(), Eric Blake, 2015/10/08
[Qemu-devel] [PATCH v6 11/12] qapi: Detect base class loops, Eric Blake, 2015/10/08
[Qemu-devel] [PATCH v6 12/12] RFC: qapi: Hide _info member, Eric Blake, 2015/10/08