Il 11/09/2014 16:26, Michael Roth ha scritto: > Also, the .kind field of a QAPI Union type is something we generate for use > by the generated visitor code. In the case of an unspecified discriminator > we generated the enum type for that field internally. In the case where it's > specified, we use an existing enum instead... > > But nothing stops us from generating a new "shadow" enum in this case as well, > with the indexes/integer values of the corresponding strings shifted by one so > we can reserve the 0 index for _INVALID. I think we can reasonably expect that > nothing outside the generated code makes use of those integer values in this > special case, and don't have to change all enum types to make that work.
But how would users fill in structs if you have to use a different enum? What about making adding visit_start_union/visit_end_union? visit_start_union can return false if the visit of the union has to be skipped. The dealloc visitor can skip it if the data field is NULL; everything else can just use a default implementation which always returns true. Paolo
