Eric Blake <ebl...@redhat.com> 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.