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
signature.asc
Description: OpenPGP digital signature