On 03/03/2016 06:29 AM, Markus Armbruster wrote:
> Eric Blake <ebl...@redhat.com> writes:
> 
>> QAPISchemaType.c_type() was a bit awkward.  Rather than having two
>> optional orthogonal boolean flags that should never both be true,
>> and where all callers pass a compile-time constant, provide three
>> different method names that can be overridden as needed, and where
>> the caller just uses the right variant.  It requires slightly more
>> Python, but is arguably easier to read.
>>

>> +
>> +    # Use of a type in a struct declaration
>> +    def c_unboxed_type(self):
>> +        return self.c_type()
> 
> This one I find bit problematic.  We only ever box object types, but
> those we box almost everywhere.  This method gets used in the select
> places where we don't box them (currently just one).  I'm afraid "used
> in a struct declaration" isn't a good definition.
> 
> I initially suggested to define c_unboxed_type() only for
> QAPISchemaObjectType because there boxed vs. unboxed makes sense.
> However, your code would like to call it for arbitrary types.

qapi-types.py is calling it for arbitrary types thanks to QAPI
alternates.  If I didn't put it here, then the code there needs to
special-case for isinstance(type, QAPISchemaObjectType) before calling
.c_unboxed_type(), and fall back to .c_type() otherwise.

> 
> Perhaps we can cure my belly-ache with nothing more than carefully
> drafted function contracts.  Let me try.
> 
>     # Return the C type for common use.
>     # For the types we commonly box, this is a pointer type.
>     def c_type(self):
> 
>     # Return the C type to be used in a parameter list.
>     def c_param_type(self):
> 
>     # Return the C type to be used where we suppress boxing.
>     def c_unboxed_type(self):

Sure, that helps.

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