On 11/21/19 9:07 AM, Markus Armbruster wrote:
Max Reitz <mre...@redhat.com> writes:
With this change, it is possible to give default values for struct
members, as follows:
What you had to do so far:
# @member: Some description, defaults to 42.
{ 'struct': 'Foo',
'data': { '*member': 'int' } }
What you can do now:
{ 'struct': 'Foo',
'data': { '*member': { 'type': 'int', 'default': 42 } }
The '*' is redundant in this form.
Can anyone think of reasons for keeping it anyway? Against?
Is there ever a reason to allow an optional member but without a
'default' value? Or can we just blindly state that if 'default' is not
present, that is the same as 'default':0/'default':null?
Or, applying your statement further,
'data': { '*a':'int', '*b':'str' }
is shorthand for:
'data': { 'a': { 'type':'int', 'default':0 },
'b': { 'type':'str', 'default':null } }
So I could live with permitting '*' only in the shorthand form, and
declaring that it is incompatible with longhand form because the
existence of a 'default' key in longhand form is evidence that the
member is therefore optional.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org