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: Markus Armbruster
Subject: Re: [Qemu-devel] [PATCH v10 11/13] qapi: Don't box branches of flat unions
Date: Thu, 18 Feb 2016 18:11:39 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Eric Blake <address@hidden> writes:

> 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.

I defined it only for object types because we box only object types.
Err, object types and lists.

If we have a need to call it for arbitrary types, we can do that, we
just need to pick names carefully, and write suitable contracts.

>> 
>> 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.

I need to run an errand now.  When I'm back, I'll review whether the
series can go to qapi-next without a respin.



reply via email to

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