On 02/10/2014 02:48 PM, Wenchao Xia wrote: > This series address two issues: > > 1. support using enum as discriminator in union. > For example, if we have following define in qapi schema: > { 'enum': 'EnumOne', > 'data': [ 'value1', 'value2', 'value3' ] } > > { 'type': 'UserDefBase0', > 'data': { 'base-string0': 'str', 'base-enum0': 'EnumOne' } } > > Before this series, discriminator in union must be a string, and a > hidden enum type as discriminator is generated. After this series, > qapi schema can directly use predefined enum type: > { 'union': 'UserDefEnumDiscriminatorUnion', > 'base': 'UserDefBase0', > 'discriminator' : 'base-enum0', > 'data': { 'value1' : 'UserDefA', > 'value2' : 'UserDefInherit', > 'value3' : 'UserDefB' } }
See also: https://lists.gnu.org/archive/html/qemu-devel/2014-02/msg01663.html There, I argued that even unions without a 'base':'TypeName' would benefit from having a discriminator that calls out an enum type listing the valid branches of the union. I think that could be a followup to this series. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature