Home
last modified time | relevance | path

Searched hist:"0 b2c1beea4358e40d1049b8ee019408ce96b37ce" (Results 1 – 3 of 3) sorted by relevance

/qemu/tests/unit/
H A Dtest-keyval.c0b2c1beea4358e40d1049b8ee019408ce96b37ce Tue Feb 28 21:27:10 UTC 2017 Markus Armbruster <armbru@redhat.com> keyval: Support lists

Additionally permit non-negative integers as key components. A
dictionary's keys must either be all integers or none. If all keys
are integers, convert the dictionary to a list. The set of keys must
be [0,N].

Examples:

* list.1=goner,list.0=null,list.1=eins,list.2=zwei
is equivalent to JSON [ "null", "eins", "zwei" ]

* a.b.c=1,a.b.0=2
is inconsistent: a.b.c clashes with a.b.0

* list.0=null,list.2=eins,list.2=zwei
has a hole: list.1 is missing

Similar design flaw as for objects: there is no way to denote an empty
list. While interpreting "key absent" as empty list seems natural
(removing a list member from the input string works when there are
multiple ones, so why not when there's just one), it doesn't work:
"key absent" already means "optional list absent", which isn't the
same as "empty list present".

Update the keyval object visitor to use this a.0 syntax in error
messages rather than the usual a[0].

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1488317230-26248-25-git-send-email-armbru@redhat.com>
[Off-by-one fix squashed in, as per Kevin's review]
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
/qemu/util/
H A Dkeyval.c0b2c1beea4358e40d1049b8ee019408ce96b37ce Tue Feb 28 21:27:10 UTC 2017 Markus Armbruster <armbru@redhat.com> keyval: Support lists

Additionally permit non-negative integers as key components. A
dictionary's keys must either be all integers or none. If all keys
are integers, convert the dictionary to a list. The set of keys must
be [0,N].

Examples:

* list.1=goner,list.0=null,list.1=eins,list.2=zwei
is equivalent to JSON [ "null", "eins", "zwei" ]

* a.b.c=1,a.b.0=2
is inconsistent: a.b.c clashes with a.b.0

* list.0=null,list.2=eins,list.2=zwei
has a hole: list.1 is missing

Similar design flaw as for objects: there is no way to denote an empty
list. While interpreting "key absent" as empty list seems natural
(removing a list member from the input string works when there are
multiple ones, so why not when there's just one), it doesn't work:
"key absent" already means "optional list absent", which isn't the
same as "empty list present".

Update the keyval object visitor to use this a.0 syntax in error
messages rather than the usual a[0].

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1488317230-26248-25-git-send-email-armbru@redhat.com>
[Off-by-one fix squashed in, as per Kevin's review]
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
/qemu/qapi/
H A Dqobject-input-visitor.c0b2c1beea4358e40d1049b8ee019408ce96b37ce Tue Feb 28 21:27:10 UTC 2017 Markus Armbruster <armbru@redhat.com> keyval: Support lists

Additionally permit non-negative integers as key components. A
dictionary's keys must either be all integers or none. If all keys
are integers, convert the dictionary to a list. The set of keys must
be [0,N].

Examples:

* list.1=goner,list.0=null,list.1=eins,list.2=zwei
is equivalent to JSON [ "null", "eins", "zwei" ]

* a.b.c=1,a.b.0=2
is inconsistent: a.b.c clashes with a.b.0

* list.0=null,list.2=eins,list.2=zwei
has a hole: list.1 is missing

Similar design flaw as for objects: there is no way to denote an empty
list. While interpreting "key absent" as empty list seems natural
(removing a list member from the input string works when there are
multiple ones, so why not when there's just one), it doesn't work:
"key absent" already means "optional list absent", which isn't the
same as "empty list present".

Update the keyval object visitor to use this a.0 syntax in error
messages rather than the usual a[0].

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1488317230-26248-25-git-send-email-armbru@redhat.com>
[Off-by-one fix squashed in, as per Kevin's review]
Reviewed-by: Kevin Wolf <kwolf@redhat.com>