[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [RFC PATCH] qapi: Use callback to determine visit filte
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [RFC PATCH] qapi: Use callback to determine visit filtering |
Date: |
Thu, 1 Oct 2015 08:09:40 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 |
On 10/01/2015 12:12 AM, Markus Armbruster wrote:
>>
>>> We can always add an indirection: instead of parameterizing a fixed
>>> predicate (ignore and isinstance(entity, ignore)) with a type ignore, we
>>> could pass a predicate, i.e. a function mapping entity to bool.
>>
>> Like this? Generates the same code before and after the
>> patch. I'm open to suggestions on any way to make it more
>> idiomatic python, althouth it at least passed pep8. In
>> particular, I'm wondering if the predicate should have its
>> sense reversed (pass False to skip, True to visit).
>>
>> I'll probably drop the 'assert info' lines in the two
>> visit_object_type() calls (I put it there to make sure the
>> predicate was working).
>
> Yes, please.
Returning True to visit and False to skip was easier to rationalize
about, so I've made that change in my local tree.
>
> I think this turned out rather nicely.
>
> Can we go one step further? Unconditionally call visitor.visit_filter()
> here, define the pass-everything filter in QAPISchemaVisitor, override
> it as needed.
>
> Name it visit_filter_out() to make the sense of the return value
> obvious?
Oh, nice idea. Then we don't even have to return it during visit_begin()
- we just blindly call it. Will work that into my local tree, and it
will be ready when I post (the next subset) of v6.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature