qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v10 11/13] qapi: Don't box branches of flat unio


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH v10 11/13] qapi: Don't box branches of flat unions
Date: Thu, 18 Feb 2016 09:51:51 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0

On 02/18/2016 01:51 AM, Markus Armbruster wrote:

>> It gets renamed to is_unboxed after the review on 10/13.  But even after
>> my patch to convert simple unions, this code will still be
>> c_type=typ.c_type(is_unboxed=True), unless I figure out a way to rework
>> .c_type() to not need two separate boolean flags for the three different
>> contexts in which we use a type name (declaring an unboxed member to a
>> struct, declaring a local variable, and declaring a const parameter).
> 
> A possible alternative to a single c_type() with flags for context would
> be separate c_CONTEXT_type().
> 
> In QAPISchemaType:
> 
>     def c_type(self):
>         pass
> 
>     def c_param_type(self):
>         return self.c_type()

and

    def c_unboxed_type(self):
        return self.c_type()

so that c_unboxed_type() is callable on all types, not just objects.

> 
> QAPISchemaBuiltinType overrides:
> 
>     def c_type(self):
>         return self._c_type_name
> 
>     def c_param_type(self):
>         if self.name == 'str':
>             return 'const ' + self._c_type_name
>         return self._c_type_name
...

> 
> Lots of trivial code, as so often with OO.

But I'm liking it a bit better than the two flags. Your suggestion came
after my v11; at this point, if you want me to pursue the idea, I'm glad
to do it as a followup, and include it in my next series where I finish
the conversion of simple unions.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]